Cryptography Reference
In-Depth Information
Function:
modular exponentiation
int mexpk_l (CLINT bas_l, CLINT exp_l,
CLINT p_l, CLINT m_l);
Syntax:
bas_l
(base)
exp_l
(exponent)
m_l
(modulus)
Input:
p_l
(power residue)
Output:
Return:
E_CLINT_OK
if all is ok
E_CLINT_DBZ
if division by 0
E_CLINT_MAL
if
malloc()
error
We begin with a segment of the table for representing
e
i
=2
t
u
,
u
odd,
0
e
i
<
2
8
. The table is represented in the form of two vectors. The first,
twotab[]
, contains
the exponents
t
of the two-factor
2
t
, while the second,
oddtab[]
, holds the odd
part
u
of a digit
0
≤ e
i
<
2
5
. The complete table is contained, of course, in the
FLINT/C source code.
≤
static int twotab[] =
{0,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5, ...};
static USHORT oddtab[]=
{0,1,1,3,1,5,3,7,1,9,5,11,3,13,7,15,1,17,9,19,5,21,11,23,3,25,13, ...};
int
mexpk_l (CLINT bas_l, CLINT exp_l, CLINT p_l, CLINT m_l)
{
The definitions reserve memory for the exponents plus the leading zero, as well as
a pointer
clint **aptr_l
to the memory still to be allocated, which will take point-
ers to the powers of
bas_l
to be precomputed. In
acc_l
the intermediate results of
the exponentiation will be stored.