Discussion:
openssl genrsa query
(too old to reply)
H H
2008-09-13 13:30:35 UTC
Permalink
Hi All,
I am a new user of the openssl utility.
I have some questions regarding openssl genrsa . It is used for creating public and private key pair.
Now, the format of the file in which public and the private key are written is PEM.

I -
For public key the format is:
-----BEGIN PUBLIC KEY-----the base64 encoded key-----END PUBLIC KEY-----
Now, i want to extract the public key from this file - so
1. i remove the header and the footer.
2. I convert the base64 encoding into normal 8 bit representation.
Is this the correct way to get the raw key that i may use to decrypt a file encrypted using openssl rsautl utility (i m writing a c program to do the decryption)?


II-
The private key format is :
-----BEGIN RSA PRIVATE KEY-----key par-----END RSA PRIVATE KEY-----
Now, i want the private key in 8 bit representation as well. However i understand that the key pair contains both private and public key.
How can i separate them ? Whats the srtucture of the is key pair ? how will i know where private key ends and where public key starts ?

It would be nice to see a response !!
Thanks,
H.



Share files, take polls, and make new friends - all under one roof. Go to http://in.promos.yahoo.com/groups/
Dr. Stephen Henson
2008-09-15 12:09:38 UTC
Permalink
Post by H H
Hi All,
I am a new user of the openssl utility.
I have some questions regarding openssl genrsa . It is used for creating public and private key pair.
Now, the format of the file in which public and the private key are written is PEM.
I -
-----BEGIN PUBLIC KEY-----the base64 encoded key-----END PUBLIC KEY-----
Now, i want to extract the public key from this file - so
1. i remove the header and the footer.
2. I convert the base64 encoding into normal 8 bit representation.
Is this the correct way to get the raw key that i may use to decrypt a file encrypted using openssl rsautl utility (i m writing a c program to do the decryption)?
II-
-----BEGIN RSA PRIVATE KEY-----key par-----END RSA PRIVATE KEY-----
Now, i want the private key in 8 bit representation as well. However i understand that the key pair contains both private and public key.
How can i separate them ? Whats the srtucture of the is key pair ? how will i know where private key ends and where public key starts ?
It would be nice to see a response !!
Thanks,
H.
The formats are DER versions of RSAPrivateKey and SubjectPublicKeyInfo
structures. That will be some effort to decode if you aren't familiar with
ASN1. You can produce readable versions of the key components with:

openssl rsa -in key.pem -noout -text
openssl rsa -pubin -in key.pem -noout -text

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-***@openssl.org
Automated List Manager ***@openssl.org
Loading...