Skip to content

Commit 19524fc

Browse files
mk-jrdlowrey
authored andcommitted
Fix for bug66501 - "key type not supported in this PHP build"
1 parent 35101e9 commit 19524fc

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

ext/openssl/openssl.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3013,6 +3013,15 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC)
30133013
return 0;
30143014
}
30153015
break;
3016+
#endif
3017+
#ifdef EVP_PKEY_EC
3018+
case EVP_PKEY_EC:
3019+
assert(pkey->pkey.ec != NULL);
3020+
3021+
if ( NULL == EC_KEY_get0_private_key(pkey->pkey.ec)) {
3022+
return 0;
3023+
}
3024+
break;
30163025
#endif
30173026
default:
30183027
php_error_docref(NULL TSRMLS_CC, E_WARNING, "key type not supported in this PHP build!");

ext/openssl/tests/bug66501.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #66501: EC private key support in openssl_sign
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("openssl")) die("skip");
6+
--FILE--
7+
<?php
8+
$pkey = 'ASN1 OID: prime256v1
9+
-----BEGIN EC PARAMETERS-----
10+
BggqhkjOPQMBBw==
11+
-----END EC PARAMETERS-----
12+
-----BEGIN EC PRIVATE KEY-----
13+
MHcCAQEEILPkqoeyM7XgwYkuSj3077lrsrfWJK5LqMolv+m2oOjZoAoGCCqGSM49
14+
AwEHoUQDQgAEPq4hbIWHvB51rdWr8ejrjWo4qVNWVugYFtPg/xLQw0mHkIPZ4DvK
15+
sqOTOnMoezkbSmVVMuwz9flvnqHGmQvmug==
16+
-----END EC PRIVATE KEY-----';
17+
$key = openssl_pkey_get_private($pkey);
18+
$res = openssl_sign($data ='alpha', $sign, $key, 'ecdsa-with-SHA1');
19+
var_dump($res);
20+
--EXPECTF--
21+
bool(true)

0 commit comments

Comments
 (0)