I have a question as to why some very similar code produces different results using 
two different versions of Crypto++, and more importantly, how to replicate the results 
using the former version with the latter.

Here is the code, first using the older version.  Unfortunately, I'm not sure of the 
version, but it's somewhere around 3.5
/////////////////////////
        time_t Time;
        time(&Time);

        BlockTransformation *pCipher = new DES_EDE_Encryption( (BYTE*)CIPHER_SEED);
        X917RNG rng( pCipher,(BYTE*)&Time );

        RSAES_PKCS1v15_Decryptor RsaPrv( rng, 1024 );
        RSAES_PKCS1v15_Encryptor RsaPub( RsaPrv );

        ByteQueue bqRsaPrv;
        RsaPrv.DEREncode( bqRsaPrv );
        DWORD dwcbRsaPrv = bqRsaPrv.CurrentSize();

        ByteQueue bqRsaPub;
        RsaPub.DEREncode( bqRsaPub );
        DWORD dwcbRsaPub = bqRsaPub.CurrentSize();
//////////////////////////

Now an attempt to do this same thing using version 5.1
/////////////////////////
        time_t Time;
        time(&Time);

        BlockTransformation *pCipher = new DES::Encryption( (BYTE*)CIPHER_SEED);
        X917RNG rng( pCipher,(BYTE*)&Time );

        RSAES_PKCS1v15_Decryptor RsaPrv( rng, 1024 );
        RSAES_PKCS1v15_Encryptor RsaPub( RsaPrv );

        ByteQueue bqRsaPrv;
        RsaPrv.DEREncode( bqRsaPrv );
        DWORD dwcbRsaPrv = bqRsaPrv.CurrentSize();

        ByteQueue bqRsaPub;
        RsaPub.DEREncode( bqRsaPub );
        DWORD dwcbRsaPub = bqRsaPub.CurrentSize();
///////////////////////////

In the first case, I get 

        dwcbRsaPrv = 605
        dwcbRsaPub = 138

In the second case, I get

        dwcbRsaPrv = 633
        dwcbRsaPub = 160

Why the difference in size and what can I do differently to get the previous sizes to 
be returned using the newer version (which is what I really need).


Reply via email to