1# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
4
5from __future__ import absolute_import, division, print_function
6
7INCLUDES = """
8#include <openssl/pkcs7.h>
9"""
10
11TYPES = """
12typedef struct {
13    Cryptography_STACK_OF_X509 *cert;
14    Cryptography_STACK_OF_X509_CRL *crl;
15    ...;
16} PKCS7_SIGNED;
17
18typedef struct {
19    Cryptography_STACK_OF_X509 *cert;
20    Cryptography_STACK_OF_X509_CRL *crl;
21    ...;
22} PKCS7_SIGN_ENVELOPE;
23
24typedef ... PKCS7_DIGEST;
25typedef ... PKCS7_ENCRYPT;
26typedef ... PKCS7_ENVELOPE;
27
28typedef struct {
29    ASN1_OBJECT *type;
30    union {
31        char *ptr;
32        ASN1_OCTET_STRING *data;
33        PKCS7_SIGNED *sign;
34        PKCS7_ENVELOPE *enveloped;
35        PKCS7_SIGN_ENVELOPE *signed_and_enveloped;
36        PKCS7_DIGEST *digest;
37        PKCS7_ENCRYPT *encrypted;
38        ASN1_TYPE *other;
39     } d;
40    ...;
41} PKCS7;
42
43static const int PKCS7_BINARY;
44static const int PKCS7_DETACHED;
45static const int PKCS7_NOATTR;
46static const int PKCS7_NOCERTS;
47static const int PKCS7_NOCHAIN;
48static const int PKCS7_NOINTERN;
49static const int PKCS7_NOSIGS;
50static const int PKCS7_NOSMIMECAP;
51static const int PKCS7_NOVERIFY;
52static const int PKCS7_STREAM;
53static const int PKCS7_TEXT;
54"""
55
56FUNCTIONS = """
57PKCS7 *SMIME_read_PKCS7(BIO *, BIO **);
58int SMIME_write_PKCS7(BIO *, PKCS7 *, BIO *, int);
59
60void PKCS7_free(PKCS7 *);
61
62PKCS7 *PKCS7_sign(X509 *, EVP_PKEY *, Cryptography_STACK_OF_X509 *,
63                  BIO *, int);
64int PKCS7_verify(PKCS7 *, Cryptography_STACK_OF_X509 *, X509_STORE *, BIO *,
65                 BIO *, int);
66Cryptography_STACK_OF_X509 *PKCS7_get0_signers(PKCS7 *,
67                                               Cryptography_STACK_OF_X509 *,
68                                               int);
69
70PKCS7 *PKCS7_encrypt(Cryptography_STACK_OF_X509 *, BIO *,
71                     const EVP_CIPHER *, int);
72int PKCS7_decrypt(PKCS7 *, EVP_PKEY *, X509 *, BIO *, int);
73
74BIO *PKCS7_dataInit(PKCS7 *, BIO *);
75int PKCS7_type_is_encrypted(PKCS7 *);
76int PKCS7_type_is_signed(PKCS7 *);
77int PKCS7_type_is_enveloped(PKCS7 *);
78int PKCS7_type_is_signedAndEnveloped(PKCS7 *);
79int PKCS7_type_is_data(PKCS7 *);
80int PKCS7_type_is_digest(PKCS7 *);
81"""
82
83CUSTOMIZATIONS = ""
84