@@ -61,6 +61,7 @@ def __exit__(self, exc_type, exc_value, exc_traceback):
61
61
from exc_value
62
62
63
63
class Inputs :
64
+ # pylint: disable=too-many-instance-attributes
64
65
"""Accumulate information about macros to test.
65
66
66
67
This includes macro names as well as information about their arguments
@@ -93,6 +94,16 @@ def __init__(self):
93
94
'KEY_TYPE' : self .key_types ,
94
95
'KEY_USAGE' : self .key_usage_flags ,
95
96
}
97
+ # Test functions
98
+ self .table_by_test_function = {
99
+ 'key_type' : self .key_types ,
100
+ 'ecc_key_types' : self .ecc_curves ,
101
+ 'dh_key_types' : self .dh_groups ,
102
+ 'hash_algorithm' : self .hash_algorithms ,
103
+ 'mac_algorithm' : self .mac_algorithms ,
104
+ 'hmac_algorithm' : self .mac_algorithms ,
105
+ 'aead_algorithm' : self .aead_algorithms ,
106
+ }
96
107
# macro name -> list of argument names
97
108
self .argspecs = {}
98
109
# argument name -> list of values
@@ -220,24 +231,17 @@ def parse_header(self, filename):
220
231
221
232
def add_test_case_line (self , function , argument ):
222
233
"""Parse a test case data line, looking for algorithm metadata tests."""
234
+ sets = []
223
235
if function .endswith ('_algorithm' ):
224
236
# As above, ECDH and FFDH algorithms are excluded for now.
225
237
# Support for them will be added in the future.
226
238
if 'ECDH' in argument or 'FFDH' in argument :
227
239
return
228
- self .algorithms .add (argument )
229
- if function == 'hash_algorithm' :
230
- self .hash_algorithms .add (argument )
231
- elif function in ['mac_algorithm' , 'hmac_algorithm' ]:
232
- self .mac_algorithms .add (argument )
233
- elif function == 'aead_algorithm' :
234
- self .aead_algorithms .add (argument )
235
- elif function == 'key_type' :
236
- self .key_types .add (argument )
237
- elif function == 'ecc_key_types' :
238
- self .ecc_curves .add (argument )
239
- elif function == 'dh_key_types' :
240
- self .dh_groups .add (argument )
240
+ sets .append (self .algorithms )
241
+ if function in self .table_by_test_function :
242
+ sets .append (self .table_by_test_function [function ])
243
+ for s in sets :
244
+ s .add (argument )
241
245
242
246
# Regex matching a *.data line containing a test function call and
243
247
# its arguments. The actual definition is partly positional, but this
0 commit comments