Page Speed Optimization Libraries
1.13.35.1
|
#include "hashed_nonce_generator.h"
Public Member Functions | |
HashedNonceGenerator (const Hasher *hasher, StringPiece key, AbstractMutex *mutex) | |
Public Member Functions inherited from net_instaweb::NonceGenerator | |
uint64 | NewNonce () |
Generate a fresh, ideally cryptographic, nonce. Thread-safe. | |
Protected Member Functions | |
virtual uint64 | NewNonceImpl () |
Subclasses must implement this method. Locking is already handled. | |
Protected Member Functions inherited from net_instaweb::NonceGenerator | |
NonceGenerator (AbstractMutex *mutex) | |
Takes ownership of mutex. | |
Implements a NonceGenerator using a hasher and a count, starting from an initial secret. See: http://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator Basically we initialize a key and a counter with random data, then return the hash of the string obtained by appending them. Incrementing the counter gives us a new hash. This means that different instantiations of a HashedNonceGenerator must use different keys to avoid repetition of nonce values. Note that (according to the above article) this is sufficient for cryptographic nonce generation, but not for generating a cryptographically secure bit stream for use as a one-time pad.
net_instaweb::HashedNonceGenerator::HashedNonceGenerator | ( | const Hasher * | hasher, |
StringPiece | key, | ||
AbstractMutex * | mutex | ||
) |
key must be at least 2*hasher->RawHashSizeInBytes() in length. Takes ownership of mutex, but not of hasher.