summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_aes.c
diff options
context:
space:
mode:
authorjsing <>2014-10-22 13:02:04 +0000
committerjsing <>2014-10-22 13:02:04 +0000
commita2960bc2e14b4c5f7d8f78d2a69ebb537ca4afa8 (patch)
tree32d920c77e1ecf12be5fad632b9ae71343194a7c /src/lib/libcrypto/evp/e_aes.c
parent5a6d7fd5a10b0ad084948463b25822d91091b325 (diff)
downloadopenbsd-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/evp/e_aes.c')
-rw-r--r--src/lib/libcrypto/evp/e_aes.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/libcrypto/evp/e_aes.c b/src/lib/libcrypto/evp/e_aes.c
index f96a15f19c..bb3b420a3b 100644
--- a/src/lib/libcrypto/evp/e_aes.c
+++ b/src/lib/libcrypto/evp/e_aes.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: e_aes.c,v 1.25 2014/07/12 19:31:03 miod Exp $ */ 1/* $OpenBSD: e_aes.c,v 1.26 2014/10/22 13:02:04 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -50,6 +50,7 @@
50 */ 50 */
51 51
52#include <assert.h> 52#include <assert.h>
53#include <stdlib.h>
53#include <string.h> 54#include <string.h>
54 55
55#include <openssl/opensslconf.h> 56#include <openssl/opensslconf.h>
@@ -58,7 +59,6 @@
58#include <openssl/aes.h> 59#include <openssl/aes.h>
59#include <openssl/err.h> 60#include <openssl/err.h>
60#include <openssl/evp.h> 61#include <openssl/evp.h>
61#include <openssl/rand.h>
62 62
63#include "evp_locl.h" 63#include "evp_locl.h"
64#include "modes_lcl.h" 64#include "modes_lcl.h"
@@ -769,9 +769,8 @@ aes_gcm_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
769 return 0; 769 return 0;
770 if (arg) 770 if (arg)
771 memcpy(gctx->iv, ptr, arg); 771 memcpy(gctx->iv, ptr, arg);
772 if (c->encrypt && 772 if (c->encrypt)
773 RAND_bytes(gctx->iv + arg, gctx->ivlen - arg) <= 0) 773 arc4random_buf(gctx->iv + arg, gctx->ivlen - arg);
774 return 0;
775 gctx->iv_gen = 1; 774 gctx->iv_gen = 1;
776 return 1; 775 return 1;
777 776