1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/openssl/tests/openssl_password.phpt
Remi Collet 32c5ce3451 Implement GH-13514 PASSWORD_ARGON2 from OpenSSL 3.2 (#13635)
* Implement GH-13514 PASSWORD_ARGON2 from OpenSSL 3.2

* simplify init/shutdown

* use php_base64_encode_ex

* - rename macros - use openssl RAND_bytes - CS

* add --with-openssl-argon2 build option

* check OSSL_KDF_PARAM_ARGON2_LANES instead of OSSL_set_max_threads

* Cleanup and CS

* save/restore old threads config + CS

* remove unneeded check
2024-09-02 13:01:09 +02:00

43 lines
934 B
PHP

--TEST--
Basic features of password_hash
--EXTENSIONS--
openssl
--SKIPIF--
<?php
if (!function_exists('openssl_password_hash')) {
echo "skip - No openssl_password_hash";
}
?>
--FILE--
<?php
echo 'Argon2 provider: ';
var_dump(PASSWORD_ARGON2_PROVIDER);
foreach([1, 2] as $mem) {
foreach([1, 2] as $time) {
$opts = [
'memory_cost' => PASSWORD_ARGON2_DEFAULT_MEMORY_COST / $mem,
'time_cost' => PASSWORD_ARGON2_DEFAULT_TIME_COST / $time,
'threads' => PASSWORD_ARGON2_DEFAULT_THREADS,
];
foreach(['argon2i', 'argon2id'] as $algo) {
$pass = "secret$mem$time$algo";
$hash = openssl_password_hash($algo, $pass, $opts);
var_dump(openssl_password_verify($algo, $pass, $hash));
}
}
}
?>
--EXPECTF--
Argon2 provider: string(%d) "%s"
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)