On Thursday, November 28, 2013 1:07:46 PM UTC-5, Nick de Smith wrote: > > I've written a DLL wrapper for Crypto++ and it works fine - just a few > things I'm not clear on,,, > > I generate an RSA public/private key pair, then store them in PEM files. > > I seem to have to call DEREncodePrivateKey on the private key before > Base64 encoding and writing to the file, and also having to call > BERDecodePrivateKey when reading back the private key. If I use BEREncode > on the private key rather than DEREncodePrivateKey when writing the key, I > get a BERDecode error on readback. > > If I try using DEREncodePublicKey on the public key when writing and > BERDecodePublicKey when reading I get a BERDecode error. However, if I just > write the public key directly I can recover it perfectly. > > Why is the private key different from the public key in this? DER encoding > is a subset of BER, so I can see why that works, but why is it needed > rather than just "Save"? > > Bit confused as to what is actually happening here (even though I have a > satisfactory solution - I just want to properly understand it). > I believe most of your questions can be answered with http://www.cryptopp.com/wiki/Keys_and_Formats.
Crypto++ does not read or write PEM encoded keys (i.e., --- BEGIN RSA PRIVATE KEY --- and friends). It only reads and writes ASN.1's DER/BER. Jeff -- -- You received this message because you are subscribed to the "Crypto++ Users" Google Group. To unsubscribe, send an email to [email protected]. More information about Crypto++ and this group is available at http://www.cryptopp.com. --- 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]. For more options, visit https://groups.google.com/groups/opt_out.
