Cryptography Reference
In-Depth Information
cpy_l (a_l, aa_l);
if (EQZ_L (a_l) || 0 == b)
{
SETZERO_L (pp_l);
return E_CLINT_OK;
}
After these preliminaries, the CLINT factor is multiplied in a pass through a loop by
the USHORT factor, and at the end the carry is stored in the most-significant USHORT
digit of the CLINT value.
msdptra_l = MSDPTR_L (a_l);
carry = 0;
for (aptr_l = LSDPTR_L (a_l), pptr_l = LSDPTR_l (p_l);
aptr_l <= msdptra_l; aptr_l++, pptr_l++)
{
*pptr_l = (USHORT)(carry = (ULONG)b * (ULONG)*aptr_l +
(ULONG)(USHORT)(carry >> BITPERDGT));
}
*pptr_l = (USHORT)(carry >> BITPERDGT);
SETDIGITS_L (p_l, DIGITS_L (a_l) + 1);
RMLDZRS_L (p_l);
if (DIGITS_L (p_l) > (USHORT)CLINTMAXDIGIT)
/* overflow ? */
{
ANDMAX_L (p_l);
/* reduce modulo (Nmax + 1) */
OFL = E_CLINT_OFL;
}
cpy_l (pp_l, p_l);
return OFL;
}
4.2.2 Squaring Is Faster
The calculation of a large square is accomplished with significantly fewer
multiplications than in the case of the multiplication of large numbers. This
is a result of the symmetry in the multiplication of identical operands. This
observation is very important, since when it comes to exponentiation, which
involves not one, but hundreds, of squarings, we shall be able to achieve
considerable savings in speed. We again look at the well-known multiplication
schema, this time with two identical factors ( a 2 a 1 a 0 ) B
(see Figure 4-2).
 
Search WWH ::




Custom Search