Esempio n. 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"
Esempio n. 2
0
def test_decrypt_fail_incorrect_version_byte():
    with pytest.raises(VersionError):
        assert decrypt(b"2ciphertext", b"password") == b"message"
Esempio n. 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"
Esempio n. 4
0
def test_decrypt_success_slow(ciphertext_with_argon2):
    assert decrypt(ciphertext_with_argon2, b"password") == b"message"
Esempio n. 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"
Esempio n. 6
0
def test_decrypt_fail_incorrect_version_byte():
    with pytest.raises(VersionError):
        assert decrypt(b'2ciphertext', b'password') == b'message'
Esempio n. 7
0
def test_decrypt_success_slow(ciphertext_with_argon2):
    assert decrypt(ciphertext_with_argon2, b'password') == b'message'
Esempio n. 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'
Esempio n. 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'