Skip to content

Commit

Permalink
test: add argon2 verify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirVondukr committed Oct 17, 2024
1 parent 00f43f5 commit 12de3a9
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/libpass/hashers/test_argon2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from libpass.inspect.phc.defs import (
Argon2PHC,
)
from tests.test_handlers import PASS_TABLE_UTF8, UPASS_TABLE


@pytest.fixture
Expand Down Expand Up @@ -81,3 +82,34 @@ def test_hash_version_19(
)
hashed = hasher.hash(secret=secret, salt=salt)
assert hashed == hash


@pytest.mark.parametrize(
("secret", "hash"),
[
("password", "$argon2i$v=19$m=256,t=1,p=1$c29tZXNhbHQ$AJFIsNZTMKTAewB4+ETN1A"),
# sample w/ all parameters different
("password", "$argon2i$v=19$m=380,t=2,p=2$c29tZXNhbHQ$SrssP8n7m/12VWPM8dvNrw"),
# ensures utf-8 used for unicode
(
UPASS_TABLE,
"$argon2i$v=19$m=512,t=2,p=2$1sV0O4PWLtc12Ypv1f7oGw$"
"z+yqzlKtrq3SaNfXDfIDnQ",
),
(
PASS_TABLE_UTF8,
"$argon2i$v=19$m=512,t=2,p=2$1sV0O4PWLtc12Ypv1f7oGw$"
"z+yqzlKtrq3SaNfXDfIDnQ",
),
(
"password\x00",
"$argon2i$v=19$m=512,t=2,p=2$c29tZXNhbHQ$Fb5+nPuLzZvtqKRwqUEtUQ",
),
(
"password",
"$argon2d$v=19$m=102400,t=2,p=8$g2RodLh8j8WbSdCp+lUy/A$zzAJqL/HSjm809PYQu6qkA",
),
],
)
def test_verify(secret: str, hash: str, hasher: Argon2Hasher) -> None:
assert hasher.verify(hash=hash, secret=secret)

0 comments on commit 12de3a9

Please sign in to comment.