Warning
This post was published 42 days ago. The information described in this article may have changed.
Hi, I am writing web project using Rocket crate. It is more for learning. Started writing from authentication module and was searching for Argon2 hasher crate. Found two I am intrested:
Argon2 and Argon2-KDF
So, I have desided to benchmark both and see who is faster.
My benchmark code is here
I have desided to share my results. Maybe someone will be intrested in them and this may help them to choose.
After testing I found out Argon2 is a little faster than Argon2-KDF if p_cost=1
but if p_cost is >1, Argon2-KDF is faster, because Argon2-KDF is multithreaded and Argon2 is single threaded. Even thinking p_cost means how many threads hasher should use Argon2 only use 1 thread. But it gets right hash.
Here are my benchmark results:
This graph shows Argon2-KDF benchmark results with diffirent parameters.
First line increases RAM used from 1GB to 15GB
Second line changes t_cost from 1 to 15
Third line use m_cost of 15 GB and increases p_cost from 1 to 15
Tourth line use t_cost of 15 and increases p_cost from 1 to 15
Last line m_cost=5GB, t_cost=5 and p_cost from 1 to 15
Graph shows that increasing m_cost and t_cost time to make hash increases linearly. And increasing p_cost time to make hash go down. Bigest diffirence is going from p_cost=1 to p_cost=2. Benefit of increasing p_cost goes down fast. And after p_cost > 4 here are little change.
In case of Argon2 we see very diffirent graph.
m_cost and t_cost increase is similar to Argon2-KDF, but little faster. p_cost increase don't have any effect on speed. I checked my Task Managers and saw that Argon2 only use 1 core for hashing.
Next graph compare Argon2-KDF and Argon2 t_cost increase from 1 to 15 while m_cost and p_cost is 1 (on left side) and p_cost increase from 1 to 15 while m_cost is 1 and t_cost is 15.
Graph show Argon2 is always faster if using only one core p_cost=1, but it changes immediantly if we increase p_cost. Argon2-KDF becomes much faster.
Changing p_cost will change hash generated by Argon2 and Argon2-KDF even if Argon2 don't use p_cost to use more cores, he used it to generate hash.
In this table I compare hashes generated by Argon2 and Argon2-KDF changing p_cost only. Both Argon2 and Argon2-KDF will generate same hashes for same passwords with same parameters even if Argon2 use only 1 core.
From my benchmarking I come to decision, if user will only use p_cost=1, Argon2 crate will be beter for him, but if user will use more p_cost, Argon2-KDF will be beter.
Also, Argon2-KDF is wrapers around Argon2 writen in C, so this crate should get updates fater if something in Argon2 specifications will change. Because original authors will update C code. At last this is my guess.
But to compile Argon2-KDF user needs to install Clang compiler, because it need to compile Argon2 C code to work. But Argon2-KDF dokumentation forgot to mention it.
Or is it posible to make Argon2 use more cores? I could not find any info about it not using more cores, so this results made me a little confused.
1 post - 1 participant
🏷️ rust_feed