1 /* $OpenBSD: pkcs7.h,v 1.18 2016/12/27 16:12:47 jsing Exp $ */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3  * All rights reserved.
4  *
5  * This package is an SSL implementation written
6  * by Eric Young (eay@cryptsoft.com).
7  * The implementation was written so as to conform with Netscapes SSL.
8  *
9  * This library is free for commercial and non-commercial use as core.stdc.config.c_long as
10  * the following conditions are aheared to.  The following conditions
11  * apply to all code found in this distribution, be it the RC4, RSA,
12  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13  * included with this distribution is covered by the same copyright terms
14  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15  *
16  * Copyright remains Eric Young's, and as such any Copyright notices in
17  * the code are not to be removed.
18  * If this package is used in a product, Eric Young should be given attribution
19  * as the author of the parts of the library used.
20  * This can be in the form of a textual message at program startup or
21  * in documentation (online or textual) provided with the package.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *    must display the following acknowledgement:
33  *    "This product includes cryptographic software written by
34  *     Eric Young (eay@cryptsoft.com)"
35  *    The word 'cryptographic' can be left out if the rouines from the library
36  *    being used are not cryptographic related :-).
37  * 4. If you include any Windows specific code (or a derivative thereof) from
38  *    the apps directory (application code) you must include an acknowledgement:
39  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40  *
41  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  *
53  * The licence and distribution terms for any publically available version or
54  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55  * copied and put under another distribution licence
56  * [including the GNU Public Licence.]
57  */
58 module libressl_d.openssl.pkcs7;
59 
60 
61 private static import core.stdc.config;
62 private static import libressl_d.compat.stdio;
63 private static import libressl_d.openssl.objects;
64 private static import libressl_d.openssl.stack;
65 private static import libressl_d.openssl.x509;
66 public import libressl_d.openssl.asn1;
67 public import libressl_d.openssl.bio;
68 public import libressl_d.openssl.opensslconf;
69 public import libressl_d.openssl.ossl_typ;
70 
71 extern (C):
72 nothrow @nogc:
73 
74 //#if defined(_WIN32) && defined(__WINCRYPT_H__)
75 	version (LIBRESSL_INTERNAL) {
76 	} else {
77 		//pragma(msg, "Warning, overriding WinCrypt defines");
78 	}
79 
80 	//#undef PKCS7_ISSUER_AND_SERIAL
81 	//#undef PKCS7_SIGNER_INFO
82 //#endif
83 
84 /*
85  * ncryption_ID		DES-CBC
86 Digest_ID		MD5
87 Digest_Encryption_ID	rsaEncryption
88 Key_Encryption_ID	rsaEncryption
89  */
90 
91 struct pkcs7_issuer_and_serial_st
92 {
93 	libressl_d.openssl.ossl_typ.X509_NAME* issuer;
94 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* serial;
95 }
96 
97 alias PKCS7_ISSUER_AND_SERIAL = .pkcs7_issuer_and_serial_st;
98 
99 struct pkcs7_signer_info_st
100 {
101 	/**
102 	 * version 1
103 	 */
104 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* version_;
105 
106 	.PKCS7_ISSUER_AND_SERIAL* issuer_and_serial;
107 	libressl_d.openssl.ossl_typ.X509_ALGOR* digest_alg;
108 
109 	/**
110 	 * [ 0 ]
111 	 */
112 	libressl_d.openssl.x509.stack_st_X509_ATTRIBUTE* auth_attr;
113 
114 	libressl_d.openssl.ossl_typ.X509_ALGOR* digest_enc_alg;
115 	libressl_d.openssl.ossl_typ.ASN1_OCTET_STRING* enc_digest;
116 
117 	/**
118 	 * [ 1 ]
119 	 */
120 	libressl_d.openssl.x509.stack_st_X509_ATTRIBUTE* unauth_attr;
121 
122 	/* The private key to sign with */
123 	libressl_d.openssl.ossl_typ.EVP_PKEY* pkey;
124 }
125 
126 alias PKCS7_SIGNER_INFO = .pkcs7_signer_info_st;
127 
128 //DECLARE_STACK_OF(PKCS7_SIGNER_INFO)
129 struct stack_st_PKCS7_SIGNER_INFO
130 {
131 	libressl_d.openssl.stack._STACK stack;
132 }
133 
134 struct pkcs7_recip_info_st
135 {
136 	/**
137 	 * version 0
138 	 */
139 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* version_;
140 
141 	.PKCS7_ISSUER_AND_SERIAL* issuer_and_serial;
142 	libressl_d.openssl.ossl_typ.X509_ALGOR* key_enc_algor;
143 	libressl_d.openssl.ossl_typ.ASN1_OCTET_STRING* enc_key;
144 
145 	/**
146 	 * get the pub-key from this
147 	 */
148 	libressl_d.openssl.ossl_typ.X509* cert;
149 }
150 
151 alias PKCS7_RECIP_INFO = .pkcs7_recip_info_st;
152 
153 //DECLARE_STACK_OF(PKCS7_RECIP_INFO)
154 struct stack_st_PKCS7_RECIP_INFO
155 {
156 	libressl_d.openssl.stack._STACK stack;
157 }
158 
159 struct pkcs7_signed_st
160 {
161 	/**
162 	 * version 1
163 	 */
164 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* version_;
165 
166 	/**
167 	 * md used
168 	 */
169 	libressl_d.openssl.asn1.stack_st_X509_ALGOR* md_algs;
170 
171 	/**
172 	 * [ 0 ]
173 	 */
174 	libressl_d.openssl.x509.stack_st_X509* cert;
175 
176 	/**
177 	 * [ 1 ]
178 	 */
179 	libressl_d.openssl.x509.stack_st_X509_CRL* crl;
180 
181 	.stack_st_PKCS7_SIGNER_INFO* signer_info;
182 
183 	.pkcs7_st* contents;
184 }
185 
186 alias PKCS7_SIGNED = .pkcs7_signed_st;
187 /*
188  * The above structure is very very similar to PKCS7_SIGN_ENVELOPE.
189  * How about merging the two
190  */
191 
192 struct pkcs7_enc_content_st
193 {
194 	libressl_d.openssl.asn1.ASN1_OBJECT* content_type;
195 	libressl_d.openssl.ossl_typ.X509_ALGOR* algorithm;
196 
197 	/**
198 	 * [ 0 ]
199 	 */
200 	libressl_d.openssl.ossl_typ.ASN1_OCTET_STRING* enc_data;
201 
202 	const (libressl_d.openssl.ossl_typ.EVP_CIPHER)* cipher;
203 }
204 
205 alias PKCS7_ENC_CONTENT = .pkcs7_enc_content_st;
206 
207 struct pkcs7_enveloped_st
208 {
209 	/**
210 	 * version 0
211 	 */
212 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* version_;
213 
214 	.stack_st_PKCS7_RECIP_INFO* recipientinfo;
215 	.PKCS7_ENC_CONTENT* enc_data;
216 }
217 
218 alias PKCS7_ENVELOPE = .pkcs7_enveloped_st;
219 
220 struct pkcs7_signedandenveloped_st
221 {
222 	/**
223 	 * version 1
224 	 */
225 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* version_;
226 
227 	/**
228 	 * md used
229 	 */
230 	libressl_d.openssl.asn1.stack_st_X509_ALGOR* md_algs;
231 
232 	/**
233 	 * [ 0 ]
234 	 */
235 	libressl_d.openssl.x509.stack_st_X509* cert;
236 
237 	/**
238 	 * [ 1 ]
239 	 */
240 	libressl_d.openssl.x509.stack_st_X509_CRL* crl;
241 
242 	.stack_st_PKCS7_SIGNER_INFO* signer_info;
243 
244 	.PKCS7_ENC_CONTENT* enc_data;
245 	.stack_st_PKCS7_RECIP_INFO* recipientinfo;
246 }
247 
248 alias PKCS7_SIGN_ENVELOPE = .pkcs7_signedandenveloped_st;
249 
250 struct pkcs7_digest_st
251 {
252 	/**
253 	 * version 0
254 	 */
255 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* version_;
256 
257 	/**
258 	 * md used
259 	 */
260 	libressl_d.openssl.ossl_typ.X509_ALGOR* md;
261 
262 	.pkcs7_st* contents;
263 	libressl_d.openssl.ossl_typ.ASN1_OCTET_STRING* digest;
264 }
265 
266 alias PKCS7_DIGEST = .pkcs7_digest_st;
267 
268 struct pkcs7_encrypted_st
269 {
270 	/**
271 	 * version 0
272 	 */
273 	libressl_d.openssl.ossl_typ.ASN1_INTEGER* version_;
274 
275 	.PKCS7_ENC_CONTENT* enc_data;
276 }
277 
278 alias PKCS7_ENCRYPT = .pkcs7_encrypted_st;
279 
280 struct pkcs7_st
281 {
282 	/*
283 	 * The following is non null if it contains ASN1 encoding of
284 	 * this structure
285 	 */
286 	ubyte* asn1;
287 	core.stdc.config.c_long length_;
288 
289 	enum PKCS7_S_HEADER = 0;
290 	enum PKCS7_S_BODY = 1;
291 	enum PKCS7_S_TAIL = 2;
292 
293 	/**
294 	 * used during processing
295 	 */
296 	int state;
297 
298 	int detached;
299 
300 	/**
301 	 * content as defined by the type
302 	 */
303 	libressl_d.openssl.asn1.ASN1_OBJECT* type;
304 
305 	/**
306 	 * all encryption/message digests are applied to the 'contents',
307 	 * leaving out the 'type' field.
308 	 */
309 	union d_
310 	{
311 		char* ptr_;
312 
313 		/**
314 		 * NID_pkcs7_data
315 		 */
316 		libressl_d.openssl.ossl_typ.ASN1_OCTET_STRING* data;
317 
318 		/**
319 		 * NID_pkcs7_signed
320 		 */
321 		.PKCS7_SIGNED* sign;
322 
323 		/**
324 		 * NID_pkcs7_enveloped
325 		 */
326 		.PKCS7_ENVELOPE* enveloped;
327 
328 		/**
329 		 * NID_pkcs7_signedAndEnveloped
330 		 */
331 		.PKCS7_SIGN_ENVELOPE* signed_and_enveloped;
332 
333 		/**
334 		 * NID_pkcs7_digest
335 		 */
336 		.PKCS7_DIGEST* digest;
337 
338 		/**
339 		 * NID_pkcs7_encrypted
340 		 */
341 		.PKCS7_ENCRYPT* encrypted;
342 
343 		/**
344 		 * Anything else
345 		 */
346 		libressl_d.openssl.asn1.ASN1_TYPE* other;
347 	}
348 
349 	d_ d;
350 }
351 
352 alias PKCS7 = .pkcs7_st;
353 
354 //DECLARE_STACK_OF(PKCS7)
355 struct stack_st_PKCS7
356 {
357 	libressl_d.openssl.stack._STACK stack;
358 }
359 
360 //libressl_d.openssl.ossl_typ.DECLARE_PKCS12_STACK_OF(PKCS7)
361 
362 enum PKCS7_OP_SET_DETACHED_SIGNATURE = 1;
363 enum PKCS7_OP_GET_DETACHED_SIGNATURE = 2;
364 
365 pragma(inline, true)
366 pure nothrow @trusted @nogc @live
367 libressl_d.openssl.x509.stack_st_X509_ATTRIBUTE* PKCS7_get_signed_attributes(return scope .PKCS7_SIGNER_INFO* si)
368 
369 	in
370 	{
371 		assert(si != null);
372 	}
373 
374 	do
375 	{
376 		return si.auth_attr;
377 	}
378 
379 pragma(inline, true)
380 pure nothrow @trusted @nogc @live
381 libressl_d.openssl.x509.stack_st_X509_ATTRIBUTE* PKCS7_get_attributes(return scope .PKCS7_SIGNER_INFO* si)
382 
383 	in
384 	{
385 		assert(si != null);
386 	}
387 
388 	do
389 	{
390 		return si.unauth_attr;
391 	}
392 
393 pragma(inline, true)
394 bool PKCS7_type_is_signed(A)(scope const A* a)
395 
396 	in
397 	{
398 		assert(a != null);
399 	}
400 
401 	do
402 	{
403 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_signed;
404 	}
405 
406 pragma(inline, true)
407 bool PKCS7_type_is_encrypted(A)(scope const A* a)
408 
409 	in
410 	{
411 		assert(a != null);
412 	}
413 
414 	do
415 	{
416 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_encrypted;
417 	}
418 
419 pragma(inline, true)
420 bool PKCS7_type_is_enveloped(A)(scope const A* a)
421 
422 	in
423 	{
424 		assert(a != null);
425 	}
426 
427 	do
428 	{
429 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_enveloped;
430 	}
431 
432 pragma(inline, true)
433 bool PKCS7_type_is_signedAndEnveloped(A)(scope const A* a)
434 
435 	in
436 	{
437 		assert(a != null);
438 	}
439 
440 	do
441 	{
442 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_signedAndEnveloped;
443 	}
444 
445 pragma(inline, true)
446 bool PKCS7_type_is_data(A)(scope const A* a)
447 
448 	in
449 	{
450 		assert(a != null);
451 	}
452 
453 	do
454 	{
455 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_data;
456 	}
457 
458 pragma(inline, true)
459 bool PKCS7_type_is_digest(A)(scope const A* a)
460 
461 	in
462 	{
463 		assert(a != null);
464 	}
465 
466 	do
467 	{
468 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_digest;
469 	}
470 
471 pragma(inline, true)
472 bool PKCS7_type_is_encrypted(A)(scope const A* a)
473 
474 	in
475 	{
476 		assert(a != null);
477 	}
478 
479 	do
480 	{
481 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_encrypted;
482 	}
483 
484 pragma(inline, true)
485 bool PKCS7_type_is_digest(A)(scope const A* a)
486 
487 	in
488 	{
489 		assert(a != null);
490 	}
491 
492 	do
493 	{
494 		return libressl_d.openssl.objects.OBJ_obj2nid(a.type) == libressl_d.openssl.objects.NID_pkcs7_digest;
495 	}
496 
497 pragma(inline, true)
498 core.stdc.config.c_long PKCS7_set_detached(.PKCS7* p, core.stdc.config.c_long v)
499 
500 	do
501 	{
502 		return .PKCS7_ctrl(p, .PKCS7_OP_SET_DETACHED_SIGNATURE, v, null);
503 	}
504 
505 pragma(inline, true)
506 core.stdc.config.c_long PKCS7_get_detached(.PKCS7* p)
507 
508 	do
509 	{
510 		return .PKCS7_ctrl(p, .PKCS7_OP_GET_DETACHED_SIGNATURE, 0, null);
511 	}
512 
513 pragma(inline, true)
514 bool PKCS7_is_detached(P7)(P7 p7)
515 
516 	do
517 	{
518 		return (.PKCS7_type_is_signed(p7)) && (.PKCS7_get_detached(p7));
519 	}
520 
521 /* S/MIME related flags */
522 
523 enum PKCS7_TEXT = 0x01;
524 enum PKCS7_NOCERTS = 0x02;
525 enum PKCS7_NOSIGS = 0x04;
526 enum PKCS7_NOCHAIN = 0x08;
527 enum PKCS7_NOINTERN = 0x10;
528 enum PKCS7_NOVERIFY = 0x20;
529 enum PKCS7_DETACHED = 0x40;
530 enum PKCS7_BINARY = 0x80;
531 enum PKCS7_NOATTR = 0x0100;
532 enum PKCS7_NOSMIMECAP = 0x0200;
533 enum PKCS7_NOOLDMIMETYPE = 0x0400;
534 enum PKCS7_CRLFEOL = 0x0800;
535 enum PKCS7_STREAM = 0x1000;
536 enum PKCS7_NOCRL = 0x2000;
537 enum PKCS7_PARTIAL = 0x4000;
538 enum PKCS7_REUSE_DIGEST = 0x8000;
539 
540 /* Flags: for compatibility with older code */
541 
542 enum SMIME_TEXT = .PKCS7_TEXT;
543 enum SMIME_NOCERTS = .PKCS7_NOCERTS;
544 enum SMIME_NOSIGS = .PKCS7_NOSIGS;
545 enum SMIME_NOCHAIN = .PKCS7_NOCHAIN;
546 enum SMIME_NOINTERN = .PKCS7_NOINTERN;
547 enum SMIME_NOVERIFY = .PKCS7_NOVERIFY;
548 enum SMIME_DETACHED = .PKCS7_DETACHED;
549 enum SMIME_BINARY = .PKCS7_BINARY;
550 enum SMIME_NOATTR = .PKCS7_NOATTR;
551 
552 .PKCS7_ISSUER_AND_SERIAL* PKCS7_ISSUER_AND_SERIAL_new();
553 void PKCS7_ISSUER_AND_SERIAL_free(.PKCS7_ISSUER_AND_SERIAL* a);
554 .PKCS7_ISSUER_AND_SERIAL* d2i_PKCS7_ISSUER_AND_SERIAL(.PKCS7_ISSUER_AND_SERIAL** a, const (ubyte)** in_, core.stdc.config.c_long len);
555 int i2d_PKCS7_ISSUER_AND_SERIAL(.PKCS7_ISSUER_AND_SERIAL* a, ubyte** out_);
556 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_ISSUER_AND_SERIAL_it;
557 
558 int PKCS7_ISSUER_AND_SERIAL_digest(.PKCS7_ISSUER_AND_SERIAL* data, const (libressl_d.openssl.ossl_typ.EVP_MD)* type, ubyte* md, uint* len);
559 .PKCS7* d2i_PKCS7_fp(libressl_d.compat.stdio.FILE* fp, .PKCS7** p7);
560 int i2d_PKCS7_fp(libressl_d.compat.stdio.FILE* fp, .PKCS7* p7);
561 .PKCS7* PKCS7_dup(.PKCS7* p7);
562 .PKCS7* d2i_PKCS7_bio(libressl_d.openssl.bio.BIO* bp, .PKCS7** p7);
563 int i2d_PKCS7_bio(libressl_d.openssl.bio.BIO* bp, .PKCS7* p7);
564 int i2d_PKCS7_bio_stream(libressl_d.openssl.bio.BIO* out_, .PKCS7* p7, libressl_d.openssl.bio.BIO* in_, int flags);
565 int PEM_write_bio_PKCS7_stream(libressl_d.openssl.bio.BIO* out_, .PKCS7* p7, libressl_d.openssl.bio.BIO* in_, int flags);
566 
567 .PKCS7_SIGNER_INFO* PKCS7_SIGNER_INFO_new();
568 void PKCS7_SIGNER_INFO_free(.PKCS7_SIGNER_INFO* a);
569 .PKCS7_SIGNER_INFO* d2i_PKCS7_SIGNER_INFO(.PKCS7_SIGNER_INFO** a, const (ubyte)** in_, core.stdc.config.c_long len);
570 int i2d_PKCS7_SIGNER_INFO(.PKCS7_SIGNER_INFO* a, ubyte** out_);
571 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_SIGNER_INFO_it;
572 .PKCS7_RECIP_INFO* PKCS7_RECIP_INFO_new();
573 void PKCS7_RECIP_INFO_free(.PKCS7_RECIP_INFO* a);
574 .PKCS7_RECIP_INFO* d2i_PKCS7_RECIP_INFO(.PKCS7_RECIP_INFO** a, const (ubyte)** in_, core.stdc.config.c_long len);
575 int i2d_PKCS7_RECIP_INFO(.PKCS7_RECIP_INFO* a, ubyte** out_);
576 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_RECIP_INFO_it;
577 .PKCS7_SIGNED* PKCS7_SIGNED_new();
578 void PKCS7_SIGNED_free(.PKCS7_SIGNED* a);
579 .PKCS7_SIGNED* d2i_PKCS7_SIGNED(.PKCS7_SIGNED** a, const (ubyte)** in_, core.stdc.config.c_long len);
580 int i2d_PKCS7_SIGNED(.PKCS7_SIGNED* a, ubyte** out_);
581 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_SIGNED_it;
582 .PKCS7_ENC_CONTENT* PKCS7_ENC_CONTENT_new();
583 void PKCS7_ENC_CONTENT_free(.PKCS7_ENC_CONTENT* a);
584 .PKCS7_ENC_CONTENT* d2i_PKCS7_ENC_CONTENT(.PKCS7_ENC_CONTENT** a, const (ubyte)** in_, core.stdc.config.c_long len);
585 int i2d_PKCS7_ENC_CONTENT(.PKCS7_ENC_CONTENT* a, ubyte** out_);
586 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_ENC_CONTENT_it;
587 .PKCS7_ENVELOPE* PKCS7_ENVELOPE_new();
588 void PKCS7_ENVELOPE_free(.PKCS7_ENVELOPE* a);
589 .PKCS7_ENVELOPE* d2i_PKCS7_ENVELOPE(.PKCS7_ENVELOPE** a, const (ubyte)** in_, core.stdc.config.c_long len);
590 int i2d_PKCS7_ENVELOPE(.PKCS7_ENVELOPE* a, ubyte** out_);
591 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_ENVELOPE_it;
592 .PKCS7_SIGN_ENVELOPE* PKCS7_SIGN_ENVELOPE_new();
593 void PKCS7_SIGN_ENVELOPE_free(.PKCS7_SIGN_ENVELOPE* a);
594 .PKCS7_SIGN_ENVELOPE* d2i_PKCS7_SIGN_ENVELOPE(.PKCS7_SIGN_ENVELOPE** a, const (ubyte)** in_, core.stdc.config.c_long len);
595 int i2d_PKCS7_SIGN_ENVELOPE(.PKCS7_SIGN_ENVELOPE* a, ubyte** out_);
596 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_SIGN_ENVELOPE_it;
597 .PKCS7_DIGEST* PKCS7_DIGEST_new();
598 void PKCS7_DIGEST_free(.PKCS7_DIGEST* a);
599 .PKCS7_DIGEST* d2i_PKCS7_DIGEST(.PKCS7_DIGEST** a, const (ubyte)** in_, core.stdc.config.c_long len);
600 int i2d_PKCS7_DIGEST(.PKCS7_DIGEST* a, ubyte** out_);
601 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_DIGEST_it;
602 .PKCS7_ENCRYPT* PKCS7_ENCRYPT_new();
603 void PKCS7_ENCRYPT_free(.PKCS7_ENCRYPT* a);
604 .PKCS7_ENCRYPT* d2i_PKCS7_ENCRYPT(.PKCS7_ENCRYPT** a, const (ubyte)** in_, core.stdc.config.c_long len);
605 int i2d_PKCS7_ENCRYPT(.PKCS7_ENCRYPT* a, ubyte** out_);
606 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_ENCRYPT_it;
607 .PKCS7* PKCS7_new();
608 void PKCS7_free(.PKCS7* a);
609 .PKCS7* d2i_PKCS7(.PKCS7** a, const (ubyte)** in_, core.stdc.config.c_long len);
610 int i2d_PKCS7(.PKCS7* a, ubyte** out_);
611 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_it;
612 
613 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_ATTR_SIGN_it;
614 extern __gshared const libressl_d.openssl.ossl_typ.ASN1_ITEM PKCS7_ATTR_VERIFY_it;
615 
616 int i2d_PKCS7_NDEF(.PKCS7* a, ubyte** out_);
617 int PKCS7_print_ctx(libressl_d.openssl.bio.BIO* out_, .PKCS7* x, int indent, const (libressl_d.openssl.ossl_typ.ASN1_PCTX)* pctx);
618 
619 core.stdc.config.c_long PKCS7_ctrl(.PKCS7* p7, int cmd, core.stdc.config.c_long larg, char* parg);
620 
621 int PKCS7_set_type(.PKCS7* p7, int type);
622 int PKCS7_set0_type_other(.PKCS7* p7, int type, libressl_d.openssl.asn1.ASN1_TYPE* other);
623 int PKCS7_set_content(.PKCS7* p7, .PKCS7* p7_data);
624 int PKCS7_SIGNER_INFO_set(.PKCS7_SIGNER_INFO* p7i, libressl_d.openssl.ossl_typ.X509* x509, libressl_d.openssl.ossl_typ.EVP_PKEY* pkey, const (libressl_d.openssl.ossl_typ.EVP_MD)* dgst);
625 int PKCS7_SIGNER_INFO_sign(.PKCS7_SIGNER_INFO* si);
626 int PKCS7_add_signer(.PKCS7* p7, .PKCS7_SIGNER_INFO* p7i);
627 int PKCS7_add_certificate(.PKCS7* p7, libressl_d.openssl.ossl_typ.X509* x509);
628 int PKCS7_add_crl(.PKCS7* p7, libressl_d.openssl.ossl_typ.X509_CRL* x509);
629 int PKCS7_content_new(.PKCS7* p7, int nid);
630 int PKCS7_dataVerify(libressl_d.openssl.ossl_typ.X509_STORE* cert_store, libressl_d.openssl.ossl_typ.X509_STORE_CTX* ctx, libressl_d.openssl.bio.BIO* bio, .PKCS7* p7, .PKCS7_SIGNER_INFO* si);
631 int PKCS7_signatureVerify(libressl_d.openssl.bio.BIO* bio, .PKCS7* p7, .PKCS7_SIGNER_INFO* si, libressl_d.openssl.ossl_typ.X509* x509);
632 
633 libressl_d.openssl.bio.BIO* PKCS7_dataInit(.PKCS7* p7, libressl_d.openssl.bio.BIO* bio);
634 int PKCS7_dataFinal(.PKCS7* p7, libressl_d.openssl.bio.BIO* bio);
635 libressl_d.openssl.bio.BIO* PKCS7_dataDecode(.PKCS7* p7, libressl_d.openssl.ossl_typ.EVP_PKEY* pkey, libressl_d.openssl.bio.BIO* in_bio, libressl_d.openssl.ossl_typ.X509* pcert);
636 
637 .PKCS7_SIGNER_INFO* PKCS7_add_signature(.PKCS7* p7, libressl_d.openssl.ossl_typ.X509* x509, libressl_d.openssl.ossl_typ.EVP_PKEY* pkey, const (libressl_d.openssl.ossl_typ.EVP_MD)* dgst);
638 libressl_d.openssl.ossl_typ.X509* PKCS7_cert_from_signer_info(.PKCS7* p7, .PKCS7_SIGNER_INFO* si);
639 int PKCS7_set_digest(.PKCS7* p7, const (libressl_d.openssl.ossl_typ.EVP_MD)* md);
640 .stack_st_PKCS7_SIGNER_INFO* PKCS7_get_signer_info(.PKCS7* p7);
641 
642 .PKCS7_RECIP_INFO* PKCS7_add_recipient(.PKCS7* p7, libressl_d.openssl.ossl_typ.X509* x509);
643 void PKCS7_SIGNER_INFO_get0_algs(.PKCS7_SIGNER_INFO* si, libressl_d.openssl.ossl_typ.EVP_PKEY** pk, libressl_d.openssl.ossl_typ.X509_ALGOR** pdig, libressl_d.openssl.ossl_typ.X509_ALGOR** psig);
644 void PKCS7_RECIP_INFO_get0_alg(.PKCS7_RECIP_INFO* ri, libressl_d.openssl.ossl_typ.X509_ALGOR** penc);
645 int PKCS7_add_recipient_info(.PKCS7* p7, .PKCS7_RECIP_INFO* ri);
646 int PKCS7_RECIP_INFO_set(.PKCS7_RECIP_INFO* p7i, libressl_d.openssl.ossl_typ.X509* x509);
647 int PKCS7_set_cipher(.PKCS7* p7, const (libressl_d.openssl.ossl_typ.EVP_CIPHER)* cipher);
648 int PKCS7_stream(ubyte*** boundary, .PKCS7* p7);
649 
650 .PKCS7_ISSUER_AND_SERIAL* PKCS7_get_issuer_and_serial(.PKCS7* p7, int idx);
651 libressl_d.openssl.ossl_typ.ASN1_OCTET_STRING* PKCS7_digest_from_attributes(libressl_d.openssl.x509.stack_st_X509_ATTRIBUTE* sk);
652 int PKCS7_add_signed_attribute(.PKCS7_SIGNER_INFO* p7si, int nid, int type, void* data);
653 int PKCS7_add_attribute(.PKCS7_SIGNER_INFO* p7si, int nid, int atrtype, void* value);
654 libressl_d.openssl.asn1.ASN1_TYPE* PKCS7_get_attribute(.PKCS7_SIGNER_INFO* si, int nid);
655 libressl_d.openssl.asn1.ASN1_TYPE* PKCS7_get_signed_attribute(.PKCS7_SIGNER_INFO* si, int nid);
656 int PKCS7_set_signed_attributes(.PKCS7_SIGNER_INFO* p7si, libressl_d.openssl.x509.stack_st_X509_ATTRIBUTE* sk);
657 int PKCS7_set_attributes(.PKCS7_SIGNER_INFO* p7si, libressl_d.openssl.x509.stack_st_X509_ATTRIBUTE* sk);
658 
659 .PKCS7* PKCS7_sign(libressl_d.openssl.ossl_typ.X509* signcert, libressl_d.openssl.ossl_typ.EVP_PKEY* pkey, libressl_d.openssl.x509.stack_st_X509* certs, libressl_d.openssl.bio.BIO* data, int flags);
660 
661 .PKCS7_SIGNER_INFO* PKCS7_sign_add_signer(.PKCS7* p7, libressl_d.openssl.ossl_typ.X509* signcert, libressl_d.openssl.ossl_typ.EVP_PKEY* pkey, const (libressl_d.openssl.ossl_typ.EVP_MD)* md, int flags);
662 
663 int PKCS7_final(.PKCS7* p7, libressl_d.openssl.bio.BIO* data, int flags);
664 int PKCS7_verify(.PKCS7* p7, libressl_d.openssl.x509.stack_st_X509* certs, libressl_d.openssl.ossl_typ.X509_STORE* store, libressl_d.openssl.bio.BIO* indata, libressl_d.openssl.bio.BIO* out_, int flags);
665 libressl_d.openssl.x509.stack_st_X509* PKCS7_get0_signers(.PKCS7* p7, libressl_d.openssl.x509.stack_st_X509* certs, int flags);
666 .PKCS7* PKCS7_encrypt(libressl_d.openssl.x509.stack_st_X509* certs, libressl_d.openssl.bio.BIO* in_, const (libressl_d.openssl.ossl_typ.EVP_CIPHER)* cipher, int flags);
667 int PKCS7_decrypt(.PKCS7* p7, libressl_d.openssl.ossl_typ.EVP_PKEY* pkey, libressl_d.openssl.ossl_typ.X509* cert, libressl_d.openssl.bio.BIO* data, int flags);
668 
669 int PKCS7_add_attrib_smimecap(.PKCS7_SIGNER_INFO* si, libressl_d.openssl.asn1.stack_st_X509_ALGOR* cap);
670 libressl_d.openssl.asn1.stack_st_X509_ALGOR* PKCS7_get_smimecap(.PKCS7_SIGNER_INFO* si);
671 int PKCS7_simple_smimecap(libressl_d.openssl.asn1.stack_st_X509_ALGOR* sk, int nid, int arg);
672 
673 int PKCS7_add_attrib_content_type(.PKCS7_SIGNER_INFO* si, libressl_d.openssl.asn1.ASN1_OBJECT* coid);
674 int PKCS7_add0_attrib_signing_time(.PKCS7_SIGNER_INFO* si, libressl_d.openssl.ossl_typ.ASN1_TIME* t);
675 int PKCS7_add1_attrib_digest(.PKCS7_SIGNER_INFO* si, const (ubyte)* md, int mdlen);
676 
677 int SMIME_write_PKCS7(libressl_d.openssl.bio.BIO* bio, .PKCS7* p7, libressl_d.openssl.bio.BIO* data, int flags);
678 .PKCS7* SMIME_read_PKCS7(libressl_d.openssl.bio.BIO* bio, libressl_d.openssl.bio.BIO** bcont);
679 
680 libressl_d.openssl.bio.BIO* BIO_new_PKCS7(libressl_d.openssl.bio.BIO* out_, .PKCS7* p7);
681 
682 /* BEGIN ERROR CODES */
683 /**
684  * The following lines are auto generated by the script mkerr.pl. Any changes
685  * made after this point may be overwritten when the script is next run.
686  */
687 void ERR_load_PKCS7_strings();
688 
689 /* Error codes for the PKCS7 functions. */
690 
691 /* Function codes. */
692 enum PKCS7_F_B64_READ_PKCS7 = 120;
693 enum PKCS7_F_B64_WRITE_PKCS7 = 121;
694 enum PKCS7_F_DO_PKCS7_SIGNED_ATTRIB = 136;
695 enum PKCS7_F_I2D_PKCS7_BIO_STREAM = 140;
696 enum PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME = 135;
697 enum PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP = 118;
698 enum PKCS7_F_PKCS7_ADD_CERTIFICATE = 100;
699 enum PKCS7_F_PKCS7_ADD_CRL = 101;
700 enum PKCS7_F_PKCS7_ADD_RECIPIENT_INFO = 102;
701 enum PKCS7_F_PKCS7_ADD_SIGNATURE = 131;
702 enum PKCS7_F_PKCS7_ADD_SIGNER = 103;
703 enum PKCS7_F_PKCS7_BIO_ADD_DIGEST = 125;
704 enum PKCS7_F_PKCS7_COPY_EXISTING_DIGEST = 138;
705 enum PKCS7_F_PKCS7_CTRL = 104;
706 enum PKCS7_F_PKCS7_DATADECODE = 112;
707 enum PKCS7_F_PKCS7_DATAFINAL = 128;
708 enum PKCS7_F_PKCS7_DATAINIT = 105;
709 enum PKCS7_F_PKCS7_DATASIGN = 106;
710 enum PKCS7_F_PKCS7_DATAVERIFY = 107;
711 enum PKCS7_F_PKCS7_DECRYPT = 114;
712 enum PKCS7_F_PKCS7_DECRYPT_RINFO = 133;
713 enum PKCS7_F_PKCS7_ENCODE_RINFO = 132;
714 enum PKCS7_F_PKCS7_ENCRYPT = 115;
715 enum PKCS7_F_PKCS7_FINAL = 134;
716 enum PKCS7_F_PKCS7_FIND_DIGEST = 127;
717 enum PKCS7_F_PKCS7_GET0_SIGNERS = 124;
718 enum PKCS7_F_PKCS7_RECIP_INFO_SET = 130;
719 enum PKCS7_F_PKCS7_SET_CIPHER = 108;
720 enum PKCS7_F_PKCS7_SET_CONTENT = 109;
721 enum PKCS7_F_PKCS7_SET_DIGEST = 126;
722 enum PKCS7_F_PKCS7_SET_TYPE = 110;
723 enum PKCS7_F_PKCS7_SIGN = 116;
724 enum PKCS7_F_PKCS7_SIGNATUREVERIFY = 113;
725 enum PKCS7_F_PKCS7_SIGNER_INFO_SET = 129;
726 enum PKCS7_F_PKCS7_SIGNER_INFO_SIGN = 139;
727 enum PKCS7_F_PKCS7_SIGN_ADD_SIGNER = 137;
728 enum PKCS7_F_PKCS7_SIMPLE_SMIMECAP = 119;
729 enum PKCS7_F_PKCS7_VERIFY = 117;
730 enum PKCS7_F_SMIME_READ_PKCS7 = 122;
731 enum PKCS7_F_SMIME_TEXT = 123;
732 
733 /* Reason codes. */
734 enum PKCS7_R_CERTIFICATE_VERIFY_ERROR = 117;
735 enum PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER = 144;
736 enum PKCS7_R_CIPHER_NOT_INITIALIZED = 116;
737 enum PKCS7_R_CONTENT_AND_DATA_PRESENT = 118;
738 enum PKCS7_R_CTRL_ERROR = 152;
739 enum PKCS7_R_DECODE_ERROR = 130;
740 enum PKCS7_R_DECRYPTED_KEY_IS_WRONG_LENGTH = 100;
741 enum PKCS7_R_DECRYPT_ERROR = 119;
742 enum PKCS7_R_DIGEST_FAILURE = 101;
743 enum PKCS7_R_ENCRYPTION_CTRL_FAILURE = 149;
744 enum PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE = 150;
745 enum PKCS7_R_ERROR_ADDING_RECIPIENT = 120;
746 enum PKCS7_R_ERROR_SETTING_CIPHER = 121;
747 enum PKCS7_R_INVALID_MIME_TYPE = 131;
748 enum PKCS7_R_INVALID_NULL_POINTER = 143;
749 enum PKCS7_R_MIME_NO_CONTENT_TYPE = 132;
750 enum PKCS7_R_MIME_PARSE_ERROR = 133;
751 enum PKCS7_R_MIME_SIG_PARSE_ERROR = 134;
752 enum PKCS7_R_MISSING_CERIPEND_INFO = 103;
753 enum PKCS7_R_NO_CONTENT = 122;
754 enum PKCS7_R_NO_CONTENT_TYPE = 135;
755 enum PKCS7_R_NO_DEFAULT_DIGEST = 151;
756 enum PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND = 154;
757 enum PKCS7_R_NO_MULTIPART_BODY_FAILURE = 136;
758 enum PKCS7_R_NO_MULTIPART_BOUNDARY = 137;
759 enum PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE = 115;
760 enum PKCS7_R_NO_RECIPIENT_MATCHES_KEY = 146;
761 enum PKCS7_R_NO_SIGNATURES_ON_DATA = 123;
762 enum PKCS7_R_NO_SIGNERS = 142;
763 enum PKCS7_R_NO_SIG_CONTENT_TYPE = 138;
764 enum PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE = 104;
765 enum PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR = 124;
766 enum PKCS7_R_PKCS7_ADD_SIGNER_ERROR = 153;
767 enum PKCS7_R_PKCS7_DATAFINAL = 126;
768 enum PKCS7_R_PKCS7_DATAFINAL_ERROR = 125;
769 enum PKCS7_R_PKCS7_DATASIGN = 145;
770 enum PKCS7_R_PKCS7_PARSE_ERROR = 139;
771 enum PKCS7_R_PKCS7_SIG_PARSE_ERROR = 140;
772 enum PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE = 127;
773 enum PKCS7_R_SIGNATURE_FAILURE = 105;
774 enum PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND = 128;
775 enum PKCS7_R_SIGNING_CTRL_FAILURE = 147;
776 enum PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE = 148;
777 enum PKCS7_R_SIG_INVALID_MIME_TYPE = 141;
778 enum PKCS7_R_SMIME_TEXT_ERROR = 129;
779 enum PKCS7_R_UNABLE_TO_FIND_CERTIFICATE = 106;
780 enum PKCS7_R_UNABLE_TO_FIND_MEM_BIO = 107;
781 enum PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST = 108;
782 enum PKCS7_R_UNKNOWN_DIGEST_TYPE = 109;
783 enum PKCS7_R_UNKNOWN_OPERATION = 110;
784 enum PKCS7_R_UNSUPPORTED_CIPHER_TYPE = 111;
785 enum PKCS7_R_UNSUPPORTED_CONTENT_TYPE = 112;
786 enum PKCS7_R_WRONG_CONTENT_TYPE = 113;
787 enum PKCS7_R_WRONG_PKCS7_TYPE = 114;