Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/borg/testsuite/crypto/key_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,13 @@ def to_dict(key):

assert to_dict(load_me) == to_dict(save_me)
assert msgpack.unpackb(a2b_base64(saved))["algorithm"] == KEY_ALGORITHMS["argon2"]


def test_argon2_wrong_passphrase_returns_none(monkeypatch):
# a wrong passphrase derives a different key, so the Argon2 integrity check fails;
# decrypt_key_file signals this by returning None, not by raising (refs #8036)
repository = MagicMock(id=b"repository_id")
monkeypatch.setenv("BORG_PASSPHRASE", "correct passphrase")
key = AESOCBRepoKey.create(repository, args=MagicMock(key_algorithm="argon2"))
saved = repository.save_key.call_args.args[0]
assert key.decrypt_key_file(a2b_base64(saved), "wrong passphrase") is None
Loading