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/rsa/rsa_ssl.c | |
| 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/rsa/rsa_ssl.c')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_ssl.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_ssl.c b/src/lib/libcrypto/rsa/rsa_ssl.c index a5fe5004b1..73262f29c1 100644 --- a/src/lib/libcrypto/rsa/rsa_ssl.c +++ b/src/lib/libcrypto/rsa/rsa_ssl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_ssl.c,v 1.13 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: rsa_ssl.c,v 1.14 2014/10/22 13:02:04 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 | * |
| @@ -57,11 +57,11 @@ | |||
| 57 | */ | 57 | */ |
| 58 | 58 | ||
| 59 | #include <stdio.h> | 59 | #include <stdio.h> |
| 60 | #include <stdlib.h> | ||
| 60 | #include <string.h> | 61 | #include <string.h> |
| 61 | 62 | ||
| 62 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
| 63 | #include <openssl/err.h> | 64 | #include <openssl/err.h> |
| 64 | #include <openssl/rand.h> | ||
| 65 | #include <openssl/rsa.h> | 65 | #include <openssl/rsa.h> |
| 66 | 66 | ||
| 67 | int | 67 | int |
| @@ -85,13 +85,10 @@ RSA_padding_add_SSLv23(unsigned char *to, int tlen, const unsigned char *from, | |||
| 85 | /* pad out with non-zero random data */ | 85 | /* pad out with non-zero random data */ |
| 86 | j = tlen - 3 - 8 - flen; | 86 | j = tlen - 3 - 8 - flen; |
| 87 | 87 | ||
| 88 | if (RAND_bytes(p, j) <= 0) | 88 | arc4random_buf(p, j); |
| 89 | return 0; | ||
| 90 | for (i = 0; i < j; i++) { | 89 | for (i = 0; i < j; i++) { |
| 91 | while (*p == '\0') { | 90 | while (*p == '\0') |
| 92 | if (RAND_bytes(p, 1) <= 0) | 91 | arc4random_buf(p, 1); |
| 93 | return 0; | ||
| 94 | } | ||
| 95 | p++; | 92 | p++; |
| 96 | } | 93 | } |
| 97 | 94 | ||
