Gabor Mezei | 308132f | 2023-01-16 16:53:29 +0100 | [diff] [blame] | 1 | """Framework classes for generation of ecp test cases.""" |
| 2 | # Copyright The Mbed TLS Contributors |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | from typing import List |
| 18 | |
Gabor Mezei | 308132f | 2023-01-16 16:53:29 +0100 | [diff] [blame] | 19 | from . import test_data_generation |
| 20 | from . import ecp_common |
| 21 | |
| 22 | class EcpTarget(test_data_generation.BaseTarget): |
| 23 | #pylint: disable=abstract-method, too-few-public-methods |
| 24 | """Target for ecp test case generation.""" |
| 25 | target_basename = 'test_suite_ecp.generated' |
Gabor Mezei | 3c6f89b | 2023-01-16 16:54:48 +0100 | [diff] [blame] | 26 | |
| 27 | class EcpQuasiReduction(ecp_common.EcpOperationCommon, |
| 28 | EcpTarget): |
| 29 | """Test cases for ecp quasi_reduction().""" |
| 30 | symbol = "-" |
| 31 | test_function = "ecp_quasi_reduction" |
| 32 | test_name = "mbedtls_ecp_quasi_reduction" |
| 33 | input_style = "fixed" |
| 34 | arity = 1 |
| 35 | |
| 36 | # Extend the default values with n < x < 2n |
| 37 | input_values = ecp_common.EcpOperationCommon.input_values + [ |
Gabor Mezei | aec3eea | 2023-01-17 16:34:24 +0100 | [diff] [blame^] | 38 | "73", |
| 39 | "ebeddd7b4fefae8755bbfb9c181a73347096b3ec70d1a021", |
| 40 | ("1f4e1d074d0b50e8d8818f9a9e5df9959f902bb955fd24fd3d791175226ad8c1" |
| 41 | "fcb6d59fa41a3dcb25412009e5e356eb65b50ca67782285290420b45b32f0d63" |
| 42 | "7c9ee549a52ad8d631ba4945435c9aec77227ec59faff878b71b920a3d631929" |
| 43 | "d636c9a409d6ffdcd95e2568e128596811fb9ade15e69f6efd509381ebbf3599") |
| 44 | ] # type: List[str] |
Gabor Mezei | 3c6f89b | 2023-01-16 16:54:48 +0100 | [diff] [blame] | 45 | |
| 46 | def result(self) -> List[str]: |
| 47 | result = self.int_a % self.int_n |
| 48 | return [self.format_result(result)] |
| 49 | |
| 50 | @property |
| 51 | def is_valid(self) -> bool: |
| 52 | return bool(self.int_a < 2 * self.int_n) |