Skip to content

Commit 9a05029

Browse files
committed
Tests: Ensure decryption failure on invalid data
1 parent 99add1e commit 9a05029

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/test_crypto.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
import pytest
12
from xcloud.protocol import srtp_crypto
23

34
def test_decrypt(test_data: dict, crypto_context: srtp_crypto.SrtpContext):
45
rtp_packet_raw = test_data['rtp_connection_probing.bin']
5-
66
rtp_header, rtp_body = rtp_packet_raw[:12], rtp_packet_raw[12:]
7+
78
plaintext = crypto_context.decrypt(rtp_body, aad=rtp_header)
9+
with pytest.raises(Exception):
10+
# Skip 1 byte of "additional data" to ensure invalid data
11+
crypto_context.decrypt(rtp_body, aad=rtp_header[1:])
812

9-
print(plaintext)
1013
assert plaintext is not None
1114

1215
def test_init_master_keys(srtp_key: str):

0 commit comments

Comments
 (0)