c – openSSL:PEM_write_RSAPublicKey和PEM_write_RSA_PUBKEY之间的区别

在openssl库中,我可以看到两种将公钥写入文件的方法:

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

在文档中,我可以看到:

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

但我不明白是什么

SubjectPublicKeyInfo

两种方法之间的基本面差异是什么!

最佳答案 SubjectPublicKeyInfo – 公钥的ASN1结构,在rfc 3280(Internet X.509公钥基础结构)中描述.事实上,这种格式包含公钥算法的id和公钥本身.在这种情况下,此公钥是根据pkcs1标准格式化的.所以X.509格式是更高级的格式,它不仅描述了RSA公钥,而且描述了公钥.

点赞