Here is the code snippet(tested with sample application):

unsigned char temprpl[4] = { '\0' };
unsigned __int32 Value = 3957804565;
CryptoPP::RandomPool vRandPool;

        memset((CryptoPP::byte *)&temprpl, 0, 4);
memcpy((CryptoPP::byte *)&temprpl, (CryptoPP::byte *)&Value, 4);

cout << "VALUE=" << Value << endl;

vRandPool.Put( reinterpret_cast<unsigned char*>(&temprpl), sizeof(Value) ); 
/* For Crypto++ 5.4 */
// vRandPool.IncorporateEntropy( (const CryptoPP::byte *)&temprpl, 4 ); /* 
For Cryptopp850 */

CryptoPP::word32 t1 = vRandPool.GenerateWord32();

cout << "FIRST RAND=" << t1 << endl;

CryptoPP::word32 t2 = vRandPool.GenerateWord32();

cout << "SECOND RAND=" << t2 << endl;

CryptoPP::word32 t3 = vRandPool.GenerateWord32();

cout << "THIRD RAND=" << t3 << endl;

With Crypto++ 5.4 it always returns 'fixed RAND' values for specific 
'Value' as follows:

FIRST RAND=123224688
SECOND RAND=3565820466
THIRD RAND=2141184933

FIRST RAND=2446881748
SECOND RAND=653021931
THIRD RAND=31285341

FIRST RAND=4090363092
SECOND RAND=1687243401
THIRD RAND=1878929729

But, with Cryptopp850, it returns 'different RAND' values(and it is 
different for every run). This is causing issues after upgrading to 
This change in behavior is observed only on Windows platform and it works 
perfectly fine on Linux.

Do you think it is a bug? Any workaround or other solution available to 
resolve this problem. 

On Tuesday, June 15, 2021 at 1:41:28 PM UTC+5:30 Jeffrey Walton wrote:

> > We are migrating from Crypto-5.4 to Crypto850.
> > Changes have been made to support the newer version(Crypto850).
> > On Linux, it works fine. But on Windows, we are facing issues.
> > We are using Visual Studio 2013 to build the cypto library(using 
> cryptest.sln).
> > There is no source code difference between Linux and Windows.
> > The same source code works fine if it is rebuilt with Crypto-5.4.
> > Only major change done is to replace Randpool.Put with 
> Randpool.IncorporateEntropy
> >
> > And also, using OldRandPool instead of RandPool works fine.
> >
> > Any Idea on how to resolve this problem?
> Also see for documentation
> on OldRandomPool.
> > One more observation is that on building manually(without using 
> cryptest.sln) and using the library, it is found to crash at randpool.cpp:39
> For custom Crypto++ builds, the Nmake makefile might be useful to you.
> It is easier to change build flags using Nmake makefile. Also see
> .
> Jeff

You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To view this discussion on the web visit

Reply via email to