summaryrefslogtreecommitdiff
path: root/ext/hash
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2013-06-06 20:32:27 +0200
committerOndřej Surý <ondrej@sury.org>2013-06-06 20:32:27 +0200
commitd9b0e944a6bfa31fec6b71170346648925e76935 (patch)
treeb6de5f6389aeb27758d34f29ea6f000570f5e9fc /ext/hash
parent4cd628b36adb52a09b58782cd60c5f4ce2ad4764 (diff)
downloadphp-d9b0e944a6bfa31fec6b71170346648925e76935.tar.gz
New upstream version 5.5.0~rc3
Diffstat (limited to 'ext/hash')
-rw-r--r--ext/hash/hash.c3
-rw-r--r--ext/hash/tests/bug64745.phpt17
2 files changed, 20 insertions, 0 deletions
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index 9492387db..9cede1412 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -659,6 +659,9 @@ PHP_FUNCTION(hash_pbkdf2)
/* Setup Main Loop to build a long enough result */
if (length == 0) {
length = ops->digest_size;
+ if (!raw_output) {
+ length = length * 2;
+ }
}
digest_length = length;
if (!raw_output) {
diff --git a/ext/hash/tests/bug64745.phpt b/ext/hash/tests/bug64745.phpt
new file mode 100644
index 000000000..427f89b72
--- /dev/null
+++ b/ext/hash/tests/bug64745.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Bug #64745 hash_pbkdf2() truncates data when using default length and hex output
+--SKIPIF--
+<?php extension_loaded('hash') or die('skip'); ?>
+--FILE--
+<?php
+$hash = hash_pbkdf2('sha1', 'password', 'salt', 1, 0);
+$rawHash = hash_pbkdf2('sha1', 'password', 'salt', 1, 0, true);
+
+var_dump($hash);
+var_dump(bin2hex($rawHash));
+
+?>
+--EXPECT--
+string(40) "0c60c80f961f0e71f3a9b524af6012062fe037a6"
+string(40) "0c60c80f961f0e71f3a9b524af6012062fe037a6"
+