php / php/php-src

openssl ext sm2 compatibility

未关闭
#9,422 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Extension: openssl Feature Status: Verified
主要语言
C
星标
40.4k
派生
8.2k
平均合并
2 天 13 小时
30 天内合并 PR
96

描述

Description

The following code:

<?php
$public_key = openssl_pkey_get_public(file_get_contents('sm2pubkey.pem'));
$d1 = openssl_pkey_get_details($public_key);
var_dump($d1);

Resulted in this output:

  ["dh"]=>
  array(1) {
    ["p"]=> 
  }
  ["type"]=>
  int(2)

But I expected this output instead:

  ["ec"]=>
  array(5) {
    ["curve_name"]=>
    string(9) "sm2"
    ["curve_oid"]=>
    ["x"]=> 
    ["y"]=> 
    ["d"]=> 
  }
  ["type"]=> int(3)

my openssl ext info

OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 3.0.2 15 Mar 2022
OpenSSL Header Version => OpenSSL 3.0.2 15 Mar 2022
Openssl default config => /usr/lib/ssl/openssl.cnf

Directive => Local Value => Master Value
openssl.cafile => no value => no value
openssl.capath => no value => no value

the sm2pubkey.pem generate command
openssl ecparam -name SM2 -genkey -noout -out sm2-key.pem
openssl ec -in sm2-key.pem -pubout -out sm2pubkey.pem

PHP Version

8.1.2

Operating System

Ubuntu 22.04.1 LTS

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用 PHP 8.1.2、OpenSSL 3.0.2 以及提供的 openssl ecparam 和 openssl ec 命令复现该报告。从 openssl_pkey_get_public() 和 openssl_pkey_get_details() 入口点开始,然后将返回的结构与预期的 SM2 EC 详细信息进行比较。当 SM2 公钥被报告为具有预期曲线信息的 EC 密钥时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
php
领域
cryptography, security
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。