Cryptography Reference
In-Depth Information
Now the actual operation takes place. The loop runs over the digits of the shorter
of the two arguments.
while (s_l <= msdptrs_l)
{
*t_l++ = *r_l++ ˆ *s_l++;
}
The remaining digits of the other argument are copied as above.
while (r_l <= msdptrr_l)
{
*t_l++ = *r_l++;
}
cpy_l (c_l, d_l);
}
The function and_l() can be used to reduce a number a modulo a power of two
2 k
by setting a CLINT variable a_l to the value a ,a CLINT variable b_l to the value
2 k
1 , and executing and_l(a_l, b_l, c_l) . However, this operation executes
faster with the function mod2_l() created for this purpose, which takes into
account that the binary representation of 2 k
1 consists exclusively of ones (see
Section 4.3).
7.3 Direct Access to Individual Binary Digits
Occasionally, it is useful to be able to access individual binary digits of a number
in order to read or change them. As an example of this we might mention the
initialization of a CLINT object as a power of 2 , which can be accomplished easily
by setting a single bit.
In the following we shall develop three functions, setbit_l() , testbit_l() ,
and clearbit_l() , which set an individual bit, test a particular bit, and delete a
single bit. The functions setbit_l() and clearbit_l() each return the state of the
specified bit before the operation. The bit positions are counted from 0 , and thus
the specified positions can be understood as logarithms of powers of two: If n_l is
equal to 0 ,then setbit_l(n_l, 0) returns the value 0 , and afterwards, n_l has the
value 2 0 =1 ;afteracallto setbit_l(n_l, 512) , n_l has the value 2 512 .
 
Search WWH ::




Custom Search