From 4768a30d9b64204f6b7d0deb42ed7681ae184975 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 30 Nov 2021 16:39:51 +0000 Subject: [PATCH] Simplify Input usage macros Also ensure they are used in test data rather than values Signed-off-by: Paul Elliott --- tests/suites/test_suite_pkcs12.data | 16 ++++++++-------- tests/suites/test_suite_pkcs12.function | 19 ++++--------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/tests/suites/test_suite_pkcs12.data b/tests/suites/test_suite_pkcs12.data index c8bfe4694..ec04f4a65 100644 --- a/tests/suites/test_suite_pkcs12.data +++ b/tests/suites/test_suite_pkcs12.data @@ -1,33 +1,33 @@ PKCS#12 derive key : Zero length password and hash depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":1:"":1:3:0 +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":USE_GIVEN_INPUT:"":USE_GIVEN_INPUT:3:0 PKCS#12 derive key: NULL password and hash depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":0:"":0:3:0 +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":USE_NULL_INPUT:"":USE_NULL_INPUT:3:0 PKCS#12 derive key: Zero length password depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":1:"0123456789abcdef":1:3:0 +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":USE_GIVEN_INPUT:"0123456789abcdef":USE_GIVEN_INPUT:3:0 PKCS#12 derive key: NULL password depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":0:"0123456789abcdef":1:3:0 +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"":USE_NULL_INPUT:"0123456789abcdef":USE_GIVEN_INPUT:3:0 PKCS#12 derive key: Invalid length NULL password depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":2:"0123456789abcdef":1:3:MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":USE_NULL_INPUT:"0123456789abcdef":USE_GIVEN_INPUT:3:MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA PKCS#12 derive key: Zero length hash depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":1:"":1:3:0 +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":USE_GIVEN_INPUT:"":USE_GIVEN_INPUT:3:0 PKCS#12 derive key: NULL hash depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":1:"":0:3:0 +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":USE_GIVEN_INPUT:"":USE_NULL_INPUT:3:0 PKCS#12 derive key: Invalid length NULL hash depends_on:MBEDTLS_MD5_C -pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":1:"0123456789abcdef":2:3:MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA +pkcs12_derive_key:MBEDTLS_MD_MD5:48:"0123456789abcdef":USE_GIVEN_INPUT:"0123456789abcdef":USE_NULL_INPUT:3:MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA diff --git a/tests/suites/test_suite_pkcs12.function b/tests/suites/test_suite_pkcs12.function index 3d402d7f0..81324ed61 100644 --- a/tests/suites/test_suite_pkcs12.function +++ b/tests/suites/test_suite_pkcs12.function @@ -5,7 +5,6 @@ typedef enum { USE_NULL_INPUT = 0, USE_GIVEN_INPUT = 1, - USE_NULL_INPUT_WITH_SIZE = 2, } input_usage_method_t; /* END_HEADER */ @@ -32,24 +31,14 @@ void pkcs12_derive_key( int md_type, int key_size_arg, size_t key_size = key_size_arg; if( password_usage == USE_GIVEN_INPUT ) - { password = password_arg->x; - password_len = password_arg->len; - } - else if( password_usage == USE_NULL_INPUT_WITH_SIZE ) - { - password_len = password_arg->len; - } + + password_len = password_arg->len; if( salt_usage == USE_GIVEN_INPUT ) - { salt = salt_arg->x; - salt_len = salt_arg->len; - } - else if( salt_usage == USE_NULL_INPUT_WITH_SIZE ) - { - salt_len = salt_arg->len; - } + + salt_len = salt_arg->len; ASSERT_ALLOC( output_data, key_size );