1use super::super::*;
2use libc::*;
3
4#[cfg(ossl300)]
5#[repr(C)]
6pub struct PKCS7_CTX {
7 libctx: *mut OSSL_LIB_CTX,
8 propq: *mut c_char,
9}
10
11#[repr(C)]
12pub struct PKCS7_SIGNED {
13 pub version: *mut ASN1_INTEGER, /* version 1 */
14 pub md_algs: *mut stack_st_X509_ALGOR, /* md used */
15 pub cert: *mut stack_st_X509, /* [ 0 ] */
16 pub crl: *mut stack_st_X509_CRL, /* [ 1 ] */
17 pub signer_info: *mut stack_st_PKCS7_SIGNER_INFO,
18 pub contents: *mut PKCS7,
19}
20#[repr(C)]
21pub struct PKCS7_ENC_CONTENT {
22 pub content_type: *mut ASN1_OBJECT,
23 pub algorithm: *mut X509_ALGOR,
24 pub enc_data: *mut ASN1_OCTET_STRING, /* [ 0 ] */
25 pub cipher: *const EVP_CIPHER,
26 #[cfg(ossl300)]
27 pub ctx: *const PKCS7_CTX,
28}
29#[repr(C)]
30pub struct PKCS7_ENVELOPE {
31 pub version: *mut ASN1_INTEGER, /* version 0 */
32 pub recipientinfo: *mut stack_st_PKCS7_RECIP_INFO,
33 pub enc_data: *mut PKCS7_ENC_CONTENT,
34}
35#[repr(C)]
36pub struct PKCS7_SIGN_ENVELOPE {
37 pub version: *mut ASN1_INTEGER, /* version 1 */
38 pub md_algs: *mut stack_st_X509_ALGOR, /* md used */
39 pub cert: *mut stack_st_X509, /* [ 0 ] */
40 pub crl: *mut stack_st_X509_CRL, /* [ 1 ] */
41 pub signer_info: *mut stack_st_PKCS7_SIGNER_INFO,
42 pub enc_data: *mut PKCS7_ENC_CONTENT,
43 pub recipientinfo: *mut stack_st_PKCS7_RECIP_INFO,
44}
45#[repr(C)]
46pub struct PKCS7_DIGEST {
47 pub version: *mut ASN1_INTEGER, /* version 0 */
48 pub md: *mut X509_ALGOR, /* md used */
49 pub contents: *mut PKCS7,
50 pub digest: *mut ASN1_OCTET_STRING,
51}
52#[repr(C)]
53pub struct PKCS7_ENCRYPT {
54 pub version: *mut ASN1_INTEGER, /* version 0 */
55 pub enc_data: *mut PKCS7_ENC_CONTENT,
56}
57
58extern "C" {
59 pub fn PKCS7_SIGNED_free(info: *mut PKCS7_SIGNED);
60 pub fn PKCS7_ENC_CONTENT_free(info: *mut PKCS7_ENC_CONTENT);
61 pub fn PKCS7_ENVELOPE_free(info: *mut PKCS7_ENVELOPE);
62 pub fn PKCS7_SIGN_ENVELOPE_free(info: *mut PKCS7_SIGN_ENVELOPE);
63 pub fn PKCS7_DIGEST_free(info: *mut PKCS7_DIGEST);
64 pub fn PKCS7_SIGNER_INFO_free(info: *mut PKCS7_SIGNER_INFO);
65 pub fn PKCS7_ENCRYPT_free(enc: *mut PKCS7_ENCRYPT);
66 pub fn PKCS7_ISSUER_AND_SERIAL_free(ias: *mut PKCS7_ISSUER_AND_SERIAL);
67 pub fn PKCS7_RECIP_INFO_free(info: *mut PKCS7_RECIP_INFO);
68}
69
70#[repr(C)]
71pub struct PKCS7 {
72 /*
73 * The following is non NULL if it contains ASN1 encoding of this
74 * structure
75 */
76 pub asn1: *mut c_uchar,
77 pub length: c_long,
78 // # define PKCS7_S_HEADER 0
79 // # define PKCS7_S_BODY 1
80 // # define PKCS7_S_TAIL 2
81 pub state: c_int, /* used during processing */
82 pub detached: c_int,
83 pub type_: *mut ASN1_OBJECT,
84 /* content as defined by the type */
85 /*
86 * all encryption/message digests are applied to the 'contents', leaving
87 * out the 'type' field.
88 */
89 pub d: PKCS7_data,
90 #[cfg(ossl300)]
91 pub ctx: PKCS7_CTX,
92}
93
94#[repr(C)]
95pub union PKCS7_data {
96 pub ptr: *mut c_char,
97 /* NID_pkcs7_data */
98 pub data: *mut ASN1_OCTET_STRING,
99 /* NID_pkcs7_signed */
100 pub sign: *mut PKCS7_SIGNED,
101 /* NID_pkcs7_enveloped */
102 pub enveloped: *mut PKCS7_ENVELOPE,
103 /* NID_pkcs7_signedAndEnveloped */
104 pub signed_and_enveloped: *mut PKCS7_SIGN_ENVELOPE,
105 /* NID_pkcs7_digest */
106 pub digest: *mut PKCS7_DIGEST,
107 /* NID_pkcs7_encrypted */
108 pub encrypted: *mut PKCS7_ENCRYPT,
109 /* Anything else */
110 pub other: *mut ASN1_TYPE,
111}
112
113#[repr(C)]
114pub struct PKCS7_ISSUER_AND_SERIAL {
115 pub issuer: *mut X509_NAME,
116 pub serial: *mut ASN1_INTEGER,
117}
118
119#[repr(C)]
120pub struct PKCS7_SIGNER_INFO {
121 pub version: *mut ASN1_INTEGER, /* version 1 */
122 pub issuer_and_serial: *mut PKCS7_ISSUER_AND_SERIAL,
123 pub digest_alg: *mut X509_ALGOR,
124 pub auth_attr: *mut stack_st_X509_ATTRIBUTE, /* [ 0 ] */
125 pub digest_enc_alg: *mut X509_ALGOR,
126 pub enc_digest: *mut ASN1_OCTET_STRING,
127 pub unauth_attr: *mut stack_st_X509_ATTRIBUTE, /* [ 1 ] */
128 pub pkey: *mut EVP_PKEY, /* The private key to sign with */
129 #[cfg(ossl300)]
130 pub ctx: *const PKCS7_CTX,
131}
132
133stack!(stack_st_PKCS7_SIGNER_INFO);
134
135#[repr(C)]
136pub struct PKCS7_RECIP_INFO {
137 pub version: *mut ASN1_INTEGER, /* version 0 */
138 pub issuer_and_serial: *mut PKCS7_ISSUER_AND_SERIAL,
139 pub key_enc_algor: *mut X509_ALGOR,
140 pub enc_key: *mut ASN1_OCTET_STRING,
141 pub cert: *mut X509, /* get the pub-key from this */
142 #[cfg(ossl300)]
143 pub ctx: *const PKCS7_CTX,
144}
145
146stack!(stack_st_PKCS7_RECIP_INFO);
147
148extern "C" {
149 pub fn d2i_PKCS7(a: *mut *mut PKCS7, pp: *mut *const c_uchar, length: c_long) -> *mut PKCS7;
150}
151
152const_ptr_api! {
153 extern "C" {
154 pub fn i2d_PKCS7(a: #[const_ptr_if(ossl300)] PKCS7, buf: *mut *mut u8) -> c_int;
155 pub fn i2d_PKCS7_bio(bio: *mut BIO, p7: #[const_ptr_if(ossl300)] PKCS7) -> c_int;
156 }
157}
158
159extern "C" {
160 pub fn PKCS7_encrypt(
161 certs: *mut stack_st_X509,
162 b: *mut BIO,
163 cipher: *const EVP_CIPHER,
164 flags: c_int,
165 ) -> *mut PKCS7;
166
167 pub fn PKCS7_verify(
168 pkcs7: *mut PKCS7,
169 certs: *mut stack_st_X509,
170 store: *mut X509_STORE,
171 indata: *mut BIO,
172 out: *mut BIO,
173 flags: c_int,
174 ) -> c_int;
175
176 pub fn PKCS7_get0_signers(
177 pkcs7: *mut PKCS7,
178 certs: *mut stack_st_X509,
179 flags: c_int,
180 ) -> *mut stack_st_X509;
181
182 pub fn PKCS7_sign(
183 signcert: *mut X509,
184 pkey: *mut EVP_PKEY,
185 certs: *mut stack_st_X509,
186 data: *mut BIO,
187 flags: c_int,
188 ) -> *mut PKCS7;
189
190 pub fn PKCS7_decrypt(
191 pkcs7: *mut PKCS7,
192 pkey: *mut EVP_PKEY,
193 cert: *mut X509,
194 data: *mut BIO,
195 flags: c_int,
196 ) -> c_int;
197
198 pub fn PKCS7_free(pkcs7: *mut PKCS7);
199
200 pub fn SMIME_write_PKCS7(
201 out: *mut BIO,
202 pkcs7: *mut PKCS7,
203 data: *mut BIO,
204 flags: c_int,
205 ) -> c_int;
206
207 pub fn SMIME_read_PKCS7(bio: *mut BIO, bcont: *mut *mut BIO) -> *mut PKCS7;
208
209 pub fn PKCS7_new() -> *mut PKCS7;
210
211 pub fn PKCS7_set_type(p7: *mut PKCS7, nid_pkcs7: c_int) -> c_int;
212
213 pub fn PKCS7_add_certificate(p7: *mut PKCS7, x509: *mut X509) -> c_int;
214
215 pub fn PKCS7_add_signature(
216 p7: *mut PKCS7,
217 x509: *mut X509,
218 pkey: *mut EVP_PKEY,
219 digest: *const EVP_MD,
220 ) -> *mut PKCS7_SIGNER_INFO;
221
222 pub fn PKCS7_set_signed_attributes(
223 p7si: *mut PKCS7_SIGNER_INFO,
224 attributes: *mut stack_st_X509_ATTRIBUTE,
225 ) -> c_int;
226
227 pub fn PKCS7_add_signed_attribute(
228 p7si: *mut PKCS7_SIGNER_INFO,
229 nid: c_int,
230 attrtype: c_int,
231 data: *mut c_void,
232 ) -> c_int;
233
234 pub fn PKCS7_content_new(p7: *mut PKCS7, nid_pkcs7: c_int) -> c_int;
235
236 pub fn PKCS7_dataInit(p7: *mut PKCS7, bio: *mut BIO) -> *mut BIO;
237
238 pub fn PKCS7_dataFinal(p7: *mut PKCS7, bio: *mut BIO) -> c_int;
239
240 pub fn PKCS7_get_signer_info(p7: *mut PKCS7) -> *mut stack_st_PKCS7_SIGNER_INFO;
241
242 pub fn PKCS7_SIGNER_INFO_get0_algs(
243 si: *mut PKCS7_SIGNER_INFO,
244 pk: *mut *mut EVP_PKEY,
245 pdig: *mut *mut X509_ALGOR,
246 psig: *mut *mut X509_ALGOR,
247 );
248}
249
250const_ptr_api! {
251 extern "C" {
252 pub fn PKCS7_get_signed_attribute(
253 si: #[const_ptr_if(ossl300)] PKCS7_SIGNER_INFO,
254 nid: c_int
255 ) -> *mut ASN1_TYPE;
256 }
257}
258