Cryptography Reference
In-Depth Information
Step 1: Initialization of the variables.
cpy_l (g_l, a_l);
cpy_l (v3_l, n_l);
SETZERO_L (v1_l);
SETONE_L (t1_l);
do
{
Step 2: With the test in
GTZ_L (t3_l)
after the division an unnecessary call to
mmul_l()
and
msub_l()
is avoided in the last run through the loop. The assignment
to the result variable
i_l
is not carried out until the end.
div_l (g_l, v3_l, q_l, t3_l);
if (GTZ_L (t3_l))
{
mmul_l (v1_l, q_l, q_l, n_l);
msub_l (t1_l, q_l, q_l, n_l);
cpy_l (t1_l, v1_l);
cpy_l (v1_l, q_l);
cpy_l (g_l, v3_l);
cpy_l (v3_l, t3_l);
}
}
while (GTZ_L (t3_l));
Step 3: As the last requisite assignment we take the greatest common divisor from
the variable
v3_l
, and if the greatest common divisor is equal to 1, we take the
inverse to
a_l
from the variable
v1_l
.
cpy_l (g_l, v3_l);
if (EQONE_L (g_l))
{
cpy_l (i_l, v1_l);
}
else
{
SETZERO_L (i_l);
}
}