Bug #79677 [Opn->Fbk]: sm2 curve public key encrypt->key type not supported in this PHP build

From: Date: Tue, 09 Nov 2021 09:24:12 +0000
Subject: Bug #79677 [Opn->Fbk]: sm2 curve public key encrypt->key type not supported in this PHP build
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237637@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79677&edit=1 ID: 79677 Updated by: cmb@php.net Reported by: 1055358033 at qq dot com Summary: sm2 curve public key encrypt->key type not supported in this PHP build -Status: Open +Status: Feedback Type: Bug Package: OpenSSL related Operating System: ubuntu 16.04 PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: > PHP Version 7.1.33-15+ubuntu16.04.1+deb.sury.org+1 PHP 7.1 is no longer actively supported for roughly three years. Do you still experience this issue with any of the actively supported PHP versions[1]? [1] <https://www.php.net/supported-versions.php> Previous Comments: ------------------------------------------------------------------------ [2020-06-05 08:09:19] 1055358033 at qq dot com 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 this bug report at https://bugs.php.net/bug.php?id=79677&edit=1

« previous php.bugs (#237637) next »