summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2015-08-27 20:17:33 +0100
committerJakub Zelenka <bukka@php.net>2015-08-27 20:17:33 +0100
commit6b9f31ab741eea5c2e590b312827f5a779cd1773 (patch)
treedc9035aa11b026259b130c908338d29e25dabef4
parent859712a89c65605477fbfd10300f2ebad25f9970 (diff)
parentc39336d1d866866de629695fbd9971fb48f27ea9 (diff)
downloadphp-git-6b9f31ab741eea5c2e590b312827f5a779cd1773.tar.gz
Merge branch 'PHP-5.6'
-rw-r--r--ext/openssl/openssl.c13
-rw-r--r--ext/openssl/tests/bug55259.phpt29
2 files changed, 34 insertions, 8 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index cf05c1b815..2ba50c9cc5 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -3629,14 +3629,11 @@ PHP_FUNCTION(openssl_pkey_new)
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), dh, g);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), dh, priv_key);
OPENSSL_PKEY_SET_BN(Z_ARRVAL_P(data), dh, pub_key);
- if (dh->p && dh->g) {
- if (!dh->pub_key) {
- DH_generate_key(dh);
- }
- if (EVP_PKEY_assign_DH(pkey, dh)) {
- ZVAL_COPY_VALUE(return_value, zend_list_insert(pkey, le_key));
- return;
- }
+ if (dh->p && dh->g &&
+ (dh->pub_key || DH_generate_key(dh)) &&
+ EVP_PKEY_assign_DH(pkey, dh)) {
+ ZVAL_COPY_VALUE(return_value, zend_list_insert(pkey, le_key));
+ return;
}
DH_free(dh);
}
diff --git a/ext/openssl/tests/bug55259.phpt b/ext/openssl/tests/bug55259.phpt
new file mode 100644
index 0000000000..27ededdb18
--- /dev/null
+++ b/ext/openssl/tests/bug55259.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Bug #55259 (openssl extension does not get the DH parameters from DH key resource)
+--SKIPIF--
+<?php if (!extension_loaded("openssl")) die("skip"); ?>
+--FILE--
+<?php
+
+$phex = 'dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61e' .
+ 'f75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d268370557' .
+ '7d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e382' .
+ '6634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab';
+$dh_details = array( 'p' => $phex, 'g' => '2' );
+$dh = openssl_pkey_new(array( 'dh'=> array( 'p' => $phex, 'g' => '2' )));
+var_dump($dh);
+$dh = openssl_pkey_new(array( 'dh'=> array( 'p' => hex2bin($phex), 'g' => '2' )));
+$details = openssl_pkey_get_details($dh);
+var_dump(bin2hex($details['dh']['p']));
+var_dump($details['dh']['g']);
+var_dump(strlen($details['dh']['pub_key']));
+var_dump(strlen($details['dh']['priv_key']));
+echo "Done";
+?>
+--EXPECT--
+bool(false)
+string(256) "dcf93a0b883972ec0e19989ac5a2ce310e1d37717e8d9571bb7623731866e61ef75a2e27898b057f9891c2e27a639c3f29b60814581cd3b2ca3986d2683705577d45c2e7e52dc81c7a171876e5cea74b1448bfdfaf18828efd2519f14e45e3826634af1949e5b535cc829a483b8a76223e5d490a257f05bdff16f2fb22c583ab"
+string(1) "2"
+int(128)
+int(128)
+Done