Cryptography Reference
In-Depth Information
To save time in the computation, instead of the initialization required above,
the partial product ( b n โˆ’ 1 b n โˆ’ 2 ...b 0 ) B
ยท
a 0 is calculated in a loop and stored in
p n ,p n โˆ’ 1 ,...,p 0 .
carry = 0;
av = *LSDPTR_L (a_l);
for (bptr_l = LSDPTR_L (b_l), pptr_l = LSDPTR_L (p_l);
bptr_l <= msdptrb_l; bptr_l++, pptr_l++)
{
*pptr_l = (USHORT)(carry = (ULONG)av * (ULONG)*bptr_l +
(ULONG)(USHORT)(carry >> BITPERDGT));
}
*pptr_l = (USHORT)(carry >> BITPERDGT);
Next follows the nested multiplication loop, beginning with the digit a_l[2] of a_l .
for (csptr_l = LSDPTR_L (p_l) + 1, aptr_l = LSDPTR_L (a_l) + 1;
aptr_l <= msdptra_l; csptr_l++, aptr_l++)
{
carry = 0;
av = *aptr_l;
for (bptr_l = LSDPTR_L (b_l), pptr_l = csptr_l;
bptr_l <= msdptrb_l; bptr_l++, pptr_l++)
{
*pptr_l = (USHORT)(carry = (ULONG)av * (ULONG)*bptr_l +
(ULONG)*pptr_l + (ULONG)(USHORT)(carry >> BITPERDGT));
}
*pptr_l = (USHORT)(carry >> BITPERDGT);
}
The largest possible length of the result is the sum of the numbers of digits of
a_l and b_l . If the result has one digit fewer, this is determined by the macro
RMLDZRS_L .
SETDIGITS_L (p_l, DIGITS_L (a_l) + DIGITS_L (b_l));
RMLDZRS_L (p_l);
If the result is larger than can be accommodated in a CLINT object, it is reduced,
and the error flag OFL is set to the value E_CLINT_OFL . Then the reduced result is
assigned to the object pp_l .
Search WWH ::




Custom Search