def test_decrypt_fail_incorrect_password_slow(ciphertext_with_argon2): with pytest.raises(nacl.exceptions.CryptoError): assert decrypt(ciphertext_with_argon2, b"password1") == b"message"
def test_decrypt_fail_incorrect_version_byte(): with pytest.raises(VersionError): assert decrypt(b"2ciphertext", b"password") == b"message"
def test_encrypt_decrypt_fail_wrong_password_kdf_monkeypatch(monkeypatch): monkeypatch.setattr("nacl.pwhash.argon2id.kdf", fast_kdf) ciphertext = encrypt(b"message", b"password") with pytest.raises(nacl.exceptions.CryptoError): assert decrypt(ciphertext, b"hunter2") == b"message"
def test_decrypt_success_slow(ciphertext_with_argon2): assert decrypt(ciphertext_with_argon2, b"password") == b"message"
def test_encrypt_decrypt_success_kdf_monkeypatch(monkeypatch): monkeypatch.setattr("nacl.pwhash.argon2id.kdf", fast_kdf) ciphertext = encrypt(b"message", b"password") assert decrypt(ciphertext, b"password") == b"message"
def test_decrypt_fail_incorrect_version_byte(): with pytest.raises(VersionError): assert decrypt(b'2ciphertext', b'password') == b'message'
def test_decrypt_success_slow(ciphertext_with_argon2): assert decrypt(ciphertext_with_argon2, b'password') == b'message'
def test_encrypt_decrypt_fail_wrong_password_kdf_monkeypatch(monkeypatch): monkeypatch.setattr('nacl.pwhash.argon2id.kdf', fast_kdf) ciphertext = encrypt(b'message', b'password') with pytest.raises(nacl.exceptions.CryptoError): assert decrypt(ciphertext, b'hunter2') == b'message'
def test_encrypt_decrypt_success_kdf_monkeypatch(monkeypatch): monkeypatch.setattr('nacl.pwhash.argon2id.kdf', fast_kdf) ciphertext = encrypt(b'message', b'password') assert decrypt(ciphertext, b'password') == b'message'