diff options
| author | jsing <> | 2014-10-22 13:02:04 +0000 |
|---|---|---|
| committer | jsing <> | 2014-10-22 13:02:04 +0000 |
| commit | fa457604779ff38b511fdfdae3c6a78664281c22 (patch) | |
| tree | 32d920c77e1ecf12be5fad632b9ae71343194a7c /src/lib/libcrypto/evp/evp_enc.c | |
| parent | 7ccbe9ff89c73fb88bf75fca3085b051d45f2f64 (diff) | |
| download | openbsd-fa457604779ff38b511fdfdae3c6a78664281c22.tar.gz openbsd-fa457604779ff38b511fdfdae3c6a78664281c22.tar.bz2 openbsd-fa457604779ff38b511fdfdae3c6a78664281c22.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/evp/evp_enc.c')
| -rw-r--r-- | src/lib/libcrypto/evp/evp_enc.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libcrypto/evp/evp_enc.c b/src/lib/libcrypto/evp/evp_enc.c index 4333e4dff8..49ceacefad 100644 --- a/src/lib/libcrypto/evp/evp_enc.c +++ b/src/lib/libcrypto/evp/evp_enc.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: evp_enc.c,v 1.24 2014/07/11 08:44:48 jsing Exp $ */ | 1 | /* $OpenBSD: evp_enc.c,v 1.25 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,13 +57,13 @@ | |||
| 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/opensslconf.h> | 63 | #include <openssl/opensslconf.h> |
| 63 | 64 | ||
| 64 | #include <openssl/err.h> | 65 | #include <openssl/err.h> |
| 65 | #include <openssl/evp.h> | 66 | #include <openssl/evp.h> |
| 66 | #include <openssl/rand.h> | ||
| 67 | 67 | ||
| 68 | #ifndef OPENSSL_NO_ENGINE | 68 | #ifndef OPENSSL_NO_ENGINE |
| 69 | #include <openssl/engine.h> | 69 | #include <openssl/engine.h> |
| @@ -613,8 +613,7 @@ EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key) | |||
| 613 | { | 613 | { |
| 614 | if (ctx->cipher->flags & EVP_CIPH_RAND_KEY) | 614 | if (ctx->cipher->flags & EVP_CIPH_RAND_KEY) |
| 615 | return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_RAND_KEY, 0, key); | 615 | return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_RAND_KEY, 0, key); |
| 616 | if (RAND_bytes(key, ctx->key_len) <= 0) | 616 | arc4random_buf(key, ctx->key_len); |
| 617 | return 0; | ||
| 618 | return 1; | 617 | return 1; |
| 619 | } | 618 | } |
| 620 | 619 | ||
