From ac72f9c213b597451d4cf1acc89b8d4792fa0266 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Wed, 2 Mar 2022 16:44:51 +0000 Subject: [PATCH 1/4] Initialise iv buffer before use Commit initialises the iv buffer before it ias passed to mbedtls_cipher_set_iv(). Signed-off-by: Thomas Daubney --- tests/suites/test_suite_cipher.function | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index 03c17331a..e23403551 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -1605,6 +1605,9 @@ void check_iv( int cipher_id, char * cipher_string, size_t iv_len = iv_len_val; unsigned char iv[16]; + /* Initialise iv buffer */ + memset( iv, 0, sizeof( iv ) ); + const mbedtls_cipher_info_t *cipher_info; mbedtls_cipher_context_t ctx_dec; mbedtls_cipher_context_t ctx_enc; From 7c4a4860816ff284674bcd53c14b042f1eee4cd0 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Wed, 2 Mar 2022 16:47:49 +0000 Subject: [PATCH 2/4] Initialise buffer before use Commit initialises buf before it is used. Signed-off-by: Thomas Daubney --- tests/suites/test_suite_md.function | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function index d918ce3b9..8cbdbe4c7 100644 --- a/tests/suites/test_suite_md.function +++ b/tests/suites/test_suite_md.function @@ -16,6 +16,7 @@ void mbedtls_md_process( ) unsigned char buf[150]; mbedtls_md_init( &ctx ); + memset( buf, 0, sizeof( buf ) ); /* * Very minimal testing of mbedtls_md_process, just make sure the various From 755cb9bf4f6d27b60b6686f3a8b78cf0ed8e4f74 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Wed, 2 Mar 2022 16:49:38 +0000 Subject: [PATCH 3/4] Changes name of check_iv to iv_len_validity Commit changes name of check_iv to iv_len_vlaidity as this seems to better describe its functionality. Signed-off-by: Thomas Daubney --- tests/suites/test_suite_cipher.function | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index e23403551..93bff1e02 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -1599,7 +1599,7 @@ void check_padding( int pad_mode, data_t * input, int ret, int dlen_check /* END_CASE */ /* BEGIN_CASE */ -void check_iv( int cipher_id, char * cipher_string, +void iv_len_validity( int cipher_id, char * cipher_string, int iv_len_val, int ret ) { size_t iv_len = iv_len_val; From 53a07dc92470e16028fa3cd415fb4e910f0c347e Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Wed, 2 Mar 2022 16:54:41 +0000 Subject: [PATCH 4/4] Modifies data files to match new test function name This commit alters the relevant .data files such that the new function name change of check_iv to iv_len_validity is reflected there. Signed-off-by: Thomas Daubney --- tests/suites/test_suite_cipher.chacha20.data | 10 +++++----- tests/suites/test_suite_cipher.chachapoly.data | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/suites/test_suite_cipher.chacha20.data b/tests/suites/test_suite_cipher.chacha20.data index dfa0e76ad..11bbfa231 100644 --- a/tests/suites/test_suite_cipher.chacha20.data +++ b/tests/suites/test_suite_cipher.chacha20.data @@ -116,20 +116,20 @@ enc_dec_buf_multipart:MBEDTLS_CIPHER_CHACHA20:256:16:16:-1:16:16:16:16 ChaCha20 IV Length 0 depends_on:MBEDTLS_CHACHA20_C -check_iv:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":0:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":0:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ChaCha20 IV Length 11 depends_on:MBEDTLS_CHACHA20_C -check_iv:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":11:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":11:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ChaCha20 IV Length 12 depends_on:MBEDTLS_CHACHA20_C -check_iv:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":12:0 +iv_len_validity:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":12:0 ChaCha20 IV Length 13 depends_on:MBEDTLS_CHACHA20_C -check_iv:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":13:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":13:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ChaCha20 IV Length 16 depends_on:MBEDTLS_CHACHA20_C -check_iv:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":16:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20:"CHACHA20":16:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA diff --git a/tests/suites/test_suite_cipher.chachapoly.data b/tests/suites/test_suite_cipher.chachapoly.data index 908951a18..df7891792 100644 --- a/tests/suites/test_suite_cipher.chachapoly.data +++ b/tests/suites/test_suite_cipher.chachapoly.data @@ -124,20 +124,20 @@ decrypt_test_vec:MBEDTLS_CIPHER_CHACHA20_POLY1305:-1:"1c9240a5eb55d38af333888604 ChaCha20+Poly1305 IV Length 0 depends_on:MBEDTLS_CHACHAPOLY_C -check_iv:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":0:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":0:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ChaCha20+Poly1305 IV Length 11 depends_on:MBEDTLS_CHACHAPOLY_C -check_iv:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":11:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":11:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ChaCha20+Poly1305 IV Length 12 depends_on:MBEDTLS_CHACHAPOLY_C -check_iv:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":12:0 +iv_len_validity:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":12:0 ChaCha20+Poly1305 IV Length 13 depends_on:MBEDTLS_CHACHAPOLY_C -check_iv:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":13:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":13:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA ChaCha20+Poly1305 IV Length 16 depends_on:MBEDTLS_CHACHAPOLY_C -check_iv:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":16:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA +iv_len_validity:MBEDTLS_CIPHER_CHACHA20_POLY1305:"CHACHA20-POLY1305":16:MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA