diff options
| author | Anthony Ferrara <ircmaxell@gmail.com> | 2012-09-12 11:47:50 -0400 |
|---|---|---|
| committer | Anthony Ferrara <ircmaxell@gmail.com> | 2012-09-12 11:47:50 -0400 |
| commit | 76f3295cdfd6a3106297352e73b9691084582211 (patch) | |
| tree | 9f9d2f3fea70dc3b7a09777b792c42d430521d7c | |
| parent | ebe0bd5dee07bebd8444d9e7c28864ba17efeef8 (diff) | |
| download | php-git-76f3295cdfd6a3106297352e73b9691084582211.tar.gz | |
Expose PASSWORD_BCRYPT_DEFAULT_COST constant and update test to use it
| -rw-r--r-- | ext/standard/password.c | 2 | ||||
| -rw-r--r-- | ext/standard/tests/password/password_needs_rehash.phpt | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/ext/standard/password.c b/ext/standard/password.c index d3dc457428..9b1bb8ccca 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 0c03d88b4d..2fc3983980 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!"; ?> |
