Cryptography Reference
In-Depth Information
The FLINT/C package contains the additional functions
ucrand64_l(void)
and
usrand64_l(void)
, which generate random numbers of types
UCHAR
and
USHORT
, respectively. However, we shall not discuss them here. We now present the
function
rand_l()
, which generates large random numbers of
CLINT
type, with the
number of binary digits to be specified.
generation of a random number of type
CLINT
Function:
void rand_l (CLINT r_l, int l);
Syntax:
l
(number of binary digits of the number to be
generated)
Input:
r_l
(random number in the interval
2
l
−
1
2
l
≤
r_l
≤
−
1
)
Output:
void
rand_l (CLINT r_l, int l)
{
USHORT i, j, ls, lr;
The requested number of binary digits
l
is first bounded by the maximum permit-
ted value for
CLINT
objects. Then the number
ls
of required
USHORT
digits and the
position
lr
of the most-significant binary digit of the most-significant
USHORT
are
determined.
l = MIN (l, CLINTMAXBIT);
ls = (USHORT)l >> LDBITPERDGT;
lr = (USHORT)l & (BITPERDGT - 1UL);
Now the digits of
r_l
are generated by successive calls to the function
usrand64_l()
. The least-significant binary digits of
SEED64
are therefore not used
for the construction of
CLINT
digits.
for (i = 1; i <= ls; i++)
{
r_l[i] = usrand64_l ();
}
Now follows the precise manufacture of
r_l
by setting the most-significant bit in
position
lr
1
of the
(
ls
+1)
st
USHORT
digit to
1
and the most-significant bits to
0
.If
lr == 0
, then the most-significant bit of the
USHORT
digit
ls
is set to 1.
−