Stack.
authorBen Laurie <ben@openssl.org>
Wed, 2 Jun 1999 17:11:53 +0000 (17:11 +0000)
committerBen Laurie <ben@openssl.org>
Wed, 2 Jun 1999 17:11:53 +0000 (17:11 +0000)
crypto/asn1/p7_s_e.c
crypto/asn1/p7_signd.c
crypto/pkcs7/pk7_doit.c
crypto/pkcs7/pk7_lib.c
crypto/pkcs7/pkcs7.h

index 1df66dd..7b3440c 100644 (file)
@@ -71,7 +71,8 @@ int i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *a, unsigned char **pp)
        M_ASN1_I2D_len(a->enc_data,i2d_PKCS7_ENC_CONTENT);
        M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(X509,a->cert,i2d_X509,0);
        M_ASN1_I2D_len_IMP_SET_opt_type(X509_CRL,a->crl,i2d_X509_CRL,1);
-       M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
+       M_ASN1_I2D_len_SET_type(PKCS7_SIGNER_INFO,a->signer_info,
+                               i2d_PKCS7_SIGNER_INFO);
 
        M_ASN1_I2D_seq_total();
 
@@ -81,7 +82,8 @@ int i2d_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE *a, unsigned char **pp)
        M_ASN1_I2D_put(a->enc_data,i2d_PKCS7_ENC_CONTENT);
        M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(X509,a->cert,i2d_X509,0);
        M_ASN1_I2D_put_IMP_SET_opt_type(X509_CRL,a->crl,i2d_X509_CRL,1);
-       M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
+       M_ASN1_I2D_put_SET_type(PKCS7_SIGNER_INFO,a->signer_info,
+                               i2d_PKCS7_SIGNER_INFO);
 
        M_ASN1_I2D_finish();
        }
@@ -102,8 +104,8 @@ PKCS7_SIGN_ENVELOPE *d2i_PKCS7_SIGN_ENVELOPE(PKCS7_SIGN_ENVELOPE **a,
        M_ASN1_D2I_get_IMP_set_opt_type(X509,ret->cert,d2i_X509,X509_free,0);
        M_ASN1_D2I_get_IMP_set_opt_type(X509_CRL,ret->crl,d2i_X509_CRL,
                                        X509_CRL_free,1);
-       M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO,
-               PKCS7_SIGNER_INFO_free);
+       M_ASN1_D2I_get_set_type(PKCS7_SIGNER_INFO,ret->signer_info,
+                               d2i_PKCS7_SIGNER_INFO,PKCS7_SIGNER_INFO_free);
 
        M_ASN1_D2I_Finish(a,PKCS7_SIGN_ENVELOPE_free,
                ASN1_F_D2I_PKCS7_SIGN_ENVELOPE);
@@ -121,7 +123,7 @@ PKCS7_SIGN_ENVELOPE *PKCS7_SIGN_ENVELOPE_new(void)
        M_ASN1_New(ret->enc_data,PKCS7_ENC_CONTENT_new);
        ret->cert=NULL;
        ret->crl=NULL;
-       M_ASN1_New(ret->signer_info,sk_new_null);
+       M_ASN1_New(ret->signer_info,sk_PKCS7_SIGNER_INFO_new_null);
        return(ret);
        M_ASN1_New_Error(ASN1_F_PKCS7_SIGN_ENVELOPE_NEW);
        }
@@ -135,7 +137,7 @@ void PKCS7_SIGN_ENVELOPE_free(PKCS7_SIGN_ENVELOPE *a)
        PKCS7_ENC_CONTENT_free(a->enc_data);
        sk_X509_pop_free(a->cert,X509_free);
        sk_X509_CRL_pop_free(a->crl,X509_CRL_free);
-       sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
+       sk_PKCS7_SIGNER_INFO_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
        Free((char *)a);
        }
 
