summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2020-09-12 17:16:36 +0000
committertb <>2020-09-12 17:16:36 +0000
commitf43b806e9c49f2808400fc8ecb084846433c8052 (patch)
tree16675833860d75c5220218c8781e2b9df8251406 /src
parentaff767284618e4bdc4cd19a50549d4be09b39c36 (diff)
downloadopenbsd-f43b806e9c49f2808400fc8ecb084846433c8052.tar.gz
openbsd-f43b806e9c49f2808400fc8ecb084846433c8052.tar.bz2
openbsd-f43b806e9c49f2808400fc8ecb084846433c8052.zip
Unindent a bit of code that performs a few too many checks to
figure out whether top > 0 or top == 0.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_rand.c18
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;