Cryptography Reference
In-Depth Information
for (i = DIGITS_L (t_l) + 1; i <= (DIGITS_L (n_l) << 1); i++)
{
t_l[i] = 0;
}
SETDIGITS_L (t_l, MAX (DIGITS_L (t_l), DIGITS_L (n_l) << 1));
Within the following double loop the partial products m i nB i with m i := t i n 0 are
calculated one after the other and added to t_l . Here again the code is essentially
that of our multiplication function.
for (tptr_l = LSDPTR_L (t_l); tptr_l <= lasttnptr; tptr_l++)
{
carry = 0;
mi = (USHORT)((ULONG)nprime * (ULONG)*tptr_l);
for (nptr_l = LSDPTR_L (n_l), tiptr_l = tptr_l;
nptr_l <= lastnptr; nptr_l++, tiptr_l++)
{
*tiptr_l = (USHORT)(carry = (ULONG)mi * (ULONG)*nptr_l +
(ULONG)*tiptr_l + (ULONG)(USHORT)(carry >> BITPERDGT));
}
In the following inner loop a possible overflow is transported to the most-
significant digit of t_l ,and t_l contains an additional digit in case it is needed.
This step is essential, since at the start of the main loop t_l was given a value and
not initialized via multiplication by 0 as was the variable p_l .
for(;
((carry >> BITPERDGT) > 0) && tiptr_l <= MSDPTR_L (t_l);
tiptr_l++)
{
*tiptr_l = (USHORT)(carry = (ULONG)*tiptr_l +
(ULONG)(USHORT)(carry >> BITPERDGT));
}
if (((carry >> BITPERDGT) > 0))
{
*tiptr_l = (USHORT)(carry >> BITPERDGT);
INCDIGITS_L (t_l);
}
}
Search WWH ::




Custom Search