diff options
author | jsing <> | 2014-10-22 13:02:04 +0000 |
---|---|---|
committer | jsing <> | 2014-10-22 13:02:04 +0000 |
commit | a2960bc2e14b4c5f7d8f78d2a69ebb537ca4afa8 (patch) | |
tree | 32d920c77e1ecf12be5fad632b9ae71343194a7c /src/lib/libcrypto/bio | |
parent | 5a6d7fd5a10b0ad084948463b25822d91091b325 (diff) | |
download | openbsd-a2960bc2e14b4c5f7d8f78d2a69ebb537ca4afa8.tar.gz openbsd-a2960bc2e14b4c5f7d8f78d2a69ebb537ca4afa8.tar.bz2 openbsd-a2960bc2e14b4c5f7d8f78d2a69ebb537ca4afa8.zip |
Use arc4random_buf() instead of RAND_bytes() or RAND_pseudo_bytes().
arc4random_buf() is guaranteed to always succeed - it is worth noting
that a number of the replaced function calls were already missing return
value checks.
ok deraadt@
Diffstat (limited to 'src/lib/libcrypto/bio')
-rw-r--r-- | src/lib/libcrypto/bio/bf_nbio.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/libcrypto/bio/bf_nbio.c b/src/lib/libcrypto/bio/bf_nbio.c index 86a13a8bc8..a86feb49c2 100644 --- a/src/lib/libcrypto/bio/bf_nbio.c +++ b/src/lib/libcrypto/bio/bf_nbio.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bf_nbio.c,v 1.17 2014/07/11 08:44:47 jsing Exp $ */ | 1 | /* $OpenBSD: bf_nbio.c,v 1.18 2014/10/22 13:02:03 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 | * |
@@ -58,9 +58,9 @@ | |||
58 | 58 | ||
59 | #include <errno.h> | 59 | #include <errno.h> |
60 | #include <stdio.h> | 60 | #include <stdio.h> |
61 | #include <stdlib.h> | ||
61 | 62 | ||
62 | #include <openssl/bio.h> | 63 | #include <openssl/bio.h> |
63 | #include <openssl/rand.h> | ||
64 | 64 | ||
65 | /* BIO_put and BIO_get both add to the digest, | 65 | /* BIO_put and BIO_get both add to the digest, |
66 | * BIO_gets returns the digest */ | 66 | * BIO_gets returns the digest */ |
@@ -142,7 +142,7 @@ nbiof_read(BIO *b, char *out, int outl) | |||
142 | 142 | ||
143 | BIO_clear_retry_flags(b); | 143 | BIO_clear_retry_flags(b); |
144 | #if 1 | 144 | #if 1 |
145 | RAND_pseudo_bytes(&n, 1); | 145 | arc4random_buf(&n, 1); |
146 | num = (n & 0x07); | 146 | num = (n & 0x07); |
147 | 147 | ||
148 | if (outl > num) | 148 | if (outl > num) |
@@ -182,7 +182,7 @@ nbiof_write(BIO *b, const char *in, int inl) | |||
182 | num = nt->lwn; | 182 | num = nt->lwn; |
183 | nt->lwn = 0; | 183 | nt->lwn = 0; |
184 | } else { | 184 | } else { |
185 | RAND_pseudo_bytes(&n, 1); | 185 | arc4random_buf(&n, 1); |
186 | num = (n&7); | 186 | num = (n&7); |
187 | } | 187 | } |
188 | 188 | ||