Require input to mbedtls_mpi_core_exp_mod() to already be in Montgomery form
Signed-off-by: Tom Cosgrove <tom.cosgrove@arm.com>
This commit is contained in:
parent
c3902ac661
commit
ecda186893
3 changed files with 19 additions and 9 deletions
|
@ -759,12 +759,23 @@ class BignumCoreExpMod(BignumCoreTarget, bignum_common.ModOperationCommon):
|
|||
"""Test cases for bignum core exponentiation."""
|
||||
symbol = "^"
|
||||
test_function = "mpi_core_exp_mod"
|
||||
test_name = "Core modular exponentiation"
|
||||
test_name = "Core modular exponentiation (Mongtomery form only)"
|
||||
input_style = "fixed"
|
||||
|
||||
def arguments(self) -> List[str]:
|
||||
# Input 'a' has to be given in Montgomery form
|
||||
mont_a = (self.int_a * self.r) % self.int_n
|
||||
arg_mont_a = self.format_arg('{:x}'.format(mont_a))
|
||||
return [bignum_common.quote_str(n) for n in [self.arg_n,
|
||||
arg_mont_a,
|
||||
self.arg_b]
|
||||
] + self.result()
|
||||
|
||||
def result(self) -> List[str]:
|
||||
# Result has to be given in Montgomery form
|
||||
result = pow(self.int_a, self.int_b, self.int_n)
|
||||
return [self.format_result(result)]
|
||||
mont_result = (result * self.r) % self.int_n
|
||||
return [self.format_result(mont_result)]
|
||||
|
||||
@property
|
||||
def is_valid(self) -> bool:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue