Cryptography Reference
In-Depth Information
if ((resl < 0) || (resl > (long) CLINTMAXBIT))
{
error = ((resl < 0) ? E_CLINT_UFL : E_CLINT_OFL); /*underflow or overflow*/
}
msdptrn_l = MSDPTR_L (n_l);
if (noofbits < 0)
{
If
noofbits
<
0
, then
n_l
is divided by
2
noofbits
. The number of digits of
n_l
to
shift is bounded by
DIGITS_L
(
n_l
). First the whole digits are shifted, and then the
remaining bits with
shr_l()
.
shorts = MIN (DIGITS_L (n_l), shorts);
msdptrn_l = MSDPTR_L (n_l) - shorts;
for (nptr_l = LSDPTR_L (n_l); nptr_l <= msdptrn_l; nptr_l++)
{
*nptr_l = *(nptr_l + shorts);
}
SETDIGITS_L (n_l, DIGITS_L (n_l) - (USHORT)shorts);
for (i = 0; i < bits; i++)
{
shr_l (n_l);
}
}
else
{
If
noofbits
>
0
,then
n_l
is multiplied by
2
noofbits
. If the number
shorts
of digits
to be shifted is greater than
MAX
B
, then the result is zero. Otherwise, first the
number of digits of the new value is determined and stored, and then the whole
digits are shifted, and the freed-up digits filled with zeros. To avoid an overflow the
start position is limited by
n_l
+ MAX
B
and stored in
nptr_l
. As before, the last
bits are shifted individually, here with
shl_l()
.