Private and Public key file format

9 views
Skip to first unread message

Nicolai Tufar

unread,
Aug 26, 2005, 9:37:03 AM8/26/05
to crypto...@eskimo.com
Hi,

it would probably be a very lame question but could someone point me
to the infromation on hwo public and private keys are encoded in
rsa1024.dat, rsa2048.dat, rsa400pb.dat, rsa400pv.dat.

I have some public key files to use with RSA Crypto-C ME. They are
coded similarily: 0x30 as SEQUENCE_TAG and 0x02 as INTEGER_TAG but
Crypto++ refuses to accept them.

Thanks in advance,
Regards,
Nicolai

Kevin Hock

unread,
Aug 26, 2005, 12:31:02 PM8/26/05
to crypto...@eskimo.com
Hi,

I would also be interested in this. I generated RSA keys using
ssh-keygen and I can get Crypto++ to accept the private key but not
the public one. Maybe I just can't do this?

Kevin

Bryan Mongeau

unread,
Aug 26, 2005, 1:44:35 PM8/26/05
to crypto...@eskimo.com
On August 26, 2005 12:25 pm, Kevin Hock wrote:
> I would also be interested in this. I generated RSA keys using
> ssh-keygen and I can get Crypto++ to accept the private key but not
> the public one. Maybe I just can't do this?

Hi Kevin,

I recently had to work out a procedure for generating keypairs with openssl
but loading them with crypto++. Here's what I did to get DSA keys working :

Generate the private key in DER format:
# openssl dsaparam -noout -outform DER -out dsakey.der -genkey 1024

Convert it to pkcs8 :
# openssl pkcs8 -topk8 -nocrypt -inform DER -in dsakey.der -outform DER -out
dsaprivkey.pk8

Create the pubkey :
# openssl dsa -inform DER -in dsakey.der -outform DER -out dsapubkey.der
-pubout

You should be able to load dsaprivkey.pk8 and dsapubkey.der from a FileSource
without problem. I think you should be able to convert your ssh keys in a
similar fashion.

Hope this helps,
--
Bryan Mongeau, BroadSign Inc.
--
"The genes are the master programmers: they are programming for their lives."
- Richard Dawkins

Nicolai Tufar

unread,
Aug 27, 2005, 2:49:52 AM8/27/05
to crypto...@eskimo.com
I see. Apparently it is PKCS #8
[ftp://ftp.rsasecurity.com/pub/pkcs/ascii/pkcs-8.asc].
Trom here we see that values are encoded using ASN.1
[http://en.wikipedia.org/wiki/ASN.1]. Also mentiond BER (Basic
Encoding Rule) [http://en.wikipedia.org/wiki/Basic_encoding_rules] and
DER (Distingushed Encoding Rule)
[http://en.wikipedia.org/wiki/Distinguished_encoding_rules].

I will post an update when I figure out what is the format exactly.

Reply all
Reply to author
Forward
0 new messages