Commit:    76f3295cdfd6a3106297352e73b9691084582211
Author:    Anthony Ferrara <ircmax...@gmail.com>         Wed, 12 Sep 2012 
11:47:50 -0400
Parents:   ebe0bd5dee07bebd8444d9e7c28864ba17efeef8
Branches:  master

Link:       
http://git.php.net/?p=php-src.git;a=commitdiff;h=76f3295cdfd6a3106297352e73b9691084582211

Log:
Expose PASSWORD_BCRYPT_DEFAULT_COST constant and update test to use it

Changed paths:
  M  ext/standard/password.c
  M  ext/standard/tests/password/password_needs_rehash.phpt


Diff:
diff --git a/ext/standard/password.c b/ext/standard/password.c
index d3dc457..9b1bb8c 100644
--- a/ext/standard/password.c
+++ b/ext/standard/password.c
@@ -40,6 +40,8 @@ PHP_MINIT_FUNCTION(password) /* {{{ */
        REGISTER_LONG_CONSTANT("PASSWORD_DEFAULT", PHP_PASSWORD_DEFAULT, 
CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT", PHP_PASSWORD_BCRYPT, CONST_CS 
| CONST_PERSISTENT);
 
+       REGISTER_LONG_CONSTANT("PASSWORD_BCRYPT_DEFAULT_COST", 
PHP_PASSWORD_BCRYPT_COST, CONST_CS | CONST_PERSISTENT);
+
        return SUCCESS;
 }
 /* }}} */
diff --git a/ext/standard/tests/password/password_needs_rehash.phpt 
b/ext/standard/tests/password/password_needs_rehash.phpt
index 0c03d88..2fc3983 100644
--- a/ext/standard/tests/password/password_needs_rehash.phpt
+++ b/ext/standard/tests/password/password_needs_rehash.phpt
@@ -22,9 +22,9 @@ 
var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9H
 // Invalid, different (higher) cost
 
var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y',
 PASSWORD_BCRYPT, array('cost' => 11)));
 
-// Valid with cost the default (may need to be updated as the default cost 
increases)
-var_dump(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y',
 PASSWORD_BCRYPT));
-
+// Valid with cost the default
+$cost = str_pad(PASSWORD_BCRYPT_DEFAULT_COST, 2, '0', STR_PAD_LEFT);
+var_dump(password_needs_rehash('$2y$'.$cost.'$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y',
 PASSWORD_BCRYPT));
 
 echo "OK!";
 ?>


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to