summaryrefslogtreecommitdiff
path: root/drbg.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-11-29 10:54:33 -0500
committerJeffrey Walton <noloader@gmail.com>2017-11-29 10:54:33 -0500
commit61ec50dabe14c5d4582ac187706ea27645b3562b (patch)
tree18a2eebb7adc8c9556ce132d7081a105fa058d6b /drbg.h
parent16ebfa72bf130c4725e652e4d3688d97d3feb0ee (diff)
downloadcryptopp-git-61ec50dabe14c5d4582ac187706ea27645b3562b.tar.gz
Change Doxygen comment style from //! to ///
Also see https://groups.google.com/forum/#!topic/cryptopp-users/A7-Xt5Knlzw
Diffstat (limited to 'drbg.h')
-rw-r--r--drbg.h332
1 files changed, 166 insertions, 166 deletions
diff --git a/drbg.h b/drbg.h
index 468b8b1c..42b5c788 100644
--- a/drbg.h
+++ b/drbg.h
@@ -1,10 +1,10 @@
// drbg.h - written and placed in public domain by Jeffrey Walton.
-//! \file drbg.h
-//! \brief Classes for NIST DRBGs from SP 800-90A
-//! \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
-//! for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
-//! \since Crypto++ 6.0
+/// \file drbg.h
+/// \brief Classes for NIST DRBGs from SP 800-90A
+/// \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
+/// for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
+/// \since Crypto++ 6.0
#ifndef CRYPTOPP_NIST_DRBG_H
#define CRYPTOPP_NIST_DRBG_H
@@ -16,16 +16,16 @@
NAMESPACE_BEGIN(CryptoPP)
-//! \class NIST_DRBG
-//! \brief Interface for NIST DRBGs from SP 800-90A
-//! \details NIST_DRBG is the base class interface for NIST DRBGs from SP 800-90A Rev 1 (June 2015)
-//! \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
-//! for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
-//! \since Crypto++ 6.0
+/// \class NIST_DRBG
+/// \brief Interface for NIST DRBGs from SP 800-90A
+/// \details NIST_DRBG is the base class interface for NIST DRBGs from SP 800-90A Rev 1 (June 2015)
+/// \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
+/// for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
+/// \since Crypto++ 6.0
class NIST_DRBG : public RandomNumberGenerator
{
public:
- //! \brief Exception thrown when a NIST DRBG encounters an error
+ /// \brief Exception thrown when a NIST DRBG encounters an error
class Err : public Exception
{
public:
@@ -36,105 +36,105 @@ public:
public:
virtual ~NIST_DRBG() {}
- //! \brief Determines if a generator can accept additional entropy
- //! \return true
- //! \details All NIST_DRBG return true
+ /// \brief Determines if a generator can accept additional entropy
+ /// \return true
+ /// \details All NIST_DRBG return true
virtual bool CanIncorporateEntropy() const {return true;}
- //! \brief Update RNG state with additional unpredictable values
- //! \param input the entropy to add to the generator
- //! \param length the size of the input buffer
- //! \throws NIST_DRBG::Err if the generator is reseeded with insufficient entropy
- //! \details NIST instantiation and reseed requirements demand the generator is constructed
- //! with at least <tt>MINIMUM_ENTROPY</tt> entropy. The byte array for <tt>input</tt> must
- //! meet <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
- //! SP 800-90C</A> requirements.
+ /// \brief Update RNG state with additional unpredictable values
+ /// \param input the entropy to add to the generator
+ /// \param length the size of the input buffer
+ /// \throws NIST_DRBG::Err if the generator is reseeded with insufficient entropy
+ /// \details NIST instantiation and reseed requirements demand the generator is constructed
+ /// with at least <tt>MINIMUM_ENTROPY</tt> entropy. The byte array for <tt>input</tt> must
+ /// meet <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
+ /// SP 800-90C</A> requirements.
virtual void IncorporateEntropy(const byte *input, size_t length)=0;
- //! \brief Update RNG state with additional unpredictable values
- //! \param entropy the entropy to add to the generator
- //! \param entropyLength the size of the input buffer
- //! \param additional additional input to add to the generator
- //! \param additionaLength the size of the additional input buffer
- //! \throws NIST_DRBG::Err if the generator is reseeded with insufficient entropy
- //! \details IncorporateEntropy() is an overload provided to match NIST requirements. NIST
- //! instantiation and reseed requirements demand the generator is constructed with at least
- //! <tt>MINIMUM_ENTROPY</tt> entropy. The byte array for <tt>entropy</tt> must meet
- //! <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
- //!! SP 800-90C</A> requirements.
+ /// \brief Update RNG state with additional unpredictable values
+ /// \param entropy the entropy to add to the generator
+ /// \param entropyLength the size of the input buffer
+ /// \param additional additional input to add to the generator
+ /// \param additionaLength the size of the additional input buffer
+ /// \throws NIST_DRBG::Err if the generator is reseeded with insufficient entropy
+ /// \details IncorporateEntropy() is an overload provided to match NIST requirements. NIST
+ /// instantiation and reseed requirements demand the generator is constructed with at least
+ /// <tt>MINIMUM_ENTROPY</tt> entropy. The byte array for <tt>entropy</tt> must meet
+ /// <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
+ ///! SP 800-90C</A> requirements.
virtual void IncorporateEntropy(const byte *entropy, size_t entropyLength, const byte* additional, size_t additionaLength)=0;
- //! \brief Generate random array of bytes
- //! \param output the byte buffer
- //! \param size the length of the buffer, in bytes
- //! \throws NIST_DRBG::Err if a reseed is required
- //! \throws NIST_DRBG::Err if the size exceeds <tt>MAXIMUM_BYTES_PER_REQUEST</tt>
+ /// \brief Generate random array of bytes
+ /// \param output the byte buffer
+ /// \param size the length of the buffer, in bytes
+ /// \throws NIST_DRBG::Err if a reseed is required
+ /// \throws NIST_DRBG::Err if the size exceeds <tt>MAXIMUM_BYTES_PER_REQUEST</tt>
virtual void GenerateBlock(byte *output, size_t size)=0;
- //! \brief Generate random array of bytes
- //! \param additional additional input to add to the generator
- //! \param additionaLength the size of the additional input buffer
- //! \param output the byte buffer
- //! \param size the length of the buffer, in bytes
- //! \throws NIST_DRBG::Err if a reseed is required
- //! \throws NIST_DRBG::Err if the size exceeds <tt>MAXIMUM_BYTES_PER_REQUEST</tt>
- //! \details GenerateBlock() is an overload provided to match NIST requirements. The byte
- //! array for <tt>additional</tt> input is optional. If present the additional randomness
- //! is mixed before generating the output bytes.
+ /// \brief Generate random array of bytes
+ /// \param additional additional input to add to the generator
+ /// \param additionaLength the size of the additional input buffer
+ /// \param output the byte buffer
+ /// \param size the length of the buffer, in bytes
+ /// \throws NIST_DRBG::Err if a reseed is required
+ /// \throws NIST_DRBG::Err if the size exceeds <tt>MAXIMUM_BYTES_PER_REQUEST</tt>
+ /// \details GenerateBlock() is an overload provided to match NIST requirements. The byte
+ /// array for <tt>additional</tt> input is optional. If present the additional randomness
+ /// is mixed before generating the output bytes.
virtual void GenerateBlock(const byte* additional, size_t additionaLength, byte *output, size_t size)=0;
- //! \brief Provides the security strength
- //! \returns The security strength of the generator, in bytes
- //! \details The equivalent class constant is <tt>SECURITY_STRENGTH</tt>
+ /// \brief Provides the security strength
+ /// \returns The security strength of the generator, in bytes
+ /// \details The equivalent class constant is <tt>SECURITY_STRENGTH</tt>
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 <tt>SEED_LENGTH</tt>. The size is
- //! used to maintain internal state of <tt>V</tt> and <tt>C</tt>.
+ /// \brief Provides the seed length
+ /// \returns The seed size of the generator, in bytes
+ /// \details The equivalent class constant is <tt>SEED_LENGTH</tt>. The size is
+ /// used to maintain internal state of <tt>V</tt> and <tt>C</tt>.
virtual unsigned int SeedLength() const=0;
- //! \brief Provides the minimum entropy size
- //! \returns The minimum entropy size required by the generator, in bytes
- //! \details The equivalent class constant is <tt>MINIMUM_ENTROPY</tt>. All NIST DRBGs must
- //! be instaniated with at least <tt>MINIMUM_ENTROPY</tt> bytes of entropy. The bytes must
- //! meet <A HREF="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
- //! SP 800-90C</A> requirements.
+ /// \brief Provides the minimum entropy size
+ /// \returns The minimum entropy size required by the generator, in bytes
+ /// \details The equivalent class constant is <tt>MINIMUM_ENTROPY</tt>. All NIST DRBGs must
+ /// be instaniated with at least <tt>MINIMUM_ENTROPY</tt> bytes of entropy. The bytes must
+ /// meet <A HREF="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
+ /// SP 800-90C</A> requirements.
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
- //! \details The equivalent class constant is <tt>MAXIMUM_ENTROPY</tt>. The bytes must
- //! meet <A HREF="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
- //! SP 800-90C</A> requirements. <tt>MAXIMUM_ENTROPY</tt> has been reduced from
- //! 2<sup>35</sup> to <tt>INT_MAX</tt> to fit the underlying C++ datatype.
+ /// \brief Provides the maximum entropy size
+ /// \returns The maximum entropy size that can be consumed by the generator, in bytes
+ /// \details The equivalent class constant is <tt>MAXIMUM_ENTROPY</tt>. The bytes must
+ /// meet <A HREF="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or
+ /// SP 800-90C</A> requirements. <tt>MAXIMUM_ENTROPY</tt> has been reduced from
+ /// 2<sup>35</sup> to <tt>INT_MAX</tt> to fit the underlying C++ datatype.
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 <tt>MINIMUM_NONCE</tt>. If a nonce is not
- //! required then <tt>MINIMUM_NONCE</tt> is 0. <tt>Hash_DRBG</tt> does not require a
- //! nonce, while <tt>HMAC_DRBG</tt> and <tt>CTR_DRBG</tt> require a nonce.
+ /// \brief Provides the minimum nonce size
+ /// \returns The minimum nonce size recommended for the generator, in bytes
+ /// \details The equivalent class constant is <tt>MINIMUM_NONCE</tt>. If a nonce is not
+ /// required then <tt>MINIMUM_NONCE</tt> is 0. <tt>Hash_DRBG</tt> does not require a
+ /// nonce, while <tt>HMAC_DRBG</tt> and <tt>CTR_DRBG</tt> require a nonce.
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
- //! \details The equivalent class constant is <tt>MAXIMUM_NONCE</tt>. <tt>MAXIMUM_NONCE</tt>
- //! has been reduced from 2<sup>35</sup> to <tt>INT_MAX</tt> to fit the underlying C++ datatype.
- //! If a nonce is not required then <tt>MINIMUM_NONCE</tt> is 0. <tt>Hash_DRBG</tt> does not
- //! require a nonce, while <tt>HMAC_DRBG</tt> and <tt>CTR_DRBG</tt> require a nonce.
+ /// \brief Provides the maximum nonce size
+ /// \returns The maximum nonce that can be consumed by the generator, in bytes
+ /// \details The equivalent class constant is <tt>MAXIMUM_NONCE</tt>. <tt>MAXIMUM_NONCE</tt>
+ /// has been reduced from 2<sup>35</sup> to <tt>INT_MAX</tt> to fit the underlying C++ datatype.
+ /// If a nonce is not required then <tt>MINIMUM_NONCE</tt> is 0. <tt>Hash_DRBG</tt> does not
+ /// require a nonce, while <tt>HMAC_DRBG</tt> and <tt>CTR_DRBG</tt> require a nonce.
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 <tt>MAXIMUM_BYTES_PER_REQUEST</tt>
+ /// \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 <tt>MAXIMUM_BYTES_PER_REQUEST</tt>
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 <tt>MAXIMUM_REQUESTS_BEFORE_RESEED</tt>.
- //! <tt>MAXIMUM_REQUESTS_BEFORE_RESEED</tt> has been reduced from 2<sup>48</sup> to <tt>INT_MAX</tt>
- //! to fit the underlying C++ datatype.
+ /// \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 <tt>MAXIMUM_REQUESTS_BEFORE_RESEED</tt>.
+ /// <tt>MAXIMUM_REQUESTS_BEFORE_RESEED</tt> has been reduced from 2<sup>48</sup> to <tt>INT_MAX</tt>
+ /// to fit the underlying C++ datatype.
virtual unsigned int MaxRequestBeforeReseed() const=0;
protected:
@@ -146,21 +146,21 @@ protected:
// *************************************************************
-//! \class Hash_DRBG
-//! \tparam HASH NIST approved hash derived from HashTransformation
-//! \tparam STRENGTH security strength, in bytes
-//! \tparam SEEDLENGTH seed length, in bytes
-//! \brief Hash_DRBG from SP 800-90A Rev 1 (June 2015)
-//! \details The NIST Hash DRBG is instantiated with a number of parameters. Two of the parameters,
-//! Security Strength and Seed Length, depend on the hash and are specified as template parameters.
-//! The remaining parameters are included in the class. The parameters and their values are listed
-//! in NIST SP 800-90A Rev. 1, Table 2: Definitions for Hash-Based DRBG Mechanisms (p.38).
-//! \details Some parameters have been reduce to fit C++ datatypes. For example, NIST allows upto
-//! 2<sup>48</sup> requests before a reseed. However, Hash_DRBG limits it to <tt>INT_MAX</tt> due
-//! to the limited data range of an int.
-//! \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
-//! for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
-//! \since Crypto++ 6.0
+/// \class Hash_DRBG
+/// \tparam HASH NIST approved hash derived from HashTransformation
+/// \tparam STRENGTH security strength, in bytes
+/// \tparam SEEDLENGTH seed length, in bytes
+/// \brief Hash_DRBG from SP 800-90A Rev 1 (June 2015)
+/// \details The NIST Hash DRBG is instantiated with a number of parameters. Two of the parameters,
+/// Security Strength and Seed Length, depend on the hash and are specified as template parameters.
+/// The remaining parameters are included in the class. The parameters and their values are listed
+/// in NIST SP 800-90A Rev. 1, Table 2: Definitions for Hash-Based DRBG Mechanisms (p.38).
+/// \details Some parameters have been reduce to fit C++ datatypes. For example, NIST allows upto
+/// 2<sup>48</sup> requests before a reseed. However, Hash_DRBG limits it to <tt>INT_MAX</tt> due
+/// to the limited data range of an int.
+/// \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
+/// for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
+/// \since Crypto++ 6.0
template <typename HASH=SHA256, unsigned int STRENGTH=128/8, unsigned int SEEDLENGTH=440/8>
class Hash_DRBG : public NIST_DRBG, public NotCopyable
{
@@ -180,31 +180,31 @@ public:
static std::string StaticAlgorithmName() { return std::string("Hash_DRBG(") + HASH::StaticAlgorithmName() + std::string(")"); }
- //! \brief Construct a Hash DRBG
- //! \param entropy the entropy to instantiate the generator
- //! \param entropyLength the size of the entropy buffer
- //! \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 personalization buffer
- //! \throws NIST_DRBG::Err if the generator is instantiated with insufficient entropy
- //! \details All NIST DRBGs must be instaniated with at least <tt>MINIMUM_ENTROPY</tt> bytes of entropy.
- //! The byte array for <tt>entropy</tt> must meet <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST
- //! SP 800-90B or SP 800-90C</A> requirements.
- //! \details The <tt>nonce</tt> and <tt>personalization</tt> are optional byte arrays. If <tt>nonce</tt> is supplied,
- //! then it should be at least <tt>MINIMUM_NONCE</tt> bytes of entropy.
- //! \details An example of instantiating a SHA256 generator is shown below.
- //! The example provides more entropy than required for SHA256. The <tt>NonblockingRng</tt> meets the
- //! requirements of <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or SP 800-90C</A>.
- //! RDRAND() and RDSEED() generators would work as well.
- //! <pre>
- //! SecByteBlock entropy(48), result(128);
- //! NonblockingRng prng;
- //! RandomNumberSource rns(prng, entropy.size(), new ArraySink(entropy, entropy.size()));
- //!
- //! Hash_DRBG<SHA256, 128/8, 440/8> drbg(entropy, 32, entropy+32, 16);
- //! drbg.GenerateBlock(result, result.size());
- //! </pre>
+ /// \brief Construct a Hash DRBG
+ /// \param entropy the entropy to instantiate the generator
+ /// \param entropyLength the size of the entropy buffer
+ /// \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 personalization buffer
+ /// \throws NIST_DRBG::Err if the generator is instantiated with insufficient entropy
+ /// \details All NIST DRBGs must be instaniated with at least <tt>MINIMUM_ENTROPY</tt> bytes of entropy.
+ /// The byte array for <tt>entropy</tt> must meet <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST
+ /// SP 800-90B or SP 800-90C</A> requirements.
+ /// \details The <tt>nonce</tt> and <tt>personalization</tt> are optional byte arrays. If <tt>nonce</tt> is supplied,
+ /// then it should be at least <tt>MINIMUM_NONCE</tt> bytes of entropy.
+ /// \details An example of instantiating a SHA256 generator is shown below.
+ /// The example provides more entropy than required for SHA256. The <tt>NonblockingRng</tt> meets the
+ /// requirements of <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or SP 800-90C</A>.
+ /// RDRAND() and RDSEED() generators would work as well.
+ /// <pre>
+ /// SecByteBlock entropy(48), result(128);
+ /// NonblockingRng prng;
+ /// RandomNumberSource rns(prng, entropy.size(), new ArraySink(entropy, entropy.size()));
+ ///
+ /// Hash_DRBG<SHA256, 128/8, 440/8> drbg(entropy, 32, entropy+32, 16);
+ /// drbg.GenerateBlock(result, result.size());
+ /// </pre>
Hash_DRBG(const byte* entropy=NULLPTR, size_t entropyLength=STRENGTH, const byte* nonce=NULLPTR,
size_t nonceLength=0, const byte* personalization=NULLPTR, size_t personalizationLength=0)
: NIST_DRBG(), m_c(SEEDLENGTH), m_v(SEEDLENGTH), m_reseed(0)
@@ -261,20 +261,20 @@ private:
// *************************************************************
-//! \class HMAC_DRBG
-//! \tparam HASH NIST approved hash derived from HashTransformation
-//! \tparam STRENGTH security strength, in bytes
-//! \tparam SEEDLENGTH seed length, in bytes
-//! \brief HMAC_DRBG from SP 800-90A Rev 1 (June 2015)
-//! \details The NIST HMAC DRBG is instantiated with a number of parameters. Two of the parameters,
-//! Security Strength and Seed Length, depend on the hash and are specified as template parameters.
-//! The remaining parameters are included in the class. The parameters and their values are listed
-//! in NIST SP 800-90A Rev. 1, Table 2: Definitions for Hash-Based DRBG Mechanisms (p.38).
-//! \details Some parameters have been reduce to fit C++ datatypes. For example, NIST allows upto 2<sup>48</sup> requests
-//! before a reseed. However, HMAC_DRBG limits it to <tt>INT_MAX</tt> due to the limited data range of an int.
-//! \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
-//! for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
-//! \since Crypto++ 6.0
+/// \class HMAC_DRBG
+/// \tparam HASH NIST approved hash derived from HashTransformation
+/// \tparam STRENGTH security strength, in bytes
+/// \tparam SEEDLENGTH seed length, in bytes
+/// \brief HMAC_DRBG from SP 800-90A Rev 1 (June 2015)
+/// \details The NIST HMAC DRBG is instantiated with a number of parameters. Two of the parameters,
+/// Security Strength and Seed Length, depend on the hash and are specified as template parameters.
+/// The remaining parameters are included in the class. The parameters and their values are listed
+/// in NIST SP 800-90A Rev. 1, Table 2: Definitions for Hash-Based DRBG Mechanisms (p.38).
+/// \details Some parameters have been reduce to fit C++ datatypes. For example, NIST allows upto 2<sup>48</sup> requests
+/// before a reseed. However, HMAC_DRBG limits it to <tt>INT_MAX</tt> due to the limited data range of an int.
+/// \sa <A HREF="http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf">Recommendation
+/// for Random Number Generation Using Deterministic Random Bit Generators, Rev 1 (June 2015)</A>
+/// \since Crypto++ 6.0
template <typename HASH=SHA256, unsigned int STRENGTH=128/8, unsigned int SEEDLENGTH=440/8>
class HMAC_DRBG : public NIST_DRBG, public NotCopyable
{
@@ -294,31 +294,31 @@ public:
static std::string StaticAlgorithmName() { return std::string("HMAC_DRBG(") + HASH::StaticAlgorithmName() + std::string(")"); }
- //! \brief Construct a HMAC DRBG
- //! \param entropy the entropy to instantiate the generator
- //! \param entropyLength the size of the entropy buffer
- //! \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 personalization buffer
- //! \throws NIST_DRBG::Err if the generator is instantiated with insufficient entropy
- //! \details All NIST DRBGs must be instaniated with at least <tt>MINIMUM_ENTROPY</tt> bytes of entropy.
- //! The byte array for <tt>entropy</tt> must meet <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST
- //! SP 800-90B or SP 800-90C</A> requirements.
- //! \details The <tt>nonce</tt> and <tt>personalization</tt> are optional byte arrays. If <tt>nonce</tt> is supplied,
- //! then it should be at least <tt>MINIMUM_NONCE</tt> bytes of entropy.
- //! \details An example of instantiating a SHA256 generator is shown below.
- //! The example provides more entropy than required for SHA256. The <tt>NonblockingRng</tt> meets the
- //! requirements of <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or SP 800-90C</A>.
- //! RDRAND() and RDSEED() generators would work as well.
- //! <pre>
- //! SecByteBlock entropy(48), result(128);
- //! NonblockingRng prng;
- //! RandomNumberSource rns(prng, entropy.size(), new ArraySink(entropy, entropy.size()));
- //!
- //! HMAC_DRBG<SHA256, 128/8, 440/8> drbg(entropy, 32, entropy+32, 16);
- //! drbg.GenerateBlock(result, result.size());
- //! </pre>
+ /// \brief Construct a HMAC DRBG
+ /// \param entropy the entropy to instantiate the generator
+ /// \param entropyLength the size of the entropy buffer
+ /// \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 personalization buffer
+ /// \throws NIST_DRBG::Err if the generator is instantiated with insufficient entropy
+ /// \details All NIST DRBGs must be instaniated with at least <tt>MINIMUM_ENTROPY</tt> bytes of entropy.
+ /// The byte array for <tt>entropy</tt> must meet <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST
+ /// SP 800-90B or SP 800-90C</A> requirements.
+ /// \details The <tt>nonce</tt> and <tt>personalization</tt> are optional byte arrays. If <tt>nonce</tt> is supplied,
+ /// then it should be at least <tt>MINIMUM_NONCE</tt> bytes of entropy.
+ /// \details An example of instantiating a SHA256 generator is shown below.
+ /// The example provides more entropy than required for SHA256. The <tt>NonblockingRng</tt> meets the
+ /// requirements of <A HREF ="http://csrc.nist.gov/publications/PubsSPs.html">NIST SP 800-90B or SP 800-90C</A>.
+ /// RDRAND() and RDSEED() generators would work as well.
+ /// <pre>
+ /// SecByteBlock entropy(48), result(128);
+ /// NonblockingRng prng;
+ /// RandomNumberSource rns(prng, entropy.size(), new ArraySink(entropy, entropy.size()));
+ ///
+ /// HMAC_DRBG<SHA256, 128/8, 440/8> drbg(entropy, 32, entropy+32, 16);
+ /// drbg.GenerateBlock(result, result.size());
+ /// </pre>
HMAC_DRBG(const byte* entropy=NULLPTR, size_t entropyLength=STRENGTH, const byte* nonce=NULLPTR,
size_t nonceLength=0, const byte* personalization=NULLPTR, size_t personalizationLength=0)
: NIST_DRBG(), m_k(HASH::DIGESTSIZE), m_v(HASH::DIGESTSIZE), m_reseed(0)