Fix for d2i_ASN1_bytes and stop PKCS#7 routines crashing is signed message
[oweals/openssl.git] / crypto / asn1 / p5_pbev2.c
index 10364a056141a8295bbed99939f0e69f2bc4e9d4..09f4bf61121b2a0a9c064c59ccf8ac57ea68b338 100644 (file)
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include "cryptlib.h"
 #include <openssl/asn1_mac.h>
+#include <openssl/x509.h>
 #include <openssl/rand.h>
 
 /* PKCS#5 v2.0 password based encryption structures */
@@ -206,6 +207,7 @@ X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter,
        if (salt) memcpy (osalt->data, salt, saltlen);
        else RAND_bytes (osalt->data, saltlen);
 
+       if(iter <= 0) iter = PKCS5_DEFAULT_ITER;
        if(!ASN1_INTEGER_set(kdf->iter, iter)) goto merr;
 
        /* Now include salt in kdf structure */