Linux on Alpha has the configuration name linux-alpha-gcc, not
[openssl.git] / crypto / pkcs12 / p12_add.c
index 7ed1c3fea497eab631b7ad3b60d7c6e0a3e149df..b563656895e0d1f9db261afc6266d0192f4ad47a 100644 (file)
@@ -125,7 +125,7 @@ PKCS12_SAFEBAG *PKCS12_MAKE_SHKEYBAG (int pbe_nid, const char *pass,
 }
 
 /* Turn a stack of SAFEBAGS into a PKCS#7 data Contentinfo */
-PKCS7 *PKCS12_pack_p7data (STACK *sk)
+PKCS7 *PKCS12_pack_p7data (STACK_OF(PKCS12_SAFEBAG) *sk)
 {
        PKCS7 *p7;
        if (!(p7 = PKCS7_new())) {
@@ -138,8 +138,9 @@ PKCS7 *PKCS12_pack_p7data (STACK *sk)
                return NULL;
        }
        
-       if (!ASN1_seq_pack(sk, i2d_PKCS12_SAFEBAG, &p7->d.data->data,
-                                       &p7->d.data->length)) {
+       if (!ASN1_seq_pack_PKCS12_SAFEBAG(sk, i2d_PKCS12_SAFEBAG,
+                                         &p7->d.data->data,
+                                         &p7->d.data->length)) {
                PKCS12err(PKCS12_F_PKCS12_PACK_P7DATA, PKCS12_R_CANT_PACK_STRUCTURE);
                return NULL;
        }
@@ -149,7 +150,8 @@ PKCS7 *PKCS12_pack_p7data (STACK *sk)
 /* Turn a stack of SAFEBAGS into a PKCS#7 encrypted data ContentInfo */
 
 PKCS7 *PKCS12_pack_p7encdata (int pbe_nid, const char *pass, int passlen,
-            unsigned char *salt, int saltlen, int iter, STACK *bags)
+                             unsigned char *salt, int saltlen, int iter,
+                             STACK_OF(PKCS12_SAFEBAG) *bags)
 {
        PKCS7 *p7;
        X509_ALGOR *pbe;
@@ -189,14 +191,14 @@ X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
 
        if (!(p8 = X509_SIG_new())) {
                PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE);
-               return NULL;
+               goto err;
        }
 
        if(pbe_nid == -1) pbe = PKCS5_pbe2_set(cipher, iter, salt, saltlen);
        else pbe = PKCS5_pbe_set(pbe_nid, iter, salt, saltlen);
        if(!pbe) {
-               PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_MALLOC_FAILURE);
-               return NULL;
+               PKCS12err(PKCS12_F_PKCS8_ENCRYPT, ERR_R_ASN1_LIB);
+               goto err;
        }
        X509_ALGOR_free(p8->algor);
        p8->algor = pbe;
@@ -205,8 +207,12 @@ X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher,
        PKCS12_i2d_encrypt (pbe, i2d_PKCS8_PRIV_KEY_INFO, pass, passlen,
                                                 (char *)p8inf, 0))) {
                PKCS12err(PKCS12_F_PKCS8_ENCRYPT, PKCS12_R_ENCRYPT_ERROR);
-               return NULL;
+               goto err;
        }
 
        return p8;
+
+       err:
+       X509_SIG_free(p8);
+       return NULL;
 }