Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用.pem文件中的公钥进行RSA加密_Rsa_Public Key Encryption_Evp Cipher - Fatal编程技术网

使用.pem文件中的公钥进行RSA加密

使用.pem文件中的公钥进行RSA加密,rsa,public-key-encryption,evp-cipher,Rsa,Public Key Encryption,Evp Cipher,我正在使用RSA_public_encrypt函数将加密数据发送到套接字。我正在使用“pkey=PEM_read_PUBKEY(f,NULL,NULL,NULL);”函数从.PEM文件读取公钥。 从上述函数中检索到的“pkey”类型为EVP_pkey*,我无法在函数RSA_public_encrypt中使用。(RSA_public_encrypt使用RSA*类型密钥) 如何将EVP_PKEY*PKEY转换为RSA*RSA?使用RSA*EVP_PKEY\u get1_RSA(EVP_PKEY*PK

我正在使用RSA_public_encrypt函数将加密数据发送到套接字。我正在使用“pkey=PEM_read_PUBKEY(f,NULL,NULL,NULL);”函数从.PEM文件读取公钥。 从上述函数中检索到的“pkey”类型为EVP_pkey*,我无法在函数RSA_public_encrypt中使用。(RSA_public_encrypt使用RSA*类型密钥)


如何将EVP_PKEY*PKEY转换为RSA*RSA?

使用
RSA*EVP_PKEY\u get1_RSA(EVP_PKEY*PKEY)
从EVP_PKEY获取RSA类型密钥

例如:

EVP_PKEY    *evp;
RSA         *pubkey

evp = ...; /* some way to get the public key */
pubkey = EVP_PKEY_get1_RSA(evp);
if (pubkey == NULL) {
    /* error handling */
}

您使用的是哪种语言???我使用的是C语言别忘了通过callint
RSA\u free释放
RSA*