1

How does the argon2-cffi python lib manage salt used to hash plaintext ? I understand that it generates itself the salt according to the salt_size I gave, but I don't understand how the lib can verify the hash without I give the salt used to encrypt.

EDIT: I found the answer to my question. To verify if a plain password matches the hash, the fonction « parse » the hash, which contains different information. The hash is like:

$argon2id$v=19$m=102400,t=2,p=8$tSm+JOWigOgPZx/g44K5fQ$WDyus6py50bVFIPkjA28lQ

Where each $ separates a piece of information. The second to last information is the salt used, and the last one is the hashed text.

This post answered my question, maybe I have to remove my one?

sultan97
  • 11
  • 2
  • 1
    A salt is not a decryption key. Its purpose is add a *random* element to the input to ensure that a given plaintext results in a different cyphertext each time. Without a salt, an attacker could see the same ciphertext attached to different accounts and conclude that they have the same plaintext password. With a salt, that can't happen because the same plaintext will yield different ciphertext on different occasions and the same ciphertext could well derive from different plaintexts. – BoarGules May 06 '22 at 14:12
  • Thank's for your precisions. What I didn't understand is how given a plainTextToVerify and a hash, the function verify was able to check if the hash of the plain was the same, without knowing the salt to use to hash the plain. – sultan97 May 07 '22 at 07:04
  • 1
    Since the salt is by design never the same, it gets discarded before checking for equality. But only the correct algorithm will know what to discard. – BoarGules May 07 '22 at 07:11

0 Answers0