diff --git a/drbg.h b/drbg.h index 35358e41..32dae5d2 100644 --- a/drbg.h +++ b/drbg.h @@ -11,6 +11,8 @@ #include "cryptlib.h" #include "secblock.h" +#include "hmac.h" +#include "sha.h" NAMESPACE_BEGIN(CryptoPP) @@ -170,6 +172,8 @@ public: CRYPTOPP_CONSTANT(MAXIMUM_BYTES_PER_REQUEST=65536) CRYPTOPP_CONSTANT(MAXIMUM_REQUESTS_BEFORE_RESEED=INT_MAX) + 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 @@ -281,6 +285,8 @@ public: CRYPTOPP_CONSTANT(MAXIMUM_BYTES_PER_REQUEST=65536) CRYPTOPP_CONSTANT(MAXIMUM_REQUESTS_BEFORE_RESEED=INT_MAX) + 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 @@ -537,8 +543,8 @@ void Hash_DRBG::Hash_Update(const byte* input1, size size_t count = STDMIN(outlen, (size_t)HASH::DIGESTSIZE); hash.TruncatedFinal(output, count); - output += count; outlen -= count; - counter++; + output += count; outlen -= count; + counter++; } } diff --git a/mersenne.h b/mersenne.h index af7b0f66..6337cb0e 100644 --- a/mersenne.h +++ b/mersenne.h @@ -30,6 +30,10 @@ template #if defined(USE_MS_CRYPTOAPI) @@ -34,7 +31,6 @@ # define CRYPT_MACHINE_KEYSET 0x00000020 #endif #elif defined(USE_MS_CNGAPI) -//#include #include #ifndef BCRYPT_SUCCESS # define BCRYPT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0) diff --git a/osrng.h b/osrng.h index 85187981..e70684d2 100644 --- a/osrng.h +++ b/osrng.h @@ -87,9 +87,12 @@ private: class CRYPTOPP_DLL NonblockingRng : public RandomNumberGenerator { public: + CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "NonblockingRng"; } + + ~NonblockingRng(); + //! \brief Construct a NonblockingRng NonblockingRng(); - ~NonblockingRng(); //! \brief Generate random array of bytes //! \param output the byte buffer @@ -115,9 +118,12 @@ protected: class CRYPTOPP_DLL BlockingRng : public RandomNumberGenerator { public: + CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "BlockingRng"; } + + ~BlockingRng(); + //! \brief Construct a BlockingRng BlockingRng(); - ~BlockingRng(); //! \brief Generate random array of bytes //! \param output the byte buffer @@ -143,7 +149,6 @@ protected: //! by way of BlockingRng, if available. CRYPTOPP_DLL void CRYPTOPP_API OS_GenerateRandomBlock(bool blocking, byte *output, size_t size); - //! \class AutoSeededRandomPool //! \brief Automatically Seeded Randomness Pool //! \details This class seeds itself using an operating system provided RNG. @@ -151,6 +156,10 @@ CRYPTOPP_DLL void CRYPTOPP_API OS_GenerateRandomBlock(bool blocking, byte *outpu class CRYPTOPP_DLL AutoSeededRandomPool : public RandomPool { public: + CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() { return "AutoSeededRandomPool"; } + + ~AutoSeededRandomPool() {} + //! \brief Construct an AutoSeededRandomPool //! \param blocking controls seeding with BlockingRng or NonblockingRng //! \param seedSize the size of the seed, in bytes @@ -178,6 +187,10 @@ template class AutoSeededX917RNG : public RandomNumberGenerator, public NotCopyable { public: + static std::string StaticAlgorithmName() { return std::string("AutoSeededX917RNG(") + BLOCK_CIPHER::StaticAlgorithmName() + std::string(")"); } + + ~AutoSeededX917RNG() {} + //! \brief Construct an AutoSeededX917RNG //! \param blocking controls seeding with BlockingRng or NonblockingRng //! \param autoSeed controls auto seeding of the generator