rename rand_bn_range() to rand_bn_upto()
This commit is contained in:
parent
22919cd4f2
commit
4221c44fbc
@ -25,7 +25,7 @@ int rand_prime(void *N, long len, prng_state *prng, int wprng);
|
||||
#ifdef LTC_SOURCE
|
||||
/* internal helper functions */
|
||||
int rand_bn_bits(void *N, int bits, prng_state *prng, int wprng);
|
||||
int rand_bn_range(void *N, void *limit, prng_state *prng, int wprng);
|
||||
int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng);
|
||||
|
||||
enum public_key_algorithms {
|
||||
PKA_RSA,
|
||||
|
@ -53,7 +53,7 @@ cleanup:
|
||||
/**
|
||||
Generate a random number N in a range: 1 <= N < limit
|
||||
*/
|
||||
int rand_bn_range(void *N, void *limit, prng_state *prng, int wprng)
|
||||
int rand_bn_upto(void *N, void *limit, prng_state *prng, int wprng)
|
||||
{
|
||||
int res, bits;
|
||||
|
||||
|
@ -76,7 +76,7 @@ int dsa_encrypt_key(const unsigned char *in, unsigned long inlen,
|
||||
/* make a random g_priv, g_pub = g^x pair
|
||||
private key x should be in range: 1 <= x <= q-1 (see FIPS 186-4 B.1.2)
|
||||
*/
|
||||
if ((err = rand_bn_range(g_priv, key->q, prng, wprng)) != CRYPT_OK) {
|
||||
if ((err = rand_bn_upto(g_priv, key->q, prng, wprng)) != CRYPT_OK) {
|
||||
goto LBL_ERR;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ int dsa_generate_key(prng_state *prng, int wprng, dsa_key *key)
|
||||
Now we need a random exponent [mod q] and it's power g^x mod p
|
||||
*/
|
||||
/* private key x should be from range: 1 <= x <= q-1 (see FIPS 186-4 B.1.2) */
|
||||
if ((err = rand_bn_range(key->x, key->q, prng, wprng)) != CRYPT_OK) { return err; }
|
||||
if ((err = rand_bn_upto(key->x, key->q, prng, wprng)) != CRYPT_OK) { return err; }
|
||||
if ((err = mp_exptmod(key->g, key->x, key->p, key->y)) != CRYPT_OK) { return err; }
|
||||
key->type = PK_PRIVATE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user