Encoding of rsa1024.dat rsa2048.dat (PKCS #1 - ASN.1/BER?)

32 views
Skip to first unread message

Jeffrey Walton

unread,
Jan 3, 2007, 1:20:25 PM1/3/07
to Crypto++ Users
Hi All,

Can anyone verify this creates files in the same format as those
provided by Wei in rsa400pb.dat, rsa400pv.dat, rsa1024.dat, and
rsa2048.dat? On the test which I have run, eack string k begins with
0x30 (SEQUENCE_TAG ), as does the various rsa*.dat files. I looked at
rsa400pv.dat from Crypto++ 4.2 - it is the same file.

I attempted to look at PK_FinalTemplate for AccessKey(),
AccessPublicKey, and AccessPrivateKey() - Crypto++ stresses the limit
of Intellisense in VS 6.0 and VS 7.0.

BTW, you can't simply call RSAES_OAEP_SHA_Decryptor::BEREncode() - it
is ambiguous due to MI.

Jeff

////////////////////////////////////////////////////////////////
AutoSeededRandomPool rng;

// Specify modulus, accept e = 17
RSAES_OAEP_SHA_Decryptor Decryptor( rng, 128 /*, e */ );

// BER Encode Key
string k;
HexEncoder encoder( new StringSink( k ) );
Decryptor.AccessKey().Save( encoder );

cout << k << endk;

Wei Dai

unread,
Jan 8, 2007, 1:32:40 AM1/8/07
to Crypto++ Users
Your code is pretty much the same as GenerateRSAKey() in test.cpp which
was used to generate rsa1024.dat and rsa2048.dat.

rsa400pv.dat actually has a different format from the rest. The other
RSA private key files are encoded as PKCS#8 privateKeyInfo, whereas
rsa400pv.dat is only the privateKey part of privateKeyInfo. If you look
at the code in validat2.cpp that loads rsa400pv.dat, you'll notice that
it's different from loading the other keys.

Jeffrey Walton

unread,
Jan 8, 2007, 5:14:52 PM1/8/07
to Crypto++ Users
Hi Wei,

Thanks. Most of my code starts from your test harness or validate
programs.

Jeff

Reply all
Reply to author
Forward
0 new messages