Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is /proc/sys/kernel/random/uuid strong keying material?

Tags:

uuid

random

I've been looking at ways to generate a strong 256 bit/32 byte symmetric key for the HMAC_SHA256 algorithm. I stumbled upon the /proc/sys/kernel/random/uuid file.

According to man random(4): "The read-only files uuid and boot_id contain random strings like 6fd5a44b-35f4-4ad4-a9b9-6b9be13e1fe9. The former is generated afresh for each read, the latter was generated once."

The string from cat /proc/sys/kernel/random/uuid looks ideal for this purpose. I can remove the '-' chars and end up with a 32 bytes of randomness.

Is this a valid approach to generate a cryptographically strong source of keying material?

like image 791
pfarber Avatar asked May 03 '11 17:05

pfarber


1 Answers

An old question but in case anyone stumbles on it, I wouldn't advise this.

/proc/sys/kernel/random/uuid is a type 4 (random) UUID with certain semantics - it's not just a string of random hex characters. For example you'll see the first digit in the third group is always a 4.

For 256 random bits just read 32 bytes from /dev/random (uses external entropy, can block) or /dev/urandom (never blocks).

like image 130
helloPiers Avatar answered Sep 27 '22 17:09

helloPiers