Example #1
0
def test_decrypt_aesgcm_truncated(ciphertext_len):
    # Check that grossly truncated ciphertexts still give the same error, and not something else.
    key = bytes.fromhex(
        "120c64583cc9831cedf6b0ffa3cb003c1a3cc057c8f40e3f6fb7f9e376beba43")
    nonce = bytes.fromhex("f5a57de46ff8daee400942c5")
    with pytest.raises(NoiseError):
        _decrypt_aesgcm(key, nonce, bytes(ciphertext_len), b'')
Example #2
0
def test_decrypt_aesgcm():
    key = bytes.fromhex("120c64583cc9831cedf6b0ffa3cb003c1a3cc057c8f40e3f6fb7f9e376beba43")
    nonce = bytes.fromhex("f5a57de46ff8daee400942c5")
    ciphertext = bytes.fromhex("44178f74e77071918e3f2c3e3d2a256916c33a85f409844bbd1b749719b2f2e71e210f763928d856479e7078cb0413e1")
    aad = bytes.fromhex("1def84acf2c1e5ae04bff2a67b0668bb2c9a285e5c5e033f00c227466c8d022b539edb6df8541fb8e56c97c6a8cd061fe1c6c874a374d8501f8a285ed5ec0922")
    expected_plaintext = bytes.fromhex("1f5349c16e430d7685d56437734d9346c3c842e4a873034d489f480a68e2ed25")

    assert _decrypt_aesgcm(key, nonce, ciphertext, aad) == expected_plaintext
Example #3
0
def test_decrypt_aesgcm():
    key = bytes.fromhex(
        "120c64583cc9831cedf6b0ffa3cb003c1a3cc057c8f40e3f6fb7f9e376beba43")
    nonce = bytes.fromhex("f5a57de46ff8daee400942c5")
    ciphertext = bytes.fromhex(
        "44178f74e77071918e3f2c3e3d2a256916c33a85f409844bbd1b749719b2f2e71e210f763928d856479e7078cb0413e1"
    )
    aad = bytes.fromhex(
        "1def84acf2c1e5ae04bff2a67b0668bb2c9a285e5c5e033f00c227466c8d022b539edb6df8541fb8e56c97c6a8cd061fe1c6c874a374d8501f8a285ed5ec0922"
    )
    expected_plaintext = bytes.fromhex(
        "1f5349c16e430d7685d56437734d9346c3c842e4a873034d489f480a68e2ed25")

    assert _decrypt_aesgcm(key, nonce, ciphertext, aad) == expected_plaintext
Example #4
0
def test_decrypt_aesgcm_truncated(ciphertext_len):
    # Check that grossly truncated ciphertexts still give the same error, and not something else.
    key = bytes.fromhex("120c64583cc9831cedf6b0ffa3cb003c1a3cc057c8f40e3f6fb7f9e376beba43")
    nonce = bytes.fromhex("f5a57de46ff8daee400942c5")
    with pytest.raises(NoiseError):
        _decrypt_aesgcm(key, nonce, bytes(ciphertext_len), b'')