diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_rand.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c index df798f41bc..4626960a0d 100644 --- a/src/lib/libcrypto/bn/bn_rand.c +++ b/src/lib/libcrypto/bn/bn_rand.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_rand.c,v 1.22 2018/11/06 06:49:45 tb Exp $ */ | 1 | /* $OpenBSD: bn_rand.c,v 1.23 2020/09/12 15:24:39 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -129,6 +129,11 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) | |||
| 129 | return (0); | 129 | return (0); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | if (bits < 0 || (bits == 1 && top > 0)) { | ||
| 133 | BNerror(BN_R_BITS_TOO_SMALL); | ||
| 134 | return (0); | ||
| 135 | } | ||
| 136 | |||
| 132 | if (bits == 0) { | 137 | if (bits == 0) { |
| 133 | BN_zero(rnd); | 138 | BN_zero(rnd); |
| 134 | return (1); | 139 | return (1); |
| @@ -166,8 +171,8 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) | |||
| 166 | } | 171 | } |
| 167 | #endif | 172 | #endif |
| 168 | 173 | ||
| 169 | if (top != -1) { | 174 | if (top >= 0) { |
| 170 | if (top) { | 175 | if (top > 0) { |
| 171 | if (bit == 0) { | 176 | if (bit == 0) { |
| 172 | buf[0] = 1; | 177 | buf[0] = 1; |
| 173 | buf[1] |= 0x80; | 178 | buf[1] |= 0x80; |
