Commit 2301d91d authored by Rich Salz's avatar Rich Salz
Browse files

Change callers to use the new constants.

parent f67cbb74
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1089,7 +1089,7 @@ int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[],
        if (tmp == NULL)
        if (tmp == NULL)
            goto err;
            goto err;
        do {
        do {
            if (!BN_rand(rho, p[0], 0, 0))
            if (!BN_rand(rho, p[0], BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
                goto err;
                goto err;
            if (!BN_GF2m_mod_arr(rho, rho, p))
            if (!BN_GF2m_mod_arr(rho, rho, p))
                goto err;
                goto err;
+6 −5
Original line number Original line Diff line number Diff line
@@ -310,7 +310,7 @@ int bn_probable_prime_dh_retry(BIGNUM *rnd, int bits, BN_CTX *ctx)
    int ret = 0;
    int ret = 0;


 loop:
 loop:
    if (!BN_rand(rnd, bits, 0, 1))
    if (!BN_rand(rnd, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
        goto err;
        goto err;


    /* we now have a random number 'rand' to test. */
    /* we now have a random number 'rand' to test. */
@@ -350,7 +350,8 @@ int bn_probable_prime_dh_coprime(BIGNUM *rnd, int bits, BN_CTX *ctx)
        goto err;
        goto err;


 loop:
 loop:
    if (!BN_rand(rnd, bits - prime_multiplier_bits, 0, 1))
    if (!BN_rand(rnd, bits - prime_multiplier_bits,
                 BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
        goto err;
        goto err;
    if (BN_is_bit_set(rnd, bits))
    if (BN_is_bit_set(rnd, bits))
        goto loop;
        goto loop;
@@ -415,7 +416,7 @@ static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods)
    char is_single_word = bits <= BN_BITS2;
    char is_single_word = bits <= BN_BITS2;


 again:
 again:
    if (!BN_rand(rnd, bits, 1, 1))
    if (!BN_rand(rnd, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ODD))
        return (0);
        return (0);
    /* we now have a random number 'rnd' to test. */
    /* we now have a random number 'rnd' to test. */
    for (i = 1; i < NUMPRIMES; i++) {
    for (i = 1; i < NUMPRIMES; i++) {
@@ -499,7 +500,7 @@ int bn_probable_prime_dh(BIGNUM *rnd, int bits,
    if ((t1 = BN_CTX_get(ctx)) == NULL)
    if ((t1 = BN_CTX_get(ctx)) == NULL)
        goto err;
        goto err;


    if (!BN_rand(rnd, bits, 0, 1))
    if (!BN_rand(rnd, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
        goto err;
        goto err;


    /* we need ((rnd-rem) % add) == 0 */
    /* we need ((rnd-rem) % add) == 0 */
@@ -555,7 +556,7 @@ static int probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd,
    if (!BN_rshift1(qadd, padd))
    if (!BN_rshift1(qadd, padd))
        goto err;
        goto err;


    if (!BN_rand(q, bits, 0, 1))
    if (!BN_rand(q, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD))
        goto err;
        goto err;


    /* we need ((rnd-rem) % add) == 0 */
    /* we need ((rnd-rem) % add) == 0 */
+2 −2
Original line number Original line Diff line number Diff line
@@ -130,7 +130,7 @@ static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range)
         * than range
         * than range
         */
         */
        do {
        do {
            if (!bn_rand(r, n + 1, -1, 0))
            if (!bn_rand(r, n + 1, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
                return 0;
                return 0;
            /*
            /*
             * If r < 3*range, use r := r MOD range (which is either r, r -
             * If r < 3*range, use r := r MOD range (which is either r, r -
@@ -156,7 +156,7 @@ static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range)
    } else {
    } else {
        do {
        do {
            /* range = 11..._2  or  range = 101..._2 */
            /* range = 11..._2  or  range = 101..._2 */
            if (!bn_rand(r, n, -1, 0))
            if (!bn_rand(r, n, BN_RAND_TOP_ANY, BN_RAND_BOTTOM_ANY))
                return 0;
                return 0;


            if (!--count) {
            if (!--count) {
+4 −4
Original line number Original line Diff line number Diff line
@@ -170,14 +170,14 @@ int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx)
     * - 1. By setting the top two bits we ensure that the lower bound is
     * - 1. By setting the top two bits we ensure that the lower bound is
     * exceeded.
     * exceeded.
     */
     */
    if (!BN_rand(Xp, nbits, 1, 0))
    if (!BN_rand(Xp, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))
        goto err;
        goto err;


    BN_CTX_start(ctx);
    BN_CTX_start(ctx);
    t = BN_CTX_get(ctx);
    t = BN_CTX_get(ctx);


    for (i = 0; i < 1000; i++) {
    for (i = 0; i < 1000; i++) {
        if (!BN_rand(Xq, nbits, 1, 0))
        if (!BN_rand(Xq, nbits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ANY))
            goto err;
            goto err;
        /* Check that |Xp - Xq| > 2^(nbits - 100) */
        /* Check that |Xp - Xq| > 2^(nbits - 100) */
        BN_sub(t, Xp, Xq);
        BN_sub(t, Xp, Xq);
@@ -218,9 +218,9 @@ int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2,
    if (!Xp2)
    if (!Xp2)
        Xp2 = BN_CTX_get(ctx);
        Xp2 = BN_CTX_get(ctx);


    if (!BN_rand(Xp1, 101, 0, 0))
    if (!BN_rand(Xp1, 101, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
        goto error;
        goto error;
    if (!BN_rand(Xp2, 101, 0, 0))
    if (!BN_rand(Xp2, 101, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
        goto error;
        goto error;
    if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb))
    if (!BN_X931_derive_prime_ex(p, p1, p2, Xp, Xp1, Xp2, e, ctx, cb))
        goto error;
        goto error;
+1 −1
Original line number Original line Diff line number Diff line
@@ -106,7 +106,7 @@ static int generate_key(DH *dh)
        } else {
        } else {
            /* secret exponent length */
            /* secret exponent length */
            l = dh->length ? dh->length : BN_num_bits(dh->p) - 1;
            l = dh->length ? dh->length : BN_num_bits(dh->p) - 1;
            if (!BN_rand(priv_key, l, 0, 0))
            if (!BN_rand(priv_key, l, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
                goto err;
                goto err;
        }
        }
    }
    }
Loading