Cryptography Reference
In-Depth Information
remainder modulo a power of 2 (reduction modulo 2 k )
Function:
int mod2_l (CLINT d_l, ULONG k, CLINT r_l);
Syntax:
d_l (dividend), k (exponent of the divisor or modulus)
Input:
Return:
r_l (remainder)
int
mod2_l (CLINT d_l, ULONG k, CLINT r_l)
{
int i;
Since 2 k > 0 , there is no test for division by 0 . First d_l is copied to r_l and a test
is made as to whether k exceeds the maximal binary length of a CLINT number, in
which case the function is terminated.
cpy_l (r_l, d_l);
if (k > CLINTMAXBIT)
return E_CLINT_OK;
The digit in r_l in which something changes is determined and is stored as an
index in i .If i is greater than the number of digits of r_l ,thenwearedone.
i=1+(k>>LDBITPERDGT);
if (i > DIGITS_L (r_l))
return E_CLINT_OK;
Now the determined digit of r_l (counting from 1) is joined by a logical AND to
the value 2 k mod BITPERDGT
1 ( =2 k mod16
1 in this implementation). The new
length i of r_l is stored in r_l[0] . After the removal of leading zeros the function
is terminated.
 
Search WWH ::




Custom Search