1 | /* |
2 | * WARNING: do not edit! |
3 | * Generated by Makefile from include/openssl/pkcs7.h.in |
4 | * |
5 | * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. |
6 | * |
7 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
8 | * this file except in compliance with the License. You can obtain a copy |
9 | * in the file LICENSE in the source distribution or at |
10 | * https://www.openssl.org/source/license.html |
11 | */ |
12 | |
13 | |
14 | |
15 | #ifndef OPENSSL_PKCS7_H |
16 | # define OPENSSL_PKCS7_H |
17 | # pragma once |
18 | |
19 | # include <openssl/macros.h> |
20 | # ifndef OPENSSL_NO_DEPRECATED_3_0 |
21 | # define |
22 | # endif |
23 | |
24 | # include <openssl/asn1.h> |
25 | # include <openssl/bio.h> |
26 | # include <openssl/e_os2.h> |
27 | |
28 | # include <openssl/symhacks.h> |
29 | # include <openssl/types.h> |
30 | # include <openssl/pkcs7err.h> |
31 | # ifndef OPENSSL_NO_STDIO |
32 | # include <stdio.h> |
33 | # endif |
34 | |
35 | #ifdef __cplusplus |
36 | extern "C" { |
37 | #endif |
38 | |
39 | |
40 | /*- |
41 | Encryption_ID DES-CBC |
42 | Digest_ID MD5 |
43 | Digest_Encryption_ID rsaEncryption |
44 | Key_Encryption_ID rsaEncryption |
45 | */ |
46 | |
47 | typedef struct PKCS7_CTX_st { |
48 | OSSL_LIB_CTX *libctx; |
49 | char *propq; |
50 | } PKCS7_CTX; |
51 | |
52 | typedef struct pkcs7_issuer_and_serial_st { |
53 | X509_NAME *issuer; |
54 | ASN1_INTEGER *serial; |
55 | } PKCS7_ISSUER_AND_SERIAL; |
56 | |
57 | typedef struct pkcs7_signer_info_st { |
58 | ASN1_INTEGER *version; /* version 1 */ |
59 | PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; |
60 | X509_ALGOR *digest_alg; |
61 | STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ |
62 | X509_ALGOR *digest_enc_alg; /* confusing name, actually used for signing */ |
63 | ASN1_OCTET_STRING *enc_digest; /* confusing name, actually signature */ |
64 | STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ |
65 | /* The private key to sign with */ |
66 | EVP_PKEY *pkey; |
67 | const PKCS7_CTX *ctx; |
68 | } PKCS7_SIGNER_INFO; |
69 | SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO, PKCS7_SIGNER_INFO) |
70 | #define sk_PKCS7_SIGNER_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) |
71 | #define sk_PKCS7_SIGNER_INFO_value(sk, idx) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_value(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), (idx))) |
72 | #define sk_PKCS7_SIGNER_INFO_new(cmp) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new(ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) |
73 | #define sk_PKCS7_SIGNER_INFO_new_null() ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_null()) |
74 | #define sk_PKCS7_SIGNER_INFO_new_reserve(cmp, n) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_new_reserve(ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp), (n))) |
75 | #define sk_PKCS7_SIGNER_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (n)) |
76 | #define sk_PKCS7_SIGNER_INFO_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) |
77 | #define sk_PKCS7_SIGNER_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) |
78 | #define sk_PKCS7_SIGNER_INFO_delete(sk, i) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (i))) |
79 | #define sk_PKCS7_SIGNER_INFO_delete_ptr(sk, ptr) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr))) |
80 | #define sk_PKCS7_SIGNER_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) |
81 | #define sk_PKCS7_SIGNER_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) |
82 | #define sk_PKCS7_SIGNER_INFO_pop(sk) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_pop(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) |
83 | #define sk_PKCS7_SIGNER_INFO_shift(sk) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_shift(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk))) |
84 | #define sk_PKCS7_SIGNER_INFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk),ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc)) |
85 | #define sk_PKCS7_SIGNER_INFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr), (idx)) |
86 | #define sk_PKCS7_SIGNER_INFO_set(sk, idx, ptr) ((PKCS7_SIGNER_INFO *)OPENSSL_sk_set(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), (idx), ossl_check_PKCS7_SIGNER_INFO_type(ptr))) |
87 | #define sk_PKCS7_SIGNER_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) |
88 | #define sk_PKCS7_SIGNER_INFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr)) |
89 | #define sk_PKCS7_SIGNER_INFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_type(ptr), pnum) |
90 | #define sk_PKCS7_SIGNER_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk)) |
91 | #define sk_PKCS7_SIGNER_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk)) |
92 | #define sk_PKCS7_SIGNER_INFO_dup(sk) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk))) |
93 | #define sk_PKCS7_SIGNER_INFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PKCS7_SIGNER_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_copyfunc_type(copyfunc), ossl_check_PKCS7_SIGNER_INFO_freefunc_type(freefunc))) |
94 | #define sk_PKCS7_SIGNER_INFO_set_cmp_func(sk, cmp) ((sk_PKCS7_SIGNER_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS7_SIGNER_INFO_sk_type(sk), ossl_check_PKCS7_SIGNER_INFO_compfunc_type(cmp))) |
95 | |
96 | |
97 | typedef struct pkcs7_recip_info_st { |
98 | ASN1_INTEGER *version; /* version 0 */ |
99 | PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; |
100 | X509_ALGOR *key_enc_algor; |
101 | ASN1_OCTET_STRING *enc_key; |
102 | X509 *cert; /* get the pub-key from this */ |
103 | const PKCS7_CTX *ctx; |
104 | } PKCS7_RECIP_INFO; |
105 | SKM_DEFINE_STACK_OF_INTERNAL(PKCS7_RECIP_INFO, PKCS7_RECIP_INFO, PKCS7_RECIP_INFO) |
106 | #define sk_PKCS7_RECIP_INFO_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) |
107 | #define sk_PKCS7_RECIP_INFO_value(sk, idx) ((PKCS7_RECIP_INFO *)OPENSSL_sk_value(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), (idx))) |
108 | #define sk_PKCS7_RECIP_INFO_new(cmp) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new(ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) |
109 | #define sk_PKCS7_RECIP_INFO_new_null() ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_null()) |
110 | #define sk_PKCS7_RECIP_INFO_new_reserve(cmp, n) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_new_reserve(ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp), (n))) |
111 | #define sk_PKCS7_RECIP_INFO_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (n)) |
112 | #define sk_PKCS7_RECIP_INFO_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) |
113 | #define sk_PKCS7_RECIP_INFO_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) |
114 | #define sk_PKCS7_RECIP_INFO_delete(sk, i) ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (i))) |
115 | #define sk_PKCS7_RECIP_INFO_delete_ptr(sk, ptr) ((PKCS7_RECIP_INFO *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr))) |
116 | #define sk_PKCS7_RECIP_INFO_push(sk, ptr) OPENSSL_sk_push(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) |
117 | #define sk_PKCS7_RECIP_INFO_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) |
118 | #define sk_PKCS7_RECIP_INFO_pop(sk) ((PKCS7_RECIP_INFO *)OPENSSL_sk_pop(ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) |
119 | #define sk_PKCS7_RECIP_INFO_shift(sk) ((PKCS7_RECIP_INFO *)OPENSSL_sk_shift(ossl_check_PKCS7_RECIP_INFO_sk_type(sk))) |
120 | #define sk_PKCS7_RECIP_INFO_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PKCS7_RECIP_INFO_sk_type(sk),ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc)) |
121 | #define sk_PKCS7_RECIP_INFO_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr), (idx)) |
122 | #define sk_PKCS7_RECIP_INFO_set(sk, idx, ptr) ((PKCS7_RECIP_INFO *)OPENSSL_sk_set(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), (idx), ossl_check_PKCS7_RECIP_INFO_type(ptr))) |
123 | #define sk_PKCS7_RECIP_INFO_find(sk, ptr) OPENSSL_sk_find(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) |
124 | #define sk_PKCS7_RECIP_INFO_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr)) |
125 | #define sk_PKCS7_RECIP_INFO_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_type(ptr), pnum) |
126 | #define sk_PKCS7_RECIP_INFO_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_RECIP_INFO_sk_type(sk)) |
127 | #define sk_PKCS7_RECIP_INFO_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk)) |
128 | #define sk_PKCS7_RECIP_INFO_dup(sk) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk))) |
129 | #define sk_PKCS7_RECIP_INFO_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PKCS7_RECIP_INFO) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_copyfunc_type(copyfunc), ossl_check_PKCS7_RECIP_INFO_freefunc_type(freefunc))) |
130 | #define sk_PKCS7_RECIP_INFO_set_cmp_func(sk, cmp) ((sk_PKCS7_RECIP_INFO_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS7_RECIP_INFO_sk_type(sk), ossl_check_PKCS7_RECIP_INFO_compfunc_type(cmp))) |
131 | |
132 | |
133 | |
134 | typedef struct pkcs7_signed_st { |
135 | ASN1_INTEGER *version; /* version 1 */ |
136 | STACK_OF(X509_ALGOR) *md_algs; /* md used */ |
137 | STACK_OF(X509) *cert; /* [ 0 ] */ /* name should be 'certificates' */ |
138 | STACK_OF(X509_CRL) *crl; /* [ 1 ] */ /* name should be 'crls' */ |
139 | STACK_OF(PKCS7_SIGNER_INFO) *signer_info; |
140 | struct pkcs7_st *contents; |
141 | } PKCS7_SIGNED; |
142 | /* |
143 | * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about |
144 | * merging the two |
145 | */ |
146 | |
147 | typedef struct pkcs7_enc_content_st { |
148 | ASN1_OBJECT *content_type; |
149 | X509_ALGOR *algorithm; |
150 | ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ |
151 | const EVP_CIPHER *cipher; |
152 | const PKCS7_CTX *ctx; |
153 | } PKCS7_ENC_CONTENT; |
154 | |
155 | typedef struct pkcs7_enveloped_st { |
156 | ASN1_INTEGER *version; /* version 0 */ |
157 | STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; |
158 | PKCS7_ENC_CONTENT *enc_data; |
159 | } PKCS7_ENVELOPE; |
160 | |
161 | typedef struct pkcs7_signedandenveloped_st { |
162 | ASN1_INTEGER *version; /* version 1 */ |
163 | STACK_OF(X509_ALGOR) *md_algs; /* md used */ |
164 | STACK_OF(X509) *cert; /* [ 0 ] */ /* name should be 'certificates' */ |
165 | STACK_OF(X509_CRL) *crl; /* [ 1 ] */ /* name should be 'crls' */ |
166 | STACK_OF(PKCS7_SIGNER_INFO) *signer_info; |
167 | PKCS7_ENC_CONTENT *enc_data; |
168 | STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; |
169 | } PKCS7_SIGN_ENVELOPE; |
170 | |
171 | typedef struct pkcs7_digest_st { |
172 | ASN1_INTEGER *version; /* version 0 */ |
173 | X509_ALGOR *md; /* md used */ |
174 | struct pkcs7_st *contents; |
175 | ASN1_OCTET_STRING *digest; |
176 | } PKCS7_DIGEST; |
177 | |
178 | typedef struct pkcs7_encrypted_st { |
179 | ASN1_INTEGER *version; /* version 0 */ |
180 | PKCS7_ENC_CONTENT *enc_data; |
181 | } PKCS7_ENCRYPT; |
182 | |
183 | typedef struct pkcs7_st { |
184 | /* |
185 | * The following is non NULL if it contains ASN1 encoding of this |
186 | * structure |
187 | */ |
188 | unsigned char *asn1; |
189 | long length; |
190 | # define 0 |
191 | # define PKCS7_S_BODY 1 |
192 | # define PKCS7_S_TAIL 2 |
193 | int state; /* used during processing */ |
194 | int detached; |
195 | ASN1_OBJECT *type; |
196 | /* content as defined by the type */ |
197 | /* |
198 | * all encryption/message digests are applied to the 'contents', leaving |
199 | * out the 'type' field. |
200 | */ |
201 | union { |
202 | char *ptr; |
203 | /* NID_pkcs7_data */ |
204 | ASN1_OCTET_STRING *data; |
205 | /* NID_pkcs7_signed */ |
206 | PKCS7_SIGNED *sign; /* field name 'signed' would clash with C keyword */ |
207 | /* NID_pkcs7_enveloped */ |
208 | PKCS7_ENVELOPE *enveloped; |
209 | /* NID_pkcs7_signedAndEnveloped */ |
210 | PKCS7_SIGN_ENVELOPE *signed_and_enveloped; |
211 | /* NID_pkcs7_digest */ |
212 | PKCS7_DIGEST *digest; |
213 | /* NID_pkcs7_encrypted */ |
214 | PKCS7_ENCRYPT *encrypted; |
215 | /* Anything else */ |
216 | ASN1_TYPE *other; |
217 | } d; |
218 | PKCS7_CTX ctx; |
219 | } PKCS7; |
220 | SKM_DEFINE_STACK_OF_INTERNAL(PKCS7, PKCS7, PKCS7) |
221 | #define sk_PKCS7_num(sk) OPENSSL_sk_num(ossl_check_const_PKCS7_sk_type(sk)) |
222 | #define sk_PKCS7_value(sk, idx) ((PKCS7 *)OPENSSL_sk_value(ossl_check_const_PKCS7_sk_type(sk), (idx))) |
223 | #define sk_PKCS7_new(cmp) ((STACK_OF(PKCS7) *)OPENSSL_sk_new(ossl_check_PKCS7_compfunc_type(cmp))) |
224 | #define sk_PKCS7_new_null() ((STACK_OF(PKCS7) *)OPENSSL_sk_new_null()) |
225 | #define sk_PKCS7_new_reserve(cmp, n) ((STACK_OF(PKCS7) *)OPENSSL_sk_new_reserve(ossl_check_PKCS7_compfunc_type(cmp), (n))) |
226 | #define sk_PKCS7_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_PKCS7_sk_type(sk), (n)) |
227 | #define sk_PKCS7_free(sk) OPENSSL_sk_free(ossl_check_PKCS7_sk_type(sk)) |
228 | #define sk_PKCS7_zero(sk) OPENSSL_sk_zero(ossl_check_PKCS7_sk_type(sk)) |
229 | #define sk_PKCS7_delete(sk, i) ((PKCS7 *)OPENSSL_sk_delete(ossl_check_PKCS7_sk_type(sk), (i))) |
230 | #define sk_PKCS7_delete_ptr(sk, ptr) ((PKCS7 *)OPENSSL_sk_delete_ptr(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr))) |
231 | #define sk_PKCS7_push(sk, ptr) OPENSSL_sk_push(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) |
232 | #define sk_PKCS7_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) |
233 | #define sk_PKCS7_pop(sk) ((PKCS7 *)OPENSSL_sk_pop(ossl_check_PKCS7_sk_type(sk))) |
234 | #define sk_PKCS7_shift(sk) ((PKCS7 *)OPENSSL_sk_shift(ossl_check_PKCS7_sk_type(sk))) |
235 | #define sk_PKCS7_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_PKCS7_sk_type(sk),ossl_check_PKCS7_freefunc_type(freefunc)) |
236 | #define sk_PKCS7_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr), (idx)) |
237 | #define sk_PKCS7_set(sk, idx, ptr) ((PKCS7 *)OPENSSL_sk_set(ossl_check_PKCS7_sk_type(sk), (idx), ossl_check_PKCS7_type(ptr))) |
238 | #define sk_PKCS7_find(sk, ptr) OPENSSL_sk_find(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) |
239 | #define sk_PKCS7_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr)) |
240 | #define sk_PKCS7_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_type(ptr), pnum) |
241 | #define sk_PKCS7_sort(sk) OPENSSL_sk_sort(ossl_check_PKCS7_sk_type(sk)) |
242 | #define sk_PKCS7_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_PKCS7_sk_type(sk)) |
243 | #define sk_PKCS7_dup(sk) ((STACK_OF(PKCS7) *)OPENSSL_sk_dup(ossl_check_const_PKCS7_sk_type(sk))) |
244 | #define sk_PKCS7_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(PKCS7) *)OPENSSL_sk_deep_copy(ossl_check_const_PKCS7_sk_type(sk), ossl_check_PKCS7_copyfunc_type(copyfunc), ossl_check_PKCS7_freefunc_type(freefunc))) |
245 | #define sk_PKCS7_set_cmp_func(sk, cmp) ((sk_PKCS7_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_PKCS7_sk_type(sk), ossl_check_PKCS7_compfunc_type(cmp))) |
246 | |
247 | |
248 | |
249 | # define PKCS7_OP_SET_DETACHED_SIGNATURE 1 |
250 | # define PKCS7_OP_GET_DETACHED_SIGNATURE 2 |
251 | |
252 | # define PKCS7_get_signed_attributes(si) ((si)->auth_attr) |
253 | # define PKCS7_get_attributes(si) ((si)->unauth_attr) |
254 | |
255 | # define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) |
256 | # define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) |
257 | # define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) |
258 | # define PKCS7_type_is_signedAndEnveloped(a) \ |
259 | (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) |
260 | # define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) |
261 | # define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) |
262 | |
263 | # define PKCS7_set_detached(p,v) \ |
264 | PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) |
265 | # define PKCS7_get_detached(p) \ |
266 | PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) |
267 | |
268 | # define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) |
269 | |
270 | /* S/MIME related flags */ |
271 | |
272 | # define PKCS7_TEXT 0x1 |
273 | # define PKCS7_NOCERTS 0x2 |
274 | # define PKCS7_NOSIGS 0x4 |
275 | # define PKCS7_NOCHAIN 0x8 |
276 | # define PKCS7_NOINTERN 0x10 |
277 | # define PKCS7_NOVERIFY 0x20 |
278 | # define PKCS7_DETACHED 0x40 |
279 | # define PKCS7_BINARY 0x80 |
280 | # define PKCS7_NOATTR 0x100 |
281 | # define PKCS7_NOSMIMECAP 0x200 |
282 | # define PKCS7_NOOLDMIMETYPE 0x400 |
283 | # define PKCS7_CRLFEOL 0x800 |
284 | # define PKCS7_STREAM 0x1000 |
285 | # define PKCS7_NOCRL 0x2000 |
286 | # define PKCS7_PARTIAL 0x4000 |
287 | # define PKCS7_REUSE_DIGEST 0x8000 |
288 | # define PKCS7_NO_DUAL_CONTENT 0x10000 |
289 | |
290 | /* Flags: for compatibility with older code */ |
291 | |
292 | # define SMIME_TEXT PKCS7_TEXT |
293 | # define SMIME_NOCERTS PKCS7_NOCERTS |
294 | # define SMIME_NOSIGS PKCS7_NOSIGS |
295 | # define SMIME_NOCHAIN PKCS7_NOCHAIN |
296 | # define SMIME_NOINTERN PKCS7_NOINTERN |
297 | # define SMIME_NOVERIFY PKCS7_NOVERIFY |
298 | # define SMIME_DETACHED PKCS7_DETACHED |
299 | # define SMIME_BINARY PKCS7_BINARY |
300 | # define SMIME_NOATTR PKCS7_NOATTR |
301 | |
302 | /* CRLF ASCII canonicalisation */ |
303 | # define SMIME_ASCIICRLF 0x80000 |
304 | |
305 | DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) |
306 | |
307 | int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, |
308 | const EVP_MD *type, unsigned char *md, |
309 | unsigned int *len); |
310 | # ifndef OPENSSL_NO_STDIO |
311 | PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7); |
312 | int i2d_PKCS7_fp(FILE *fp, const PKCS7 *p7); |
313 | # endif |
314 | DECLARE_ASN1_DUP_FUNCTION(PKCS7) |
315 | PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7); |
316 | int i2d_PKCS7_bio(BIO *bp, const PKCS7 *p7); |
317 | int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); |
318 | int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); |
319 | |
320 | DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) |
321 | DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) |
322 | DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) |
323 | DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) |
324 | DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) |
325 | DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) |
326 | DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) |
327 | DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) |
328 | DECLARE_ASN1_FUNCTIONS(PKCS7) |
329 | PKCS7 *PKCS7_new_ex(OSSL_LIB_CTX *libctx, const char *propq); |
330 | |
331 | DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) |
332 | DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) |
333 | |
334 | DECLARE_ASN1_NDEF_FUNCTION(PKCS7) |
335 | DECLARE_ASN1_PRINT_FUNCTION(PKCS7) |
336 | |
337 | long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); |
338 | |
339 | int PKCS7_type_is_other(PKCS7 *p7); |
340 | int PKCS7_set_type(PKCS7 *p7, int type); |
341 | int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); |
342 | int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); |
343 | int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, |
344 | const EVP_MD *dgst); |
345 | int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si); |
346 | int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); |
347 | int PKCS7_add_certificate(PKCS7 *p7, X509 *cert); |
348 | int PKCS7_add_crl(PKCS7 *p7, X509_CRL *crl); |
349 | int PKCS7_content_new(PKCS7 *p7, int nid); |
350 | int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, |
351 | BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); |
352 | int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, |
353 | X509 *signer); |
354 | |
355 | BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); |
356 | int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); |
357 | BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); |
358 | |
359 | PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, |
360 | EVP_PKEY *pkey, const EVP_MD *dgst); |
361 | X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); |
362 | int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); |
363 | STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); |
364 | |
365 | PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); |
366 | void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, |
367 | X509_ALGOR **pdig, X509_ALGOR **psig); |
368 | void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc); |
369 | int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); |
370 | int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); |
371 | int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); |
372 | int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7); |
373 | |
374 | PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); |
375 | ASN1_OCTET_STRING *PKCS7_get_octet_string(PKCS7 *p7); |
376 | ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); |
377 | int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type, |
378 | void *data); |
379 | int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, |
380 | void *value); |
381 | ASN1_TYPE *PKCS7_get_attribute(const PKCS7_SIGNER_INFO *si, int nid); |
382 | ASN1_TYPE *PKCS7_get_signed_attribute(const PKCS7_SIGNER_INFO *si, int nid); |
383 | int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, |
384 | STACK_OF(X509_ATTRIBUTE) *sk); |
385 | int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, |
386 | STACK_OF(X509_ATTRIBUTE) *sk); |
387 | |
388 | PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, |
389 | BIO *data, int flags); |
390 | PKCS7 *PKCS7_sign_ex(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, |
391 | BIO *data, int flags, OSSL_LIB_CTX *libctx, |
392 | const char *propq); |
393 | |
394 | PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, |
395 | X509 *signcert, EVP_PKEY *pkey, |
396 | const EVP_MD *md, int flags); |
397 | |
398 | int PKCS7_final(PKCS7 *p7, BIO *data, int flags); |
399 | int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, |
400 | BIO *indata, BIO *out, int flags); |
401 | STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, |
402 | int flags); |
403 | PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, |
404 | int flags); |
405 | PKCS7 *PKCS7_encrypt_ex(STACK_OF(X509) *certs, BIO *in, |
406 | const EVP_CIPHER *cipher, int flags, |
407 | OSSL_LIB_CTX *libctx, const char *propq); |
408 | int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, |
409 | int flags); |
410 | |
411 | int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, |
412 | STACK_OF(X509_ALGOR) *cap); |
413 | STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); |
414 | int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); |
415 | |
416 | int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid); |
417 | int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t); |
418 | int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, |
419 | const unsigned char *md, int mdlen); |
420 | |
421 | int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); |
422 | PKCS7 *SMIME_read_PKCS7_ex(BIO *bio, BIO **bcont, PKCS7 **p7); |
423 | PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); |
424 | |
425 | BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7); |
426 | |
427 | # ifdef __cplusplus |
428 | } |
429 | # endif |
430 | #endif |
431 | |