Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An RNG faster than /dev/random but cryptographically useful?

I've started some work of which requires some quality random bytes, such as 32 at a time for an initialising vector for certain cryptographic applications. My issue is, this may be called upon multiple times simultaneously and I cannot afford the block /dev/random issues to wait for more collection of entropy.

I could use it to seed other algorithms, for example what /dev/urandom may do - however I do not trust what I cannot understand, I do not have any readily available resource on its method nor do I know if it remains the same between many kernel versions, I prefer a well defined method of some sort.

Are you aware of any methods you can think of over standard PRNGs that would be suited enough to use for (simultaneous) key generation and alike?

Would certain ciphers such as RC4 with a large seed be sufficient to generate random output? (I've seen a /dev/frandom implementation that uses this, however am not entirely sure of it.)

If it means anything, I am on a headless Debian server, reason of lack of entropy gathering.

like image 824
Alexander Avatar asked Aug 04 '11 22:08

Alexander


2 Answers

The response is simple: use /dev/urandom, not /dev/random. /dev/urandom is cryptographically secure, and will not block. The "superiority" of /dev/random over /dev/urandom exist only in a specific theoretical setting which makes no sense if the random bytes are to be used with just about any "normal" cryptographic algorithm, such as encryption or signatures.

See this for more details.

(Trust me, I am a cryptographer.)

like image 111
Thomas Pornin Avatar answered Nov 07 '22 19:11

Thomas Pornin


Consider using a hardware random number generator. For example, the entropy key or Whirlygig. Using /dev/urandom instead will avoid blocking but may (depending on your level of paranoia) degrade security (you'll output more random bits than you have input entropy, so in theory the output is predictable - this isn't a problem if you're just using it for IVs however)

like image 38
bdonlan Avatar answered Nov 07 '22 19:11

bdonlan