Cryptography Reference
In-Depth Information
In the preceding call by
sub_l()
some care was taken: We supply
sub_l()
with the
argument
tmp_l
, which here as the sum of
a_l
and
b_l
is possibly one digit larger
than allowed by the constant
MAX
B
. Within the function
sub_l()
nothing can
go awry as long as we provide storage space for an additional digit in the result.
Therefore, we let the result be stored in
tmp_l
and not immediately in
c_l
,asone
might suppose. Because of these conditions, at the end of
sub_l()
we have that
tmp_l
has at most
MAX
B
digits.
cpy_l (c_l, tmp_l);
}
return E_CLINT_OK;
}
The function for modular subtraction
msub_l()
uses only the positive
intermediate results of the functions
add_l()
,
sub_l()
, and
mod_l()
, in order to
remain within a positive residue system.
Function:
modular subtraction
Syntax:
int msub_l (CLINT aa_l, CLINT bb_l, CLINT c_l,
CLINT m_l);
aa_l
(minuend),
bb_l
(subtrahend),
m_l
(modulus)
Input:
c_l
(remainder)
Output:
E_CLINT_OK
if all is ok
E_CLINT_DBZ
if division by 0
Return:
int
msub_l (CLINT aa_l, CLINT bb_l, CLINT c_l, CLINT m_l)
{
CLINT a_l, b_l, tmp_l;
if (EQZ_L (m_l))
{
return E_CLINT_DBZ;
}
cpy_l (a_l, aa_l);
cpy_l (b_l, bb_l);