summaryrefslogtreecommitdiff
path: root/lib/libcrypto/pkcs12
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2014-10-22 13:02:05 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2014-10-22 13:02:05 +0000
commit80fb32c087ebd4e7c3ef9467cca1392931be5034 (patch)
treebc399a065fb5876e02859b77f4bb5d2d0fa7f0e6 /lib/libcrypto/pkcs12
parentbcad82539542acc3528c59c25491ef55b8130f7a (diff)
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/pkcs12')
-rw-r--r--lib/libcrypto/pkcs12/p12_mutl.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/libcrypto/pkcs12/p12_mutl.c b/lib/libcrypto/pkcs12/p12_mutl.c
index 453d30d65f5..0c49bf96fde 100644
--- a/lib/libcrypto/pkcs12/p12_mutl.c
+++ b/lib/libcrypto/pkcs12/p12_mutl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: p12_mutl.c,v 1.17 2014/07/11 08:44:49 jsing Exp $ */
+/* $OpenBSD: p12_mutl.c,v 1.18 2014/10/22 13:02:04 jsing Exp $ */
/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project 1999.
*/
@@ -57,6 +57,7 @@
*/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <openssl/opensslconf.h>
@@ -66,7 +67,6 @@
#include <openssl/err.h>
#include <openssl/hmac.h>
#include <openssl/pkcs12.h>
-#include <openssl/rand.h>
/* Generate a MAC */
int
@@ -193,10 +193,9 @@ PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
PKCS12err(PKCS12_F_PKCS12_SETUP_MAC, ERR_R_MALLOC_FAILURE);
return 0;
}
- if (!salt) {
- if (RAND_pseudo_bytes (p12->mac->salt->data, saltlen) < 0)
- return 0;
- } else
+ if (!salt)
+ arc4random_buf(p12->mac->salt->data, saltlen);
+ else
memcpy (p12->mac->salt->data, salt, saltlen);
p12->mac->dinfo->algor->algorithm = OBJ_nid2obj(EVP_MD_type(md_type));
if (!(p12->mac->dinfo->algor->parameter = ASN1_TYPE_new())) {