From f0f0bd068b25ca754078c3655229279fd8c58cc4 Mon Sep 17 00:00:00 2001 From: Przemek Stekiel Date: Fri, 3 Jun 2022 08:43:32 +0200 Subject: [PATCH] test_suite_psa_crypto_metadata: add test cases for the HKDF-Extract/Expand algorithms Signed-off-by: Przemek Stekiel --- .../test_suite_psa_crypto_metadata.data | 16 +++++++++++++++ .../test_suite_psa_crypto_metadata.function | 20 +++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/tests/suites/test_suite_psa_crypto_metadata.data b/tests/suites/test_suite_psa_crypto_metadata.data index 83763c55d..2c4930614 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.data +++ b/tests/suites/test_suite_psa_crypto_metadata.data @@ -270,6 +270,22 @@ Key derivation: HKDF using SHA-384 depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_384 key_derivation_algorithm:PSA_ALG_HKDF( PSA_ALG_SHA_384 ):ALG_IS_HKDF +Key derivation: HKDF-Extract using SHA-256 +depends_on:PSA_WANT_ALG_HKDF_EXTRACT:PSA_WANT_ALG_SHA_256 +key_derivation_algorithm:PSA_ALG_HKDF_EXTRACT( PSA_ALG_SHA_256 ):ALG_IS_HKDF_EXTRACT + +Key derivation: HKDF-Extract using SHA-384 +depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_384 +key_derivation_algorithm:PSA_ALG_HKDF_EXTRACT( PSA_ALG_SHA_384 ):ALG_IS_HKDF_EXTRACT + +Key derivation: HKDF-Expand using SHA-256 +depends_on:PSA_WANT_ALG_HKDF_EXPAND:PSA_WANT_ALG_SHA_256 +key_derivation_algorithm:PSA_ALG_HKDF_EXPAND( PSA_ALG_SHA_256 ):ALG_IS_HKDF_EXPAND + +Key derivation: HKDF-Expand using SHA-384 +depends_on:PSA_WANT_ALG_HKDF:PSA_WANT_ALG_SHA_384 +key_derivation_algorithm:PSA_ALG_HKDF_EXPAND( PSA_ALG_SHA_384 ):ALG_IS_HKDF_EXPAND + Key derivation: TLS 1.2 PRF using SHA-256 depends_on:PSA_WANT_ALG_SHA_256:PSA_WANT_ALG_TLS12_PRF key_derivation_algorithm:PSA_ALG_TLS12_PRF( PSA_ALG_SHA_256 ):ALG_IS_TLS12_PRF diff --git a/tests/suites/test_suite_psa_crypto_metadata.function b/tests/suites/test_suite_psa_crypto_metadata.function index 092780c4d..643a92f5e 100644 --- a/tests/suites/test_suite_psa_crypto_metadata.function +++ b/tests/suites/test_suite_psa_crypto_metadata.function @@ -37,14 +37,16 @@ #define ALG_IS_HASH_AND_SIGN ( 1u << 18 ) #define ALG_IS_RSA_OAEP ( 1u << 19 ) #define ALG_IS_HKDF ( 1u << 20 ) -#define ALG_IS_FFDH ( 1u << 21 ) -#define ALG_IS_ECDH ( 1u << 22 ) -#define ALG_IS_WILDCARD ( 1u << 23 ) -#define ALG_IS_RAW_KEY_AGREEMENT ( 1u << 24 ) -#define ALG_IS_AEAD_ON_BLOCK_CIPHER ( 1u << 25 ) -#define ALG_IS_TLS12_PRF ( 1u << 26 ) -#define ALG_IS_TLS12_PSK_TO_MS ( 1u << 27 ) -#define ALG_FLAG_MASK_PLUS_ONE ( 1u << 28 ) /* must be last! */ +#define ALG_IS_HKDF_EXTRACT ( 1u << 21 ) +#define ALG_IS_HKDF_EXPAND ( 1u << 22 ) +#define ALG_IS_FFDH ( 1u << 23 ) +#define ALG_IS_ECDH ( 1u << 24 ) +#define ALG_IS_WILDCARD ( 1u << 25 ) +#define ALG_IS_RAW_KEY_AGREEMENT ( 1u << 26 ) +#define ALG_IS_AEAD_ON_BLOCK_CIPHER ( 1u << 27 ) +#define ALG_IS_TLS12_PRF ( 1u << 28 ) +#define ALG_IS_TLS12_PSK_TO_MS ( 1u << 29 ) +#define ALG_FLAG_MASK_PLUS_ONE ( 1u << 30 ) /* must be last! */ /* Flags for key type classification macros. There is a flag for every * key type classification macro PSA_KEY_TYPE_IS_xxx except for some that @@ -140,6 +142,8 @@ void algorithm_classification( psa_algorithm_t alg, unsigned flags ) TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HASH_AND_SIGN, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_RSA_OAEP, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HKDF, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HKDF_EXTRACT, alg, flags ); + TEST_CLASSIFICATION_MACRO( 1, ALG_IS_HKDF_EXPAND, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_WILDCARD, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_ECDH, alg, flags ); TEST_CLASSIFICATION_MACRO( 1, ALG_IS_FFDH, alg, flags );