5555#include "alloc.h" /* for crypto_alloc(), crypto_free() */
5656
5757srtp_debug_module_t srtp_mod_cipher = {
58- 0 , /* debugging is off by default */
58+ false, /* debugging is off by default */
5959 "cipher" /* printable module name */
6060};
6161
@@ -88,7 +88,7 @@ srtp_err_status_t srtp_cipher_init(srtp_cipher_t *c, const uint8_t *key)
8888
8989srtp_err_status_t srtp_cipher_set_iv (srtp_cipher_t * c ,
9090 uint8_t * iv ,
91- int direction )
91+ srtp_cipher_direction_t direction )
9292{
9393 if (!c || !c -> type || !c -> state ) {
9494 return (srtp_err_status_bad_param );
@@ -213,8 +213,7 @@ srtp_err_status_t srtp_cipher_type_test(
213213 uint8_t buffer2 [SELF_TEST_BUF_OCTETS ];
214214 size_t tag_len ;
215215 size_t len ;
216- int i , j , case_num = 0 ;
217- unsigned k = 0 ;
216+ size_t case_num = 0 ;
218217
219218 debug_print (srtp_mod_cipher , "running self-test for cipher %s" ,
220219 ct -> description );
@@ -256,7 +255,7 @@ srtp_err_status_t srtp_cipher_type_test(
256255 srtp_cipher_dealloc (c );
257256 return srtp_err_status_bad_param ;
258257 }
259- for (k = 0 ; k < test_case -> plaintext_length_octets ; k ++ ) {
258+ for (size_t k = 0 ; k < test_case -> plaintext_length_octets ; k ++ ) {
260259 buffer [k ] = test_case -> plaintext [k ];
261260 }
262261
@@ -321,11 +320,11 @@ srtp_err_status_t srtp_cipher_type_test(
321320 return srtp_err_status_algo_fail ;
322321 }
323322 status = srtp_err_status_ok ;
324- for (k = 0 ; k < test_case -> ciphertext_length_octets ; k ++ ) {
323+ for (size_t k = 0 ; k < test_case -> ciphertext_length_octets ; k ++ ) {
325324 if (buffer [k ] != test_case -> ciphertext [k ]) {
326325 status = srtp_err_status_algo_fail ;
327- debug_print (srtp_mod_cipher , "test case %d failed" , case_num );
328- debug_print (srtp_mod_cipher , "(failure at byte %u )" , k );
326+ debug_print (srtp_mod_cipher , "test case %zu failed" , case_num );
327+ debug_print (srtp_mod_cipher , "(failure at byte %zu )" , k );
329328 break ;
330329 }
331330 }
@@ -359,7 +358,7 @@ srtp_err_status_t srtp_cipher_type_test(
359358 srtp_cipher_dealloc (c );
360359 return srtp_err_status_bad_param ;
361360 }
362- for (k = 0 ; k < test_case -> ciphertext_length_octets ; k ++ ) {
361+ for (size_t k = 0 ; k < test_case -> ciphertext_length_octets ; k ++ ) {
363362 buffer [k ] = test_case -> ciphertext [k ];
364363 }
365364
@@ -408,11 +407,11 @@ srtp_err_status_t srtp_cipher_type_test(
408407 return srtp_err_status_algo_fail ;
409408 }
410409 status = srtp_err_status_ok ;
411- for (k = 0 ; k < test_case -> plaintext_length_octets ; k ++ ) {
410+ for (size_t k = 0 ; k < test_case -> plaintext_length_octets ; k ++ ) {
412411 if (buffer [k ] != test_case -> plaintext [k ]) {
413412 status = srtp_err_status_algo_fail ;
414- debug_print (srtp_mod_cipher , "test case %d failed" , case_num );
415- debug_print (srtp_mod_cipher , "(failure at byte %u )" , k );
413+ debug_print (srtp_mod_cipher , "test case %zu failed" , case_num );
414+ debug_print (srtp_mod_cipher , "(failure at byte %zu )" , k );
416415 }
417416 }
418417 if (status ) {
@@ -452,7 +451,7 @@ srtp_err_status_t srtp_cipher_type_test(
452451 return status ;
453452 }
454453
455- for (j = 0 ; j < NUM_RAND_TESTS ; j ++ ) {
454+ for (size_t j = 0 ; j < NUM_RAND_TESTS ; j ++ ) {
456455 size_t length ;
457456 size_t plaintext_len ;
458457 uint8_t key [MAX_KEY_LEN ];
@@ -467,7 +466,7 @@ srtp_err_status_t srtp_cipher_type_test(
467466 srtp_octet_string_hex_string (buffer , length ));
468467
469468 /* copy plaintext into second buffer */
470- for (i = 0 ; ( unsigned int ) i < length ; i ++ ) {
469+ for (size_t i = 0 ; i < length ; i ++ ) {
471470 buffer2 [i ] = buffer [i ];
472471 }
473472
@@ -578,12 +577,12 @@ srtp_err_status_t srtp_cipher_type_test(
578577 return srtp_err_status_algo_fail ;
579578 }
580579 status = srtp_err_status_ok ;
581- for (k = 0 ; k < plaintext_len ; k ++ ) {
580+ for (size_t k = 0 ; k < plaintext_len ; k ++ ) {
582581 if (buffer [k ] != buffer2 [k ]) {
583582 status = srtp_err_status_algo_fail ;
584- debug_print (srtp_mod_cipher , "random test case %d failed" ,
583+ debug_print (srtp_mod_cipher , "random test case %zu failed" ,
585584 case_num );
586- debug_print (srtp_mod_cipher , "(failure at byte %u )" , k );
585+ debug_print (srtp_mod_cipher , "(failure at byte %zu )" , k );
587586 }
588587 }
589588 if (status ) {
@@ -621,15 +620,14 @@ srtp_err_status_t srtp_cipher_type_self_test(const srtp_cipher_type_t *ct)
621620 */
622621uint64_t srtp_cipher_bits_per_second (srtp_cipher_t * c ,
623622 size_t octets_in_buffer ,
624- int num_trials )
623+ size_t num_trials )
625624{
626- int i ;
627625 v128_t nonce ;
628626 clock_t timer ;
629627 uint8_t * enc_buf ;
630628 size_t len = octets_in_buffer ;
631629 size_t tag_len = SRTP_MAX_TAG_LEN ;
632- unsigned char aad [4 ] = { 0 , 0 , 0 , 0 };
630+ uint8_t aad [4 ] = { 0 , 0 , 0 , 0 };
633631 size_t aad_len = 4 ;
634632
635633 enc_buf = (uint8_t * )srtp_crypto_alloc (octets_in_buffer + tag_len );
@@ -639,7 +637,7 @@ uint64_t srtp_cipher_bits_per_second(srtp_cipher_t *c,
639637 /* time repeated trials */
640638 v128_set_to_zero (& nonce );
641639 timer = clock ();
642- for (i = 0 ; i < num_trials ; i ++ , nonce .v32 [3 ] = i ) {
640+ for (size_t i = 0 ; i < num_trials ; i ++ , nonce .v32 [3 ] = ( uint32_t ) i ) {
643641 // Set IV
644642 if (srtp_cipher_set_iv (c , (uint8_t * )& nonce , srtp_direction_encrypt ) !=
645643 srtp_err_status_ok ) {
0 commit comments