Re: how to extract the private key out of the KEY.PEM

2013-11-20 Thread Robert W Weaver
Kenneth Goldman/Watson/IBM@IBMUS wrote on 11/20/2013 10:37:04 AM: > > Encrypt with a private key for integrity purposes: this shows that the > > data that was encrypted corresponds to the owner of the key. > > Encrypt with a public key for confidentiality purposes: this shows that > > the data can

Re: how to extract the private key out of the KEY.PEM

2013-11-20 Thread Ken Goldman
On 11/18/2013 11:29 AM, Robert W Weaver wrote: owner-openssl-us...@openssl.org (Kenneth Goldman/Watson/IBM@IBMUS) wrote on 11/18/2013 10:03:29 AM: > Do not encrypt with a private key. Encrypt with the public key and > decrypt with the private key. Encrypt with a private key for integrity purp

Re: how to extract the private key out of the KEY.PEM

2013-11-19 Thread sampo
"Dave Thompson" said: > privatekeys - man PEM -- but the PEM_read routines can handle This is how I do it... #define PEM_CERT_START "-BEGIN CERTIFICATE-" #define PEM_CERT_END "-END CERTIFICATE-" #define PEM_RSA_PRIV_KEY_START "-BEGIN RSA PRIVATE KEY---

RE: how to extract the private key out of the KEY.PEM

2013-11-18 Thread Robert W Weaver
> "Dave Thompson" wrote on 11/18/2013 05:07:14 PM: > For RSA the private key is at least (d,n), and OpenSSL always generates > the “CRT” form which has half a dozen other elements to allow more Oh, well if you are going to be *helpful* ... >> So our question is how do we extract the private key

RE: how to extract the private key out of the KEY.PEM

2013-11-18 Thread Dave Thompson
PEM files are not hex. They are base64, plus header and trailer lines. You can read any supported PEM file with the functions in pem.h. OpenSSL historically supports several different PEM formats for privatekeys - man PEM -- but the PEM_read routines can handle all of them automatically becau

Re: how to extract the private key out of the KEY.PEM

2013-11-18 Thread Robert W Weaver
owner-openssl-us...@openssl.org (Kenneth Goldman/Watson/IBM@IBMUS) wrote on 11/18/2013 10:03:29 AM: > Do not encrypt with a private key. Encrypt with the public key and > decrypt with the private key. Encrypt with a private key for integrity purposes: this shows that the data that was encrypted c

Re: how to extract the private key out of the KEY.PEM

2013-11-18 Thread Ken Goldman
Do not encrypt with a private key. Encrypt with the public key and decrypt with the private key. I would extract the key parts by converting the pem format to an RSA structure, get the BIGNUMs from the structure, and convert BIGNUM to bin. I don't guarantee that this is the best way, but it