Cryptography Reference
In-Depth Information
case FLINT_RND64:
rand_l (r_l, MIN (l, (int)CLINTMAXBIT));
error = rand_l (r_l, MIN (l, (int)CLINTMAXBIT));
break;
default:
return E_CLINT_RNG;
}
if (E_CLINT_OK != error)
{
return error;
}
Calculate
r_l mod t_l + rmin_l
.
mod_l (r_l, t_l, r_l);
add_l (r_l, rmin_l, r_l);
return error;
}
With the help of the function
RandMinMax_l()
, we can begin our search for
prime numbers
p
that lie within the interval
[
r
min
,r
max
]
and that satisfy the
additional condition that
p −
1
is relatively prime to a specified number
f
.We
search for these numbers with the following algorithm and associated function
FindPrimeMinMaxGcd_l()
:
Algorithm for determining a random prime number
p
with
r
min
≤
p
≤
r
max
that satisfies the additional condition
gcd(
p −
1
,f
)=1
, after [IEEE]
1.
Set
k
min
←
(
r
min
−
1)
/
2
and
k
max
←
(
r
max
−
1)
/
2
.
2.
Generate randomly an integer
k
satisfying
k
min
≤ k ≤ k
max
.
3.
Set
p ←
2
k
+1
.
4.
Compute
d ←
gcd(
p −
1
,f
)
.
5.
If
d
=1
, test
p
for primality. If
p
is prime, set
d ←
gcd(
p −
1
,f
)
. Otherwise,
go to step 2.