Last active
November 29, 2023 01:08
-
-
Save Sean-Der/7a42bd70edfe1324ccc6ab399d653c0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <srtp2/auth.h> | |
#include <srtp2/cipher.h> | |
#include <srtp2/crypto_types.h> | |
#include <srtp2/srtp.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdio.h> | |
char SKEL_RTP_PACKET[17] = {0x80, 0x60, 0x69, 0x8f, 0xd9, 0xc2, 0x93, 0xda, 0x1c, 0x64, 0x27, 0x82, 0x98, 0x36, 0xbe, 0x88, 0x9e}; | |
int RTP_PACKET_SIZE = sizeof(SKEL_RTP_PACKET) + SRTP_MAX_TRAILER_LEN; | |
uint32_t ITERATIONS = 5000000; | |
char *populate_packet(char *dst) { | |
static uint16_t seqnum = 0; | |
seqnum++; | |
memset(dst, 0x0, RTP_PACKET_SIZE); | |
memcpy(dst, SKEL_RTP_PACKET, sizeof(SKEL_RTP_PACKET)); | |
uint16_t *dst_seq = (uint16_t *)dst + 1; | |
*dst_seq = htons(seqnum); | |
return dst; | |
} | |
int main() { | |
srtp_t session; | |
srtp_policy_t policy; | |
uint8_t key[30] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | |
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, | |
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, | |
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D}; | |
srtp_init(); | |
memset(&policy, 0x0, sizeof(srtp_policy_t)); | |
// srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(&(policy.rtp)); | |
// srtp_crypto_policy_set_aes_cm_128_hmac_sha1_32(&(policy.rtcp)); | |
srtp_crypto_policy_set_aes_gcm_128_16_auth(&(policy.rtp)); | |
srtp_crypto_policy_set_aes_gcm_128_16_auth(&(policy.rtcp)); | |
policy.ssrc.type = ssrc_any_outbound; | |
policy.key = key; | |
policy.next = NULL; | |
srtp_create(&session, &policy); | |
int status; | |
char *rtp_buffer = malloc(RTP_PACKET_SIZE); | |
for (uint32_t i = 1; i != ITERATIONS; i++) { | |
populate_packet(rtp_buffer); | |
int len = sizeof(SKEL_RTP_PACKET); | |
if ((status = srtp_protect(session, rtp_buffer, &len)) != srtp_err_status_ok) { | |
exit(status); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@cameronelliott done!