feat: implement PBKDF2 algorithm with registry
This commit is contained in:
@@ -21,3 +21,20 @@ def test_get_algorithm_unknown_raises_error():
|
||||
"""Verify unknown algorithm raises ValueError."""
|
||||
with pytest.raises(ValueError, match="Unknown algorithm"):
|
||||
get_algorithm("unknown")
|
||||
|
||||
|
||||
def test_pbkdf2_algorithm_hash_round_trip():
|
||||
"""Verify PBKDF2 algorithm can hash and verify passwords."""
|
||||
algo = get_algorithm("pbkdf2")
|
||||
salt, hashed = algo.hash("test password")
|
||||
assert algo.verify("test password", salt, hashed)
|
||||
assert not algo.verify("wrong password", salt, hashed)
|
||||
|
||||
|
||||
def test_pbkdf2_algorithm_respects_iterations():
|
||||
"""Verify PBKDF2 algorithm respects custom iterations."""
|
||||
algo = get_algorithm("pbkdf2")
|
||||
salt1, hash1 = algo.hash("test", iterations=100000)
|
||||
salt2, hash2 = algo.hash("test", iterations=200000)
|
||||
# Different iterations should produce different hashes even with same password
|
||||
assert hash1 != hash2
|
||||
|
||||
Reference in New Issue
Block a user