diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/bn/bn_rand.c | 11 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/bn/bn_rand.c | 11 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/libcrypto/bn/bn_rand.c b/src/lib/libcrypto/bn/bn_rand.c index 334c65dd57..ac5c5eb308 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.16 2014/10/22 13:02:04 jsing Exp $ */ | 1 | /* $OpenBSD: bn_rand.c,v 1.17 2015/02/19 06:10:29 jsing 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 | * |
@@ -123,9 +123,14 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) | |||
123 | unsigned char *buf = NULL; | 123 | unsigned char *buf = NULL; |
124 | int ret = 0, bit, bytes, mask; | 124 | int ret = 0, bit, bytes, mask; |
125 | 125 | ||
126 | if (rnd == NULL) { | ||
127 | BNerr(BN_F_BNRAND, ERR_R_PASSED_NULL_PARAMETER); | ||
128 | return (0); | ||
129 | } | ||
130 | |||
126 | if (bits == 0) { | 131 | if (bits == 0) { |
127 | BN_zero(rnd); | 132 | BN_zero(rnd); |
128 | return 1; | 133 | return (1); |
129 | } | 134 | } |
130 | 135 | ||
131 | bytes = (bits + 7) / 8; | 136 | bytes = (bits + 7) / 8; |
@@ -175,7 +180,7 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) | |||
175 | buf[0] &= ~mask; | 180 | buf[0] &= ~mask; |
176 | if (bottom) /* set bottom bit if requested */ | 181 | if (bottom) /* set bottom bit if requested */ |
177 | buf[bytes - 1] |= 1; | 182 | buf[bytes - 1] |= 1; |
178 | if (!BN_bin2bn(buf, bytes, rnd)) | 183 | if (BN_bin2bn(buf, bytes, rnd) == NULL) |
179 | goto err; | 184 | goto err; |
180 | ret = 1; | 185 | ret = 1; |
181 | 186 | ||
diff --git a/src/lib/libssl/src/crypto/bn/bn_rand.c b/src/lib/libssl/src/crypto/bn/bn_rand.c index 334c65dd57..ac5c5eb308 100644 --- a/src/lib/libssl/src/crypto/bn/bn_rand.c +++ b/src/lib/libssl/src/crypto/bn/bn_rand.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_rand.c,v 1.16 2014/10/22 13:02:04 jsing Exp $ */ | 1 | /* $OpenBSD: bn_rand.c,v 1.17 2015/02/19 06:10:29 jsing 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 | * |
@@ -123,9 +123,14 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) | |||
123 | unsigned char *buf = NULL; | 123 | unsigned char *buf = NULL; |
124 | int ret = 0, bit, bytes, mask; | 124 | int ret = 0, bit, bytes, mask; |
125 | 125 | ||
126 | if (rnd == NULL) { | ||
127 | BNerr(BN_F_BNRAND, ERR_R_PASSED_NULL_PARAMETER); | ||
128 | return (0); | ||
129 | } | ||
130 | |||
126 | if (bits == 0) { | 131 | if (bits == 0) { |
127 | BN_zero(rnd); | 132 | BN_zero(rnd); |
128 | return 1; | 133 | return (1); |
129 | } | 134 | } |
130 | 135 | ||
131 | bytes = (bits + 7) / 8; | 136 | bytes = (bits + 7) / 8; |
@@ -175,7 +180,7 @@ bnrand(int pseudorand, BIGNUM *rnd, int bits, int top, int bottom) | |||
175 | buf[0] &= ~mask; | 180 | buf[0] &= ~mask; |
176 | if (bottom) /* set bottom bit if requested */ | 181 | if (bottom) /* set bottom bit if requested */ |
177 | buf[bytes - 1] |= 1; | 182 | buf[bytes - 1] |= 1; |
178 | if (!BN_bin2bn(buf, bytes, rnd)) | 183 | if (BN_bin2bn(buf, bytes, rnd) == NULL) |
179 | goto err; | 184 | goto err; |
180 | ret = 1; | 185 | ret = 1; |
181 | 186 | ||