使用OpenSSL的EC公钥加密

问题描述

PHP的OpenSSL实现中是否有可能使用PHP OpenSSL通过公钥加密/通过私钥解密?

根据OpenSSL documentationopenssl_seal()不支持EC公钥。

公钥必须是RSA,因为它是唯一的OpenSSL公钥 支持密钥传输的算法。

openssl_public_encrypt()与EC密钥一起使用时也会引发错误。

我的密钥创建工作如下:

// Configuration settings for the key
$config = array(
    "private_key_type" => OPENSSL_KEYTYPE_EC,"curve_name" => "secp521r1"
);
    
// Create the private and public key
$res = openssl_pkey_new($config);
    
// Extract the private key into $private_key
openssl_pkey_export($res,$private_key);
    
// Extract the public key into $public_key
$public_key = openssl_pkey_get_details($res);
$public_key = $public_key["key"];

有什么方法可以使用OpenSSL进行ec公钥加密吗?

为什么php.net上没有记录到EC的openssl()openssl_public_encrypt()的失败?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...