index f7a15a3..75ceb96 100644 (file)
@@ -70,7 +70,8 @@ int i2d_PKCS7_SIGNED(PKCS7_SIGNED *a, unsigned char **pp)
        M_ASN1_I2D_len(a->contents,i2d_PKCS7);
        M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(X509,a->cert,i2d_X509,0);
        M_ASN1_I2D_len_IMP_SET_opt_type(X509_CRL,a->crl,i2d_X509_CRL,1);
-       M_ASN1_I2D_len_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
+       M_ASN1_I2D_len_SET_type(PKCS7_SIGNER_INFO,a->signer_info,
+                               i2d_PKCS7_SIGNER_INFO);
 
        M_ASN1_I2D_seq_total();
 
@@ -79,7 +80,8 @@ int i2d_PKCS7_SIGNED(PKCS7_SIGNED *a, unsigned char **pp)
        M_ASN1_I2D_put(a->contents,i2d_PKCS7);
        M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(X509,a->cert,i2d_X509,0);
        M_ASN1_I2D_put_IMP_SET_opt_type(X509_CRL,a->crl,i2d_X509_CRL,1);
-       M_ASN1_I2D_put_SET(a->signer_info,i2d_PKCS7_SIGNER_INFO);
+       M_ASN1_I2D_put_SET_type(PKCS7_SIGNER_INFO,a->signer_info,
+                               i2d_PKCS7_SIGNER_INFO);
 
        M_ASN1_I2D_finish();
        }
@@ -98,8 +100,8 @@ PKCS7_SIGNED *d2i_PKCS7_SIGNED(PKCS7_SIGNED **a, unsigned char **pp,
        M_ASN1_D2I_get_IMP_set_opt_type(X509,ret->cert,d2i_X509,X509_free,0);
        M_ASN1_D2I_get_IMP_set_opt_type(X509_CRL,ret->crl,d2i_X509_CRL,
                                        X509_CRL_free,1);
-       M_ASN1_D2I_get_set(ret->signer_info,d2i_PKCS7_SIGNER_INFO,
-               PKCS7_SIGNER_INFO_free);
+       M_ASN1_D2I_get_set_type(PKCS7_SIGNER_INFO,ret->signer_info,
+                               d2i_PKCS7_SIGNER_INFO,PKCS7_SIGNER_INFO_free);
 
        M_ASN1_D2I_Finish(a,PKCS7_SIGNED_free,ASN1_F_D2I_PKCS7_SIGNED);
        }
@@ -115,7 +117,7 @@ PKCS7_SIGNED *PKCS7_SIGNED_new(void)
        M_ASN1_New(ret->contents,PKCS7_new);
        ret->cert=NULL;
        ret->crl=NULL;
-       M_ASN1_New(ret->signer_info,sk_new_null);
+       M_ASN1_New(ret->signer_info,sk_PKCS7_SIGNER_INFO_new_null);
        return(ret);
        M_ASN1_New_Error(ASN1_F_PKCS7_SIGNED_NEW);
        }
@@ -128,11 +130,13 @@ void PKCS7_SIGNED_free(PKCS7_SIGNED *a)
        PKCS7_free(a->contents);
        sk_X509_pop_free(a->cert,X509_free);
        sk_X509_CRL_pop_free(a->crl,X509_CRL_free);
-       sk_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
-       Free((char *)a);
+       sk_PKCS7_SIGNER_INFO_pop_free(a->signer_info,PKCS7_SIGNER_INFO_free);
+       Free(a);
        }
 
 IMPLEMENT_STACK_OF(X509_ALGOR)
 IMPLEMENT_ASN1_SET_OF(X509_ALGOR)
 IMPLEMENT_STACK_OF(X509_CRL)
 IMPLEMENT_ASN1_SET_OF(X509_CRL)
+IMPLEMENT_STACK_OF(PKCS7_SIGNER_INFO)
+IMPLEMENT_ASN1_SET_OF(PKCS7_SIGNER_INFO)
index 5a51d64..16c1556 100644 (file)
@@ -466,7 +466,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
        PKCS7_SIGNER_INFO *si;
        EVP_MD_CTX *mdc,ctx_tmp;
        STACK_OF(X509_ATTRIBUTE) *sk;
