DTLS: throw exceptions from SRTP

This commit is contained in:
Marvin W 2021-11-09 22:06:48 +01:00 committed by fiaxh
parent ea19a9c5cb
commit dfda2f25f0

View file

@ -37,9 +37,8 @@ public class Handler {
this.own_fingerprint = creds.own_fingerprint; this.own_fingerprint = creds.own_fingerprint;
} }
public uint8[]? process_incoming_data(uint component_id, uint8[] data) { public uint8[]? process_incoming_data(uint component_id, uint8[] data) throws Crypto.Error {
if (srtp_session.has_decrypt) { if (srtp_session.has_decrypt) {
try {
if (component_id == 1) { if (component_id == 1) {
if (data.length >= 2 && data[1] >= 192 && data[1] < 224) { if (data.length >= 2 && data[1] >= 192 && data[1] < 224) {
return srtp_session.decrypt_rtcp(data); return srtp_session.decrypt_rtcp(data);
@ -47,19 +46,14 @@ public class Handler {
return srtp_session.decrypt_rtp(data); return srtp_session.decrypt_rtp(data);
} }
if (component_id == 2) return srtp_session.decrypt_rtcp(data); if (component_id == 2) return srtp_session.decrypt_rtcp(data);
} catch (Error e) {
warning("%s (%d)", e.message, e.code);
return null;
}
} else if (component_id == 1) { } else if (component_id == 1) {
on_data_rec(data); on_data_rec(data);
} }
return null; return null;
} }
public uint8[]? process_outgoing_data(uint component_id, uint8[] data) { public uint8[]? process_outgoing_data(uint component_id, uint8[] data) throws Crypto.Error {
if (srtp_session.has_encrypt) { if (srtp_session.has_encrypt) {
try {
if (component_id == 1) { if (component_id == 1) {
if (data.length >= 2 && data[1] >= 192 && data[1] < 224) { if (data.length >= 2 && data[1] >= 192 && data[1] < 224) {
return srtp_session.encrypt_rtcp(data); return srtp_session.encrypt_rtcp(data);
@ -67,10 +61,6 @@ public class Handler {
return srtp_session.encrypt_rtp(data); return srtp_session.encrypt_rtp(data);
} }
if (component_id == 2) return srtp_session.encrypt_rtcp(data); if (component_id == 2) return srtp_session.encrypt_rtcp(data);
} catch (Error e) {
warning("%s (%d)", e.message, e.code);
return null;
}
} }
return null; return null;
} }