Sign in to follow this  
JY

Crypto keys

Recommended Posts

Can anybody take me through the steps I need to perform to export a public key create with CryptoGenKey to a format that can be imported into PGP please? I've exported the key using CryptExportKey and encoded it with Base64 (which I assume is correct) but the data is never as long as a key exported from PGP, and PGP complains that it's not long enough when I try to import. As an aside, but maybe related. When I create keys in PGP I need to supply a passphrase, but CryptoGenKey doesn't require one. Does that mean it's up to me encrypt the key myself? Thanks for any help.

Share this post


Link to post
Share on other sites
One usually encodes keys in hexadecimal, not base64. You'll get (bitlength / 4) characters, and each will be one of 0-9,A-F.

In Base64, you get (bitlength / 6) characters, which'll be 0-9,a-z,A-Z,'+','_', or '='.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by JY
Can anybody take me through the steps I need to perform to export a public key create with CryptoGenKey to a format that can be imported into PGP please?

I've exported the key using CryptExportKey and encoded it with Base64 (which I assume is correct) but the data is never as long as a key exported from PGP, and PGP complains that it's not long enough when I try to import.

As an aside, but maybe related. When I create keys in PGP I need to supply a passphrase, but w doesn't require one. Does that mean it's up to me encrypt the key myself?


Thanks for any help.



What length key are you generating? I believe PGP has a minimum length of 1024 bits. You might want go look up the PGP Public Key Block format as there is more to the PGP Public Key Block format than just the public key it's self. It also contains infromation about the user like their email address. You are right in that the key block is base64 encoded.

Share this post


Link to post
Share on other sites
Great, thanks for the reference. I also found RFC2440 over the weekend, I think i'm getting to grips with it but I guess the proof will be when I get it to work (!)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this