Cryptography Reference
In-Depth Information
Next, the optimal value for k is determined; the value 2 k
is stored in pow2k ,and
in k_mask the value 2 k
1 . For this the function ld_l() is used, which returns the
number of binary digits of its argument.
lge = ld_l (e_l);
k=8;
while (k>1&&((k-1)*(k<<((k-1)<<1))/((1 <<k)-k-1))>=lge-1)
{
--k;
}
pow2k = 1U << k;
k_mask = pow2k - 1U;
Memory is allocated for the pointers to the powers of a_l to be computed. The
base a_l is reduced modulo m_l .
if ((aptr_l = (clint **) malloc (sizeof(clint *) * pow2k)) == NULL)
{
return E_CLINT_MAL;
}
mod_l (a_l, m_l, a_l);
aptr_l[1] = a_l;
If k> 1 , then memory is allocated for the powers to be computed. This is not nec-
essary for k =1 , since then no powers have to be precomputed. In the following
setting of the pointer aptr_l[i] one should note that in the addition of an offset
to a pointer p a scaling of the offset by the compiler takes place, so that it counts
objects of the pointer type of p .
We have already mentioned that the allocation of working memory can be car-
ried out alternatively in a one-time initialization. The pointers to the CLINT objects
would in this case be contained in global variables outside of the function or in
static variables within mexpk_l() .
Search WWH ::




Custom Search