summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/evp/evp_enc.c
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2014-10-22 13:02:03 +0000
committerjsing <jsing@openbsd.org>2014-10-22 13:02:03 +0000
commitef624301d95e1d2367e46a80103e7ba867cb892f (patch)
treee7fb573ba5a2197cf6381ea6fe87308de30b6b53 /lib/libcrypto/evp/evp_enc.c
parentIntroduce a special hack for carp during IPv6 source address selection: (diff)
downloadwireguard-openbsd-ef624301d95e1d2367e46a80103e7ba867cb892f.tar.xz
wireguard-openbsd-ef624301d95e1d2367e46a80103e7ba867cb892f.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 'lib/libcrypto/evp/evp_enc.c')
-rw-r--r--lib/libcrypto/evp/evp_enc.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/libcrypto/evp/evp_enc.c b/lib/libcrypto/evp/evp_enc.c
index 4333e4dff82..49ceacefad1 100644
--- a/lib/libcrypto/evp/evp_enc.c
+++ b/lib/libcrypto/evp/evp_enc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: evp_enc.c,v 1.24 2014/07/11 08:44:48 jsing Exp $ */
+/* $OpenBSD: evp_enc.c,v 1.25 2014/10/22 13:02:04 jsing Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -57,13 +57,13 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <openssl/opensslconf.h>
#include <openssl/err.h>
#include <openssl/evp.h>
-#include <openssl/rand.h>
#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
@@ -613,8 +613,7 @@ EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key)
{
if (ctx->cipher->flags & EVP_CIPH_RAND_KEY)
return EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_RAND_KEY, 0, key);
- if (RAND_bytes(key, ctx->key_len) <= 0)
- return 0;
+ arc4random_buf(key, ctx->key_len);
return 1;
}