~andersk/ubuntu/oneiric/openssl/spurious-reboot

« back to all changes in this revision

Viewing changes to crypto/pkcs7/pk7_mime.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2010-12-12 15:37:21 UTC
  • mto: (1.2.1 upstream) (11.2.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 55.
  • Revision ID: james.westby@ubuntu.com-20101212153721-mfw51stum5hwztpd
Tags: upstream-1.0.0c
ImportĀ upstreamĀ versionĀ 1.0.0c

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
#include <openssl/x509.h>
60
60
#include <openssl/asn1.h>
61
61
 
62
 
/* PKCS#7 wrappers round generalised MIME routines */
 
62
/* PKCS#7 wrappers round generalised stream and MIME routines */
63
63
 
64
 
PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont)
 
64
int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags)
65
65
        {
66
 
        return (PKCS7 *)SMIME_read_ASN1(bio, bcont, ASN1_ITEM_rptr(PKCS7));
 
66
        return i2d_ASN1_bio_stream(out, (ASN1_VALUE *)p7, in, flags,
 
67
                                        ASN1_ITEM_rptr(PKCS7));
67
68
        }
68
69
 
69
 
/* Callback for int_smime_write_ASN1 */
70
 
 
71
 
static int pk7_output_data(BIO *out, BIO *data, ASN1_VALUE *val, int flags,
72
 
                                        const ASN1_ITEM *it)
 
70
int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags)
73
71
        {
74
 
        PKCS7 *p7 = (PKCS7 *)val;
75
 
        BIO *tmpbio, *p7bio;
76
 
        int r = 0;
77
 
 
78
 
        if (!(flags & SMIME_DETACHED))
79
 
                {
80
 
                SMIME_crlf_copy(data, out, flags);
81
 
                return 1;
82
 
                }
83
 
 
84
 
        /* Let PKCS7 code prepend any needed BIOs */
85
 
 
86
 
        p7bio = PKCS7_dataInit(p7, out);
87
 
 
88
 
        if (!p7bio)
89
 
                return 0;
90
 
 
91
 
        /* Copy data across, passing through filter BIOs for processing */
92
 
        SMIME_crlf_copy(data, p7bio, flags);
93
 
 
94
 
        /* Finalize structure */
95
 
        if (PKCS7_dataFinal(p7, p7bio) <= 0)
96
 
                goto err;
97
 
 
98
 
        r = 1;
99
 
 
100
 
        err:
101
 
 
102
 
        /* Now remove any digests prepended to the BIO */
103
 
 
104
 
        while (p7bio != out)
105
 
                {
106
 
                tmpbio = BIO_pop(p7bio);
107
 
                BIO_free(p7bio);
108
 
                p7bio = tmpbio;
109
 
                }
110
 
 
111
 
        return 1;
112
 
 
 
72
        return PEM_write_bio_ASN1_stream(out, (ASN1_VALUE *) p7, in, flags,
 
73
                                                "PKCS7",
 
74
                                                ASN1_ITEM_rptr(PKCS7));
113
75
        }
114
76
 
115
77
int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags)
121
83
        else
122
84
                mdalgs = NULL;
123
85
 
124
 
        return int_smime_write_ASN1(bio, (ASN1_VALUE *)p7, data, flags,
 
86
        flags ^= SMIME_OLDMIME;
 
87
 
 
88
 
 
89
        return SMIME_write_ASN1(bio, (ASN1_VALUE *)p7, data, flags,
125
90
                                        ctype_nid, NID_undef, mdalgs,
126
 
                                        pk7_output_data,
127
91
                                        ASN1_ITEM_rptr(PKCS7)); 
128
92
        }
 
93
 
 
94
PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont)
 
95
        {
 
96
        return (PKCS7 *)SMIME_read_ASN1(bio, bcont, ASN1_ITEM_rptr(PKCS7));
 
97
        }