Merge branch 'PHP-5.5' into PHP-5.6

* PHP-5.5:
  Fix for bug66501 - "key type not supported in this PHP build"
This commit is contained in:
Daniel Lowrey 2014-02-14 18:20:01 -07:00
commit b60cb2b88a
2 changed files with 30 additions and 0 deletions

View File

@ -3467,6 +3467,15 @@ static int php_openssl_is_private_key(EVP_PKEY* pkey TSRMLS_DC)
return 0;
}
break;
#endif
#ifdef EVP_PKEY_EC
case EVP_PKEY_EC:
assert(pkey->pkey.ec != NULL);
if ( NULL == EC_KEY_get0_private_key(pkey->pkey.ec)) {
return 0;
}
break;
#endif
default:
php_error_docref(NULL TSRMLS_CC, E_WARNING, "key type not supported in this PHP build!");

View File

@ -0,0 +1,21 @@
--TEST--
Bug #66501: EC private key support in openssl_sign
--SKIPIF--
<?php
if (!extension_loaded("openssl")) die("skip");
--FILE--
<?php
$pkey = 'ASN1 OID: prime256v1
-----BEGIN EC PARAMETERS-----
BggqhkjOPQMBBw==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHcCAQEEILPkqoeyM7XgwYkuSj3077lrsrfWJK5LqMolv+m2oOjZoAoGCCqGSM49
AwEHoUQDQgAEPq4hbIWHvB51rdWr8ejrjWo4qVNWVugYFtPg/xLQw0mHkIPZ4DvK
sqOTOnMoezkbSmVVMuwz9flvnqHGmQvmug==
-----END EC PRIVATE KEY-----';
$key = openssl_pkey_get_private($pkey);
$res = openssl_sign($data ='alpha', $sign, $key, 'ecdsa-with-SHA1');
var_dump($res);
--EXPECTF--
bool(true)