Cryptography Reference
In-Depth Information
r_l[i] &= (1U << (k & (BITPERDGT - 1))) - 1U;
SETDIGITS_L (r_l, i);
RMLDZRS_L (r_l);
return E_CLINT_OK;
}
The mixed variant of calculating residues employs a
USHORT
type as divisor
and represents the remainder again as a
USHORT
type, where here again only the
interface is given, and we refer the reader to the FLINT/C source code for the
short functions.
remainders, division of a
CLINT
type by a
USHORT
type
Function:
USHORT umod_l (CLINT dv_l, USHORT uds);
Syntax:
Input:
dv_l
(dividend),
uds
(divisor)
Return:
nonnegative remainder if all is ok
0xFFFF
if division by 0
For testing the division there are—as for all other functions as well—some
considerations to be taken into account (see Chapter 13). In particular, it is
important that step 5 be tested explicitly, though in randomly selected test cases it
will appear with a probability of only about
2
/B
(
=2
−
15
in our implementation)
(see [Knut], Section 4.3.1, Exercise 21).
In the following the given dividend
a
and divisor
b
with associated quotient
q
and remainder
r
have the effect that the program sequence associated to step 5 of
the division algorithm is run through twice, and can therefore be used as test data
for this particular case. Additional values with this property are contained in the
test program
testdiv.c
.