c++ - openSSL:PEM_write_RSAPublicKey 和 PEM_write_RSA_PUBKEY 之间的区别

标签 c++ openssl public-key

在 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/

相关文章:

c++ - 如何防止递归函数中不必要的内存使用

C++容器/数组/元组一致访问接口(interface)

iphone - 我们可以在 IOS SDK iphone 中检索序列号、颁发者 DN、x509 证书的主题详细信息吗

ssl - 谁的 key 用于加密 HTTPS 响应?

encryption - 在c#中生成公钥和私钥对并将公钥保存为纯文本

ssh - 如何使用 .crt 文件进行 SSH 公钥认证

c++ - 即时编译 C++ : clang/libtooling fails to set Triple for LLVM IR

c++ - 使用 operator<< 并打印错误值的类的程序 c++

security - svn 的 SSL 协商失败

c++ - 将 select() 与 OpenSSL 套接字一起使用?