RE: PEM_read_RSA_PUBKEY() & PEM_read_RSAPublicKey()

2013-08-27 Thread Dave Thompson
> From: owner-openssl-us...@openssl.org On Behalf Of Dr. Stephen Henson
> Sent: Tuesday, 27 August, 2013 08:10

Adding a little:

> On Tue, Aug 27, 2013, Cyberman Wu wrote:
> 
> > I've tried both to load public key from PEM file, but
> > PEM_read_RSAPublicKey() failed.
> > 
> 
> It would help if you said what error you get or posted the file.
> 
> See also:
> 
> http://www.openssl.org/support/faq.html#PROG6
> 
Preferably #PROG7 also, although that's not vital.

> > I can't get any information from manual
> 
> The pem manual pages gives information:
> 
> http://www.openssl.org/docs/crypto/pem.html
> 
>  The RSAPublicKey functions process an RSA public key using 
> an RSA structure.
>  The public key is encoded using a PKCS#1 RSAPublicKey structure.
> 
>  The RSA_PUBKEY functions also process an RSA public key using an RSA
>  structure. However the public key is encoded using a 
> SubjectPublicKeyInfo
>  structure and an error occurs if the public key is not RSA. 
> 
And PEM can easily be distinguished by the dash lines:
RSAPublicKey is "BEGIN/END RSA PUBLIC KEY" while RSA_PUBKEY 
(and also DSA_PUBKEY etc) is "BEGIN/END PUBLIC KEY".

The same two structures are supported in DER, and there if 
you lose track which is which you have to asn1parse and grovel.

Usually PUBKEY is more likely because it is the default for 
commandline utilities like rsa -pubout and x509 -pubout .
Though >=1.0.0 rsa has undocumented options for RSAPublicKey.


__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: PEM_read_RSA_PUBKEY() & PEM_read_RSAPublicKey()

2013-08-27 Thread Dr. Stephen Henson
On Tue, Aug 27, 2013, Cyberman Wu wrote:

> I've tried both to load public key from PEM file, but
> PEM_read_RSAPublicKey() failed.
> 

It would help if you said what error you get or posted the file.

See also:

http://www.openssl.org/support/faq.html#PROG6

> I can't get any information from manual

The pem manual pages gives information:

http://www.openssl.org/docs/crypto/pem.html

 The RSAPublicKey functions process an RSA public key using an RSA structure.
 The public key is encoded using a PKCS#1 RSAPublicKey structure.

 The RSA_PUBKEY functions also process an RSA public key using an RSA
 structure. However the public key is encoded using a SubjectPublicKeyInfo
 structure and an error occurs if the public key is not RSA. 

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org