def test_decrypt_outbound_srtp(fixtures, capture, material, out_address, out_port, expected): km = dsrtp.KeyingMaterial.unpack_encoded(fixtures.join(material).read()) with fixtures.join(capture).open('rb') as fo: dec_pkts = dsrtp.decrypt_packets( dsrtp.SRTPStream(km.local, out_address, out_port), dsrtp.read_packets(fo), unknown='drop', malformed='raise', ) count = 0 for _, pkt in dec_pkts: assert (dsrtp.is_srtp_packet(pkt) or dsrtp.is_srtcp_packet(pkt)) count += 1 assert count == expected
def test_decrypt_inbound_srtp( fixtures, capture, material, in_address, in_port, expected): km = dsrtp.KeyingMaterial.unpack_encoded( fixtures.join(material).read() ) with fixtures.join(capture).open('rb') as fo: dec_pkts = dsrtp.decrypt_packets( dsrtp.SRTPStream(km.remote, in_address, in_port), dsrtp.read_packets(fo), unknown='drop', malformed='raise', ) count = 0 for _, pkt in dec_pkts: assert ( dsrtp.is_srtp_packet(pkt) or dsrtp.is_srtcp_packet(pkt) ) count += 1 assert count == expected
def test_is_srtp(fixtures, packet, expected): raw = fixtures.join(packet).read().decode('hex') eth = dpkt.ethernet.Ethernet(raw) assert dsrtp.is_srtp_packet(eth) is expected