Пример #1
0
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"
Пример #2
0
def test_decrypt_fail_incorrect_version_byte():
    with pytest.raises(VersionError):
        assert decrypt(b"2ciphertext", b"password") == b"message"
Пример #3
0
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"
Пример #4
0
def test_decrypt_success_slow(ciphertext_with_argon2):
    assert decrypt(ciphertext_with_argon2, b"password") == b"message"
Пример #5
0
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"
Пример #6
0
def test_decrypt_fail_incorrect_version_byte():
    with pytest.raises(VersionError):
        assert decrypt(b'2ciphertext', b'password') == b'message'
Пример #7
0
def test_decrypt_success_slow(ciphertext_with_argon2):
    assert decrypt(ciphertext_with_argon2, b'password') == b'message'
Пример #8
0
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'
Пример #9
0
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'