问题
In the openssl library I can see two methods to write a 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 can see:
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
But i don't understand what is
SubjectPublicKeyInfo
And what are the fundamentals differences between the 2 methods!
回答1:
SubjectPublicKeyInfo - ASN1 structure for public keys which is described in rfc 3280(Internet X.509 Public Key Infrastructure). This format in fact contains id of the public key algorithm and the public key itself. And in this case this public key is formatted according to the pkcs1 standard. So X.509 format is more high level format, it describes not just RSA public key but public key in general.
来源:https://stackoverflow.com/questions/13818567/openssl-difference-between-pem-write-rsapublickey-and-pem-write-rsa-pubkey