From 31e13a202514f0cc3d43f6990a5f4dc28e10c455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20B=C3=BChler?= Date: Mon, 4 Dec 2023 15:15:24 +0100 Subject: [PATCH 1/2] fix cipher test with -a option The null cipher does not need a key --- crypto/test/cipher_driver.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crypto/test/cipher_driver.c b/crypto/test/cipher_driver.c index 33f8e73ec..641d0c781 100644 --- a/crypto/test/cipher_driver.c +++ b/crypto/test/cipher_driver.c @@ -438,7 +438,7 @@ srtp_err_status_t cipher_array_alloc_init(srtp_cipher_t ***ca, { int i, j; srtp_err_status_t status; - uint8_t *key; + uint8_t *key = NULL; srtp_cipher_t **cipher_array; /* pad klen allocation, to handle aes_icm reading 16 bytes for the 14-byte salt */ @@ -453,11 +453,13 @@ srtp_err_status_t cipher_array_alloc_init(srtp_cipher_t ***ca, /* set ca to location of cipher_array */ *ca = cipher_array; - /* allocate key */ - key = srtp_crypto_alloc(klen_pad); - if (key == NULL) { - srtp_crypto_free(cipher_array); - return srtp_err_status_alloc_fail; + /* allocate key , allow zero key for example null cipher */ + if (klen_pad > 0) { + key = srtp_crypto_alloc(klen_pad); + if (key == NULL) { + srtp_crypto_free(cipher_array); + return srtp_err_status_alloc_fail; + } } /* allocate and initialize an array of ciphers */ From 9ed404273900ce721173447e307a1eb94359aa80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20B=C3=BChler?= Date: Fri, 1 Dec 2023 13:57:38 +0100 Subject: [PATCH 2/2] use correct function type There is a decrypt function type defined so use it in the struct. It has the same signature as the encrypt function so will not cause an issue. --- crypto/include/cipher.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/include/cipher.h b/crypto/include/cipher.h index 4f14e3560..43d453e6f 100644 --- a/crypto/include/cipher.h +++ b/crypto/include/cipher.h @@ -153,7 +153,7 @@ typedef struct srtp_cipher_type_t { srtp_cipher_init_func_t init; srtp_cipher_set_aad_func_t set_aad; srtp_cipher_encrypt_func_t encrypt; - srtp_cipher_encrypt_func_t decrypt; + srtp_cipher_decrypt_func_t decrypt; srtp_cipher_set_iv_func_t set_iv; srtp_cipher_get_tag_func_t get_tag; const char *description;