Practical-Cryptography-for-Developers-Book
Practical-Cryptography-for-Developers-Book copied to clipboard
PRNG exercises need clarification about integer representation
In the PRNG exercise, the solution is based on the following calculation, where n
is the iteration number:
1 + HMAC-SHA256(n, seed) % 10
However, n can be represented a number of different ways, depending on
- Whether it should be an encoded string value (e.g. similar to the example given in https://cryptobook.nakov.com/secure-random-generators/pseudo-random-numbers-examples)
- Whether it's big or little-endian
- Whether it's signed or unsigned
When implementing the exercise, I struggled with trying a number of different representations until I finally figured out that the byte representation was supposed to be unencoded and unsigned. It might be good to include a note about this in the exercise.