我正在努力使用给定的参数e,n,d生成RSA私钥。
m_pKey = EVP_PKEY_new();
RSA* rsa = RSA_new();
rsa->e = e;
rsa->n = n;
rsa->d = d;
EVP_PKEY_assign_RSA(m_pKey, rsa);
这适用于公钥生成 - 我可以轻松创建.pem文件,使用命令行检查并验证它是否正确。但是,私钥.pem文件似乎缺少一些额外的参数。
sudo openssl rsa -noout -text -inform PEM -in priv_test.pem
unable to load Private Key
139753508435600:error:0D078079:asn1 encoding routines:ASN1_ITEM_EX_D2I:field missing:tasn_dec.c:519:Field=p, Type=RSA
139753508435600:error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA lib:rsa_ameth.c:115:
139753508435600:error:0606F091:digital envelope routines:EVP_PKCS82PKEY:private key decode error:evp_pkey.c:95:
139753508435600:error:0907B00D:PEM routines:PEM_READ_BIO_PRIVATEKEY:ASN1 lib:pem_pkey.c:132: