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_oaep.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_oaep.c')
| -rw-r--r-- | src/lib/libcrypto/rsa/rsa_oaep.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libcrypto/rsa/rsa_oaep.c b/src/lib/libcrypto/rsa/rsa_oaep.c index 9be0f9be31..8585d7c3aa 100644 --- a/src/lib/libcrypto/rsa/rsa_oaep.c +++ b/src/lib/libcrypto/rsa/rsa_oaep.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rsa_oaep.c,v 1.23 2014/07/11 08:44:49 jsing Exp $ */ | 1 | /* $OpenBSD: rsa_oaep.c,v 1.24 2014/10/22 13:02:04 jsing Exp $ */ |
| 2 | /* Written by Ulf Moeller. This software is distributed on an "AS IS" | 2 | /* Written by Ulf Moeller. This software is distributed on an "AS IS" |
| 3 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ | 3 | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. */ |
| 4 | 4 | ||
| @@ -19,6 +19,7 @@ | |||
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | #include <stdio.h> | 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> | ||
| 22 | #include <string.h> | 23 | #include <string.h> |
| 23 | 24 | ||
| 24 | #include <openssl/opensslconf.h> | 25 | #include <openssl/opensslconf.h> |
| @@ -28,7 +29,6 @@ | |||
| 28 | #include <openssl/bn.h> | 29 | #include <openssl/bn.h> |
| 29 | #include <openssl/err.h> | 30 | #include <openssl/err.h> |
| 30 | #include <openssl/evp.h> | 31 | #include <openssl/evp.h> |
| 31 | #include <openssl/rand.h> | ||
| 32 | #include <openssl/rsa.h> | 32 | #include <openssl/rsa.h> |
| 33 | #include <openssl/sha.h> | 33 | #include <openssl/sha.h> |
| 34 | 34 | ||
| @@ -65,8 +65,7 @@ RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, | |||
| 65 | emlen - flen - 2 * SHA_DIGEST_LENGTH - 1); | 65 | emlen - flen - 2 * SHA_DIGEST_LENGTH - 1); |
| 66 | db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01; | 66 | db[emlen - flen - SHA_DIGEST_LENGTH - 1] = 0x01; |
| 67 | memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, flen); | 67 | memcpy(db + emlen - flen - SHA_DIGEST_LENGTH, from, flen); |
| 68 | if (RAND_bytes(seed, SHA_DIGEST_LENGTH) <= 0) | 68 | arc4random_buf(seed, SHA_DIGEST_LENGTH); |
| 69 | return 0; | ||
| 70 | 69 | ||
| 71 | dbmask = malloc(emlen - SHA_DIGEST_LENGTH); | 70 | dbmask = malloc(emlen - SHA_DIGEST_LENGTH); |
| 72 | if (dbmask == NULL) { | 71 | if (dbmask == NULL) { |
