class Hash_DRBG : public NIST_DRBG
@@ -156,12 +162,12 @@ public:
CRYPTOPP_CONSTANT(MINIMUM_NONCE=0)
CRYPTOPP_CONSTANT(MINIMUM_ADDITIONAL=0)
CRYPTOPP_CONSTANT(MINIMUM_PERSONALIZATION=0)
- CRYPTOPP_CONSTANT(MAXIMUM_ENTROPY=UINT_MAX)
- CRYPTOPP_CONSTANT(MAXIMUM_NONCE=UINT_MAX)
- CRYPTOPP_CONSTANT(MAXIMUM_ADDITIONAL=UINT_MAX)
- CRYPTOPP_CONSTANT(MAXIMUM_PERSONALIZATION=UINT_MAX)
+ CRYPTOPP_CONSTANT(MAXIMUM_ENTROPY=INT_MAX)
+ CRYPTOPP_CONSTANT(MAXIMUM_NONCE=INT_MAX)
+ CRYPTOPP_CONSTANT(MAXIMUM_ADDITIONAL=INT_MAX)
+ CRYPTOPP_CONSTANT(MAXIMUM_PERSONALIZATION=INT_MAX)
CRYPTOPP_CONSTANT(MAXIMUM_BYTES_PER_REQUEST=65536)
- CRYPTOPP_CONSTANT(MAXIMUM_REQUESTS_BEFORE_RESEED=UINT_MAX)
+ CRYPTOPP_CONSTANT(MAXIMUM_REQUESTS_BEFORE_RESEED=INT_MAX)
//! \brief Construct a Hash DRBG
//! \param entropy the entropy to instantiate the generator
@@ -169,14 +175,16 @@ public:
//! \param nonce additional input to instantiate the generator
//! \param nonceLength the size of the nonce buffer
//! \param personalization additional input to instantiate the generator
- //! \param personalizationLength the size of the additional input buffer
+ //! \param personalizationLength the size of the personalization buffer
//! \throws NIST_DRBG::Err if the generator is instantiated with insufficient entropy
- //! \details All NIST DRBGs must be instaniated with at least MINIMUM_ENTROPY bytes of entropy. The byte array for entropy must meet NIST
- //! SP 800-90C requirements.
- //! \details The nonce and personalization are optional byte arrays. If nonce is supplied, then it should include MINIMUM_NONCE bytes of entropy.
+ //! \details All NIST DRBGs must be instaniated with at least MINIMUM_ENTROPY bytes of entropy.
+ //! The byte array for entropy must meet NIST
+ //! SP 800-90B or SP 800-90C requirements.
+ //! \details The nonce and personalization are optional byte arrays. If nonce is supplied,
+ //! then it should be at least MINIMUM_NONCE bytes of entropy.
//! \details An example of instantiating a SHA256 generator is shown below.
//! The example provides more entropy than required for SHA256. The NonblockingRng meets the
- //! requirements of NIST SP 800-90C.
+ //! requirements of NIST SP 800-90B or SP 800-90C.
//! RDRAND() and RDSEED() generators would work as well.
//!
//! SecByteBlock entropy(48), result(128);
@@ -196,11 +204,11 @@ public:
unsigned int GetSecurityStrength() const {return SECURITY_STRENGTH;}
unsigned int GetSeedLength() const {return SEED_LENGTH;}
unsigned int GetMinEntropy() const {return MINIMUM_ENTROPY;}
- unsigned int GetMaxEntropy() const {return static_cast(MAXIMUM_ENTROPY);}
+ unsigned int GetMaxEntropy() const {return MAXIMUM_ENTROPY;}
unsigned int GetMinNonce() const {return MINIMUM_NONCE;}
- unsigned int GetMaxNonce() const {return static_cast(MAXIMUM_NONCE);}
- unsigned int GetMaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} // 2^16 bytes per request
- unsigned int GetMaxRequestBeforeReseed() const {return static_cast(MAXIMUM_REQUESTS_BEFORE_RESEED);}
+ unsigned int GetMaxNonce() const {return MAXIMUM_NONCE;}
+ unsigned int GetMaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;}
+ unsigned int GetMaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;}
void IncorporateEntropy(const byte *input, size_t length)
{return DRBG_Reseed(input, length, NULL, 0);}
@@ -247,11 +255,11 @@ protected:
void DRBG_Instantiate(const byte* entropy, size_t entropyLength, const byte* nonce, size_t nonceLength,
const byte* personalization, size_t personalizationLength)
{
- // 8.6.3: The entropy input shall have entropy that is equal to or greater than the security strength of the
- // instantiation. Additional entropy may be provided in the nonce or the optional personalization
- // string during instantiation, or in the additional input during reseeding and generation, but this is
- // not required and does not increase the “official” security strength of the DRBG instantiation that
- // is recorded in the internal state.
+ // SP 800-90A, 8.6.3: The entropy input shall have entropy that is equal to or greater than the security
+ // strength of the instantiation. Additional entropy may be provided in the nonce or the optional
+ // personalization string during instantiation, or in the additional input during reseeding and generation,
+ // but this is not required and does not increase the "official" security strength of the DRBG
+ // instantiation that is recorded in the internal state.
CRYPTOPP_ASSERT(entropyLength >= MINIMUM_ENTROPY);
if (entropyLength < MINIMUM_ENTROPY)
throw NIST_DRBG::Err("Hash_DRBG", "Insufficient entropy during instantiate");
@@ -274,11 +282,11 @@ protected:
// 10.1.1.3 Reseeding a Hash_DRBG Instantiation (p.49)
void DRBG_Reseed(const byte* entropy, size_t entropyLength, const byte* additional, size_t additionaLength)
{
- // 8.6.3: The entropy input shall have entropy that is equal to or greater than the security strength of the
- // instantiation. Additional entropy may be provided in the nonce or the optional personalization
- // string during instantiation, or in the additional input during reseeding and generation, but this is
- // not required and does not increase the “official” security strength of the DRBG instantiation that
- // is recorded in the internal state.
+ // SP 800-90A, 8.6.3: The entropy input shall have entropy that is equal to or greater than the security
+ // strength of the instantiation. Additional entropy may be provided in the nonce or the optional
+ // personalization string during instantiation, or in the additional input during reseeding and generation,
+ // but this is not required and does not increase the "official" security strength of the DRBG
+ // instantiation that is recorded in the internal state..
CRYPTOPP_ASSERT(entropyLength >= MINIMUM_ENTROPY);
if (entropyLength < MINIMUM_ENTROPY)
throw NIST_DRBG::Err("Hash_DRBG", "Insufficient entropy during reseed");