Opened 4 years ago

Closed 4 years ago

#17944 closed enhancement (implemented)

[PATCH] support timingsafe_memcmp() on Operating Systems that support it

Reported by: logan Owned by:
Priority: Medium Milestone: Tor: 0.2.8.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Hi guys,

Tor has its own hand-rolled timing-safe memcmp() which is nice, but Operating Systems like OpenBSD, NetBSD, and possibly others soon are starting to ship with a timing safe memcmp().

On OpenBSD, it's called timingsafe_memcmp().

Below is a patch that checks for it, and uses it if the host platform has a timingsafe_memcmp().

Child Tickets

Attachments (1)

timingsafe_memcmp.diff (797 bytes) - added by logan 4 years ago.

Download all attachments as: .zip

Change History (9)

Changed 4 years ago by logan

Attachment: timingsafe_memcmp.diff added

comment:1 Changed 4 years ago by cypherpunks_backup

Component: - Select a componentTor

comment:2 Changed 4 years ago by teor

Milestone: Tor: 0.2.8.x-final
Status: newneeds_review

comment:3 Changed 4 years ago by teor

This looks like a good patch, and it's simple, I'd be happy to see it merged, but I can't test it, because I don't have access to OpenBSD or a platform with timingsafe_memcmp.

comment:4 Changed 4 years ago by logan

I ran Tor with it on my OpenBSD. May I know the specific tests that you're looking for ?

comment:5 Changed 4 years ago by teor

I can't verify that it compiles and runs correctly on an OS with timingsafe_memcmp.
(But it's a simple patch, and it looks like it should work.)

Does the di_ops unit test pass on OpenBSD with the patch applied?
(The unit tests can be run using make test.)

comment:6 Changed 4 years ago by logan

util/strtok: OK
util/di_ops: OK
util/di_map: OK

comment:7 Changed 4 years ago by teor

OK, I'd be happy to see this merged, but the final decision is up to nickm.

comment:8 Changed 4 years ago by nickm

Resolution: implemented
Status: needs_reviewclosed

Applied as bc2cd0ff2bfc70916efe6b6a7fe0a4aae481df3b

Note: See TracTickets for help on using tickets.