xref: /minix3/crypto/external/bsd/openssl/dist/crypto/pkcs7/pkcs7.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1ebfedea0SLionel Sambuc /* crypto/pkcs7/pkcs7.h */
2ebfedea0SLionel Sambuc /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3ebfedea0SLionel Sambuc  * All rights reserved.
4ebfedea0SLionel Sambuc  *
5ebfedea0SLionel Sambuc  * This package is an SSL implementation written
6ebfedea0SLionel Sambuc  * by Eric Young (eay@cryptsoft.com).
7ebfedea0SLionel Sambuc  * The implementation was written so as to conform with Netscapes SSL.
8ebfedea0SLionel Sambuc  *
9ebfedea0SLionel Sambuc  * This library is free for commercial and non-commercial use as long as
10ebfedea0SLionel Sambuc  * the following conditions are aheared to.  The following conditions
11ebfedea0SLionel Sambuc  * apply to all code found in this distribution, be it the RC4, RSA,
12ebfedea0SLionel Sambuc  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13ebfedea0SLionel Sambuc  * included with this distribution is covered by the same copyright terms
14ebfedea0SLionel Sambuc  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15ebfedea0SLionel Sambuc  *
16ebfedea0SLionel Sambuc  * Copyright remains Eric Young's, and as such any Copyright notices in
17ebfedea0SLionel Sambuc  * the code are not to be removed.
18ebfedea0SLionel Sambuc  * If this package is used in a product, Eric Young should be given attribution
19ebfedea0SLionel Sambuc  * as the author of the parts of the library used.
20ebfedea0SLionel Sambuc  * This can be in the form of a textual message at program startup or
21ebfedea0SLionel Sambuc  * in documentation (online or textual) provided with the package.
22ebfedea0SLionel Sambuc  *
23ebfedea0SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
24ebfedea0SLionel Sambuc  * modification, are permitted provided that the following conditions
25ebfedea0SLionel Sambuc  * are met:
26ebfedea0SLionel Sambuc  * 1. Redistributions of source code must retain the copyright
27ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
28ebfedea0SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
29ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
30ebfedea0SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
31ebfedea0SLionel Sambuc  * 3. All advertising materials mentioning features or use of this software
32ebfedea0SLionel Sambuc  *    must display the following acknowledgement:
33ebfedea0SLionel Sambuc  *    "This product includes cryptographic software written by
34ebfedea0SLionel Sambuc  *     Eric Young (eay@cryptsoft.com)"
35ebfedea0SLionel Sambuc  *    The word 'cryptographic' can be left out if the rouines from the library
36ebfedea0SLionel Sambuc  *    being used are not cryptographic related :-).
37ebfedea0SLionel Sambuc  * 4. If you include any Windows specific code (or a derivative thereof) from
38ebfedea0SLionel Sambuc  *    the apps directory (application code) you must include an acknowledgement:
39ebfedea0SLionel Sambuc  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40ebfedea0SLionel Sambuc  *
41ebfedea0SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42ebfedea0SLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43ebfedea0SLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44ebfedea0SLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45ebfedea0SLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46ebfedea0SLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47ebfedea0SLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48ebfedea0SLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49ebfedea0SLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50ebfedea0SLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51ebfedea0SLionel Sambuc  * SUCH DAMAGE.
52ebfedea0SLionel Sambuc  *
53ebfedea0SLionel Sambuc  * The licence and distribution terms for any publically available version or
54ebfedea0SLionel Sambuc  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55ebfedea0SLionel Sambuc  * copied and put under another distribution licence
56ebfedea0SLionel Sambuc  * [including the GNU Public Licence.]
57ebfedea0SLionel Sambuc  */
58ebfedea0SLionel Sambuc 
59ebfedea0SLionel Sambuc #ifndef HEADER_PKCS7_H
60ebfedea0SLionel Sambuc # define HEADER_PKCS7_H
61ebfedea0SLionel Sambuc 
62ebfedea0SLionel Sambuc # include <openssl/asn1.h>
63ebfedea0SLionel Sambuc # include <openssl/bio.h>
64ebfedea0SLionel Sambuc # include <openssl/e_os2.h>
65ebfedea0SLionel Sambuc 
66ebfedea0SLionel Sambuc # include <openssl/symhacks.h>
67ebfedea0SLionel Sambuc # include <openssl/ossl_typ.h>
68ebfedea0SLionel Sambuc 
69ebfedea0SLionel Sambuc #ifdef  __cplusplus
70ebfedea0SLionel Sambuc extern "C" {
71ebfedea0SLionel Sambuc #endif
72ebfedea0SLionel Sambuc 
73ebfedea0SLionel Sambuc # ifdef OPENSSL_SYS_WIN32
74ebfedea0SLionel Sambuc /* Under Win32 thes are defined in wincrypt.h */
75ebfedea0SLionel Sambuc #  undef PKCS7_ISSUER_AND_SERIAL
76ebfedea0SLionel Sambuc #  undef PKCS7_SIGNER_INFO
77ebfedea0SLionel Sambuc # endif
78ebfedea0SLionel Sambuc 
79*0a6a1f1dSLionel Sambuc /*-
80ebfedea0SLionel Sambuc Encryption_ID           DES-CBC
81ebfedea0SLionel Sambuc Digest_ID               MD5
82ebfedea0SLionel Sambuc Digest_Encryption_ID    rsaEncryption
83ebfedea0SLionel Sambuc Key_Encryption_ID       rsaEncryption
84ebfedea0SLionel Sambuc */
85ebfedea0SLionel Sambuc 
86*0a6a1f1dSLionel Sambuc typedef struct pkcs7_issuer_and_serial_st {
87ebfedea0SLionel Sambuc     X509_NAME *issuer;
88ebfedea0SLionel Sambuc     ASN1_INTEGER *serial;
89ebfedea0SLionel Sambuc } PKCS7_ISSUER_AND_SERIAL;
90ebfedea0SLionel Sambuc 
91*0a6a1f1dSLionel Sambuc typedef struct pkcs7_signer_info_st {
92ebfedea0SLionel Sambuc     ASN1_INTEGER *version;      /* version 1 */
93ebfedea0SLionel Sambuc     PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
94ebfedea0SLionel Sambuc     X509_ALGOR *digest_alg;
95ebfedea0SLionel Sambuc     STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */
96ebfedea0SLionel Sambuc     X509_ALGOR *digest_enc_alg;
97ebfedea0SLionel Sambuc     ASN1_OCTET_STRING *enc_digest;
98ebfedea0SLionel Sambuc     STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */
99ebfedea0SLionel Sambuc     /* The private key to sign with */
100ebfedea0SLionel Sambuc     EVP_PKEY *pkey;
101ebfedea0SLionel Sambuc } PKCS7_SIGNER_INFO;
102ebfedea0SLionel Sambuc 
103ebfedea0SLionel Sambuc DECLARE_STACK_OF(PKCS7_SIGNER_INFO)
104ebfedea0SLionel Sambuc DECLARE_ASN1_SET_OF(PKCS7_SIGNER_INFO)
105ebfedea0SLionel Sambuc 
106*0a6a1f1dSLionel Sambuc typedef struct pkcs7_recip_info_st {
107ebfedea0SLionel Sambuc     ASN1_INTEGER *version;      /* version 0 */
108ebfedea0SLionel Sambuc     PKCS7_ISSUER_AND_SERIAL *issuer_and_serial;
109ebfedea0SLionel Sambuc     X509_ALGOR *key_enc_algor;
110ebfedea0SLionel Sambuc     ASN1_OCTET_STRING *enc_key;
111ebfedea0SLionel Sambuc     X509 *cert;                 /* get the pub-key from this */
112ebfedea0SLionel Sambuc } PKCS7_RECIP_INFO;
113ebfedea0SLionel Sambuc 
114ebfedea0SLionel Sambuc DECLARE_STACK_OF(PKCS7_RECIP_INFO)
115ebfedea0SLionel Sambuc DECLARE_ASN1_SET_OF(PKCS7_RECIP_INFO)
116ebfedea0SLionel Sambuc 
117*0a6a1f1dSLionel Sambuc typedef struct pkcs7_signed_st {
118ebfedea0SLionel Sambuc     ASN1_INTEGER *version;      /* version 1 */
119ebfedea0SLionel Sambuc     STACK_OF(X509_ALGOR) *md_algs; /* md used */
120ebfedea0SLionel Sambuc     STACK_OF(X509) *cert;       /* [ 0 ] */
121ebfedea0SLionel Sambuc     STACK_OF(X509_CRL) *crl;    /* [ 1 ] */
122ebfedea0SLionel Sambuc     STACK_OF(PKCS7_SIGNER_INFO) *signer_info;
123ebfedea0SLionel Sambuc     struct pkcs7_st *contents;
124ebfedea0SLionel Sambuc } PKCS7_SIGNED;
125*0a6a1f1dSLionel Sambuc /*
126*0a6a1f1dSLionel Sambuc  * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about
127*0a6a1f1dSLionel Sambuc  * merging the two
128*0a6a1f1dSLionel Sambuc  */
129ebfedea0SLionel Sambuc 
130*0a6a1f1dSLionel Sambuc typedef struct pkcs7_enc_content_st {
131ebfedea0SLionel Sambuc     ASN1_OBJECT *content_type;
132ebfedea0SLionel Sambuc     X509_ALGOR *algorithm;
133ebfedea0SLionel Sambuc     ASN1_OCTET_STRING *enc_data; /* [ 0 ] */
134ebfedea0SLionel Sambuc     const EVP_CIPHER *cipher;
135ebfedea0SLionel Sambuc } PKCS7_ENC_CONTENT;
136ebfedea0SLionel Sambuc 
137*0a6a1f1dSLionel Sambuc typedef struct pkcs7_enveloped_st {
138ebfedea0SLionel Sambuc     ASN1_INTEGER *version;      /* version 0 */
139ebfedea0SLionel Sambuc     STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
140ebfedea0SLionel Sambuc     PKCS7_ENC_CONTENT *enc_data;
141ebfedea0SLionel Sambuc } PKCS7_ENVELOPE;
142ebfedea0SLionel Sambuc 
143*0a6a1f1dSLionel Sambuc typedef struct pkcs7_signedandenveloped_st {
144ebfedea0SLionel Sambuc     ASN1_INTEGER *version;      /* version 1 */
145ebfedea0SLionel Sambuc     STACK_OF(X509_ALGOR) *md_algs; /* md used */
146ebfedea0SLionel Sambuc     STACK_OF(X509) *cert;       /* [ 0 ] */
147ebfedea0SLionel Sambuc     STACK_OF(X509_CRL) *crl;    /* [ 1 ] */
148ebfedea0SLionel Sambuc     STACK_OF(PKCS7_SIGNER_INFO) *signer_info;
149ebfedea0SLionel Sambuc     PKCS7_ENC_CONTENT *enc_data;
150ebfedea0SLionel Sambuc     STACK_OF(PKCS7_RECIP_INFO) *recipientinfo;
151ebfedea0SLionel Sambuc } PKCS7_SIGN_ENVELOPE;
152ebfedea0SLionel Sambuc 
153*0a6a1f1dSLionel Sambuc typedef struct pkcs7_digest_st {
154ebfedea0SLionel Sambuc     ASN1_INTEGER *version;      /* version 0 */
155ebfedea0SLionel Sambuc     X509_ALGOR *md;             /* md used */
156ebfedea0SLionel Sambuc     struct pkcs7_st *contents;
157ebfedea0SLionel Sambuc     ASN1_OCTET_STRING *digest;
158ebfedea0SLionel Sambuc } PKCS7_DIGEST;
159ebfedea0SLionel Sambuc 
160*0a6a1f1dSLionel Sambuc typedef struct pkcs7_encrypted_st {
161ebfedea0SLionel Sambuc     ASN1_INTEGER *version;      /* version 0 */
162ebfedea0SLionel Sambuc     PKCS7_ENC_CONTENT *enc_data;
163ebfedea0SLionel Sambuc } PKCS7_ENCRYPT;
164ebfedea0SLionel Sambuc 
165*0a6a1f1dSLionel Sambuc typedef struct pkcs7_st {
166*0a6a1f1dSLionel Sambuc     /*
167*0a6a1f1dSLionel Sambuc      * The following is non NULL if it contains ASN1 encoding of this
168*0a6a1f1dSLionel Sambuc      * structure
169*0a6a1f1dSLionel Sambuc      */
170ebfedea0SLionel Sambuc     unsigned char *asn1;
171ebfedea0SLionel Sambuc     long length;
172ebfedea0SLionel Sambuc # define PKCS7_S_HEADER  0
173ebfedea0SLionel Sambuc # define PKCS7_S_BODY    1
174ebfedea0SLionel Sambuc # define PKCS7_S_TAIL    2
175ebfedea0SLionel Sambuc     int state;                  /* used during processing */
176ebfedea0SLionel Sambuc     int detached;
177ebfedea0SLionel Sambuc     ASN1_OBJECT *type;
178ebfedea0SLionel Sambuc     /* content as defined by the type */
179*0a6a1f1dSLionel Sambuc     /*
180*0a6a1f1dSLionel Sambuc      * all encryption/message digests are applied to the 'contents', leaving
181*0a6a1f1dSLionel Sambuc      * out the 'type' field.
182*0a6a1f1dSLionel Sambuc      */
183ebfedea0SLionel Sambuc     union {
184ebfedea0SLionel Sambuc         char *ptr;
185ebfedea0SLionel Sambuc         /* NID_pkcs7_data */
186ebfedea0SLionel Sambuc         ASN1_OCTET_STRING *data;
187ebfedea0SLionel Sambuc         /* NID_pkcs7_signed */
188ebfedea0SLionel Sambuc         PKCS7_SIGNED *sign;
189ebfedea0SLionel Sambuc         /* NID_pkcs7_enveloped */
190ebfedea0SLionel Sambuc         PKCS7_ENVELOPE *enveloped;
191ebfedea0SLionel Sambuc         /* NID_pkcs7_signedAndEnveloped */
192ebfedea0SLionel Sambuc         PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
193ebfedea0SLionel Sambuc         /* NID_pkcs7_digest */
194ebfedea0SLionel Sambuc         PKCS7_DIGEST *digest;
195ebfedea0SLionel Sambuc         /* NID_pkcs7_encrypted */
196ebfedea0SLionel Sambuc         PKCS7_ENCRYPT *encrypted;
197ebfedea0SLionel Sambuc         /* Anything else */
198ebfedea0SLionel Sambuc         ASN1_TYPE *other;
199ebfedea0SLionel Sambuc     } d;
200ebfedea0SLionel Sambuc } PKCS7;
201ebfedea0SLionel Sambuc 
202ebfedea0SLionel Sambuc DECLARE_STACK_OF(PKCS7)
203ebfedea0SLionel Sambuc DECLARE_ASN1_SET_OF(PKCS7)
204ebfedea0SLionel Sambuc DECLARE_PKCS12_STACK_OF(PKCS7)
205ebfedea0SLionel Sambuc 
206ebfedea0SLionel Sambuc # define PKCS7_OP_SET_DETACHED_SIGNATURE 1
207ebfedea0SLionel Sambuc # define PKCS7_OP_GET_DETACHED_SIGNATURE 2
208ebfedea0SLionel Sambuc 
209ebfedea0SLionel Sambuc # define PKCS7_get_signed_attributes(si) ((si)->auth_attr)
210ebfedea0SLionel Sambuc # define PKCS7_get_attributes(si)        ((si)->unauth_attr)
211ebfedea0SLionel Sambuc 
212ebfedea0SLionel Sambuc # define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed)
213ebfedea0SLionel Sambuc # define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted)
214ebfedea0SLionel Sambuc # define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped)
215ebfedea0SLionel Sambuc # define PKCS7_type_is_signedAndEnveloped(a) \
216ebfedea0SLionel Sambuc                 (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped)
217ebfedea0SLionel Sambuc # define PKCS7_type_is_data(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_data)
218ebfedea0SLionel Sambuc # define PKCS7_type_is_digest(a)   (OBJ_obj2nid((a)->type) == NID_pkcs7_digest)
219ebfedea0SLionel Sambuc 
220ebfedea0SLionel Sambuc # define PKCS7_set_detached(p,v) \
221ebfedea0SLionel Sambuc                 PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL)
222ebfedea0SLionel Sambuc # define PKCS7_get_detached(p) \
223ebfedea0SLionel Sambuc                 PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL)
224ebfedea0SLionel Sambuc 
225ebfedea0SLionel Sambuc # define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7))
226ebfedea0SLionel Sambuc 
227ebfedea0SLionel Sambuc /* S/MIME related flags */
228ebfedea0SLionel Sambuc 
229ebfedea0SLionel Sambuc # define PKCS7_TEXT              0x1
230ebfedea0SLionel Sambuc # define PKCS7_NOCERTS           0x2
231ebfedea0SLionel Sambuc # define PKCS7_NOSIGS            0x4
232ebfedea0SLionel Sambuc # define PKCS7_NOCHAIN           0x8
233ebfedea0SLionel Sambuc # define PKCS7_NOINTERN          0x10
234ebfedea0SLionel Sambuc # define PKCS7_NOVERIFY          0x20
235ebfedea0SLionel Sambuc # define PKCS7_DETACHED          0x40
236ebfedea0SLionel Sambuc # define PKCS7_BINARY            0x80
237ebfedea0SLionel Sambuc # define PKCS7_NOATTR            0x100
238ebfedea0SLionel Sambuc # define PKCS7_NOSMIMECAP        0x200
239ebfedea0SLionel Sambuc # define PKCS7_NOOLDMIMETYPE     0x400
240ebfedea0SLionel Sambuc # define PKCS7_CRLFEOL           0x800
241ebfedea0SLionel Sambuc # define PKCS7_STREAM            0x1000
242ebfedea0SLionel Sambuc # define PKCS7_NOCRL             0x2000
243ebfedea0SLionel Sambuc # define PKCS7_PARTIAL           0x4000
244ebfedea0SLionel Sambuc # define PKCS7_REUSE_DIGEST      0x8000
245ebfedea0SLionel Sambuc 
246ebfedea0SLionel Sambuc /* Flags: for compatibility with older code */
247ebfedea0SLionel Sambuc 
248ebfedea0SLionel Sambuc # define SMIME_TEXT      PKCS7_TEXT
249ebfedea0SLionel Sambuc # define SMIME_NOCERTS   PKCS7_NOCERTS
250ebfedea0SLionel Sambuc # define SMIME_NOSIGS    PKCS7_NOSIGS
251ebfedea0SLionel Sambuc # define SMIME_NOCHAIN   PKCS7_NOCHAIN
252ebfedea0SLionel Sambuc # define SMIME_NOINTERN  PKCS7_NOINTERN
253ebfedea0SLionel Sambuc # define SMIME_NOVERIFY  PKCS7_NOVERIFY
254ebfedea0SLionel Sambuc # define SMIME_DETACHED  PKCS7_DETACHED
255ebfedea0SLionel Sambuc # define SMIME_BINARY    PKCS7_BINARY
256ebfedea0SLionel Sambuc # define SMIME_NOATTR    PKCS7_NOATTR
257ebfedea0SLionel Sambuc 
258ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL)
259ebfedea0SLionel Sambuc 
260*0a6a1f1dSLionel Sambuc int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data,
261*0a6a1f1dSLionel Sambuc                                    const EVP_MD *type, unsigned char *md,
262*0a6a1f1dSLionel Sambuc                                    unsigned int *len);
263ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_FP_API
264ebfedea0SLionel Sambuc PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7);
265ebfedea0SLionel Sambuc int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7);
266ebfedea0SLionel Sambuc # endif
267ebfedea0SLionel Sambuc PKCS7 *PKCS7_dup(PKCS7 *p7);
268ebfedea0SLionel Sambuc PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7);
269ebfedea0SLionel Sambuc int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7);
270ebfedea0SLionel Sambuc int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
271ebfedea0SLionel Sambuc int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags);
272ebfedea0SLionel Sambuc 
273ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO)
274ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO)
275ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED)
276ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT)
277ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE)
278ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE)
279ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST)
280ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT)
281ebfedea0SLionel Sambuc DECLARE_ASN1_FUNCTIONS(PKCS7)
282ebfedea0SLionel Sambuc 
283ebfedea0SLionel Sambuc DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN)
284ebfedea0SLionel Sambuc DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY)
285ebfedea0SLionel Sambuc 
286ebfedea0SLionel Sambuc DECLARE_ASN1_NDEF_FUNCTION(PKCS7)
287ebfedea0SLionel Sambuc DECLARE_ASN1_PRINT_FUNCTION(PKCS7)
288ebfedea0SLionel Sambuc 
289ebfedea0SLionel Sambuc long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg);
290ebfedea0SLionel Sambuc 
291ebfedea0SLionel Sambuc int PKCS7_set_type(PKCS7 *p7, int type);
292ebfedea0SLionel Sambuc int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other);
293ebfedea0SLionel Sambuc int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
294ebfedea0SLionel Sambuc int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
295ebfedea0SLionel Sambuc                           const EVP_MD *dgst);
296ebfedea0SLionel Sambuc int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si);
297ebfedea0SLionel Sambuc int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
298ebfedea0SLionel Sambuc int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
299ebfedea0SLionel Sambuc int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
300ebfedea0SLionel Sambuc int PKCS7_content_new(PKCS7 *p7, int nid);
301ebfedea0SLionel Sambuc int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx,
302ebfedea0SLionel Sambuc                      BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si);
303ebfedea0SLionel Sambuc int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si,
304ebfedea0SLionel Sambuc                           X509 *x509);
305ebfedea0SLionel Sambuc 
306ebfedea0SLionel Sambuc BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio);
307ebfedea0SLionel Sambuc int PKCS7_dataFinal(PKCS7 *p7, BIO *bio);
308ebfedea0SLionel Sambuc BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert);
309ebfedea0SLionel Sambuc 
310ebfedea0SLionel Sambuc PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
311ebfedea0SLionel Sambuc                                        EVP_PKEY *pkey, const EVP_MD *dgst);
312ebfedea0SLionel Sambuc X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
313ebfedea0SLionel Sambuc int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md);
314ebfedea0SLionel Sambuc STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);
315ebfedea0SLionel Sambuc 
316ebfedea0SLionel Sambuc PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509);
317ebfedea0SLionel Sambuc void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk,
318ebfedea0SLionel Sambuc                                  X509_ALGOR **pdig, X509_ALGOR **psig);
319ebfedea0SLionel Sambuc void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc);
320ebfedea0SLionel Sambuc int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri);
321ebfedea0SLionel Sambuc int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509);
322ebfedea0SLionel Sambuc int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher);
323ebfedea0SLionel Sambuc int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7);
324ebfedea0SLionel Sambuc 
325ebfedea0SLionel Sambuc PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx);
326ebfedea0SLionel Sambuc ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk);
327ebfedea0SLionel Sambuc int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type,
328ebfedea0SLionel Sambuc                                void *data);
329ebfedea0SLionel Sambuc int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype,
330ebfedea0SLionel Sambuc                         void *value);
331ebfedea0SLionel Sambuc ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid);
332ebfedea0SLionel Sambuc ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid);
333ebfedea0SLionel Sambuc int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si,
334ebfedea0SLionel Sambuc                                 STACK_OF(X509_ATTRIBUTE) *sk);
335*0a6a1f1dSLionel Sambuc int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si,
336*0a6a1f1dSLionel Sambuc                          STACK_OF(X509_ATTRIBUTE) *sk);
337ebfedea0SLionel Sambuc 
338ebfedea0SLionel Sambuc PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs,
339ebfedea0SLionel Sambuc                   BIO *data, int flags);
340ebfedea0SLionel Sambuc 
341ebfedea0SLionel Sambuc PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7,
342*0a6a1f1dSLionel Sambuc                                          X509 *signcert, EVP_PKEY *pkey,
343*0a6a1f1dSLionel Sambuc                                          const EVP_MD *md, int flags);
344ebfedea0SLionel Sambuc 
345ebfedea0SLionel Sambuc int PKCS7_final(PKCS7 *p7, BIO *data, int flags);
346ebfedea0SLionel Sambuc int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
347ebfedea0SLionel Sambuc                  BIO *indata, BIO *out, int flags);
348*0a6a1f1dSLionel Sambuc STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs,
349*0a6a1f1dSLionel Sambuc                                    int flags);
350ebfedea0SLionel Sambuc PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
351ebfedea0SLionel Sambuc                      int flags);
352*0a6a1f1dSLionel Sambuc int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data,
353*0a6a1f1dSLionel Sambuc                   int flags);
354ebfedea0SLionel Sambuc 
355ebfedea0SLionel Sambuc int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si,
356ebfedea0SLionel Sambuc                               STACK_OF(X509_ALGOR) *cap);
357ebfedea0SLionel Sambuc STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si);
358ebfedea0SLionel Sambuc int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg);
359ebfedea0SLionel Sambuc 
360ebfedea0SLionel Sambuc int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid);
361ebfedea0SLionel Sambuc int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t);
362ebfedea0SLionel Sambuc int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si,
363ebfedea0SLionel Sambuc                              const unsigned char *md, int mdlen);
364ebfedea0SLionel Sambuc 
365ebfedea0SLionel Sambuc int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags);
366ebfedea0SLionel Sambuc PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont);
367ebfedea0SLionel Sambuc 
368ebfedea0SLionel Sambuc BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7);
369ebfedea0SLionel Sambuc 
370ebfedea0SLionel Sambuc /* BEGIN ERROR CODES */
371*0a6a1f1dSLionel Sambuc /*
372*0a6a1f1dSLionel Sambuc  * The following lines are auto generated by the script mkerr.pl. Any changes
373ebfedea0SLionel Sambuc  * made after this point may be overwritten when the script is next run.
374ebfedea0SLionel Sambuc  */
375ebfedea0SLionel Sambuc void ERR_load_PKCS7_strings(void);
376ebfedea0SLionel Sambuc 
377ebfedea0SLionel Sambuc /* Error codes for the PKCS7 functions. */
378ebfedea0SLionel Sambuc 
379ebfedea0SLionel Sambuc /* Function codes. */
380ebfedea0SLionel Sambuc # define PKCS7_F_B64_READ_PKCS7                           120
381ebfedea0SLionel Sambuc # define PKCS7_F_B64_WRITE_PKCS7                          121
382ebfedea0SLionel Sambuc # define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB                   136
383ebfedea0SLionel Sambuc # define PKCS7_F_I2D_PKCS7_BIO_STREAM                     140
384ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME           135
385ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP                118
386ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ADD_CERTIFICATE                    100
387ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ADD_CRL                            101
388ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO                 102
389ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ADD_SIGNATURE                      131
390ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ADD_SIGNER                         103
391ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_BIO_ADD_DIGEST                     125
392ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST               138
393ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_CTRL                               104
394ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_DATADECODE                         112
395ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_DATAFINAL                          128
396ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_DATAINIT                           105
397ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_DATASIGN                           106
398ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_DATAVERIFY                         107
399ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_DECRYPT                            114
400ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_DECRYPT_RINFO                      133
401ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ENCODE_RINFO                       132
402ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_ENCRYPT                            115
403ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_FINAL                              134
404ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_FIND_DIGEST                        127
405ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_GET0_SIGNERS                       124
406ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_RECIP_INFO_SET                     130
407ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SET_CIPHER                         108
408ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SET_CONTENT                        109
409ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SET_DIGEST                         126
410ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SET_TYPE                           110
411ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SIGN                               116
412ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SIGNATUREVERIFY                    113
413ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SIGNER_INFO_SET                    129
414ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SIGNER_INFO_SIGN                   139
415ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SIGN_ADD_SIGNER                    137
416ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_SIMPLE_SMIMECAP                    119
417ebfedea0SLionel Sambuc # define PKCS7_F_PKCS7_VERIFY                             117
418ebfedea0SLionel Sambuc # define PKCS7_F_SMIME_READ_PKCS7                         122
419ebfedea0SLionel Sambuc # define PKCS7_F_SMIME_TEXT                               123
420ebfedea0SLionel Sambuc 
421ebfedea0SLionel Sambuc /* Reason codes. */
422ebfedea0SLionel Sambuc # define PKCS7_R_CERTIFICATE_VERIFY_ERROR                 117
423ebfedea0SLionel Sambuc # define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER          144
424ebfedea0SLionel Sambuc # define PKCS7_R_CIPHER_NOT_INITIALIZED                   116
425ebfedea0SLionel Sambuc # define PKCS7_R_CONTENT_AND_DATA_PRESENT                 118
426ebfedea0SLionel Sambuc # define PKCS7_R_CTRL_ERROR                               152
427ebfedea0SLionel Sambuc # define PKCS7_R_DECODE_ERROR                             130
428ebfedea0SLionel Sambuc # define PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH            100
429ebfedea0SLionel Sambuc # define PKCS7_R_DECRYPT_ERROR                            119
430ebfedea0SLionel Sambuc # define PKCS7_R_DIGEST_FAILURE                           101
431ebfedea0SLionel Sambuc # define PKCS7_R_ENCRYPTION_CTRL_FAILURE                  149
432ebfedea0SLionel Sambuc # define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150
433ebfedea0SLionel Sambuc # define PKCS7_R_ERROR_ADDING_RECIPIENT                   120
434ebfedea0SLionel Sambuc # define PKCS7_R_ERROR_SETTING_CIPHER                     121
435ebfedea0SLionel Sambuc # define PKCS7_R_INVALID_MIME_TYPE                        131
436ebfedea0SLionel Sambuc # define PKCS7_R_INVALID_NULL_POINTER                     143
437*0a6a1f1dSLionel Sambuc # define PKCS7_R_INVALID_SIGNED_DATA_TYPE                 155
438ebfedea0SLionel Sambuc # define PKCS7_R_MIME_NO_CONTENT_TYPE                     132
439ebfedea0SLionel Sambuc # define PKCS7_R_MIME_PARSE_ERROR                         133
440ebfedea0SLionel Sambuc # define PKCS7_R_MIME_SIG_PARSE_ERROR                     134
441ebfedea0SLionel Sambuc # define PKCS7_R_MISSING_CERIPEND_INFO                    103
442ebfedea0SLionel Sambuc # define PKCS7_R_NO_CONTENT                               122
443ebfedea0SLionel Sambuc # define PKCS7_R_NO_CONTENT_TYPE                          135
444ebfedea0SLionel Sambuc # define PKCS7_R_NO_DEFAULT_DIGEST                        151
445ebfedea0SLionel Sambuc # define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND            154
446ebfedea0SLionel Sambuc # define PKCS7_R_NO_MULTIPART_BODY_FAILURE                136
447ebfedea0SLionel Sambuc # define PKCS7_R_NO_MULTIPART_BOUNDARY                    137
448ebfedea0SLionel Sambuc # define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE         115
449ebfedea0SLionel Sambuc # define PKCS7_R_NO_RECIPIENT_MATCHES_KEY                 146
450ebfedea0SLionel Sambuc # define PKCS7_R_NO_SIGNATURES_ON_DATA                    123
451ebfedea0SLionel Sambuc # define PKCS7_R_NO_SIGNERS                               142
452ebfedea0SLionel Sambuc # define PKCS7_R_NO_SIG_CONTENT_TYPE                      138
453ebfedea0SLionel Sambuc # define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE     104
454ebfedea0SLionel Sambuc # define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR                124
455ebfedea0SLionel Sambuc # define PKCS7_R_PKCS7_ADD_SIGNER_ERROR                   153
456ebfedea0SLionel Sambuc # define PKCS7_R_PKCS7_DATAFINAL                          126
457ebfedea0SLionel Sambuc # define PKCS7_R_PKCS7_DATAFINAL_ERROR                    125
458ebfedea0SLionel Sambuc # define PKCS7_R_PKCS7_DATASIGN                           145
459ebfedea0SLionel Sambuc # define PKCS7_R_PKCS7_PARSE_ERROR                        139
460ebfedea0SLionel Sambuc # define PKCS7_R_PKCS7_SIG_PARSE_ERROR                    140
461ebfedea0SLionel Sambuc # define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE   127
462ebfedea0SLionel Sambuc # define PKCS7_R_SIGNATURE_FAILURE                        105
463ebfedea0SLionel Sambuc # define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND             128
464ebfedea0SLionel Sambuc # define PKCS7_R_SIGNING_CTRL_FAILURE                     147
465ebfedea0SLionel Sambuc # define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE  148
466ebfedea0SLionel Sambuc # define PKCS7_R_SIG_INVALID_MIME_TYPE                    141
467ebfedea0SLionel Sambuc # define PKCS7_R_SMIME_TEXT_ERROR                         129
468ebfedea0SLionel Sambuc # define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE               106
469ebfedea0SLionel Sambuc # define PKCS7_R_UNABLE_TO_FIND_MEM_BIO                   107
470ebfedea0SLionel Sambuc # define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST            108
471ebfedea0SLionel Sambuc # define PKCS7_R_UNKNOWN_DIGEST_TYPE                      109
472ebfedea0SLionel Sambuc # define PKCS7_R_UNKNOWN_OPERATION                        110
473ebfedea0SLionel Sambuc # define PKCS7_R_UNSUPPORTED_CIPHER_TYPE                  111
474ebfedea0SLionel Sambuc # define PKCS7_R_UNSUPPORTED_CONTENT_TYPE                 112
475ebfedea0SLionel Sambuc # define PKCS7_R_WRONG_CONTENT_TYPE                       113
476ebfedea0SLionel Sambuc # define PKCS7_R_WRONG_PKCS7_TYPE                         114
477ebfedea0SLionel Sambuc 
478ebfedea0SLionel Sambuc #ifdef  __cplusplus
479ebfedea0SLionel Sambuc }
480ebfedea0SLionel Sambuc #endif
481ebfedea0SLionel Sambuc #endif
482