I want to use Argon2 as the hashing algorithm for the passwords in my system and I'm trying to find the right parameters to set for it. I'm using PHP.
While testing a few variations, I tried to see how's the memory impacted by using Argon2.
The documentation mentions this :
memory_cost (integer) - Maximum memory (in kibibytes) that may be used to compute the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_MEMORY_COST.
However, using PHP's function memory_get_peak_usage
the amount of memory consumed by my script never seems impacted. Here is an example :
$hash = password_hash('password1', PASSWORD_ARGON2I, ['memory_cost' => (1024*100), 'time_cost' => 20, 'threads' => 2]); // Should require 100MiB
$memory_peak = memory_get_peak_usage(true);
echo $memory_peak / (1024*1024); // To have the result in MiB
On my system, this takes ~0.5 second to execute, BUT memory usage is always 2MiB.
Can someone explain why PHP memory usage is not affected by using memory_cost
parameter of Argon2 ?