summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/p5_pbev2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/p5_pbev2.c')
-rw-r--r--src/lib/libcrypto/asn1/p5_pbev2.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib/libcrypto/asn1/p5_pbev2.c b/src/lib/libcrypto/asn1/p5_pbev2.c
index 8085aba453..0947965219 100644
--- a/src/lib/libcrypto/asn1/p5_pbev2.c
+++ b/src/lib/libcrypto/asn1/p5_pbev2.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: p5_pbev2.c,v 1.17 2014/07/11 08:44:47 jsing Exp $ */ 1/* $OpenBSD: p5_pbev2.c,v 1.18 2014/10/22 13:02:03 jsing Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999-2004. 3 * project 1999-2004.
4 */ 4 */
@@ -57,11 +57,11 @@
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/asn1t.h> 63#include <openssl/asn1t.h>
63#include <openssl/err.h> 64#include <openssl/err.h>
64#include <openssl/rand.h>
65#include <openssl/x509.h> 65#include <openssl/x509.h>
66 66
67/* PKCS#5 v2.0 password based encryption structures */ 67/* PKCS#5 v2.0 password based encryption structures */
@@ -121,9 +121,8 @@ PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt,
121 if (EVP_CIPHER_iv_length(cipher)) { 121 if (EVP_CIPHER_iv_length(cipher)) {
122 if (aiv) 122 if (aiv)
123 memcpy(iv, aiv, EVP_CIPHER_iv_length(cipher)); 123 memcpy(iv, aiv, EVP_CIPHER_iv_length(cipher));
124 else if (RAND_pseudo_bytes(iv, 124 else
125 EVP_CIPHER_iv_length(cipher)) < 0) 125 arc4random_buf(iv, EVP_CIPHER_iv_length(cipher));
126 goto err;
127 } 126 }
128 127
129 EVP_CIPHER_CTX_init(&ctx); 128 EVP_CIPHER_CTX_init(&ctx);
@@ -227,8 +226,8 @@ PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, int prf_nid,
227 226
228 if (salt) 227 if (salt)
229 memcpy (osalt->data, salt, saltlen); 228 memcpy (osalt->data, salt, saltlen);
230 else if (RAND_pseudo_bytes (osalt->data, saltlen) < 0) 229 else
231 goto merr; 230 arc4random_buf(osalt->data, saltlen);
232 231
233 if (iter <= 0) 232 if (iter <= 0)
234 iter = PKCS5_DEFAULT_ITER; 233 iter = PKCS5_DEFAULT_ITER;