Check PKCS7 structures in PKCS#12 files are of type data.
[openssl.git] / crypto / pkcs12 / p12_mutl.c
index 5eac25f..7bff048 100644 (file)
@@ -72,6 +72,12 @@ int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
        unsigned char key[PKCS12_MAC_KEY_LENGTH], *salt;
        int saltlen, iter;
 
+       if (!PKCS7_type_is_data(p12->authsafes))
+               {
+               PKCS12err(PKCS12_F_PKCS12_GEN_MAC,PKCS12_R_CONTENT_TYPE_NOT_DATA);
+               return 0;
+               }
+
        salt = p12->mac->salt->data;
        saltlen = p12->mac->salt->length;
        if (!p12->mac->iter) iter = 1;