From deb4c84d52bb941634e9d302bf281e79cb2de44e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20B=C3=BChler?= Date: Thu, 30 Nov 2023 23:55:34 +0100 Subject: [PATCH] introduce xxx2 api --- CMakeLists.txt | 1 + include/srtp.h | 30 +++++ srtp/srtp.c | 64 ++++++++++ test/srtp_driver.c | 311 +++++++++++++++++++++++++++------------------ 4 files changed, 282 insertions(+), 124 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 314b6ecc0..fc179d8b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,6 +345,7 @@ if(LIBSRTP_TEST_APPS) test/util.c test/getopt_s.c) target_link_libraries(srtp_driver srtp2) add_test(srtp_driver srtp_driver -v) + add_test(srtp_driver_x2 srtp_driver -v -n) if(NOT (BUILD_SHARED_LIBS AND WIN32)) add_executable(test_srtp test/test_srtp.c) diff --git a/include/srtp.h b/include/srtp.h index 40b0c783f..de1e59246 100644 --- a/include/srtp.h +++ b/include/srtp.h @@ -478,6 +478,14 @@ srtp_err_status_t srtp_protect_mki(srtp_ctx_t *ctx, unsigned int use_mki, unsigned int mki_index); +srtp_err_status_t srtp_protect2(srtp_t ctx, + const void *rtp, + int rtp_len, + void *srtp, + int *srtp_len, + unsigned int use_mki, + unsigned int mki_index); + /** * @brief srtp_unprotect() is the Secure RTP receiver-side packet * processing function. @@ -571,6 +579,13 @@ srtp_err_status_t srtp_unprotect_mki(srtp_t ctx, int *len_ptr, unsigned int use_mki); +srtp_err_status_t srtp_unprotect2(srtp_t ctx, + const void *srtp, + int srtp_len, + void *rtp, + int *rtp_len, + unsigned int use_mki); + /** * @brief srtp_create() allocates and initializes an SRTP session. @@ -1382,6 +1397,14 @@ srtp_err_status_t srtp_protect_rtcp_mki(srtp_t ctx, unsigned int use_mki, unsigned int mki_index); +srtp_err_status_t srtp_protect_rtcp2(srtp_t ctx, + const void *rtcp, + int rtcp_len, + void *srtcp, + int *srtcp_len, + unsigned int use_mki, + unsigned int mki_index); + /** * @brief srtp_unprotect_rtcp() is the Secure RTCP receiver-side packet * processing function. @@ -1474,6 +1497,13 @@ srtp_err_status_t srtp_unprotect_rtcp_mki(srtp_t ctx, int *pkt_octet_len, unsigned int use_mki); +srtp_err_status_t srtp_unprotect_rtcp2(srtp_t ctx, + const void *srtcp, + int srtcp_len, + void *rtcp, + int *rtcp_len, + unsigned int use_mki); + /** * @} */ diff --git a/srtp/srtp.c b/srtp/srtp.c index 75b71fb6e..31357a169 100644 --- a/srtp/srtp.c +++ b/srtp/srtp.c @@ -2142,6 +2142,22 @@ srtp_err_status_t srtp_protect(srtp_ctx_t *ctx, return srtp_protect_mki(ctx, rtp_hdr, pkt_octet_len, 0, 0); } +srtp_err_status_t srtp_protect2(srtp_t ctx, + const void *rtp, + int rtp_len, + void *srtp, + int *srtp_len, + unsigned int use_mki, + unsigned int mki_index) +{ + if (*srtp_len < rtp_len) { + return srtp_err_status_bad_param; + } + memcpy(srtp, rtp, rtp_len); + *srtp_len = rtp_len; + return srtp_protect_mki(ctx, srtp, srtp_len, use_mki, mki_index); +} + srtp_err_status_t srtp_protect_mki(srtp_ctx_t *ctx, void *rtp_hdr, int *pkt_octet_len, @@ -2470,6 +2486,22 @@ srtp_err_status_t srtp_unprotect(srtp_ctx_t *ctx, return srtp_unprotect_mki(ctx, srtp_hdr, pkt_octet_len, 0); } +srtp_err_status_t srtp_unprotect2(srtp_t ctx, + const void *srtp, + int srtp_len, + void *rtp, + int *rtp_len, + unsigned int use_mki) +{ + if (*rtp_len < srtp_len) { + // this is actually expected but for the tests this should not happen + return srtp_err_status_bad_param; + } + memcpy(rtp, srtp, srtp_len); + *rtp_len = srtp_len; + return srtp_unprotect_mki(ctx, rtp, rtp_len, use_mki); +} + srtp_err_status_t srtp_unprotect_mki(srtp_ctx_t *ctx, void *srtp_hdr, int *pkt_octet_len, @@ -3987,6 +4019,22 @@ srtp_err_status_t srtp_protect_rtcp(srtp_t ctx, return srtp_protect_rtcp_mki(ctx, rtcp_hdr, pkt_octet_len, 0, 0); } +srtp_err_status_t srtp_protect_rtcp2(srtp_t ctx, + const void *rtcp, + int rtcp_len, + void *srtcp, + int *srtcp_len, + unsigned int use_mki, + unsigned int mki_index) +{ + if (*srtcp_len < rtcp_len) { + return srtp_err_status_bad_param; + } + memcpy(srtcp, rtcp, rtcp_len); + *srtcp_len = rtcp_len; + return srtp_protect_rtcp_mki(ctx, srtcp, srtcp_len, use_mki, mki_index); +} + srtp_err_status_t srtp_protect_rtcp_mki(srtp_t ctx, void *rtcp_hdr, int *pkt_octet_len, @@ -4219,6 +4267,22 @@ srtp_err_status_t srtp_unprotect_rtcp(srtp_t ctx, return srtp_unprotect_rtcp_mki(ctx, srtcp_hdr, pkt_octet_len, 0); } +srtp_err_status_t srtp_unprotect_rtcp2(srtp_t ctx, + const void *srtcp, + int srtcp_len, + void *rtcp, + int *rtcp_len, + unsigned int use_mki) +{ + if (*rtcp_len < srtcp_len) { + // this is actually expected but for the tests this should not happen + return srtp_err_status_bad_param; + } + memcpy(rtcp, srtcp, srtcp_len); + *rtcp_len = srtcp_len; + return srtp_unprotect_rtcp_mki(ctx, rtcp, rtcp_len, use_mki); +} + srtp_err_status_t srtp_unprotect_rtcp_mki(srtp_t ctx, void *srtcp_hdr, int *pkt_octet_len, diff --git a/test/srtp_driver.c b/test/srtp_driver.c index 53173ad7c..6816cee16 100644 --- a/test/srtp_driver.c +++ b/test/srtp_driver.c @@ -155,95 +155,151 @@ srtp_master_key_t *test_keys[2] = { }; // clang-format on -srtp_err_status_t __srtp_protect_mki(srtp_t srtp_sender, - srtp_hdr_t *hdr, - int *len, - int mki_index) +int use_srtp_xxx2_api = 0; + +srtp_err_status_t call_srtp_protect_mki(srtp_ctx_t *ctx, + void *rtp, + int *rtp_len, + int mki_index) { - if (mki_index == -1) { - return srtp_protect(srtp_sender, hdr, len); + srtp_err_status_t status = srtp_err_status_fail; + int use_mki = mki_index >= 0 ? 1 : 0; + if (use_srtp_xxx2_api == 1) { + uint8_t out_buf[4048]; + int out_len = sizeof(out_buf); + status = srtp_protect2(ctx, rtp, *rtp_len, out_buf, &out_len, use_mki, + mki_index); + if (status == srtp_err_status_ok) { + memcpy(rtp, out_buf, out_len); + *rtp_len = out_len; + } } else { - return srtp_protect_mki(srtp_sender, hdr, len, 1, mki_index); + if (use_mki == 0) { + status = srtp_protect(ctx, rtp, rtp_len); + } else { + status = srtp_protect_mki(ctx, rtp, rtp_len, use_mki, mki_index); + } } + return status; } -srtp_err_status_t __srtp_protect(srtp_ctx_t *ctx, - void *rtp_hdr, - int *pkt_octet_len) +srtp_err_status_t call_srtp_protect(srtp_ctx_t *ctx, void *rtp, int *rtp_len) { - return __srtp_protect_mki(ctx, rtp_hdr, pkt_octet_len, -1); + return call_srtp_protect_mki(ctx, rtp, rtp_len, -1); } -srtp_err_status_t __srtp_unprotect_mki(srtp_t srtp_sender, - srtp_hdr_t *hdr, - int *len, - int use_mki) +srtp_err_status_t call_srtp_unprotect_mki(srtp_ctx_t *ctx, + void *srtp, + int *srtp_len, + int use_mki) { - if (use_mki == 0) { - return srtp_unprotect(srtp_sender, hdr, len); + srtp_err_status_t status = srtp_err_status_fail; + if (use_srtp_xxx2_api == 1) { + uint8_t out_buf[4048]; + int out_len = sizeof(out_buf); + status = + srtp_unprotect2(ctx, srtp, *srtp_len, out_buf, &out_len, use_mki); + if (status == srtp_err_status_ok) { + memcpy(srtp, out_buf, out_len); + *srtp_len = out_len; + } } else { - return srtp_unprotect_mki(srtp_sender, hdr, len, use_mki); + if (use_mki == 0) { + status = srtp_unprotect(ctx, srtp, srtp_len); + } else { + status = srtp_unprotect_mki(ctx, srtp, srtp_len, use_mki); + } } + return status; } -srtp_err_status_t __srtp_unprotect(srtp_ctx_t *ctx, - void *srtp_hdr, - int *pkt_octet_len) +srtp_err_status_t call_srtp_unprotect(srtp_ctx_t *ctx, + void *srtp, + int *srtp_len) { - return __srtp_unprotect_mki(ctx, srtp_hdr, pkt_octet_len, 0); + return call_srtp_unprotect_mki(ctx, srtp, srtp_len, 0); } -srtp_err_status_t __srtp_protect_rtcp_mki(srtp_t srtp_sender, - srtcp_hdr_t *hdr, - int *len, - int mki_index) +srtp_err_status_t call_srtp_protect_rtcp_mki(srtp_ctx_t *ctx, + void *rtcp, + int *rtcp_len, + int mki_index) { - if (mki_index == -1) { - return srtp_protect_rtcp(srtp_sender, hdr, len); + srtp_err_status_t status = srtp_err_status_fail; + int use_mki = mki_index >= 0 ? 1 : 0; + if (use_srtp_xxx2_api == 1) { + uint8_t out_buf[4048]; + int out_len = sizeof(out_buf); + status = srtp_protect_rtcp2(ctx, rtcp, *rtcp_len, out_buf, &out_len, + use_mki, mki_index); + if (status == srtp_err_status_ok) { + memcpy(rtcp, out_buf, out_len); + *rtcp_len = out_len; + } } else { - return srtp_protect_rtcp_mki(srtp_sender, hdr, len, 1, mki_index); + if (use_mki == 0) { + status = srtp_protect_rtcp(ctx, rtcp, rtcp_len); + } else { + status = + srtp_protect_rtcp_mki(ctx, rtcp, rtcp_len, use_mki, mki_index); + } } + return status; } -srtp_err_status_t __srtp_protect_rtcp(srtp_ctx_t *ctx, - void *rtcp_hdr, - int *pkt_octet_len) +srtp_err_status_t call_srtp_protect_rtcp(srtp_ctx_t *ctx, + void *rtcp, + int *rtcp_len) { - return __srtp_protect_rtcp_mki(ctx, rtcp_hdr, pkt_octet_len, -1); + return call_srtp_protect_rtcp_mki(ctx, rtcp, rtcp_len, -1); } -srtp_err_status_t __srtp_unprotect_rtcp_mki(srtp_t srtp_sender, - srtcp_hdr_t *hdr, - int *len, - int use_mki) +srtp_err_status_t call_srtp_unprotect_rtcp_mki(srtp_ctx_t *ctx, + void *srtcp, + int *srtcp_len, + int use_mki) { - if (use_mki == 0) { - return srtp_unprotect_rtcp(srtp_sender, hdr, len); + srtp_err_status_t status = srtp_err_status_fail; + if (use_srtp_xxx2_api == 1) { + uint8_t out_buf[4048]; + int out_len = sizeof(out_buf); + status = srtp_unprotect_rtcp2(ctx, srtcp, *srtcp_len, out_buf, &out_len, + use_mki); + if (status == srtp_err_status_ok) { + memcpy(srtcp, out_buf, out_len); + *srtcp_len = out_len; + } } else { - return srtp_unprotect_rtcp_mki(srtp_sender, hdr, len, use_mki); + if (use_mki == 0) { + status = srtp_unprotect_rtcp(ctx, srtcp, srtcp_len); + } else { + status = srtp_unprotect_rtcp_mki(ctx, srtcp, srtcp_len, use_mki); + } } + return status; } -srtp_err_status_t __srtp_unprotect_rtcp(srtp_ctx_t *ctx, - void *srtcp_hdr, - int *pkt_octet_len) +srtp_err_status_t call_srtp_unprotect_rtcp(srtp_ctx_t *ctx, + void *srtcp, + int *srtcp_len) { - return __srtp_unprotect_rtcp_mki(ctx, srtcp_hdr, pkt_octet_len, 0); + return call_srtp_unprotect_rtcp_mki(ctx, srtcp, srtcp_len, 0); } void usage(char *prog_name) { - printf( - "usage: %s [ -t ][ -c ][ -v ][ -s ][ -o ][-d ]* [ -l ]\n" - " -t run timing test\n" - " -r run rejection timing test\n" - " -c run codec timing test\n" - " -v run validation tests\n" - " -s run stream list tests only\n" - " -o output logging to stdout\n" - " -d turn on debugging module \n" - " -l list debugging modules\n", - prog_name); + printf("usage: %s [ -t ][ -c ][ -v ][ -s ][ -o ][-d ]* [ -l " + "][ -n ]\n" + " -t run timing test\n" + " -r run rejection timing test\n" + " -c run codec timing test\n" + " -v run validation tests\n" + " -s run stream list tests only\n" + " -o output logging to stdout\n" + " -d turn on debugging module \n" + " -l list debugging modules\n" + " -n run with non inplace api\n", + prog_name); exit(1); } @@ -334,7 +390,7 @@ int main(int argc, char *argv[]) /* process input arguments */ while (1) { - q = getopt_s(argc, argv, "trcvsold:"); + q = getopt_s(argc, argv, "trcvsold:n"); if (q == -1) { break; } @@ -368,6 +424,10 @@ int main(int argc, char *argv[]) exit(1); } break; + case 'n': + printf("using srtp_xxx2() functions\n"); + use_srtp_xxx2_api = 1; + break; default: usage(argv[0]); } @@ -1033,7 +1093,7 @@ double srtp_bits_per_second(int msg_len_octets, const srtp_policy_t *policy) for (i = 0; i < num_trials; i++) { len = input_len; /* srtp protect message */ - status = __srtp_protect(srtp, mesg, &len); + status = call_srtp_protect(srtp, mesg, &len); if (status) { printf("error: srtp_protect() failed with error code %d\n", status); exit(1); @@ -1085,12 +1145,12 @@ double srtp_rejections_per_second(int msg_len_octets, if (mesg == NULL) { return 0.0; /* indicate failure by returning zero */ } - __srtp_protect(srtp, (srtp_hdr_t *)mesg, &len); + call_srtp_protect(srtp, (srtp_hdr_t *)mesg, &len); timer = clock(); for (i = 0; i < num_trials; i++) { len = msg_len_octets; - __srtp_unprotect(srtp, (srtp_hdr_t *)mesg, &len); + call_srtp_unprotect(srtp, (srtp_hdr_t *)mesg, &len); } timer = clock() - timer; @@ -1186,7 +1246,7 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy, debug_print(mod_driver, "reference packet before protection:\n%s", octet_string_hex_string((uint8_t *)hdr, len)); #endif - err_check(__srtp_protect_mki(srtp_sender, hdr, &len, mki_index)); + err_check(call_srtp_protect_mki(srtp_sender, hdr, &len, mki_index)); debug_print(mod_driver, "after protection:\n%s", srtp_packet_to_string(hdr, len)); @@ -1274,7 +1334,7 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy, err_check(srtp_create(&srtp_rcvr, rcvr_policy)); - err_check(__srtp_unprotect_mki(srtp_rcvr, hdr, &len, use_mki)); + err_check(call_srtp_unprotect_mki(srtp_rcvr, hdr, &len, use_mki)); debug_print(mod_driver, "after unprotection:\n%s", srtp_packet_to_string(hdr, len)); @@ -1302,7 +1362,7 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy, printf("testing for false positives in replay check..."); /* unprotect a second time - should fail with a replay error */ - status = __srtp_unprotect_mki(srtp_rcvr, hdr, &msg_len_enc, use_mki); + status = call_srtp_unprotect_mki(srtp_rcvr, hdr, &msg_len_enc, use_mki); if (status != srtp_err_status_replay_fail) { printf("failed with error code %d\n", status); free(hdr); @@ -1319,13 +1379,13 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy, hdr->seq++; /* apply protection */ - err_check(__srtp_protect_mki(srtp_sender, hdr, &len, mki_index)); + err_check(call_srtp_protect_mki(srtp_sender, hdr, &len, mki_index)); /* flip bits in packet */ data[0] ^= 0xff; /* unprotect, and check for authentication failure */ - status = __srtp_unprotect_mki(srtp_rcvr, hdr, &len, use_mki); + status = call_srtp_unprotect_mki(srtp_rcvr, hdr, &len, use_mki); if (status != srtp_err_status_auth_fail) { printf("failed\n"); free(hdr); @@ -1401,7 +1461,7 @@ srtp_err_status_t srtcp_test(const srtp_policy_t *policy, int mki_index) debug_print(mod_driver, "reference packet before protection:\n%s", octet_string_hex_string((uint8_t *)hdr, len)); #endif - err_check(__srtp_protect_rtcp_mki(srtcp_sender, hdr, &len, mki_index)); + err_check(call_srtp_protect_rtcp_mki(srtcp_sender, hdr, &len, mki_index)); debug_print(mod_driver, "after protection:\n%s", srtcp_packet_to_string(hdr, len)); @@ -1482,7 +1542,7 @@ srtp_err_status_t srtcp_test(const srtp_policy_t *policy, int mki_index) err_check(srtp_create(&srtcp_rcvr, rcvr_policy)); - err_check(__srtp_unprotect_rtcp_mki(srtcp_rcvr, hdr, &len, use_mki)); + err_check(call_srtp_unprotect_rtcp_mki(srtcp_rcvr, hdr, &len, use_mki)); debug_print(mod_driver, "after unprotection:\n%s", srtcp_packet_to_string(hdr, len)); @@ -1510,8 +1570,8 @@ srtp_err_status_t srtcp_test(const srtp_policy_t *policy, int mki_index) printf("testing for false positives in replay check..."); /* unprotect a second time - should fail with a replay error */ - status = - __srtp_unprotect_rtcp_mki(srtcp_rcvr, hdr, &msg_len_enc, use_mki); + status = call_srtp_unprotect_rtcp_mki(srtcp_rcvr, hdr, &msg_len_enc, + use_mki); if (status != srtp_err_status_replay_fail) { printf("failed with error code %d\n", status); free(hdr); @@ -1525,13 +1585,14 @@ srtp_err_status_t srtcp_test(const srtp_policy_t *policy, int mki_index) printf("testing for false positives in auth check..."); /* apply protection */ - err_check(__srtp_protect_rtcp_mki(srtcp_sender, hdr, &len, mki_index)); + err_check( + call_srtp_protect_rtcp_mki(srtcp_sender, hdr, &len, mki_index)); /* flip bits in packet */ data[0] ^= 0xff; /* unprotect, and check for authentication failure */ - status = __srtp_unprotect_rtcp_mki(srtcp_rcvr, hdr, &len, use_mki); + status = call_srtp_unprotect_rtcp_mki(srtcp_rcvr, hdr, &len, use_mki); if (status != srtp_err_status_auth_fail) { printf("failed\n"); free(hdr); @@ -1844,7 +1905,7 @@ srtp_err_status_t srtp_validate(void) * protect plaintext, then compare with ciphertext */ len = 28; - status = __srtp_protect(srtp_snd, srtp_plaintext, &len); + status = call_srtp_protect(srtp_snd, srtp_plaintext, &len); if (status || (len != 38)) { return srtp_err_status_fail; } @@ -1862,7 +1923,7 @@ srtp_err_status_t srtp_validate(void) * protect plaintext rtcp, then compare with srtcp ciphertext */ len = 24; - status = __srtp_protect_rtcp(srtp_snd, rtcp_plaintext, &len); + status = call_srtp_protect_rtcp(srtp_snd, rtcp_plaintext, &len); if (status || (len != 38)) { return srtp_err_status_fail; } @@ -1889,7 +1950,7 @@ srtp_err_status_t srtp_validate(void) /* * unprotect ciphertext, then compare with plaintext */ - status = __srtp_unprotect(srtp_recv, srtp_ciphertext, &len); + status = call_srtp_unprotect(srtp_recv, srtp_ciphertext, &len); if (status || (len != 28)) { return status; } @@ -1902,7 +1963,7 @@ srtp_err_status_t srtp_validate(void) * unprotect srtcp ciphertext, then compare with rtcp plaintext */ len = 38; - status = __srtp_unprotect_rtcp(srtp_recv, srtcp_ciphertext, &len); + status = call_srtp_unprotect_rtcp(srtp_recv, srtcp_ciphertext, &len); if (status || (len != 24)) { return status; } @@ -2004,7 +2065,7 @@ srtp_err_status_t srtp_validate_null(void) * protect plaintext, then compare with ciphertext */ len = 28; - status = __srtp_protect(srtp_snd, srtp_plaintext, &len); + status = call_srtp_protect(srtp_snd, srtp_plaintext, &len); if (status || (len != 38)) { return srtp_err_status_fail; } @@ -2022,7 +2083,7 @@ srtp_err_status_t srtp_validate_null(void) * protect plaintext rtcp, then compare with srtcp ciphertext */ len = 24; - status = __srtp_protect_rtcp(srtp_snd, rtcp_plaintext, &len); + status = call_srtp_protect_rtcp(srtp_snd, rtcp_plaintext, &len); if (status || (len != 38)) { return srtp_err_status_fail; } @@ -2049,7 +2110,7 @@ srtp_err_status_t srtp_validate_null(void) /* * unprotect ciphertext, then compare with plaintext */ - status = __srtp_unprotect(srtp_recv, srtp_ciphertext, &len); + status = call_srtp_unprotect(srtp_recv, srtp_ciphertext, &len); if (status || (len != 28)) { return status; } @@ -2062,7 +2123,7 @@ srtp_err_status_t srtp_validate_null(void) * unprotect srtcp ciphertext, then compare with rtcp plaintext */ len = 38; - status = __srtp_unprotect_rtcp(srtp_recv, srtcp_ciphertext, &len); + status = call_srtp_unprotect_rtcp(srtp_recv, srtcp_ciphertext, &len); if (status || (len != 24)) { return status; } @@ -2166,7 +2227,7 @@ srtp_err_status_t srtp_validate_gcm(void) * protect plaintext rtp, then compare with srtp ciphertext */ len = 28; - status = __srtp_protect(srtp_snd, rtp_plaintext, &len); + status = call_srtp_protect(srtp_snd, rtp_plaintext, &len); if (status || (len != 44)) { return srtp_err_status_fail; } @@ -2184,7 +2245,7 @@ srtp_err_status_t srtp_validate_gcm(void) * protect plaintext rtcp, then compare with srtcp ciphertext */ len = 24; - status = __srtp_protect_rtcp(srtp_snd, rtcp_plaintext, &len); + status = call_srtp_protect_rtcp(srtp_snd, rtcp_plaintext, &len); if (status || (len != 44)) { return srtp_err_status_fail; } @@ -2212,7 +2273,7 @@ srtp_err_status_t srtp_validate_gcm(void) * unprotect srtp ciphertext, then compare with rtp plaintext */ len = 44; - status = __srtp_unprotect(srtp_recv, srtp_ciphertext, &len); + status = call_srtp_unprotect(srtp_recv, srtp_ciphertext, &len); if (status || (len != 28)) { return status; } @@ -2225,7 +2286,7 @@ srtp_err_status_t srtp_validate_gcm(void) * unprotect srtcp ciphertext, then compare with rtcp plaintext */ len = 44; - status = __srtp_unprotect_rtcp(srtp_recv, srtcp_ciphertext, &len); + status = call_srtp_unprotect_rtcp(srtp_recv, srtcp_ciphertext, &len); if (status || (len != 24)) { return status; } @@ -2330,7 +2391,7 @@ srtp_err_status_t srtp_validate_encrypted_extensions_headers(void) * protect plaintext, then compare with ciphertext */ len = sizeof(srtp_plaintext_ref); - status = __srtp_protect(srtp_snd, srtp_plaintext, &len); + status = call_srtp_protect(srtp_snd, srtp_plaintext, &len); if (status || (len != sizeof(srtp_plaintext))) return srtp_err_status_fail; @@ -2354,7 +2415,7 @@ srtp_err_status_t srtp_validate_encrypted_extensions_headers(void) /* * unprotect ciphertext, then compare with plaintext */ - status = __srtp_unprotect(srtp_recv, srtp_ciphertext, &len); + status = call_srtp_unprotect(srtp_recv, srtp_ciphertext, &len); if (status) { return status; } else if (len != sizeof(srtp_plaintext_ref)) { @@ -2451,7 +2512,7 @@ srtp_err_status_t srtp_validate_encrypted_extensions_headers_gcm(void) * protect plaintext, then compare with ciphertext */ len = sizeof(srtp_plaintext_ref); - status = __srtp_protect(srtp_snd, srtp_plaintext, &len); + status = call_srtp_protect(srtp_snd, srtp_plaintext, &len); if (status || (len != sizeof(srtp_plaintext))) return srtp_err_status_fail; @@ -2475,7 +2536,7 @@ srtp_err_status_t srtp_validate_encrypted_extensions_headers_gcm(void) /* * unprotect ciphertext, then compare with plaintext */ - status = __srtp_unprotect(srtp_recv, srtp_ciphertext, &len); + status = call_srtp_unprotect(srtp_recv, srtp_ciphertext, &len); if (status) { return status; } else if (len != sizeof(srtp_plaintext_ref)) { @@ -2566,7 +2627,7 @@ srtp_err_status_t srtp_validate_aes_256(void) * protect plaintext, then compare with ciphertext */ len = 28; - status = __srtp_protect(srtp_snd, srtp_plaintext, &len); + status = call_srtp_protect(srtp_snd, srtp_plaintext, &len); if (status || (len != 38)) { return srtp_err_status_fail; } @@ -2593,7 +2654,7 @@ srtp_err_status_t srtp_validate_aes_256(void) /* * unprotect ciphertext, then compare with plaintext */ - status = __srtp_unprotect(srtp_recv, srtp_ciphertext, &len); + status = call_srtp_unprotect(srtp_recv, srtp_ciphertext, &len); if (status || (len != 28)) { return status; } @@ -2695,7 +2756,7 @@ srtp_err_status_t srtp_test_empty_payload(void) return srtp_err_status_fail; } - status = __srtp_protect(srtp_snd, mesg, &len); + status = call_srtp_protect(srtp_snd, mesg, &len); if (status) { return status; } else if (len != 12 + 10) { @@ -2715,7 +2776,7 @@ srtp_err_status_t srtp_test_empty_payload(void) /* * unprotect ciphertext, then compare with plaintext */ - status = __srtp_unprotect(srtp_recv, mesg, &len); + status = call_srtp_unprotect(srtp_recv, mesg, &len); if (status) { return status; } else if (len != 12) { @@ -2771,7 +2832,7 @@ srtp_err_status_t srtp_test_empty_payload_gcm(void) return srtp_err_status_fail; } - status = __srtp_protect(srtp_snd, mesg, &len); + status = call_srtp_protect(srtp_snd, mesg, &len); if (status) { return status; } else if (len != 12 + 8) { @@ -2791,7 +2852,7 @@ srtp_err_status_t srtp_test_empty_payload_gcm(void) /* * unprotect ciphertext, then compare with plaintext */ - status = __srtp_unprotect(srtp_recv, mesg, &len); + status = call_srtp_unprotect(srtp_recv, mesg, &len); if (status) { return status; } else if (len != 12) { @@ -2965,11 +3026,11 @@ srtp_err_status_t srtp_test_update(void) return srtp_err_status_alloc_fail; msg->seq = htons(65535); - status = __srtp_protect(srtp_snd, msg, &protected_msg_len_octets); + status = call_srtp_protect(srtp_snd, msg, &protected_msg_len_octets); if (status) return srtp_err_status_fail; - status = __srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); + status = call_srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); if (status) return status; @@ -2981,11 +3042,11 @@ srtp_err_status_t srtp_test_update(void) return srtp_err_status_alloc_fail; msg->seq = htons(1); - status = __srtp_protect(srtp_snd, msg, &protected_msg_len_octets); + status = call_srtp_protect(srtp_snd, msg, &protected_msg_len_octets); if (status) return srtp_err_status_fail; - status = __srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); + status = call_srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); if (status) return status; @@ -3004,11 +3065,11 @@ srtp_err_status_t srtp_test_update(void) return srtp_err_status_alloc_fail; msg->seq = htons(2); - status = __srtp_protect(srtp_snd, msg, &protected_msg_len_octets); + status = call_srtp_protect(srtp_snd, msg, &protected_msg_len_octets); if (status) return srtp_err_status_fail; - status = __srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); + status = call_srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); if (status) return status; @@ -3028,13 +3089,13 @@ srtp_err_status_t srtp_test_update(void) return srtp_err_status_alloc_fail; msg->seq = htons(3); - status = __srtp_protect(srtp_snd, msg, &protected_msg_len_octets); + status = call_srtp_protect(srtp_snd, msg, &protected_msg_len_octets); if (status) return srtp_err_status_fail; /* verify that recive ctx will fail to unprotect as it still uses test_key */ - status = __srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); + status = call_srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); if (status == srtp_err_status_ok) return srtp_err_status_fail; @@ -3050,8 +3111,8 @@ srtp_err_status_t srtp_test_update(void) if (status) return status; - status = - __srtp_unprotect(srtp_recv_roc_0, msg, &protected_msg_len_octets); + status = call_srtp_unprotect(srtp_recv_roc_0, msg, + &protected_msg_len_octets); if (status == srtp_err_status_ok) return srtp_err_status_fail; @@ -3069,7 +3130,7 @@ srtp_err_status_t srtp_test_update(void) /* verify that can still unprotect, therfore key is updated and ROC value is * preserved */ - status = __srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); + status = call_srtp_unprotect(srtp_recv, msg, &protected_msg_len_octets); if (status) return status; @@ -3347,7 +3408,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) /* Create and protect packets to get to get roc == 1 */ pkts[0] = srtp_create_test_packet_extended(64, sender_policy.ssrc.value, 65534, 0, &pkt_len_octets[0]); - status = __srtp_protect(sender_session, pkts[0], &pkt_len_octets[0]); + status = call_srtp_protect(sender_session, pkts[0], &pkt_len_octets[0]); if (status) { return status; } @@ -3362,7 +3423,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) pkts[1] = srtp_create_test_packet_extended(64, sender_policy.ssrc.value, 65535, 1, &pkt_len_octets[1]); - status = __srtp_protect(sender_session, pkts[1], &pkt_len_octets[1]); + status = call_srtp_protect(sender_session, pkts[1], &pkt_len_octets[1]); if (status) { return status; } @@ -3377,7 +3438,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) pkts[2] = srtp_create_test_packet_extended(64, sender_policy.ssrc.value, 0, 2, &pkt_len_octets[2]); - status = __srtp_protect(sender_session, pkts[2], &pkt_len_octets[2]); + status = call_srtp_protect(sender_session, pkts[2], &pkt_len_octets[2]); if (status) { return status; } @@ -3392,7 +3453,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) pkts[3] = srtp_create_test_packet_extended(64, sender_policy.ssrc.value, 1, 3, &pkt_len_octets[3]); - status = __srtp_protect(sender_session, pkts[3], &pkt_len_octets[3]); + status = call_srtp_protect(sender_session, pkts[3], &pkt_len_octets[3]); if (status) { return status; } @@ -3407,7 +3468,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) pkts[4] = srtp_create_test_packet_extended(64, sender_policy.ssrc.value, 2, 4, &pkt_len_octets[4]); - status = __srtp_protect(sender_session, pkts[4], &pkt_len_octets[4]); + status = call_srtp_protect(sender_session, pkts[4], &pkt_len_octets[4]); if (status) { return status; } @@ -3422,7 +3483,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) /* Unprotect packets in this seq order 65534, 0, 2, 1, 65535 which is * equivalent to index 0, 2, 4, 3, 1*/ - status = __srtp_unprotect(receiver_session, pkts[0], &pkt_len_octets[0]); + status = call_srtp_unprotect(receiver_session, pkts[0], &pkt_len_octets[0]); if (status) { return status; } @@ -3435,7 +3496,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) return srtp_err_status_fail; } - status = __srtp_unprotect(receiver_session, pkts[2], &pkt_len_octets[2]); + status = call_srtp_unprotect(receiver_session, pkts[2], &pkt_len_octets[2]); if (status) { return status; } @@ -3448,7 +3509,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) return srtp_err_status_fail; } - status = __srtp_unprotect(receiver_session, pkts[4], &pkt_len_octets[4]); + status = call_srtp_unprotect(receiver_session, pkts[4], &pkt_len_octets[4]); if (status) { return status; } @@ -3461,7 +3522,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) return srtp_err_status_fail; } - status = __srtp_unprotect(receiver_session, pkts[3], &pkt_len_octets[3]); + status = call_srtp_unprotect(receiver_session, pkts[3], &pkt_len_octets[3]); if (status) { return status; } @@ -3474,7 +3535,7 @@ srtp_err_status_t srtp_test_out_of_order_after_rollover(void) return srtp_err_status_fail; } - status = __srtp_unprotect(receiver_session, pkts[1], &pkt_len_octets[1]); + status = call_srtp_unprotect(receiver_session, pkts[1], &pkt_len_octets[1]); if (status) { return status; } @@ -3541,7 +3602,7 @@ srtp_err_status_t srtp_test_get_roc(void) pkt = srtp_create_test_packet_extended(msg_len_octets, policy.ssrc.value, seq, ts, &protected_msg_len_octets); - status = __srtp_protect(session, pkt, &protected_msg_len_octets); + status = call_srtp_protect(session, pkt, &protected_msg_len_octets); free(pkt); if (status) { return status; @@ -3626,7 +3687,7 @@ static srtp_err_status_t test_set_receiver_roc(uint32_t packets, tmp_pkt = srtp_create_test_packet_extended( msg_len_octets, sender_policy.ssrc.value, seq, ts, &tmp_len); - status = __srtp_protect(sender_session, tmp_pkt, &tmp_len); + status = call_srtp_protect(sender_session, tmp_pkt, &tmp_len); free(tmp_pkt); if (status) { return status; @@ -3645,7 +3706,8 @@ static srtp_err_status_t test_set_receiver_roc(uint32_t packets, pkt_1 = srtp_create_test_packet_extended(msg_len_octets, sender_policy.ssrc.value, seq, ts, &protected_msg_len_octets_1); - status = __srtp_protect(sender_session, pkt_1, &protected_msg_len_octets_1); + status = + call_srtp_protect(sender_session, pkt_1, &protected_msg_len_octets_1); if (status) { return status; } @@ -3656,7 +3718,8 @@ static srtp_err_status_t test_set_receiver_roc(uint32_t packets, pkt_2 = srtp_create_test_packet_extended(msg_len_octets, sender_policy.ssrc.value, seq, ts, &protected_msg_len_octets_2); - status = __srtp_protect(sender_session, pkt_2, &protected_msg_len_octets_2); + status = + call_srtp_protect(sender_session, pkt_2, &protected_msg_len_octets_2); if (status) { return status; } @@ -3703,15 +3766,15 @@ static srtp_err_status_t test_set_receiver_roc(uint32_t packets, } /* Unprotect the first packet */ - status = __srtp_unprotect(receiver_session, recv_pkt_1, - &protected_msg_len_octets_1); + status = call_srtp_unprotect(receiver_session, recv_pkt_1, + &protected_msg_len_octets_1); if (status) { return status; } /* Unprotect the second packet */ - status = __srtp_unprotect(receiver_session, recv_pkt_2, - &protected_msg_len_octets_2); + status = call_srtp_unprotect(receiver_session, recv_pkt_2, + &protected_msg_len_octets_2); if (status) { return status; } @@ -3785,7 +3848,7 @@ static srtp_err_status_t test_set_sender_roc(uint16_t seq, uint32_t roc_to_set) pkt = srtp_create_test_packet_extended(msg_len_octets, sender_policy.ssrc.value, seq, ts, &protected_msg_len_octets); - status = __srtp_protect(sender_session, pkt, &protected_msg_len_octets); + status = call_srtp_protect(sender_session, pkt, &protected_msg_len_octets); if (status) { return status; } @@ -3824,8 +3887,8 @@ static srtp_err_status_t test_set_sender_roc(uint16_t seq, uint32_t roc_to_set) return status; } - status = - __srtp_unprotect(receiver_session, recv_pkt, &protected_msg_len_octets); + status = call_srtp_unprotect(receiver_session, recv_pkt, + &protected_msg_len_octets); if (status) { return status; }