mirror of
https://github.com/php/php-src.git
synced 2026-04-29 19:23:22 +02:00
145ffd93fc
libsodium measures the memory cost in bytes, while password_hash() and friends expect kibibyte values. We have to properly map between these scales not only when calling libsodium functions, but also when checking for allowed values. We also refactor to rid the code duplication.
19 lines
645 B
PHP
19 lines
645 B
PHP
--TEST--
|
|
Bug #78516 (password_hash(): Memory cost is not in allowed range)
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('sodium')) die('skip sodium extension not available');
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$pass = password_hash('secret', PASSWORD_ARGON2ID, ['memory_cost' => 8191]);
|
|
password_needs_rehash($pass, PASSWORD_ARGON2ID, ['memory_cost' => 8191]);
|
|
var_dump(password_get_info($pass)['options']['memory_cost']);
|
|
$pass = password_hash('secret', PASSWORD_ARGON2I, ['memory_cost' => 8191]);
|
|
password_needs_rehash($pass, PASSWORD_ARGON2I, ['memory_cost' => 8191]);
|
|
var_dump(password_get_info($pass)['options']['memory_cost']);
|
|
?>
|
|
--EXPECT--
|
|
int(8191)
|
|
int(8191)
|