Cryptography Reference
In-Depth Information
l2 = len_a/2;
a1ptr_l = aptr_l + l2;
b1ptr_l = bptr_l + l2;
kmul (aptr_l, bptr_l, l2, l2, c0_l);
kmul (a1ptr_l, b1ptr_l, l2, l2, c1_l);
The value
c
2
:= (
a
0
+
a
1
)(
b
0
+
b
1
)
− c
0
− c
1
is computed with two additions, a
call to
kmul()
, and two subtractions. The auxiliary function
addkar()
takes pointers
to the least-significant digits of two equally long summands together with their
number of digits, and outputs the sum of the two as a
CLINT
value.
addkar (a1ptr_l, aptr_l, l2, c01_l);
addkar (b1ptr_l, bptr_l, l2, c10_l);
kmul (LSDPTR_L (c01_l), LSDPTR_L (c10_l),
DIGITS_L (c01_l), DIGITS_L (c10_l), c2_l);
sub (c2_l, c1_l, tmp_l);
sub (tmp_l, c0_l, c2_l);
The function branch ends with the calculation of
B
k
B
k
c
1
+
c
2
+
c
0
, which
used the auxiliary function
shiftadd()
, which during the addition left shifts the
first of the two
CLINT
summands by a given number of places to base
B
.
shiftadd (c1_l, c2_l, l2, tmp_l);
shiftadd (tmp_l, c0_l, l2, p_l);
}
If one of the input conditions is not fulfilled, the recursion is interrupted and the
nonrecursive multiplication
mult()
is called. As a requirement for calling
mult()
the two factor halves in
aptr_l
and
bptr_l
are brought into
CLINT
format.
else
{
memcpy (LSDPTR_L (c1_l), aptr_l, len_a * sizeof (clint));
memcpy (LSDPTR_L (c2_l), bptr_l, len_b * sizeof (clint));
SETDIGITS_L (c1_l, len_a);
SETDIGITS_L (c2_l, len_b);
mult (c1_l, c2_l, p_l);
RMLDZRS_L (p_l);
}
}