blob: 713dd96df7360d397127c27591fc990301627be3 [file] [log] [blame]
Gabor Mezei308132f2023-01-16 16:53:29 +01001"""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
17from typing import List
18
19from . import test_case
20from . import test_data_generation
21from . import ecp_common
22
23class EcpTarget(test_data_generation.BaseTarget):
24 #pylint: disable=abstract-method, too-few-public-methods
25 """Target for ecp test case generation."""
26 target_basename = 'test_suite_ecp.generated'
Gabor Mezei3c6f89b2023-01-16 16:54:48 +010027
28class EcpQuasiReduction(ecp_common.EcpOperationCommon,
29 EcpTarget):
30 """Test cases for ecp quasi_reduction()."""
31 symbol = "-"
32 test_function = "ecp_quasi_reduction"
33 test_name = "mbedtls_ecp_quasi_reduction"
34 input_style = "fixed"
35 arity = 1
36
37 # Extend the default values with n < x < 2n
38 input_values = ecp_common.EcpOperationCommon.input_values + [
39 "73",
40 "ebeddd7b4fefae8755bbfb9c181a73347096b3ec70d1a021",
41 ("1f4e1d074d0b50e8d8818f9a9e5df9959f902bb955fd24fd3d791175226ad8c1"
42 "fcb6d59fa41a3dcb25412009e5e356eb65b50ca67782285290420b45b32f0d63"
43 "7c9ee549a52ad8d631ba4945435c9aec77227ec59faff878b71b920a3d631929"
44 "d636c9a409d6ffdcd95e2568e128596811fb9ade15e69f6efd509381ebbf3599")
45 ] # type: List[str]
46
47 def result(self) -> List[str]:
48 result = self.int_a % self.int_n
49 return [self.format_result(result)]
50
51 @property
52 def is_valid(self) -> bool:
53 return bool(self.int_a < 2 * self.int_n)