Cryptography Reference
In-Depth Information
The quotient digit is stored, subject to a possible necessary correction.
*qptr_l = qhat;
As promised, now a test is made as to whether the quotient digit is too large by
1 . This is extremely seldom the case (further below, special test data will be pre-
sented) and is indicated by the high-valued word of the ULONG variable borrow
being equal to zero; that is, that borrow < BASE . If this is the case, then u ← u + b
modulo B n +1 is calculated (notation as above).
if (borrow < BASE)
{
carry = 0;
for (bptr_l = LSDPTR_L (b_l), rptr_l = lsdptrr_l;
bptr_l <= msdptrb_l; bptr_l++, rptr_l++)
{
*rptr_l = (USHORT)(carry = ((ULONG)*rptr_l + (ULONG)(*bptr_l) +
(ULONG)(USHORT)(carry >> BITPERDGT)));
}
*rptr_l += (USHORT)(carry >> BITPERDGT);
(*qptr_l)--;
}
Now the pointers are set to the remainder and the quotient, and we return to the
beginning of the main loop.
msdptrr_l--;
lsdptrr_l--;
qptr_l--;
}
The length of the remainder and that of the quotient are determined. The
number of digits is at most 1 more than the number of digits of the dividend
minus the number of digits of the divisor. The remainder possesses at most the
number of digits of the divisor. In both cases the exact length is set by the removal
of leading zeros.
Search WWH ::




Custom Search