From 79616687383c9ad8afe99d39d835ffd3d6145ea4 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Thu, 21 Nov 2019 20:08:10 +0100 Subject: [PATCH] Support key agreement Key agreement algorithms were excluded back when they were constructed with a macro conveying the key agreement itself taking the KDF as an argument, because that was hard to support. Now the encoding has changed and key agreement algorithms are constructed with PSA_ALG_KEY_AGREEMENT taking two arguments, one that identifies the raw key agreement and one that identifies the KDF. This is easy to process, so add support. --- tests/scripts/test_psa_constant_names.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/scripts/test_psa_constant_names.py b/tests/scripts/test_psa_constant_names.py index 8f393a1ab..6e7bf48b1 100755 --- a/tests/scripts/test_psa_constant_names.py +++ b/tests/scripts/test_psa_constant_names.py @@ -104,6 +104,8 @@ class Inputs: 'mac_algorithm': self.mac_algorithms, 'hmac_algorithm': self.mac_algorithms, 'aead_algorithm': self.aead_algorithms, + 'key_derivation_algorithm': self.kdf_algorithms, + 'key_agreement_algorithm': self.ka_algorithms, } # macro name -> list of argument names self.argspecs = {} @@ -197,10 +199,6 @@ class Inputs: # Auxiliary macro whose name doesn't fit the usual patterns for # auxiliary macros. 'PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE', - # PSA_ALG_ECDH and PSA_ALG_FFDH are excluded for now as the script - # currently doesn't support them. - 'PSA_ALG_ECDH', - 'PSA_ALG_FFDH', # Deprecated aliases. 'PSA_ERROR_UNKNOWN_ERROR', 'PSA_ERROR_OCCUPIED_SLOT', @@ -248,11 +246,13 @@ class Inputs: """Parse a test case data line, looking for algorithm metadata tests.""" sets = [] if function.endswith('_algorithm'): - # As above, ECDH and FFDH algorithms are excluded for now. - # Support for them will be added in the future. - if 'ECDH' in argument or 'FFDH' in argument: - return sets.append(self.algorithms) + if function == 'key_agreement_algorithm' and \ + argument.startswith('PSA_ALG_KEY_AGREEMENT('): + # We only want *raw* key agreement algorithms as such, so + # exclude ones that are already chained with a KDF. + # Keep the expression as one to test as an algorithm. + function = 'other_algorithm' if function in self.table_by_test_function: sets.append(self.table_by_test_function[function]) if self.accept_test_case_line(function, argument):