diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_rand.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c index 4626960a0d..f94ce1dceb 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.23 2020/09/12 15:24:39 tb Exp $ */ | 1 | /* $OpenBSD: bn_rand.c,v 1.24 2020/09/12 17:16:36 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 | * |
| @@ -171,18 +171,16 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) | |||
| 171 | } | 171 | } |
| 172 | #endif | 172 | #endif |
| 173 | 173 | ||
| 174 | if (top >= 0) { | 174 | if (top > 0) { |
| 175 | if (top > 0) { | 175 | if (bit == 0) { |
| 176 | if (bit == 0) { | 176 | buf[0] = 1; |
| 177 | buf[0] = 1; | 177 | buf[1] |= 0x80; |
| 178 | buf[1] |= 0x80; | ||
| 179 | } else { | ||
| 180 | buf[0] |= (3 << (bit - 1)); | ||
| 181 | } | ||
| 182 | } else { | 178 | } else { |
| 183 | buf[0] |= (1 << bit); | 179 | buf[0] |= (3 << (bit - 1)); |
| 184 | } | 180 | } |
| 185 | } | 181 | } |
| 182 | if (top == 0) | ||
| 183 | buf[0] |= (1 << bit); | ||
| 186 | buf[0] &= ~mask; | 184 | buf[0] &= ~mask; |
| 187 | if (bottom) /* set bottom bit if requested */ | 185 | if (bottom) /* set bottom bit if requested */ |
| 188 | buf[bytes - 1] |= 1; | 186 | buf[bytes - 1] |= 1; |
