Re: openssl RSA public key does not match key read from C code

2014-01-22 Thread lists
On 01/06/2014 10:34 PM, Alan Cabrera wrote: I should have obtained the DER form using i2d_RSA_PUBKEY(). Also, passing &buf to the method should have warned me that the pointer was being modified. I have no idea why it gets modified and what it points to after the call. So now I do |der_f

Re: openssl RSA public key does not match key read from C code

2014-01-06 Thread Alan Cabrera
On Jan 5, 2014, at 11:49 AM, Alan D. Cabrera wrote: > I've created a public key file using the following commands: > > openssl genrsa -out mykey.pem 2046 > openssl rsa -in mykey.pem -pubout > mykey.pub > > I then read it from some C code: > > public_key = PEM_read_RSA_PUBKEY(fp, NULL, NULL, N

Re: openssl RSA public key does not match key read from C code

2014-01-06 Thread Dr. Stephen Henson
On Sun, Jan 05, 2014, Alan D. Cabrera wrote: > I've created a public key file using the following commands: > > openssl genrsa -out mykey.pem 2046 > openssl rsa -in mykey.pem -pubout > mykey.pub > > I then read it from some C code: > > public_key = PEM_read_RSA_PUBKEY(fp, NULL, NULL, NULL); >

Re: openssl RSA public key does not match key read from C code

2014-01-06 Thread Viktor Dukhovni
On Mon, Jan 06, 2014 at 09:02:22AM +0100, Dereck Hurtubise wrote: > There is currently a parsing bug when converting from PEM to DER. > I encountered this as well, but with DSA keys. > I suppose the same bug occurs with RSA keys. No. > > public_key = PEM_read_RSA_PUBKEY(fp, NULL, NULL, NULL); >

Re: openssl RSA public key does not match key read from C code

2014-01-06 Thread Dereck Hurtubise
There is currently a parsing bug when converting from PEM to DER. I encountered this as well, but with DSA keys. I suppose the same bug occurs with RSA keys. In DSA the G component gets copied to the pub component when converting from PEM to DER. >From DER to PEM works fine. Regards, Dereck