Bug #79677 [NEW]: sm2 curve public key encrypt->key type not supported in this PHP build
| From: | 1055358033 at qq dot com | Date: | Fri, 05 Jun 2020 08:09:20 +0000 |
| Subject: | Bug #79677 [NEW]: sm2 curve public key encrypt->key type not supported in this PHP build | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-227328@lists.php.net to get a copy of this message | ||
From: 1055358033 at qq dot com
Operating system: ubuntu 16.04
PHP version: Irrelevant
Package: OpenSSL related
Bug Type: Bug
Bug description:sm2 curve public key encrypt->key type not supported in this PHP build
Description:
------------
---
From manual page: https://php.net/book.openssl
---
-----to begin with: sorry to bother, Im not sure this is a bug or i just
get it wrong, i notice that there is two bug report look like mine, but
why answer is between this problem will fixed in 5.6+ and openssl not
support ec key...? and i really dont know who to turn to for this,
appreciate it if you can answer me.
env: PHP Version 7.1.33-15+ubuntu16.04.1+deb.sury.org+1 openssl-1.1.1g
public/private Key generate by those commands:
./openssl ecparam -genkey -name SM2 -out priv.key
./openssl ec -in priv.key -pubout -out pub.key
then:
$pubKey = openssl_pkey_get_public('file://path/pub.key');
openssl_public_encrypt($data, $encrypted_data, $pubKey);
I tried to print $pubKey, nothing wrong here,
and this come out:
openssl_public_encrypt(): key type not supported in this PHP build!
openssl_get_curve_names() to make sure sm2 curve is supported, and it
is.
in the end: really thanks if you can answer me this, plz let me know if
I do
it the wrong way, thanks. below are my public/private Key
my publicKey=========->:
-----BEGIN PUBLIC KEY-----
MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE/J1aKDMqqIpVaudSK0XA/TfC4IFv
MYl2C5VQzCDpvSu6TPW4j8JzrvZg1fsuYhqbvdfFcNGHWLJ1jMNALGFtSg==
-----END PUBLIC KEY-----
my privateKey========->:
-----BEGIN EC PARAMETERS-----
BggqgRzPVQGCLQ==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEIG8ejJ9q4va/aFwihqPNC6AooKwcV85/DlcCQpGiXCLyoAoGCCqBHM9V
AYItoUQDQgAE/J1aKDMqqIpVaudSK0XA/TfC4IFvMYl2C5VQzCDpvSu6TPW4j8Jz
rvZg1fsuYhqbvdfFcNGHWLJ1jMNALGFtSg==
-----END EC PRIVATE KEY-----
Test script:
---------------
public/private Key generate by those commands:
./openssl ecparam -genkey -name SM2 -out priv.key
./openssl ec -in priv.key -pubout -out pub.key
$pubKey = openssl_pkey_get_public('file://path/pub.key');
openssl_public_encrypt($data, $encrypted_data, $pubKey);
Expected result:
----------------
publicKey encrypted data
Actual result:
--------------
openssl_public_encrypt(): key type not supported in this PHP build!
--
Edit bug report at https://bugs.php.net/bug.php?id=79677&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79677&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79677&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79677&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79677&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79677&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79677&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79677&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79677&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79677&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79677&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79677&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79677&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79677&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79677&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79677&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79677&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79677&r=mysqlcfg