Skip to content

Commit db0eaa8

Browse files
committed
improve libargon2/libsodium compatibility
1 parent 48abed7 commit db0eaa8

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

ext/standard/password.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,21 @@ static const php_password_algo* php_password_algo_find_zval_ex(zval *arg, const
571571
#if HAVE_ARGON2LIB
572572
case 2: return &php_password_algo_argon2i;
573573
case 3: return &php_password_algo_argon2id;
574+
#else
575+
case 2:
576+
{
577+
zend_string *n = zend_string_init("argon2i", sizeof("argon2i")-1, 0);
578+
const php_password_algo* ret = php_password_algo_find(n);
579+
zend_string_release(n);
580+
return ret;
581+
}
582+
case 3:
583+
{
584+
zend_string *n = zend_string_init("argon2id", sizeof("argon2id")-1, 0);
585+
const php_password_algo* ret = php_password_algo_find(n);
586+
zend_string_release(n);
587+
return ret;
588+
}
574589
#endif
575590
}
576591
return NULL;

ext/standard/tests/password/bug75221.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (!defined('PASSWORD_ARGON2I')) die('skip password_hash not built with Argon2'
99
$hash = password_hash(
1010
"php",
1111
PASSWORD_ARGON2I,
12-
['memory_cost' => 16384, 'time_cost' => 2, 'threads' => 4]
12+
['memory_cost' => 64 << 10, 'time_cost' => 4, 'threads' => 1]
1313
);
1414
var_dump(substr($hash, -1, 1) !== "\0");
1515
?>

ext/standard/tests/password/password_hash_error_argon2.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ NULL
2121
Warning: password_hash(): Time cost is outside of allowed time range in %s on line %d
2222
NULL
2323

24-
Warning: password_hash(): Invalid number of threads in %s on line %d
24+
Warning: password_hash(): %sthread%s
2525
NULL
2626

2727
Warning: password_hash(): Memory cost is outside of allowed memory range in %s on line %d
@@ -30,5 +30,5 @@ NULL
3030
Warning: password_hash(): Time cost is outside of allowed time range in %s on line %d
3131
NULL
3232

33-
Warning: password_hash(): Invalid number of threads in %s on line %d
33+
Warning: password_hash(): %sthread%s
3434
NULL

0 commit comments

Comments
 (0)