-       STACK *si_sk=NULL;
+       STACK_OF(PKCS7_SIGNER_INFO) *si_sk=NULL;
        unsigned char *p,*pp=NULL;
        int x;
        ASN1_OCTET_STRING *os=NULL;
@@ -505,10 +505,9 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
                        PKCS7err(PKCS7_F_PKCS7_DATASIGN,ERR_R_BIO_LIB);
                        goto err;
                        }
-               for (i=0; i<sk_num(si_sk); i++)
+               for (i=0; i<sk_PKCS7_SIGNER_INFO_num(si_sk); i++)
                        {
-                       si=(PKCS7_SIGNER_INFO *)
-                               sk_value(si_sk,i);
+                       si=sk_PKCS7_SIGNER_INFO_value(si_sk,i);
                        if (si->pkey == NULL) continue;
 
                        j=OBJ_obj2nid(si->digest_alg->algorithm);
index 79f6f61..89b2e81 100644 (file)
@@ -190,7 +190,7 @@ int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi)
        {
        int i,j,nid;
        X509_ALGOR *alg;
-       STACK *signer_sk;
+       STACK_OF(PKCS7_SIGNER_INFO) *signer_sk;
        STACK_OF(X509_ALGOR) *md_sk;
 
        i=OBJ_obj2nid(p7->type);
@@ -229,7 +229,7 @@ int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *psi)
                sk_X509_ALGOR_push(md_sk,alg);
                }
 
-       sk_push(signer_sk,(char *)psi);
+       sk_PKCS7_SIGNER_INFO_push(signer_sk,psi);
        return(1);
        }
 
@@ -342,7 +342,7 @@ err:
        return(NULL);
        }
 
-STACK *PKCS7_get_signer_info(PKCS7 *p7)
+STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7)
        {
        if (PKCS7_type_is_signed(p7))
                {
index d10a14c..9e80f86 100644 (file)
@@ -98,6 +98,9 @@ typedef struct pkcs7_signer_info_st
        EVP_PKEY                        *pkey;
        } PKCS7_SIGNER_INFO;
 
+DECLARE_STACK_OF(PKCS7_SIGNER_INFO)
+DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)
+
 typedef struct pkcs7_recip_info_st
        {
        ASN1_INTEGER                    *version;       /* version 0 */
@@ -113,7 +116,7 @@ typedef struct pkcs7_signed_st
        STACK_OF(X509_ALGOR)            *md_algs;       /* md used */
        STACK_OF(X509)                  *cert;          /* [ 0 ] */
        STACK_OF(X509_CRL)              *crl;           /* [ 1 ] */
-       STACK /* PKCS7_SIGNER_INFO */   *signer_info;
+       STACK_OF(PKCS7_SIGNER_INFO)     *signer_info;
 
        struct pkcs7_st                 *contents;
        } PKCS7_SIGNED;
@@ -141,7 +144,7 @@ typedef struct pkcs7_signedandenveloped_st
        STACK_OF(X509_ALGOR)            *md_algs;       /* md used */
        STACK_OF(X509)                  *cert;          /* [ 0 ] */
        STACK_OF(X509_CRL)              *crl;           /* [ 1 ] */
-       STACK /* PKCS7_SIGNER_INFO */   *signer_info;
+       STACK_OF(PKCS7_SIGNER_INFO)     *signer_info;
 
        PKCS7_ENC_CONTENT               *enc_data;
        STACK /* PKCS7_RECIP_INFO */    *recipientinfo;
@@ -336,7 +339,7 @@ BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);
 PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
        EVP_PKEY *pkey, EVP_MD *dgst);
 X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
-STACK *PKCS7_get_signer_info(PKCS7 *p7);
+STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);
 
 PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
 int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);