Skip to content

Commit 7961668

Browse files
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.
1 parent 2bcfc71 commit 7961668

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/scripts/test_psa_constant_names.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def __init__(self):
104104
'mac_algorithm': self.mac_algorithms,
105105
'hmac_algorithm': self.mac_algorithms,
106106
'aead_algorithm': self.aead_algorithms,
107+
'key_derivation_algorithm': self.kdf_algorithms,
108+
'key_agreement_algorithm': self.ka_algorithms,
107109
}
108110
# macro name -> list of argument names
109111
self.argspecs = {}
@@ -197,10 +199,6 @@ def _argument_split(cls, arguments):
197199
# Auxiliary macro whose name doesn't fit the usual patterns for
198200
# auxiliary macros.
199201
'PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH_CASE',
200-
# PSA_ALG_ECDH and PSA_ALG_FFDH are excluded for now as the script
201-
# currently doesn't support them.
202-
'PSA_ALG_ECDH',
203-
'PSA_ALG_FFDH',
204202
# Deprecated aliases.
205203
'PSA_ERROR_UNKNOWN_ERROR',
206204
'PSA_ERROR_OCCUPIED_SLOT',
@@ -248,11 +246,13 @@ def add_test_case_line(self, function, argument):
248246
"""Parse a test case data line, looking for algorithm metadata tests."""
249247
sets = []
250248
if function.endswith('_algorithm'):
251-
# As above, ECDH and FFDH algorithms are excluded for now.
252-
# Support for them will be added in the future.
253-
if 'ECDH' in argument or 'FFDH' in argument:
254-
return
255249
sets.append(self.algorithms)
250+
if function == 'key_agreement_algorithm' and \
251+
argument.startswith('PSA_ALG_KEY_AGREEMENT('):
252+
# We only want *raw* key agreement algorithms as such, so
253+
# exclude ones that are already chained with a KDF.
254+
# Keep the expression as one to test as an algorithm.
255+
function = 'other_algorithm'
256256
if function in self.table_by_test_function:
257257
sets.append(self.table_by_test_function[function])
258258
if self.accept_test_case_line(function, argument):

0 commit comments

Comments
 (0)