diff --git a/bench1.cpp b/bench1.cpp index d288cdc7..94173005 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -235,7 +235,7 @@ void BenchMark(const char *name, NIST_DRBG &rng, double timeTotal) Test::GlobalRNG().GenerateBlock(buf, BUF_SIZE); buf.SetMark(16); - rng.IncorporateEntropy(buf, rng.GetMinEntropy()); + rng.IncorporateEntropy(buf, rng.MinEntropyLength()); unsigned long long blocks = 1; double timeTaken; diff --git a/drbg.h b/drbg.h index e7262138..468b8b1c 100644 --- a/drbg.h +++ b/drbg.h @@ -86,13 +86,13 @@ public: //! \brief Provides the security strength //! \returns The security strength of the generator, in bytes //! \details The equivalent class constant is SECURITY_STRENGTH - virtual unsigned int GetSecurityStrength() const=0; + virtual unsigned int SecurityStrength() const=0; //! \brief Provides the seed length //! \returns The seed size of the generator, in bytes //! \details The equivalent class constant is SEED_LENGTH. The size is //! used to maintain internal state of V and C. - virtual unsigned int GetSeedLength() const=0; + virtual unsigned int SeedLength() const=0; //! \brief Provides the minimum entropy size //! \returns The minimum entropy size required by the generator, in bytes @@ -100,7 +100,7 @@ public: //! be instaniated with at least MINIMUM_ENTROPY bytes of entropy. The bytes must //! meet NIST SP 800-90B or //! SP 800-90C requirements. - virtual unsigned int GetMinEntropy() const=0; + virtual unsigned int MinEntropyLength() const=0; //! \brief Provides the maximum entropy size //! \returns The maximum entropy size that can be consumed by the generator, in bytes @@ -108,14 +108,14 @@ public: //! meet NIST SP 800-90B or //! SP 800-90C requirements. MAXIMUM_ENTROPY has been reduced from //! 235 to INT_MAX to fit the underlying C++ datatype. - virtual unsigned int GetMaxEntropy() const=0; + virtual unsigned int MaxEntropyLength() const=0; //! \brief Provides the minimum nonce size //! \returns The minimum nonce size recommended for the generator, in bytes //! \details The equivalent class constant is MINIMUM_NONCE. If a nonce is not //! required then MINIMUM_NONCE is 0. Hash_DRBG does not require a //! nonce, while HMAC_DRBG and CTR_DRBG require a nonce. - virtual unsigned int GetMinNonce() const=0; + virtual unsigned int MinNonceLength() const=0; //! \brief Provides the maximum nonce size //! \returns The maximum nonce that can be consumed by the generator, in bytes @@ -123,19 +123,19 @@ public: //! has been reduced from 235 to INT_MAX to fit the underlying C++ datatype. //! If a nonce is not required then MINIMUM_NONCE is 0. Hash_DRBG does not //! require a nonce, while HMAC_DRBG and CTR_DRBG require a nonce. - virtual unsigned int GetMaxNonce() const=0; + virtual unsigned int MaxNonceLength() const=0; //! \brief Provides the maximum size of a request to GenerateBlock //! \returns The the maximum size of a request to GenerateBlock(), in bytes //! \details The equivalent class constant is MAXIMUM_BYTES_PER_REQUEST - virtual unsigned int GetMaxBytesPerRequest() const=0; + virtual unsigned int MaxBytesPerRequest() const=0; //! \brief Provides the maximum number of requests before a reseed //! \returns The the maximum number of requests before a reseed, in bytes //! \details The equivalent class constant is MAXIMUM_REQUESTS_BEFORE_RESEED. //! MAXIMUM_REQUESTS_BEFORE_RESEED has been reduced from 248 to INT_MAX //! to fit the underlying C++ datatype. - virtual unsigned int GetMaxRequestBeforeReseed() const=0; + virtual unsigned int MaxRequestBeforeReseed() const=0; protected: virtual void DRBG_Instantiate(const byte* entropy, size_t entropyLength, @@ -213,14 +213,14 @@ public: DRBG_Instantiate(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength); } - 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 MAXIMUM_ENTROPY;} - unsigned int GetMinNonce() const {return MINIMUM_NONCE;} - 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;} + unsigned int SecurityStrength() const {return SECURITY_STRENGTH;} + unsigned int SeedLength() const {return SEED_LENGTH;} + unsigned int MinEntropyLength() const {return MINIMUM_ENTROPY;} + unsigned int MaxEntropyLength() const {return MAXIMUM_ENTROPY;} + unsigned int MinNonceLength() const {return MINIMUM_NONCE;} + unsigned int MaxNonceLength() const {return MAXIMUM_NONCE;} + unsigned int MaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} + unsigned int MaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} void IncorporateEntropy(const byte *input, size_t length) {return DRBG_Reseed(input, length, NULLPTR, 0);} @@ -327,14 +327,14 @@ public: DRBG_Instantiate(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength); } - 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 MAXIMUM_ENTROPY;} - unsigned int GetMinNonce() const {return MINIMUM_NONCE;} - 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;} + unsigned int SecurityStrength() const {return SECURITY_STRENGTH;} + unsigned int SeedLength() const {return SEED_LENGTH;} + unsigned int MinEntropyLength() const {return MINIMUM_ENTROPY;} + unsigned int MaxEntropyLength() const {return MAXIMUM_ENTROPY;} + unsigned int MinNonceLength() const {return MINIMUM_NONCE;} + unsigned int MaxNonceLength() const {return MAXIMUM_NONCE;} + unsigned int MaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} + unsigned int MaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} void IncorporateEntropy(const byte *input, size_t length) {return DRBG_Reseed(input, length, NULLPTR, 0);} @@ -435,10 +435,10 @@ template void Hash_DRBG::Hash_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size) { // Step 1 - if (static_cast(m_reseed) >= static_cast(GetMaxRequestBeforeReseed())) + if (static_cast(m_reseed) >= static_cast(MaxRequestBeforeReseed())) throw NIST_DRBG::Err("Hash_DRBG", "Reseed required"); - if (size > GetMaxBytesPerRequest()) + if (size > MaxBytesPerRequest()) throw NIST_DRBG::Err("Hash_DRBG", "Request size exceeds limit"); // SP 800-90A, Section 9, says we should throw if we have too much entropy, too large a nonce, @@ -658,10 +658,10 @@ template void HMAC_DRBG::HMAC_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size) { // Step 1 - if (static_cast(m_reseed) >= static_cast(GetMaxRequestBeforeReseed())) + if (static_cast(m_reseed) >= static_cast(MaxRequestBeforeReseed())) throw NIST_DRBG::Err("HMAC_DRBG", "Reseed required"); - if (size > GetMaxBytesPerRequest()) + if (size > MaxBytesPerRequest()) throw NIST_DRBG::Err("HMAC_DRBG", "Request size exceeds limit"); // SP 800-90A, Section 9, says we should throw if we have too much entropy, too large a nonce,