[php-src] Issue #9422: openssl ext sm2 compatibility
| From: | xywf221 | Date: | Thu, 25 Aug 2022 10:23:04 +0000 |
| Subject: | [php-src] Issue #9422: openssl ext sm2 compatibility | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242307@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9422
Author: xywf221
### Description
The following code:
```php
<?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:
```
["ec"]=>
array(5) {
["curve_name"]=>
string(9) "sm2"
["curve_oid"]=>
["x"]=>
["y"]=>
["d"]=>
}
["type"]=> int(3)
```
But I expected this output instead:
```
["dh"]=>
array(1) {
["p"]=>
}
["type"]=>
int(2)
```
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