1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 19:23:22 +02:00
Files
archived-php-src/ext/sodium/tests/bug78516.phpt
T
Christoph M. Becker 145ffd93fc Fix #78516: password_hash(): Memory cost is not in allowed range
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.
2019-09-16 14:58:39 +02:00

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)