Skip to content

Commit 86072d6

Browse files
committed
Reduce cost factors in sodium password_hash tests
Drop the 4x factors to make these tests a bit less obscenely slow.
1 parent 5072321 commit 86072d6

File tree

3 files changed

+5
-67
lines changed

3 files changed

+5
-67
lines changed

ext/sodium/tests/php_password_hash_argon2i.phpt

+3-22
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ if (!function_exists('sodium_crypto_pwhash_str_verify')) {
88
if (!in_array('argon2i', password_algos(), true /* strict */)) {
99
echo "skip - No argon2i support in password_hash()";
1010
}
11+
?>
1112
--FILE--
1213
<?php
1314

1415
echo 'Argon2 provider: ';
1516
var_dump(PASSWORD_ARGON2_PROVIDER);
1617

17-
foreach([1, 2, 4] as $mem) {
18-
foreach([1, 2, 4] as $time) {
18+
foreach([1, 2] as $mem) {
19+
foreach([1, 2] as $time) {
1920
$opts = [
2021
'memory_cost' => PASSWORD_ARGON2_DEFAULT_MEMORY_COST * $mem,
2122
'time_cost' => PASSWORD_ARGON2_DEFAULT_TIME_COST * $time,
@@ -45,30 +46,10 @@ Hash: string(96) "$argon2i$v=19$m=65536,t=8,p=1$%s$%s"
4546
bool(true)
4647
bool(false)
4748
Using password: string(44) "%s"
48-
Hash: string(97) "$argon2i$v=19$m=65536,t=16,p=1$%s$%s"
49-
bool(true)
50-
bool(false)
51-
Using password: string(44) "%s"
5249
Hash: string(97) "$argon2i$v=19$m=131072,t=4,p=1$%s$%s"
5350
bool(true)
5451
bool(false)
5552
Using password: string(44) "%s"
5653
Hash: string(97) "$argon2i$v=19$m=131072,t=8,p=1$%s$%s"
5754
bool(true)
5855
bool(false)
59-
Using password: string(44) "%s"
60-
Hash: string(98) "$argon2i$v=19$m=131072,t=16,p=1$%s$%s"
61-
bool(true)
62-
bool(false)
63-
Using password: string(44) "%s"
64-
Hash: string(97) "$argon2i$v=19$m=262144,t=4,p=1$%s$%s"
65-
bool(true)
66-
bool(false)
67-
Using password: string(44) "%s"
68-
Hash: string(97) "$argon2i$v=19$m=262144,t=8,p=1$%s$%s"
69-
bool(true)
70-
bool(false)
71-
Using password: string(44) "%s"
72-
Hash: string(98) "$argon2i$v=19$m=262144,t=16,p=1$%s$%s"
73-
bool(true)
74-
bool(false)

ext/sodium/tests/php_password_hash_argon2id.phpt

+2-23
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ if (!in_array('argon2id', password_algos(), true /* strict */)) {
1414
echo 'Argon2 provider: ';
1515
var_dump(PASSWORD_ARGON2_PROVIDER);
1616

17-
foreach([1, 2, 4] as $mem) {
18-
foreach([1, 2, 4] as $time) {
17+
foreach([1, 2] as $mem) {
18+
foreach([1, 2] as $time) {
1919
$opts = [
2020
'memory_cost' => PASSWORD_ARGON2_DEFAULT_MEMORY_COST * $mem,
2121
'time_cost' => PASSWORD_ARGON2_DEFAULT_TIME_COST * $time,
@@ -45,31 +45,10 @@ Hash: string(97) "$argon2id$v=19$m=65536,t=8,p=1$%s$%s"
4545
bool(true)
4646
bool(false)
4747
Using password: string(44) "%s"
48-
Hash: string(98) "$argon2id$v=19$m=65536,t=16,p=1$%s$%s"
49-
bool(true)
50-
bool(false)
51-
Using password: string(44) "%s"
5248
Hash: string(98) "$argon2id$v=19$m=131072,t=4,p=1$%s$%s"
5349
bool(true)
5450
bool(false)
5551
Using password: string(44) "%s"
5652
Hash: string(98) "$argon2id$v=19$m=131072,t=8,p=1$%s$%s"
5753
bool(true)
5854
bool(false)
59-
Using password: string(44) "%s"
60-
Hash: string(99) "$argon2id$v=19$m=131072,t=16,p=1$%s$%s"
61-
bool(true)
62-
bool(false)
63-
Using password: string(44) "%s"
64-
Hash: string(98) "$argon2id$v=19$m=262144,t=4,p=1$%s$%s"
65-
bool(true)
66-
bool(false)
67-
Using password: string(44) "%s"
68-
Hash: string(98) "$argon2id$v=19$m=262144,t=8,p=1$%s$%s"
69-
bool(true)
70-
bool(false)
71-
Using password: string(44) "%s"
72-
Hash: string(99) "$argon2id$v=19$m=262144,t=16,p=1$%s$%s"
73-
bool(true)
74-
bool(false)
75-

ext/sodium/tests/php_password_verify.phpt

-22
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ if (!in_array($algo, password_algos(), true /* strict */)) {
1919
$opsSet = [
2020
SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE,
2121
SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE,
22-
SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE,
2322
];
2423
$memSet = [
2524
SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE,
2625
SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE,
27-
SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE,
2826
];
2927

3028
echo 'Argon2 provider: ';
@@ -56,30 +54,10 @@ Hash: string(98) "$argon2id$v=19$m=262144,t=2,p=1$%s$%s"
5654
bool(true)
5755
bool(false)
5856
Using password: string(44) "%s"
59-
Hash: string(99) "$argon2id$v=19$m=1048576,t=2,p=1$%s$%s"
60-
bool(true)
61-
bool(false)
62-
Using password: string(44) "%s"
6357
Hash: string(97) "$argon2id$v=19$m=65536,t=3,p=1$%s$%s"
6458
bool(true)
6559
bool(false)
6660
Using password: string(44) "%s"
6761
Hash: string(98) "$argon2id$v=19$m=262144,t=3,p=1$%s$%s"
6862
bool(true)
6963
bool(false)
70-
Using password: string(44) "%s"
71-
Hash: string(99) "$argon2id$v=19$m=1048576,t=3,p=1$%s$%s"
72-
bool(true)
73-
bool(false)
74-
Using password: string(44) "%s"
75-
Hash: string(97) "$argon2id$v=19$m=65536,t=4,p=1$%s$%s"
76-
bool(true)
77-
bool(false)
78-
Using password: string(44) "%s"
79-
Hash: string(98) "$argon2id$v=19$m=262144,t=4,p=1$%s$%s"
80-
bool(true)
81-
bool(false)
82-
Using password: string(44) "%s"
83-
Hash: string(99) "$argon2id$v=19$m=1048576,t=4,p=1$%s$%s"
84-
bool(true)
85-
bool(false)

0 commit comments

Comments
 (0)