@@ -78,6 +78,10 @@ srtp_err_status_t srtp_validate_encrypted_extensions_headers_gcm(void);
7878
7979srtp_err_status_t srtp_validate_aes_256 (void );
8080
81+ #ifdef GCM
82+ srtp_err_status_t srtp_validate_aes_192 (void );
83+ #endif
84+
8185srtp_err_status_t srtp_create_big_policy (srtp_policy_t * * list );
8286
8387srtp_err_status_t srtp_dealloc_big_policy (srtp_policy_t * list );
@@ -509,6 +513,21 @@ int main(int argc, char *argv[])
509513 }
510514#endif
511515
516+ #ifdef GCM
517+ /*
518+ * run validation test against the reference packets for
519+ * AES-192
520+ */
521+ printf ("testing srtp_protect and srtp_unprotect against "
522+ "reference packet (AES-192)\n" );
523+ if (srtp_validate_aes_192 () == srtp_err_status_ok ) {
524+ printf ("passed\n\n" );
525+ } else {
526+ printf ("failed\n" );
527+ exit (1 );
528+ }
529+ #endif
530+
512531 /*
513532 * run validation test against the reference packets for
514533 * AES-256
@@ -2652,6 +2671,122 @@ srtp_err_status_t srtp_validate_encrypted_extensions_headers_gcm(void)
26522671
26532672 return srtp_err_status_ok ;
26542673}
2674+
2675+ /*
2676+ * srtp_validate_aes_192() verifies the correctness of libsrtp by comparing
2677+ * some computed packets against some pre-computed reference values.
2678+ * These packets were made with the AES-CM-192/HMAC-SHA-1-80 policy.
2679+ *
2680+ * The master key and master salt come from RFC 6188 section 7.4 .
2681+ * The test vectors where generated using the cipher key and cipher salt
2682+ * in section 7.4 with cipher_driver with the nonce and plaintext in the
2683+ * srtp_plaintext_ref.
2684+ */
2685+
2686+ srtp_err_status_t srtp_validate_aes_192 (void )
2687+ {
2688+ // clang-format off
2689+ uint8_t aes_192_test_key [38 ] = {
2690+ 0x73 , 0xed , 0xc6 , 0x6c , 0x4f , 0xa1 , 0x57 , 0x76 ,
2691+ 0xfb , 0x57 , 0xf9 , 0x50 , 0x5c , 0x17 , 0x13 , 0x65 ,
2692+ 0x50 , 0xff , 0xda , 0x71 , 0xf3 , 0xe8 , 0xe5 , 0xf1 ,
2693+
2694+ 0xc8 , 0x52 , 0x2f , 0x3a , 0xcd , 0x4c , 0xe8 , 0x6d ,
2695+ 0x5a , 0xdd , 0x78 , 0xed , 0xbb , 0x11
2696+ };
2697+ uint8_t srtp_plaintext_ref [28 ] = {
2698+ 0x80 , 0x0f , 0x00 , 0x00 , 0xde , 0xca , 0xfb , 0xad ,
2699+ 0x00 , 0x00 , 0x00 , 0x00 , 0xab , 0xab , 0xab , 0xab ,
2700+ 0xab , 0xab , 0xab , 0xab , 0xab , 0xab , 0xab , 0xab ,
2701+ 0xab , 0xab , 0xab , 0xab
2702+ };
2703+ uint8_t srtp_plaintext [38 ] = {
2704+ 0x80 , 0x0f , 0x00 , 0x00 , 0xde , 0xca , 0xfb , 0xad ,
2705+ 0x00 , 0x00 , 0x00 , 0x00 , 0xab , 0xab , 0xab , 0xab ,
2706+ 0xab , 0xab , 0xab , 0xab , 0xab , 0xab , 0xab , 0xab ,
2707+ 0xab , 0xab , 0xab , 0xab , 0x00 , 0x00 , 0x00 , 0x00 ,
2708+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00
2709+ };
2710+ uint8_t srtp_ciphertext [38 ] = {
2711+ 0x80 , 0x0f , 0x00 , 0x00 , 0xde , 0xca , 0xfb , 0xad ,
2712+ 0x00 , 0x00 , 0x00 , 0x00 , 0xd9 , 0x88 , 0x65 , 0x55 ,
2713+ 0x2f , 0x27 , 0x62 , 0xc3 , 0xef , 0x37 , 0xf8 , 0x37 ,
2714+ 0xac , 0xfd , 0xb7 , 0x12 , 0x2d , 0x6b , 0xc4 , 0xdc ,
2715+ 0x84 , 0xc7 , 0x6f , 0x74 , 0xae , 0xa5
2716+ };
2717+ // clang-format on
2718+
2719+ srtp_t srtp_snd , srtp_recv ;
2720+ srtp_err_status_t status ;
2721+ int len ;
2722+ srtp_policy_t policy ;
2723+
2724+ /*
2725+ * create a session with a single stream using the default srtp
2726+ * policy and with the SSRC value 0xcafebabe
2727+ */
2728+ memset (& policy , 0 , sizeof (policy ));
2729+ srtp_crypto_policy_set_aes_cm_192_hmac_sha1_80 (& policy .rtp );
2730+ srtp_crypto_policy_set_aes_cm_192_hmac_sha1_80 (& policy .rtcp );
2731+ policy .ssrc .type = ssrc_specific ;
2732+ policy .ssrc .value = 0x00000000 ;
2733+ policy .key = aes_192_test_key ;
2734+ policy .window_size = 128 ;
2735+ policy .allow_repeat_tx = 0 ;
2736+ policy .next = NULL ;
2737+
2738+ status = srtp_create (& srtp_snd , & policy );
2739+ if (status )
2740+ return status ;
2741+
2742+ /*
2743+ * protect plaintext, then compare with ciphertext
2744+ */
2745+ len = 28 ;
2746+ status = srtp_protect (srtp_snd , srtp_plaintext , & len );
2747+ if (status || (len != 38 ))
2748+ return srtp_err_status_fail ;
2749+
2750+ debug_print (mod_driver , "ciphertext:\n %s" ,
2751+ octet_string_hex_string (srtp_plaintext , len ));
2752+ debug_print (mod_driver , "ciphertext reference:\n %s" ,
2753+ octet_string_hex_string (srtp_ciphertext , len ));
2754+
2755+ if (srtp_octet_string_is_eq (srtp_plaintext , srtp_ciphertext , len ))
2756+ return srtp_err_status_fail ;
2757+
2758+ /*
2759+ * create a receiver session context comparable to the one created
2760+ * above - we need to do this so that the replay checking doesn't
2761+ * complain
2762+ */
2763+ status = srtp_create (& srtp_recv , & policy );
2764+ if (status )
2765+ return status ;
2766+
2767+ /*
2768+ * unprotect ciphertext, then compare with plaintext
2769+ */
2770+ status = srtp_unprotect (srtp_recv , srtp_ciphertext , & len );
2771+ if (status ) {
2772+ return status ;
2773+ } else if (len != 28 ) {
2774+ return srtp_err_status_fail ;
2775+ }
2776+
2777+ if (srtp_octet_string_is_eq (srtp_ciphertext , srtp_plaintext_ref , len ))
2778+ return srtp_err_status_fail ;
2779+
2780+ status = srtp_dealloc (srtp_snd );
2781+ if (status )
2782+ return status ;
2783+
2784+ status = srtp_dealloc (srtp_recv );
2785+ if (status )
2786+ return status ;
2787+
2788+ return srtp_err_status_ok ;
2789+ }
26552790#endif
26562791
26572792/*
0 commit comments