Latest update.
This commit is contained in:
@@ -21,34 +21,20 @@
|
||||
*/
|
||||
int ffc_generate_private_key(BN_CTX *ctx, const FFC_PARAMS *params,
|
||||
int N, int s, BIGNUM *priv)
|
||||
{
|
||||
#ifdef FIPS_MODE
|
||||
return ffc_generate_private_key_fips(ctx, params, N, s, priv);
|
||||
#else
|
||||
do {
|
||||
if (!BN_priv_rand_range_ex(priv, params->q, ctx))
|
||||
return 0;
|
||||
} while (BN_is_zero(priv) || BN_is_one(priv));
|
||||
return 1;
|
||||
#endif /* FIPS_MODE */
|
||||
}
|
||||
|
||||
int ffc_generate_private_key_fips(BN_CTX *ctx, const FFC_PARAMS *params,
|
||||
int N, int s, BIGNUM *priv)
|
||||
{
|
||||
int ret = 0, qbits = BN_num_bits(params->q);
|
||||
BIGNUM *m, *two_powN = NULL;
|
||||
|
||||
/* Deal with the edge case where the value of N is not set */
|
||||
if (N == 0)
|
||||
N = qbits;
|
||||
if (s == 0)
|
||||
s = N / 2;
|
||||
|
||||
/* Step (2) : check range of N */
|
||||
if (N < 2 * s || N > qbits)
|
||||
return 0;
|
||||
|
||||
/* Deal with the edge case where the value of N is not set */
|
||||
if (N == 0) {
|
||||
N = qbits;
|
||||
s = N / 2;
|
||||
}
|
||||
|
||||
two_powN = BN_new();
|
||||
/* 2^N */
|
||||
if (two_powN == NULL || !BN_lshift(two_powN, BN_value_one(), N))
|
||||
|
||||
Reference in New Issue
Block a user