@@ -117,6 +117,8 @@ srtp_err_status_t srtp_test_cryptex_disable(void);
117117
118118srtp_err_status_t srtp_test_require_cryptex (void );
119119
120+ srtp_err_status_t srtp_test_cryptex_and_enc_xtn_hdr_invalid (void );
121+
120122double srtp_bits_per_second (int msg_len_octets , const srtp_policy_t * policy );
121123
122124double srtp_rejections_per_second (int msg_len_octets ,
@@ -694,6 +696,14 @@ int main(int argc, char *argv[])
694696 printf ("failed\n" );
695697 exit (1 );
696698 }
699+
700+ printf ("testing cryptex_and_enc_xtn_hdr_invalid()..." );
701+ if (srtp_test_cryptex_and_enc_xtn_hdr_invalid () == srtp_err_status_ok ) {
702+ printf ("passed\n" );
703+ } else {
704+ printf ("failed\n" );
705+ exit (1 );
706+ }
697707 }
698708
699709 if (do_stream_list ) {
@@ -2758,6 +2768,42 @@ srtp_err_status_t srtp_test_require_cryptex(void)
27582768 return srtp_err_status_ok ;
27592769}
27602770
2771+ srtp_err_status_t srtp_test_cryptex_and_enc_xtn_hdr_invalid (void )
2772+ {
2773+ int headers [] = { 1 };
2774+
2775+ srtp_policy_t policy ;
2776+ memset (& policy , 0 , sizeof (policy ));
2777+ srtp_crypto_policy_set_rtp_default (& policy .rtp );
2778+ srtp_crypto_policy_set_rtcp_default (& policy .rtcp );
2779+ policy .ssrc .type = ssrc_specific ;
2780+ policy .ssrc .value = 0xcafebabe ;
2781+ policy .key = test_key ;
2782+ policy .window_size = 128 ;
2783+ policy .allow_repeat_tx = 0 ;
2784+ policy .enc_xtn_hdr = headers ;
2785+ policy .enc_xtn_hdr_count = sizeof (headers ) / sizeof (headers [0 ]);
2786+ policy .next = NULL ;
2787+
2788+ srtp_t srtp_snd ;
2789+ CHECK_OK (srtp_create (& srtp_snd , & policy ));
2790+ CHECK_RETURN (srtp_set_stream_use_cryptex (srtp_snd , & policy .ssrc , 1 ),
2791+ srtp_err_status_bad_param );
2792+ /* disabling is still allowed */
2793+ CHECK_OK (srtp_set_stream_use_cryptex (srtp_snd , & policy .ssrc , 0 ));
2794+ CHECK_OK (srtp_dealloc (srtp_snd ));
2795+
2796+ policy .ssrc .type = ssrc_any_outbound ;
2797+ srtp_t srtp_snd_wildcard ;
2798+ CHECK_OK (srtp_create (& srtp_snd_wildcard , & policy ));
2799+ CHECK_RETURN (
2800+ srtp_set_stream_use_cryptex (srtp_snd_wildcard , & policy .ssrc , 1 ),
2801+ srtp_err_status_bad_param );
2802+ CHECK_OK (srtp_dealloc (srtp_snd_wildcard ));
2803+
2804+ return srtp_err_status_ok ;
2805+ }
2806+
27612807#ifdef GCM
27622808/*
27632809 * srtp_validate_gcm() verifies the correctness of libsrtp by comparing
0 commit comments