Skip to content

Commit 42a85fc

Browse files
authored
password_hash: Increase PHP_PASSWORD_BCRYPT_COST to 12 (#12367)
RFC: https://wiki.php.net/rfc/bcrypt_cost_2023
1 parent 4c22060 commit 42a85fc

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Standard:
2525
. Partly fix GH-12143 (Incorrect round() result for 0.49999999999999994).
2626
(timwolla)
2727
. Fix GH-12252 (round(): Validate the rounding mode). (timwolla)
28+
. Increase the default BCrypt cost to 12. (timwolla)
2829

2930
XSL:
3031
. Implement request #64137 (XSLTProcessor::setParameter() should allow both

UPGRADING

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ PHP 8.4 UPGRADE NOTES
8080
would have resulted in 1.0 instead of the correct result 0.0. Additional
8181
inputs might also be affected and result in different outputs compared to
8282
earlier PHP versions.
83+
. The default value of the 'cost' option for PASSWORD_BCRYPT for password_hash()
84+
has been increased from '10' to '12'.
85+
86+
RFC: https://wiki.php.net/rfc/bcrypt_cost_2023
8387

8488
========================================
8589
6. New Functions

ext/standard/php_password.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PHP_MINIT_FUNCTION(password);
2222
PHP_MSHUTDOWN_FUNCTION(password);
2323

2424
#define PHP_PASSWORD_DEFAULT PHP_PASSWORD_BCRYPT
25-
#define PHP_PASSWORD_BCRYPT_COST 10
25+
#define PHP_PASSWORD_BCRYPT_COST 12
2626

2727
#ifdef HAVE_ARGON2LIB
2828
/**

ext/standard/tests/password/password_hash.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
--TEST--
22
Test normal operation of password_hash()
3+
--SKIPIF--
4+
<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?>
35
--FILE--
46
<?php
57
//-=-=-=-
68

7-
var_dump(strlen(password_hash("foo", PASSWORD_BCRYPT)));
9+
var_dump(password_hash("foo", PASSWORD_BCRYPT));
810

911
$algos = [
1012
PASSWORD_BCRYPT,
@@ -19,8 +21,8 @@ foreach ($algos as $algo) {
1921

2022
echo "OK!";
2123
?>
22-
--EXPECT--
23-
int(60)
24+
--EXPECTF--
25+
string(60) "$2y$12$%s"
2426
bool(true)
2527
bool(true)
2628
bool(true)

ext/standard/tests/password/password_removed_salt_option.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
Test removed support for explicit salt option
3+
--SKIPIF--
4+
<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?>
35
--FILE--
46
<?php
57
//-=-=-=-

0 commit comments

Comments
 (0)