Opened 4 years ago

Closed 4 years ago

#17697 closed enhancement (implemented)

Add crypto_rand unit tests to check for predictable values

Reported by: teor 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

Add unit tests that check for common RNG failure modes, such as
returning all zeroes, identical values, or incrementing values
(OpenSSL's rand_predictable feature).

See my branch rand-failure-modes, it's based on bug17686_v2_027 in #17686.
https://github.com/teor2345/tor.git

As well as doing these checks during unit tests, we could also do these checks every time we reseed OpenSSL's PRNG. (With an appropriately large buffer so that the chance of failure during normal operation is astronomically improbable, or at least less probable than a bit-flip in the return value.)

In particular, OpenSSL's rand_predictable feature concerns me - we currently don't check if Tor is run against an OpenSSL with it on.

Child Tickets

Change History (1)

comment:1 Changed 4 years ago by nickm

Resolution: implemented
Status: newclosed

Sure; took this one.

Instead of adding more tests of this kind though, we should probably add a way to pipe output from crypto_rand() to stdout, so that we can test it with some statistics package. (I've used dieharder in the past; Yawning told me about a cleaner one recently.)

Note: See TracTickets for help on using tickets.