OpenSSL: difference between PEM_write_RSAPublicKey and PEM_write_RSA_PUBKEY

In the openssl library, I can see two methods for writing the public key to a file:

int PEM_write_RSAPublicKey(FILE *fp, RSA *x); int PEM_write_RSA_PUBKEY(FILE *fp, RSA *x); 

In the documentation, I see:

RSAPublicKey functions process the RSA public key using the RSA composition. The public key is encoded using the PKCS # 1 RSAPublicKey structure.

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

But I do not understand what is

SubjectPublicKeyInfo

And what are the main differences between the two methods!

+4
source share
1 answer

SubjectPublicKeyInfo - ASN1 structure for public keys, which is described in rfc 3280 (Internet X.509 Public Key Infrastructure). This format actually contains the identifier of the public key algorithm and the public key itself. And in this case, this public key is formatted in accordance with the pkcs1 standard. Thus, the X.509 format is higher-level; it describes not only the RSA public key, but also the public key as a whole.

+2
source

All Articles