• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""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
17from typing import Dict, List # pylint: disable=unused-import
18
19from . import test_data_generation
20from . import bignum_common # pylint: disable=unused-import
21
22class BignumModTarget(test_data_generation.BaseTarget):
23    #pylint: disable=abstract-method, too-few-public-methods
24    """Target for bignum mod test case generation."""
25    target_basename = 'test_suite_bignum_mod.generated'
26
27# 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
37class 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
45    def result(self) -> List[str]:
46        result = (self.int_a - self.int_b) % self.int_n
47        # To make negative tests easier, append 0 for success to the
48        # generated cases
49        return [self.format_result(result), "0"]
50
51# 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
80