blob: aa06fe8634d757e53c111358f0bba243b7991e80 [file] [log] [blame]
Janos Follathb99b0562022-11-02 14:44:08 +00001"""Framework classes for generation of bignum mod 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
Werner Lewiscff75782022-11-30 16:34:07 +000017from typing import Dict, List # pylint: disable=unused-import
18
Janos Follathb99b0562022-11-02 14:44:08 +000019from . import test_data_generation
Werner Lewiscff75782022-11-30 16:34:07 +000020from . import bignum_common # pylint: disable=unused-import
Janos Follathb99b0562022-11-02 14:44:08 +000021
Janos Follath0cd89672022-11-09 12:14:14 +000022class BignumModTarget(test_data_generation.BaseTarget):
23 #pylint: disable=abstract-method, too-few-public-methods
Janos Follathb99b0562022-11-02 14:44:08 +000024 """Target for bignum mod test case generation."""
25 target_basename = 'test_suite_bignum_mod.generated'
26
Janos Follath1be322a2022-11-02 14:46:23 +000027# BEGIN MERGE SLOT 1
28
29# END MERGE SLOT 1
30
31# BEGIN MERGE SLOT 2
32
33# END MERGE SLOT 2
34
35# BEGIN MERGE SLOT 3
36
Tom Cosgrove62b20482022-12-01 14:27:37 +000037class BignumModSub(bignum_common.ModOperationCommon, BignumModTarget):
38 """Test cases for bignum mpi_mod_sub()."""
39 symbol = "-"
40 test_function = "mpi_mod_sub"
41 test_name = "mbedtls_mpi_mod_sub"
42 input_style = "fixed"
43 arity = 2
44
Tom Cosgrove62b20482022-12-01 14:27:37 +000045 def result(self) -> List[str]:
46 result = (self.int_a - self.int_b) % self.int_n
Tom Cosgrovef51f9722022-12-05 15:47:40 +000047 # To make negative tests easier, append 0 for success to the
48 # generated cases
49 return [self.format_result(result), "0"]
Tom Cosgrove62b20482022-12-01 14:27:37 +000050
Janos Follath1be322a2022-11-02 14:46:23 +000051# END MERGE SLOT 3
52
53# BEGIN MERGE SLOT 4
54
55# END MERGE SLOT 4
56
57# BEGIN MERGE SLOT 5
58
59# END MERGE SLOT 5
60
61# BEGIN MERGE SLOT 6
62
63# END MERGE SLOT 6
64
65# BEGIN MERGE SLOT 7
66
67# END MERGE SLOT 7
68
69# BEGIN MERGE SLOT 8
70
71# END MERGE SLOT 8
72
73# BEGIN MERGE SLOT 9
74
75# END MERGE SLOT 9
76
77# BEGIN MERGE SLOT 10
78
79# END MERGE SLOT 10