在 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公钥,而是一般的公钥。
关于c++ - openSSL:PEM_write_RSAPublicKey 和 PEM_write_RSA_PUBKEY 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13818567/