nakov / Practical-Cryptography-for-Developers-Book

Practical Cryptography for Developers: Hashes, MAC, Key Derivation, DHKE, Symmetric and Asymmetric Ciphers, Public Key Cryptosystems, RSA, Elliptic Curves, ECC, secp256k1, ECDH, ECIES, Digital Signatures, ECDSA, EdDSA
https://cryptobook.nakov.com
MIT License
3.46k stars 418 forks source link

PRNG exercises need clarification about integer representation #35

Open terrabitz opened 4 years ago

terrabitz commented 4 years ago

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

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.