Re: Difference in behavior of Crypto850 build on Windows and non-Windows

Jeffrey Walton <[email protected]>
Newsgroups gmane.comp.encryption.cryptopp
Message-ID <CAH8yC8njUw58yBCHK=iLHFJa+gj3kVJeK8EP49=YprSj8kH0Cw@mail.gmail.com>
On Thu, Jun 17, 2021 at 7:22 AM Jeffrey Walton <[email protected]> wrote:
>
> On Wed, Jun 16, 2021 at 6:38 AM Vinay Kumar <[email protected]> wrote:
> >
> > Thanq.
> >
> > 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:
> >
> > VALUE=3957804565
> > FIRST RAND=123224688
> > SECOND RAND=3565820466
> > THIRD RAND=2141184933
> >
> >
> > VALUE=15201583
> > FIRST RAND=2446881748
> > SECOND RAND=653021931
> > THIRD RAND=31285341
> >
> > VALUE=1947237586
> > 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 Cryptopp850.
> > 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.

OK, I had some time to do some digging. Here's what Crypto++ 5.4
prints out in hex:

$ ./test.exe
VALUE=3957804565
FIRST RAND=7584270
SECOND RAND=d48a1a32
THIRD RAND=7f9fe3a5

The OldRandomPool class provides an endian-swapped value. I'm not sure why.

To fix it, we checked in this change:
https://github.com/weidai11/cryptopp/commit/7101e9e73a66.

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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8njUw58yBCHK%3DiLHFJa%2Bgj3kVJeK8EP49%3DYprSj8kH0Cw%40mail.gmail.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.