Say I roll a six sided die 200 times (6^200 = ~2^517) and string all the results together into a long string of numbers and hash then result with SHA-512. Can I use that result for cryptographic purposes such as keys? Can I then use the hash of that result to generate more keys?


Yes, the output should have an entropy of 512 bit (or slightly less). Using it as a key is a good idea. If you want to generate more than 512 bits of key material out of the 512 bit you need to use a Key Derivation Function (KDF). You do not need to stretch the key, because it is no password and has a high amount of entropy - enough to make any brute force attempt impossible.

To do this, you can take the HMAC algorithm. Use a unique number (you can use a counter, it doesn't need to be random) as the message and the original key as the HMAC key. The result is your first real key material. If you need more, use another unique number (you can increment the counter for example) and compute the HMAC with this new number. Do this as long as you want, until you got enough keys. If you do this, don't use the original key material for anything else. If it ever leaks to an attacker, he/she can construct every other key with this original key material.

  • 1
    $\begingroup$ If you are talking about KDF's you are talking about KBKDF (key based KDF's). In that case you may want to refer to NIST SP 800-108 (counter based KDF's) and HKDF, as well as KDF1/2. Some libraries may already have implementations. $\endgroup$
    – Maarten Bodewes
    Apr 25 '15 at 18:52
  • $\begingroup$ See also NIST SP 800-90 for hash (and HMAC) based RNGs. $\endgroup$ Apr 26 '15 at 2:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.