Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 1 | #!/usr/bin/env python3 |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 2 | |
| 3 | """Analyze the test outcomes from a full CI run. |
| 4 | |
| 5 | This script can also run on outcomes from a partial run, but the results are |
| 6 | less likely to be useful. |
| 7 | """ |
| 8 | |
| 9 | import argparse |
| 10 | import sys |
| 11 | import traceback |
Przemek Stekiel | 85c54ea | 2022-11-17 11:50:23 +0100 | [diff] [blame] | 12 | import re |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 13 | import subprocess |
| 14 | import os |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 15 | |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 16 | import check_test_cases |
| 17 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 18 | class Results: |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 19 | """Process analysis results.""" |
| 20 | |
| 21 | def __init__(self): |
| 22 | self.error_count = 0 |
| 23 | self.warning_count = 0 |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 24 | |
| 25 | def info(self, fmt, *args, **kwargs): |
Valerio Setti | 3f33989 | 2023-10-17 10:42:11 +0200 | [diff] [blame] | 26 | self.print_line('Info: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 27 | |
| 28 | def error(self, fmt, *args, **kwargs): |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 29 | self.error_count += 1 |
Valerio Setti | 3f33989 | 2023-10-17 10:42:11 +0200 | [diff] [blame] | 30 | self.print_line('Error: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 31 | |
| 32 | def warning(self, fmt, *args, **kwargs): |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 33 | self.warning_count += 1 |
Valerio Setti | 3f33989 | 2023-10-17 10:42:11 +0200 | [diff] [blame] | 34 | self.print_line('Warning: ' + fmt, *args, **kwargs) |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 35 | |
Valerio Setti | 3f33989 | 2023-10-17 10:42:11 +0200 | [diff] [blame] | 36 | @staticmethod |
| 37 | def print_line(fmt, *args, **kwargs): |
| 38 | sys.stderr.write(fmt, *args, **kwargs) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 39 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 40 | class TestCaseOutcomes: |
| 41 | """The outcomes of one test case across many configurations.""" |
| 42 | # pylint: disable=too-few-public-methods |
| 43 | |
| 44 | def __init__(self): |
Gilles Peskine | 3d863f2 | 2020-06-26 13:02:30 +0200 | [diff] [blame] | 45 | # Collect a list of witnesses of the test case succeeding or failing. |
| 46 | # Currently we don't do anything with witnesses except count them. |
| 47 | # The format of a witness is determined by the read_outcome_file |
| 48 | # function; it's the platform and configuration joined by ';'. |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 49 | self.successes = [] |
| 50 | self.failures = [] |
| 51 | |
| 52 | def hits(self): |
| 53 | """Return the number of times a test case has been run. |
| 54 | |
| 55 | This includes passes and failures, but not skips. |
| 56 | """ |
| 57 | return len(self.successes) + len(self.failures) |
| 58 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 59 | def execute_reference_driver_tests(results: Results, ref_component, driver_component, \ |
| 60 | outcome_file) -> Results: |
Valerio Setti | 22992a0 | 2023-03-29 11:15:28 +0200 | [diff] [blame] | 61 | """Run the tests specified in ref_component and driver_component. Results |
| 62 | are stored in the output_file and they will be used for the following |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 63 | coverage analysis""" |
| 64 | # If the outcome file already exists, we assume that the user wants to |
| 65 | # perform the comparison analysis again without repeating the tests. |
| 66 | if os.path.exists(outcome_file): |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 67 | results.info("Outcome file (" + outcome_file + ") already exists. " + \ |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 68 | "Tests will be skipped.") |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 69 | return results |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 70 | |
| 71 | shell_command = "tests/scripts/all.sh --outcome-file " + outcome_file + \ |
| 72 | " " + ref_component + " " + driver_component |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 73 | results.info("Running: " + shell_command) |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 74 | ret_val = subprocess.run(shell_command.split(), check=False).returncode |
| 75 | |
| 76 | if ret_val != 0: |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 77 | results.error("failed to run reference/driver components") |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 78 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 79 | return results |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 80 | |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 81 | def analyze_coverage(results, outcomes, allow_list, full_coverage): |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 82 | """Check that all available test cases are executed at least once.""" |
Gilles Peskine | 686c292 | 2022-01-07 15:58:38 +0100 | [diff] [blame] | 83 | available = check_test_cases.collect_available_test_cases() |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 84 | for key in available: |
| 85 | hits = outcomes[key].hits() if key in outcomes else 0 |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 86 | if hits == 0 and key not in allow_list: |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 87 | if full_coverage: |
| 88 | results.error('Test case not executed: {}', key) |
| 89 | else: |
| 90 | results.warning('Test case not executed: {}', key) |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 91 | elif hits != 0 and key in allow_list: |
| 92 | # Test Case should be removed from the allow list. |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 93 | if full_coverage: |
Tomás González | a063144 | 2023-08-22 12:17:57 +0100 | [diff] [blame] | 94 | results.error('Allow listed test case was executed: {}', key) |
Tomás González | 7ebb18f | 2023-08-22 09:40:23 +0100 | [diff] [blame] | 95 | else: |
| 96 | results.warning('Allow listed test case was executed: {}', key) |
Gilles Peskine | 8d3c70a | 2020-06-25 18:37:43 +0200 | [diff] [blame] | 97 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 98 | def analyze_driver_vs_reference(results: Results, outcomes, |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 99 | component_ref, component_driver, |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 100 | ignored_suites, ignored_test=None): |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 101 | """Check that all tests executed in the reference component are also |
| 102 | executed in the corresponding driver component. |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 103 | Skip: |
| 104 | - full test suites provided in ignored_suites list |
| 105 | - only some specific test inside a test suite, for which the corresponding |
| 106 | output string is provided |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 107 | """ |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 108 | available = check_test_cases.collect_available_test_cases() |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 109 | |
| 110 | for key in available: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 111 | # Continue if test was not executed by any component |
| 112 | hits = outcomes[key].hits() if key in outcomes else 0 |
Przemek Stekiel | c86dedf | 2022-10-24 09:16:04 +0200 | [diff] [blame] | 113 | if hits == 0: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 114 | continue |
Valerio Setti | 00c1ccb | 2023-02-02 11:33:31 +0100 | [diff] [blame] | 115 | # Skip ignored test suites |
| 116 | full_test_suite = key.split(';')[0] # retrieve full test suite name |
| 117 | test_string = key.split(';')[1] # retrieve the text string of this test |
| 118 | test_suite = full_test_suite.split('.')[0] # retrieve main part of test suite name |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 119 | if test_suite in ignored_suites or full_test_suite in ignored_suites: |
Valerio Setti | 00c1ccb | 2023-02-02 11:33:31 +0100 | [diff] [blame] | 120 | continue |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 121 | if ((full_test_suite in ignored_test) and |
| 122 | (test_string in ignored_test[full_test_suite])): |
| 123 | continue |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 124 | # Search for tests that run in reference component and not in driver component |
| 125 | driver_test_passed = False |
| 126 | reference_test_passed = False |
| 127 | for entry in outcomes[key].successes: |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 128 | if component_driver in entry: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 129 | driver_test_passed = True |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 130 | if component_ref in entry: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 131 | reference_test_passed = True |
Manuel Pégourié-Gonnard | c6967d2 | 2022-12-30 13:40:34 +0100 | [diff] [blame] | 132 | if(reference_test_passed and not driver_test_passed): |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 133 | results.error(key) |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 134 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 135 | return results |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 136 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 137 | def analyze_outcomes(results: Results, outcomes, args) -> Results: |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 138 | """Run all analyses on the given outcome collection.""" |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 139 | analyze_coverage(results, outcomes, args['allow_list'], |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 140 | args['full_coverage']) |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 141 | return results |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 142 | |
| 143 | def read_outcome_file(outcome_file): |
| 144 | """Parse an outcome file and return an outcome collection. |
| 145 | |
| 146 | An outcome collection is a dictionary mapping keys to TestCaseOutcomes objects. |
| 147 | The keys are the test suite name and the test case description, separated |
| 148 | by a semicolon. |
| 149 | """ |
| 150 | outcomes = {} |
| 151 | with open(outcome_file, 'r', encoding='utf-8') as input_file: |
| 152 | for line in input_file: |
| 153 | (platform, config, suite, case, result, _cause) = line.split(';') |
| 154 | key = ';'.join([suite, case]) |
| 155 | setup = ';'.join([platform, config]) |
| 156 | if key not in outcomes: |
| 157 | outcomes[key] = TestCaseOutcomes() |
| 158 | if result == 'PASS': |
| 159 | outcomes[key].successes.append(setup) |
| 160 | elif result == 'FAIL': |
| 161 | outcomes[key].failures.append(setup) |
| 162 | return outcomes |
| 163 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 164 | def do_analyze_coverage(results: Results, outcome_file, args) -> Results: |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 165 | """Perform coverage analysis.""" |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 166 | results.info("\n*** Analyze coverage ***\n") |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 167 | outcomes = read_outcome_file(outcome_file) |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 168 | results = analyze_outcomes(results, outcomes, args) |
| 169 | return results |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 170 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 171 | def do_analyze_driver_vs_reference(results: Results, outcome_file, args) -> Results: |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 172 | """Perform driver vs reference analyze.""" |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 173 | results.info("\n*** Analyze driver {} vs reference {} ***\n".format( |
Valerio Setti | b0c618e | 2023-10-16 14:19:49 +0200 | [diff] [blame] | 174 | args['component_driver'], args['component_ref'])) |
| 175 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 176 | results = execute_reference_driver_tests(results, args['component_ref'], \ |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 177 | args['component_driver'], outcome_file) |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 178 | |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 179 | ignored_suites = ['test_suite_' + x for x in args['ignored_suites']] |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 180 | |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 181 | outcomes = read_outcome_file(outcome_file) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 182 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 183 | results = analyze_driver_vs_reference(results, outcomes, |
| 184 | args['component_ref'], args['component_driver'], |
| 185 | ignored_suites, args['ignored_tests']) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 186 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 187 | return results |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 188 | |
Przemek Stekiel | 6856f4c | 2022-11-09 10:50:29 +0100 | [diff] [blame] | 189 | # List of tasks with a function that can handle this task and additional arguments if required |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 190 | KNOWN_TASKS = { |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 191 | 'analyze_coverage': { |
| 192 | 'test_function': do_analyze_coverage, |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 193 | 'args': { |
Tomás González | 358c6c6 | 2023-08-14 15:43:46 +0100 | [diff] [blame] | 194 | 'allow_list': [ |
Tomás González | 5022311 | 2023-08-22 09:52:06 +0100 | [diff] [blame] | 195 | # Algorithm not supported yet |
| 196 | 'test_suite_psa_crypto_metadata;Asymmetric signature: pure EdDSA', |
| 197 | # Algorithm not supported yet |
| 198 | 'test_suite_psa_crypto_metadata;Cipher: XTS', |
Tomás González | d43cab3 | 2023-08-24 09:12:40 +0100 | [diff] [blame] | 199 | ], |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 200 | 'full_coverage': False, |
Tomás González | 07bdcc2 | 2023-08-11 14:59:03 +0100 | [diff] [blame] | 201 | } |
Tomás González | d43cab3 | 2023-08-24 09:12:40 +0100 | [diff] [blame] | 202 | }, |
Valerio Setti | a266332 | 2023-03-24 08:20:18 +0100 | [diff] [blame] | 203 | # There are 2 options to use analyze_driver_vs_reference_xxx locally: |
| 204 | # 1. Run tests and then analysis: |
| 205 | # - tests/scripts/all.sh --outcome-file "$PWD/out.csv" <component_ref> <component_driver> |
| 206 | # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx |
| 207 | # 2. Let this script run both automatically: |
| 208 | # - tests/scripts/analyze_outcomes.py out.csv analyze_driver_vs_reference_xxx |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 209 | 'analyze_driver_vs_reference_hash': { |
| 210 | 'test_function': do_analyze_driver_vs_reference, |
| 211 | 'args': { |
Przemek Stekiel | 51f30ff | 2022-11-09 12:07:29 +0100 | [diff] [blame] | 212 | 'component_ref': 'test_psa_crypto_config_reference_hash_use_psa', |
| 213 | 'component_driver': 'test_psa_crypto_config_accel_hash_use_psa', |
Manuel Pégourié-Gonnard | 10e3963 | 2022-12-29 12:29:09 +0100 | [diff] [blame] | 214 | 'ignored_suites': [ |
| 215 | 'shax', 'mdx', # the software implementations that are being excluded |
Manuel Pégourié-Gonnard | 7d381f5 | 2023-03-17 15:13:08 +0100 | [diff] [blame] | 216 | 'md.psa', # purposefully depends on whether drivers are present |
Gilles Peskine | 35b49c4 | 2023-10-04 12:28:41 +0200 | [diff] [blame] | 217 | 'psa_crypto_low_hash.generated', # testing the builtins |
Valerio Setti | 3002c99 | 2023-01-18 17:28:36 +0100 | [diff] [blame] | 218 | ], |
| 219 | 'ignored_tests': { |
| 220 | } |
| 221 | } |
| 222 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 223 | 'analyze_driver_vs_reference_ecp_light_only': { |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 224 | 'test_function': do_analyze_driver_vs_reference, |
| 225 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 226 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ecp_light_only', |
| 227 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ecp_light_only', |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 228 | 'ignored_suites': [ |
| 229 | 'ecdsa', |
| 230 | 'ecdh', |
| 231 | 'ecjpake', |
| 232 | ], |
| 233 | 'ignored_tests': { |
| 234 | 'test_suite_random': [ |
| 235 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 236 | ], |
Valerio Setti | 0c477d3 | 2023-04-07 15:54:20 +0200 | [diff] [blame] | 237 | # In the accelerated test ECP_C is not set (only ECP_LIGHT is) |
| 238 | # so we must ignore disparities in the tests for which ECP_C |
| 239 | # is required. |
| 240 | 'test_suite_ecp': [ |
| 241 | 'ECP check public-private #1 (OK)', |
| 242 | 'ECP check public-private #2 (group none)', |
| 243 | 'ECP check public-private #3 (group mismatch)', |
| 244 | 'ECP check public-private #4 (Qx mismatch)', |
| 245 | 'ECP check public-private #5 (Qy mismatch)', |
| 246 | 'ECP check public-private #6 (wrong Qx)', |
| 247 | 'ECP check public-private #7 (wrong Qy)', |
| 248 | 'ECP gen keypair [#1]', |
| 249 | 'ECP gen keypair [#2]', |
| 250 | 'ECP gen keypair [#3]', |
| 251 | 'ECP gen keypair wrapper', |
| 252 | 'ECP point muladd secp256r1 #1', |
| 253 | 'ECP point muladd secp256r1 #2', |
| 254 | 'ECP point multiplication Curve25519 (element of order 2: origin) #3', |
| 255 | 'ECP point multiplication Curve25519 (element of order 4: 1) #4', |
| 256 | 'ECP point multiplication Curve25519 (element of order 8) #5', |
| 257 | 'ECP point multiplication Curve25519 (normalized) #1', |
| 258 | 'ECP point multiplication Curve25519 (not normalized) #2', |
| 259 | 'ECP point multiplication rng fail Curve25519', |
| 260 | 'ECP point multiplication rng fail secp256r1', |
| 261 | 'ECP test vectors Curve25519', |
| 262 | 'ECP test vectors Curve448 (RFC 7748 6.2, after decodeUCoordinate)', |
| 263 | 'ECP test vectors brainpoolP256r1 rfc 7027', |
| 264 | 'ECP test vectors brainpoolP384r1 rfc 7027', |
| 265 | 'ECP test vectors brainpoolP512r1 rfc 7027', |
| 266 | 'ECP test vectors secp192k1', |
| 267 | 'ECP test vectors secp192r1 rfc 5114', |
| 268 | 'ECP test vectors secp224k1', |
| 269 | 'ECP test vectors secp224r1 rfc 5114', |
| 270 | 'ECP test vectors secp256k1', |
| 271 | 'ECP test vectors secp256r1 rfc 5114', |
| 272 | 'ECP test vectors secp384r1 rfc 5114', |
| 273 | 'ECP test vectors secp521r1 rfc 5114', |
Valerio Setti | e50a75f | 2023-05-19 17:43:06 +0200 | [diff] [blame] | 274 | ], |
Valerio Setti | 482a0b9 | 2023-08-18 15:55:10 +0200 | [diff] [blame] | 275 | 'test_suite_psa_crypto': [ |
| 276 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1', |
| 277 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1 (1 redraw)', |
| 278 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1, exercise ECDSA', |
| 279 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp384r1', |
| 280 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #0', |
| 281 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #1', |
| 282 | ], |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 283 | 'test_suite_ssl': [ |
| 284 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 285 | ], |
Valerio Setti | 5f54020 | 2023-06-30 17:20:49 +0200 | [diff] [blame] | 286 | } |
Valerio Setti | 42d5f19 | 2023-03-20 13:54:41 +0100 | [diff] [blame] | 287 | } |
| 288 | }, |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 289 | 'analyze_driver_vs_reference_no_ecp_at_all': { |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 290 | 'test_function': do_analyze_driver_vs_reference, |
| 291 | 'args': { |
Valerio Setti | 4d25a8d | 2023-06-14 10:33:10 +0200 | [diff] [blame] | 292 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_ecp_at_all', |
| 293 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_ecp_at_all', |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 294 | 'ignored_suites': [ |
| 295 | # Ignore test suites for the modules that are disabled in the |
| 296 | # accelerated test case. |
| 297 | 'ecp', |
| 298 | 'ecdsa', |
| 299 | 'ecdh', |
| 300 | 'ecjpake', |
| 301 | ], |
| 302 | 'ignored_tests': { |
| 303 | 'test_suite_random': [ |
| 304 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 305 | ], |
| 306 | 'test_suite_psa_crypto': [ |
| 307 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1', |
| 308 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1 (1 redraw)', |
| 309 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1, exercise ECDSA', |
| 310 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp384r1', |
| 311 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #0', |
| 312 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #1', |
| 313 | 'PSA key derivation: bits=7 invalid for ECC BRAINPOOL_P_R1 (ECC enabled)', |
| 314 | 'PSA key derivation: bits=7 invalid for ECC SECP_K1 (ECC enabled)', |
| 315 | 'PSA key derivation: bits=7 invalid for ECC SECP_R1 (ECC enabled)', |
| 316 | 'PSA key derivation: bits=7 invalid for ECC SECP_R2 (ECC enabled)', |
| 317 | 'PSA key derivation: bits=7 invalid for ECC SECT_K1 (ECC enabled)', |
| 318 | 'PSA key derivation: bits=7 invalid for ECC SECT_R1 (ECC enabled)', |
| 319 | 'PSA key derivation: bits=7 invalid for ECC SECT_R2 (ECC enabled)', |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 320 | ], |
| 321 | 'test_suite_pkparse': [ |
Valerio Setti | 5bd2523 | 2023-06-19 19:32:14 +0200 | [diff] [blame] | 322 | # When PK_PARSE_C and ECP_C are defined then PK_PARSE_EC_COMPRESSED |
| 323 | # is automatically enabled in build_info.h (backward compatibility) |
| 324 | # even if it is disabled in config_psa_crypto_no_ecp_at_all(). As a |
| 325 | # consequence compressed points are supported in the reference |
| 326 | # component but not in the accelerated one, so they should be skipped |
| 327 | # while checking driver's coverage. |
| 328 | 'Parse EC Key #10a (SEC1 PEM, secp384r1, compressed)', |
| 329 | 'Parse EC Key #11a (SEC1 PEM, secp521r1, compressed)', |
| 330 | 'Parse EC Key #12a (SEC1 PEM, bp256r1, compressed)', |
| 331 | 'Parse EC Key #13a (SEC1 PEM, bp384r1, compressed)', |
| 332 | 'Parse EC Key #14a (SEC1 PEM, bp512r1, compressed)', |
| 333 | 'Parse EC Key #2a (SEC1 PEM, secp192r1, compressed)', |
| 334 | 'Parse EC Key #8a (SEC1 PEM, secp224r1, compressed)', |
| 335 | 'Parse EC Key #9a (SEC1 PEM, secp256r1, compressed)', |
| 336 | 'Parse Public EC Key #2a (RFC 5480, PEM, secp192r1, compressed)', |
| 337 | 'Parse Public EC Key #3a (RFC 5480, secp224r1, compressed)', |
| 338 | 'Parse Public EC Key #4a (RFC 5480, secp256r1, compressed)', |
| 339 | 'Parse Public EC Key #5a (RFC 5480, secp384r1, compressed)', |
| 340 | 'Parse Public EC Key #6a (RFC 5480, secp521r1, compressed)', |
| 341 | 'Parse Public EC Key #7a (RFC 5480, brainpoolP256r1, compressed)', |
| 342 | 'Parse Public EC Key #8a (RFC 5480, brainpoolP384r1, compressed)', |
| 343 | 'Parse Public EC Key #9a (RFC 5480, brainpoolP512r1, compressed)', |
Valerio Setti | addeee4 | 2023-06-14 10:46:55 +0200 | [diff] [blame] | 344 | ], |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 345 | 'test_suite_ssl': [ |
| 346 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 347 | ], |
Valerio Setti | e618cb0 | 2023-04-12 14:59:16 +0200 | [diff] [blame] | 348 | } |
| 349 | } |
| 350 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 351 | 'analyze_driver_vs_reference_ecc_no_bignum': { |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 352 | 'test_function': do_analyze_driver_vs_reference, |
| 353 | 'args': { |
| 354 | 'component_ref': 'test_psa_crypto_config_reference_ecc_no_bignum', |
| 355 | 'component_driver': 'test_psa_crypto_config_accel_ecc_no_bignum', |
| 356 | 'ignored_suites': [ |
| 357 | # Ignore test suites for the modules that are disabled in the |
| 358 | # accelerated test case. |
| 359 | 'ecp', |
| 360 | 'ecdsa', |
| 361 | 'ecdh', |
| 362 | 'ecjpake', |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 363 | 'bignum_core', |
| 364 | 'bignum_random', |
| 365 | 'bignum_mod', |
| 366 | 'bignum_mod_raw', |
| 367 | 'bignum.generated', |
| 368 | 'bignum.misc', |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 369 | ], |
| 370 | 'ignored_tests': { |
| 371 | 'test_suite_random': [ |
| 372 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 373 | ], |
| 374 | 'test_suite_psa_crypto': [ |
| 375 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1', |
| 376 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1 (1 redraw)', |
| 377 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1, exercise ECDSA', |
| 378 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp384r1', |
| 379 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #0', |
| 380 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #1', |
| 381 | 'PSA key derivation: bits=7 invalid for ECC BRAINPOOL_P_R1 (ECC enabled)', |
| 382 | 'PSA key derivation: bits=7 invalid for ECC SECP_K1 (ECC enabled)', |
| 383 | 'PSA key derivation: bits=7 invalid for ECC SECP_R1 (ECC enabled)', |
| 384 | 'PSA key derivation: bits=7 invalid for ECC SECP_R2 (ECC enabled)', |
| 385 | 'PSA key derivation: bits=7 invalid for ECC SECT_K1 (ECC enabled)', |
| 386 | 'PSA key derivation: bits=7 invalid for ECC SECT_R1 (ECC enabled)', |
| 387 | 'PSA key derivation: bits=7 invalid for ECC SECT_R2 (ECC enabled)', |
| 388 | ], |
| 389 | 'test_suite_pkparse': [ |
| 390 | # See the description provided above in the |
| 391 | # analyze_driver_vs_reference_no_ecp_at_all component. |
| 392 | 'Parse EC Key #10a (SEC1 PEM, secp384r1, compressed)', |
| 393 | 'Parse EC Key #11a (SEC1 PEM, secp521r1, compressed)', |
| 394 | 'Parse EC Key #12a (SEC1 PEM, bp256r1, compressed)', |
| 395 | 'Parse EC Key #13a (SEC1 PEM, bp384r1, compressed)', |
| 396 | 'Parse EC Key #14a (SEC1 PEM, bp512r1, compressed)', |
| 397 | 'Parse EC Key #2a (SEC1 PEM, secp192r1, compressed)', |
| 398 | 'Parse EC Key #8a (SEC1 PEM, secp224r1, compressed)', |
| 399 | 'Parse EC Key #9a (SEC1 PEM, secp256r1, compressed)', |
| 400 | 'Parse Public EC Key #2a (RFC 5480, PEM, secp192r1, compressed)', |
| 401 | 'Parse Public EC Key #3a (RFC 5480, secp224r1, compressed)', |
| 402 | 'Parse Public EC Key #4a (RFC 5480, secp256r1, compressed)', |
| 403 | 'Parse Public EC Key #5a (RFC 5480, secp384r1, compressed)', |
| 404 | 'Parse Public EC Key #6a (RFC 5480, secp521r1, compressed)', |
| 405 | 'Parse Public EC Key #7a (RFC 5480, brainpoolP256r1, compressed)', |
| 406 | 'Parse Public EC Key #8a (RFC 5480, brainpoolP384r1, compressed)', |
| 407 | 'Parse Public EC Key #9a (RFC 5480, brainpoolP512r1, compressed)', |
| 408 | ], |
Valerio Setti | 9b3dbcc | 2023-07-26 18:00:31 +0200 | [diff] [blame] | 409 | 'test_suite_asn1parse': [ |
| 410 | # This test depends on BIGNUM_C |
| 411 | 'INTEGER too large for mpi', |
| 412 | ], |
| 413 | 'test_suite_asn1write': [ |
| 414 | # Following tests depends on BIGNUM_C |
| 415 | 'ASN.1 Write mpi 0 (1 limb)', |
| 416 | 'ASN.1 Write mpi 0 (null)', |
| 417 | 'ASN.1 Write mpi 0x100', |
| 418 | 'ASN.1 Write mpi 0x7f', |
| 419 | 'ASN.1 Write mpi 0x7f with leading 0 limb', |
| 420 | 'ASN.1 Write mpi 0x80', |
| 421 | 'ASN.1 Write mpi 0x80 with leading 0 limb', |
| 422 | 'ASN.1 Write mpi 0xff', |
| 423 | 'ASN.1 Write mpi 1', |
| 424 | 'ASN.1 Write mpi, 127*8 bits', |
| 425 | 'ASN.1 Write mpi, 127*8+1 bits', |
| 426 | 'ASN.1 Write mpi, 127*8-1 bits', |
| 427 | 'ASN.1 Write mpi, 255*8 bits', |
| 428 | 'ASN.1 Write mpi, 255*8-1 bits', |
| 429 | 'ASN.1 Write mpi, 256*8-1 bits', |
| 430 | ], |
Valerio Setti | e0be95e | 2023-08-01 09:07:43 +0200 | [diff] [blame] | 431 | 'test_suite_debug': [ |
| 432 | # Following tests depends on BIGNUM_C |
| 433 | 'Debug print mbedtls_mpi #2: 3 bits', |
| 434 | 'Debug print mbedtls_mpi: 0 (empty representation)', |
| 435 | 'Debug print mbedtls_mpi: 0 (non-empty representation)', |
| 436 | 'Debug print mbedtls_mpi: 49 bits', |
| 437 | 'Debug print mbedtls_mpi: 759 bits', |
| 438 | 'Debug print mbedtls_mpi: 764 bits #1', |
| 439 | 'Debug print mbedtls_mpi: 764 bits #2', |
| 440 | ], |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 441 | 'test_suite_ssl': [ |
| 442 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 443 | ], |
Manuel Pégourié-Gonnard | abd00d0 | 2023-06-12 17:51:33 +0200 | [diff] [blame] | 444 | } |
| 445 | } |
| 446 | }, |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 447 | 'analyze_driver_vs_reference_ecc_ffdh_no_bignum': { |
| 448 | 'test_function': do_analyze_driver_vs_reference, |
| 449 | 'args': { |
| 450 | 'component_ref': 'test_psa_crypto_config_reference_ecc_ffdh_no_bignum', |
| 451 | 'component_driver': 'test_psa_crypto_config_accel_ecc_ffdh_no_bignum', |
| 452 | 'ignored_suites': [ |
| 453 | # Ignore test suites for the modules that are disabled in the |
| 454 | # accelerated test case. |
| 455 | 'ecp', |
| 456 | 'ecdsa', |
| 457 | 'ecdh', |
| 458 | 'ecjpake', |
| 459 | 'bignum_core', |
| 460 | 'bignum_random', |
| 461 | 'bignum_mod', |
| 462 | 'bignum_mod_raw', |
| 463 | 'bignum.generated', |
| 464 | 'bignum.misc', |
| 465 | 'dhm', |
| 466 | ], |
| 467 | 'ignored_tests': { |
| 468 | 'test_suite_random': [ |
| 469 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 470 | ], |
| 471 | 'test_suite_psa_crypto': [ |
| 472 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1', |
| 473 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1 (1 redraw)', |
| 474 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1, exercise ECDSA', |
| 475 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp384r1', |
| 476 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #0', |
| 477 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp521r1 #1', |
| 478 | 'PSA key derivation: bits=7 invalid for ECC BRAINPOOL_P_R1 (ECC enabled)', |
| 479 | 'PSA key derivation: bits=7 invalid for ECC SECP_K1 (ECC enabled)', |
| 480 | 'PSA key derivation: bits=7 invalid for ECC SECP_R1 (ECC enabled)', |
| 481 | 'PSA key derivation: bits=7 invalid for ECC SECP_R2 (ECC enabled)', |
| 482 | 'PSA key derivation: bits=7 invalid for ECC SECT_K1 (ECC enabled)', |
| 483 | 'PSA key derivation: bits=7 invalid for ECC SECT_R1 (ECC enabled)', |
| 484 | 'PSA key derivation: bits=7 invalid for ECC SECT_R2 (ECC enabled)', |
| 485 | ], |
| 486 | 'test_suite_pkparse': [ |
| 487 | # See the description provided above in the |
| 488 | # analyze_driver_vs_reference_no_ecp_at_all component. |
| 489 | 'Parse EC Key #10a (SEC1 PEM, secp384r1, compressed)', |
| 490 | 'Parse EC Key #11a (SEC1 PEM, secp521r1, compressed)', |
| 491 | 'Parse EC Key #12a (SEC1 PEM, bp256r1, compressed)', |
| 492 | 'Parse EC Key #13a (SEC1 PEM, bp384r1, compressed)', |
| 493 | 'Parse EC Key #14a (SEC1 PEM, bp512r1, compressed)', |
| 494 | 'Parse EC Key #2a (SEC1 PEM, secp192r1, compressed)', |
| 495 | 'Parse EC Key #8a (SEC1 PEM, secp224r1, compressed)', |
| 496 | 'Parse EC Key #9a (SEC1 PEM, secp256r1, compressed)', |
| 497 | 'Parse Public EC Key #2a (RFC 5480, PEM, secp192r1, compressed)', |
| 498 | 'Parse Public EC Key #3a (RFC 5480, secp224r1, compressed)', |
| 499 | 'Parse Public EC Key #4a (RFC 5480, secp256r1, compressed)', |
| 500 | 'Parse Public EC Key #5a (RFC 5480, secp384r1, compressed)', |
| 501 | 'Parse Public EC Key #6a (RFC 5480, secp521r1, compressed)', |
| 502 | 'Parse Public EC Key #7a (RFC 5480, brainpoolP256r1, compressed)', |
| 503 | 'Parse Public EC Key #8a (RFC 5480, brainpoolP384r1, compressed)', |
| 504 | 'Parse Public EC Key #9a (RFC 5480, brainpoolP512r1, compressed)', |
| 505 | ], |
| 506 | 'test_suite_asn1parse': [ |
| 507 | # This test depends on BIGNUM_C |
| 508 | 'INTEGER too large for mpi', |
| 509 | ], |
| 510 | 'test_suite_asn1write': [ |
| 511 | # Following tests depends on BIGNUM_C |
| 512 | 'ASN.1 Write mpi 0 (1 limb)', |
| 513 | 'ASN.1 Write mpi 0 (null)', |
| 514 | 'ASN.1 Write mpi 0x100', |
| 515 | 'ASN.1 Write mpi 0x7f', |
| 516 | 'ASN.1 Write mpi 0x7f with leading 0 limb', |
| 517 | 'ASN.1 Write mpi 0x80', |
| 518 | 'ASN.1 Write mpi 0x80 with leading 0 limb', |
| 519 | 'ASN.1 Write mpi 0xff', |
| 520 | 'ASN.1 Write mpi 1', |
| 521 | 'ASN.1 Write mpi, 127*8 bits', |
| 522 | 'ASN.1 Write mpi, 127*8+1 bits', |
| 523 | 'ASN.1 Write mpi, 127*8-1 bits', |
| 524 | 'ASN.1 Write mpi, 255*8 bits', |
| 525 | 'ASN.1 Write mpi, 255*8-1 bits', |
| 526 | 'ASN.1 Write mpi, 256*8-1 bits', |
| 527 | ], |
| 528 | 'test_suite_debug': [ |
| 529 | # Following tests depends on BIGNUM_C |
| 530 | 'Debug print mbedtls_mpi #2: 3 bits', |
| 531 | 'Debug print mbedtls_mpi: 0 (empty representation)', |
| 532 | 'Debug print mbedtls_mpi: 0 (non-empty representation)', |
| 533 | 'Debug print mbedtls_mpi: 49 bits', |
| 534 | 'Debug print mbedtls_mpi: 759 bits', |
| 535 | 'Debug print mbedtls_mpi: 764 bits #1', |
| 536 | 'Debug print mbedtls_mpi: 764 bits #2', |
| 537 | ], |
Manuel Pégourié-Gonnard | f07ce3b | 2023-09-22 11:53:41 +0200 | [diff] [blame] | 538 | 'test_suite_ssl': [ |
| 539 | 'Test configuration of groups for DHE through mbedtls_ssl_conf_curves()', |
| 540 | ], |
Valerio Setti | 307810b | 2023-08-15 10:12:25 +0200 | [diff] [blame] | 541 | } |
| 542 | } |
| 543 | }, |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 544 | 'analyze_driver_vs_reference_ffdh_alg': { |
| 545 | 'test_function': do_analyze_driver_vs_reference, |
| 546 | 'args': { |
| 547 | 'component_ref': 'test_psa_crypto_config_reference_ffdh', |
| 548 | 'component_driver': 'test_psa_crypto_config_accel_ffdh', |
Przemek Stekiel | 84f4ff1 | 2023-07-04 12:35:31 +0200 | [diff] [blame] | 549 | 'ignored_suites': ['dhm'], |
Przemek Stekiel | 565353e | 2023-07-05 11:07:07 +0200 | [diff] [blame] | 550 | 'ignored_tests': {} |
Przemek Stekiel | 85b6442 | 2023-05-26 09:55:23 +0200 | [diff] [blame] | 551 | } |
| 552 | }, |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 553 | 'analyze_driver_vs_reference_tfm_config': { |
| 554 | 'test_function': do_analyze_driver_vs_reference, |
| 555 | 'args': { |
| 556 | 'component_ref': 'test_tfm_config', |
| 557 | 'component_driver': 'test_tfm_config_p256m_driver_accel_ec', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 558 | 'ignored_suites': [ |
| 559 | # Ignore test suites for the modules that are disabled in the |
| 560 | # accelerated test case. |
| 561 | 'ecp', |
| 562 | 'ecdsa', |
| 563 | 'ecdh', |
| 564 | 'ecjpake', |
| 565 | 'bignum_core', |
| 566 | 'bignum_random', |
| 567 | 'bignum_mod', |
| 568 | 'bignum_mod_raw', |
| 569 | 'bignum.generated', |
| 570 | 'bignum.misc', |
| 571 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 572 | 'ignored_tests': { |
| 573 | # Ignore all tests that require DERIVE support which is disabled |
| 574 | # in the driver version |
| 575 | 'test_suite_psa_crypto': [ |
| 576 | 'PSA key agreement setup: ECDH + HKDF-SHA-256: good', |
| 577 | ('PSA key agreement setup: ECDH + HKDF-SHA-256: good, key algorithm broader ' |
| 578 | 'than required'), |
| 579 | 'PSA key agreement setup: ECDH + HKDF-SHA-256: public key not on curve', |
| 580 | 'PSA key agreement setup: KDF instead of a key agreement algorithm', |
| 581 | 'PSA key agreement setup: bad key agreement algorithm', |
| 582 | 'PSA key agreement: ECDH SECP256R1 (RFC 5903) + HKDF-SHA-256: capacity=8160', |
| 583 | 'PSA key agreement: ECDH SECP256R1 (RFC 5903) + HKDF-SHA-256: read 0+32', |
| 584 | 'PSA key agreement: ECDH SECP256R1 (RFC 5903) + HKDF-SHA-256: read 1+31', |
| 585 | 'PSA key agreement: ECDH SECP256R1 (RFC 5903) + HKDF-SHA-256: read 31+1', |
| 586 | 'PSA key agreement: ECDH SECP256R1 (RFC 5903) + HKDF-SHA-256: read 32+0', |
| 587 | 'PSA key agreement: ECDH SECP256R1 (RFC 5903) + HKDF-SHA-256: read 32+32', |
| 588 | 'PSA key agreement: ECDH SECP256R1 (RFC 5903) + HKDF-SHA-256: read 64+0', |
| 589 | 'PSA key derivation: ECDH on P256 with HKDF-SHA256, info first', |
| 590 | 'PSA key derivation: ECDH on P256 with HKDF-SHA256, key output', |
| 591 | 'PSA key derivation: ECDH on P256 with HKDF-SHA256, missing info', |
| 592 | 'PSA key derivation: ECDH on P256 with HKDF-SHA256, omitted salt', |
| 593 | 'PSA key derivation: ECDH on P256 with HKDF-SHA256, raw output', |
| 594 | 'PSA key derivation: ECDH on P256 with HKDF-SHA256, salt after secret', |
| 595 | 'PSA key derivation: ECDH with TLS 1.2 PRF SHA-256, good case', |
| 596 | 'PSA key derivation: ECDH with TLS 1.2 PRF SHA-256, missing label', |
| 597 | 'PSA key derivation: ECDH with TLS 1.2 PRF SHA-256, missing label and secret', |
| 598 | 'PSA key derivation: ECDH with TLS 1.2 PRF SHA-256, no inputs', |
| 599 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1', |
| 600 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1 (1 redraw)', |
| 601 | 'PSA key derivation: HKDF-SHA-256 -> ECC secp256r1, exercise ECDSA', |
| 602 | 'PSA key derivation: TLS 1.2 Mix-PSK-to-MS, SHA-256, 0+48, ka', |
| 603 | 'PSA key derivation: TLS 1.2 Mix-PSK-to-MS, SHA-256, 24+24, ka', |
| 604 | 'PSA key derivation: TLS 1.2 Mix-PSK-to-MS, SHA-256, 48+0, ka', |
| 605 | 'PSA key derivation: TLS 1.2 Mix-PSK-to-MS, bad state #1, ka', |
| 606 | 'PSA key derivation: TLS 1.2 Mix-PSK-to-MS, bad state #3, ka', |
| 607 | 'PSA key derivation: TLS 1.2 Mix-PSK-to-MS, bad state #4, ka', |
| 608 | 'PSA key derivation: bits=7 invalid for ECC BRAINPOOL_P_R1 (ECC enabled)', |
| 609 | 'PSA key derivation: bits=7 invalid for ECC MONTGOMERY (ECC enabled)', |
| 610 | 'PSA key derivation: bits=7 invalid for ECC SECP_K1 (ECC enabled)', |
| 611 | 'PSA key derivation: bits=7 invalid for ECC SECP_R1 (ECC enabled)', |
| 612 | 'PSA key derivation: bits=7 invalid for ECC SECP_R2 (ECC enabled)', |
| 613 | 'PSA key derivation: bits=7 invalid for ECC SECT_K1 (ECC enabled)', |
| 614 | 'PSA key derivation: bits=7 invalid for ECC SECT_R1 (ECC enabled)', |
| 615 | 'PSA key derivation: bits=7 invalid for ECC SECT_R2 (ECC enabled)', |
| 616 | 'PSA raw key agreement: ECDH SECP256R1 (RFC 5903)', |
| 617 | ], |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 618 | 'test_suite_random': [ |
| 619 | 'PSA classic wrapper: ECDSA signature (SECP256R1)', |
| 620 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 621 | 'test_suite_psa_crypto_pake': [ |
| 622 | 'PSA PAKE: ecjpake size macros', |
Manuel Pégourié-Gonnard | e9d9797 | 2023-08-08 18:34:47 +0200 | [diff] [blame] | 623 | ], |
| 624 | 'test_suite_asn1parse': [ |
| 625 | # This test depends on BIGNUM_C |
| 626 | 'INTEGER too large for mpi', |
| 627 | ], |
| 628 | 'test_suite_asn1write': [ |
| 629 | # Following tests depends on BIGNUM_C |
| 630 | 'ASN.1 Write mpi 0 (1 limb)', |
| 631 | 'ASN.1 Write mpi 0 (null)', |
| 632 | 'ASN.1 Write mpi 0x100', |
| 633 | 'ASN.1 Write mpi 0x7f', |
| 634 | 'ASN.1 Write mpi 0x7f with leading 0 limb', |
| 635 | 'ASN.1 Write mpi 0x80', |
| 636 | 'ASN.1 Write mpi 0x80 with leading 0 limb', |
| 637 | 'ASN.1 Write mpi 0xff', |
| 638 | 'ASN.1 Write mpi 1', |
| 639 | 'ASN.1 Write mpi, 127*8 bits', |
| 640 | 'ASN.1 Write mpi, 127*8+1 bits', |
| 641 | 'ASN.1 Write mpi, 127*8-1 bits', |
| 642 | 'ASN.1 Write mpi, 255*8 bits', |
| 643 | 'ASN.1 Write mpi, 255*8-1 bits', |
| 644 | 'ASN.1 Write mpi, 256*8-1 bits', |
| 645 | ], |
Valerio Setti | f01d648 | 2023-08-04 13:51:18 +0200 | [diff] [blame] | 646 | } |
| 647 | } |
| 648 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 649 | } |
Przemek Stekiel | 4d13c83 | 2022-10-26 16:11:26 +0200 | [diff] [blame] | 650 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 651 | def main(): |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 652 | main_results = Results() |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 653 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 654 | try: |
| 655 | parser = argparse.ArgumentParser(description=__doc__) |
Przemek Stekiel | 58bbc23 | 2022-10-24 08:10:10 +0200 | [diff] [blame] | 656 | parser.add_argument('outcomes', metavar='OUTCOMES.CSV', |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 657 | help='Outcome file to analyze') |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 658 | parser.add_argument('specified_tasks', default='all', nargs='?', |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 659 | help='Analysis to be done. By default, run all tasks. ' |
| 660 | 'With one or more TASK, run only those. ' |
| 661 | 'TASK can be the name of a single task or ' |
Przemek Stekiel | 85c54ea | 2022-11-17 11:50:23 +0100 | [diff] [blame] | 662 | 'comma/space-separated list of tasks. ') |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 663 | parser.add_argument('--list', action='store_true', |
| 664 | help='List all available tasks and exit.') |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 665 | parser.add_argument('--require-full-coverage', action='store_true', |
| 666 | dest='full_coverage', help="Require all available " |
| 667 | "test cases to be executed and issue an error " |
| 668 | "otherwise. This flag is ignored if 'task' is " |
| 669 | "neither 'all' nor 'analyze_coverage'") |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 670 | options = parser.parse_args() |
Przemek Stekiel | 4e95590 | 2022-10-21 13:42:08 +0200 | [diff] [blame] | 671 | |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 672 | if options.list: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 673 | for task in KNOWN_TASKS: |
Valerio Setti | 5329ff0 | 2023-10-17 09:44:36 +0200 | [diff] [blame] | 674 | print(task) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 675 | sys.exit(0) |
| 676 | |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 677 | if options.specified_tasks == 'all': |
| 678 | tasks_list = KNOWN_TASKS.keys() |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 679 | else: |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 680 | tasks_list = re.split(r'[, ]+', options.specified_tasks) |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 681 | for task in tasks_list: |
| 682 | if task not in KNOWN_TASKS: |
Valerio Setti | fb2750e | 2023-10-17 10:11:45 +0200 | [diff] [blame] | 683 | sys.stderr.write('invalid task: {}'.format(task)) |
| 684 | sys.exit(2) |
Przemek Stekiel | 992de3c | 2022-11-09 13:54:49 +0100 | [diff] [blame] | 685 | |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 686 | KNOWN_TASKS['analyze_coverage']['args']['full_coverage'] = options.full_coverage |
Tomás González | b401e11 | 2023-08-11 15:22:04 +0100 | [diff] [blame] | 687 | |
Valerio Setti | fb2750e | 2023-10-17 10:11:45 +0200 | [diff] [blame] | 688 | for task in tasks_list: |
| 689 | test_function = KNOWN_TASKS[task]['test_function'] |
| 690 | test_args = KNOWN_TASKS[task]['args'] |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 691 | main_results = test_function(main_results, options.outcomes, test_args) |
Valerio Setti | dfd7ca6 | 2023-10-09 16:30:11 +0200 | [diff] [blame] | 692 | |
Valerio Setti | f075e47 | 2023-10-17 11:03:16 +0200 | [diff] [blame^] | 693 | main_results.info("Overall results:\n" + \ |
| 694 | "{} warnings\n".format(main_results.warning_count) + \ |
| 695 | "{} errors\n".format(main_results.error_count)) |
| 696 | |
| 697 | sys.exit(0 if (main_results.error_count == 0) else 2) |
Valerio Setti | aaef0bc | 2023-10-10 09:42:13 +0200 | [diff] [blame] | 698 | |
Gilles Peskine | 15c2cbf | 2020-06-25 18:36:28 +0200 | [diff] [blame] | 699 | except Exception: # pylint: disable=broad-except |
| 700 | # Print the backtrace and exit explicitly with our chosen status. |
| 701 | traceback.print_exc() |
| 702 | sys.exit(120) |
| 703 | |
| 704 | if __name__ == '__main__': |
| 705 | main() |