Thanks again Wei.  I promise this is the last follow up in this thread.  Your 
suggestion worked for the case cited, but did not work in the following instance:

                        RSAES_PKCS1v15_Decryptor RsaPrv;
                        RsaPrv.AccessKey().BERDecodeKey(bqRsaPrv);

Could you give me one of your famous 1 or 2 lines of code that make everything work?

-----Original Message-----
From: Wei Dai [mailto:[EMAIL PROTECTED]
Sent: Tuesday, November 18, 2003 3:00 PM
To: [EMAIL PROTECTED]
Subject: Re: Getting different results from different Crypto++ versions


RSASSA_PKCS1v15_MD5_Signer RsaPrv;
RsaPrv.AccessKey().BERDecodeKey(bqRsaPrv);

On Tue, Nov 18, 2003 at 02:18:11PM -0800, James Goodrich wrote:
> Thanks Wei, that did the trick.  Now I have to solve the problem in reverse: I need 
> to use the byte queue to create a key, which I assume is now expecting the 
> x509/pkcs8 wrapped key. How can I get the following to work in 5.1, after making the 
> modifications to the sample code as you suggested?
> 
>       RSASSA_PKCS1v15_MD5_Signer RsaPrv( bqRsaPrv );
> 
> -----Original Message-----
> From: Wei Dai [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, November 18, 2003 1:07 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Getting different results from different Crypto++ versions
> 
> 
> You can get the same behavior in 5.1 using:
> 
> RsaPrv.GetKey().DEREncodeKey(bqRsaPrv);
> 
> The DEREncode() function added an additional x509/pkcs8 wrapper around the
> key to be more compatible with other applications.
> 
> On Tue, Nov 18, 2003 at 11:21:40AM -0800, James Goodrich wrote:
> > 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