PEM_read_RSA_PUBKEY() PEM_read_RSAPublicKey()
I've tried both to load public key from PEM file, but PEM_read_RSAPublicKey() failed. I can't get any information from manual, so I've googled a lot, and got that opnion: = You might try PEM_read_RSA_PUBKEY() instead of PEM_read_RSAPublicKey(). This is all about formats. The default public key file format generated by openssl is the PEM format. PEM_read_RSA_PUBKEY() reads the PEM format. PEM_read_RSAPublicKey() reads the PKCS#1 format. So if you want to stick to PEM_read_RSAPublicKey() you could generate the public key file using the PKCS#1 format by specifying the -outform DER option when generating the public key. = (From http://stackoverflow.com/questions/7818117/why-i-cant-read-openssl-generated-rsa-pub-key-with-pem-read-rsapublickey) But it's PEM_xxx, why it used to read from DER format? Then I tried it on DER format, but it still failed. So, where should I use that it? BTW: where is the source code of that two APIs? I've grep all the files under openssl, but only doc and./util/libeay.num. -- Cyberman Wu __ 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()
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
RE: PEM_read_RSA_PUBKEY() PEM_read_RSAPublicKey()
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