openSSL: difference between PEM_write_RSAPublicKey and PEM_write_RSA_PUBKEY

两盒软妹~` 提交于 2020-04-10 11:56:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!