diff options
Diffstat (limited to 'src/lib/libcrypto/cms/cms_lcl.h')
-rw-r--r-- | src/lib/libcrypto/cms/cms_lcl.h | 438 |
1 files changed, 0 insertions, 438 deletions
diff --git a/src/lib/libcrypto/cms/cms_lcl.h b/src/lib/libcrypto/cms/cms_lcl.h deleted file mode 100644 index d5feec0969..0000000000 --- a/src/lib/libcrypto/cms/cms_lcl.h +++ /dev/null | |||
@@ -1,438 +0,0 @@ | |||
1 | /* $OpenBSD: cms_lcl.h,v 1.3 2014/06/12 15:49:28 deraadt Exp $ */ | ||
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | ||
3 | * project. | ||
4 | */ | ||
5 | /* ==================================================================== | ||
6 | * Copyright (c) 2008 The OpenSSL Project. All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * 1. Redistributions of source code must retain the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer. | ||
14 | * | ||
15 | * 2. Redistributions in binary form must reproduce the above copyright | ||
16 | * notice, this list of conditions and the following disclaimer in | ||
17 | * the documentation and/or other materials provided with the | ||
18 | * distribution. | ||
19 | * | ||
20 | * 3. All advertising materials mentioning features or use of this | ||
21 | * software must display the following acknowledgment: | ||
22 | * "This product includes software developed by the OpenSSL Project | ||
23 | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" | ||
24 | * | ||
25 | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
26 | * endorse or promote products derived from this software without | ||
27 | * prior written permission. For written permission, please contact | ||
28 | * licensing@OpenSSL.org. | ||
29 | * | ||
30 | * 5. Products derived from this software may not be called "OpenSSL" | ||
31 | * nor may "OpenSSL" appear in their names without prior written | ||
32 | * permission of the OpenSSL Project. | ||
33 | * | ||
34 | * 6. Redistributions of any form whatsoever must retain the following | ||
35 | * acknowledgment: | ||
36 | * "This product includes software developed by the OpenSSL Project | ||
37 | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" | ||
38 | * | ||
39 | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
40 | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
42 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
43 | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
44 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
45 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
46 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
47 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
48 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
49 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
50 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
51 | * ==================================================================== | ||
52 | */ | ||
53 | |||
54 | #ifndef HEADER_CMS_LCL_H | ||
55 | #define HEADER_CMS_LCL_H | ||
56 | |||
57 | #ifdef __cplusplus | ||
58 | extern "C" { | ||
59 | #endif | ||
60 | |||
61 | #include <openssl/x509.h> | ||
62 | |||
63 | /* Cryptographic message syntax (CMS) structures: taken | ||
64 | * from RFC3852 | ||
65 | */ | ||
66 | |||
67 | /* Forward references */ | ||
68 | |||
69 | typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber; | ||
70 | typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo; | ||
71 | typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier; | ||
72 | typedef struct CMS_SignedData_st CMS_SignedData; | ||
73 | typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat; | ||
74 | typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo; | ||
75 | typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo; | ||
76 | typedef struct CMS_EnvelopedData_st CMS_EnvelopedData; | ||
77 | typedef struct CMS_DigestedData_st CMS_DigestedData; | ||
78 | typedef struct CMS_EncryptedData_st CMS_EncryptedData; | ||
79 | typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData; | ||
80 | typedef struct CMS_CompressedData_st CMS_CompressedData; | ||
81 | typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat; | ||
82 | typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo; | ||
83 | typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey; | ||
84 | typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey; | ||
85 | typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo; | ||
86 | typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute; | ||
87 | typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier; | ||
88 | typedef struct CMS_KeyAgreeRecipientIdentifier_st CMS_KeyAgreeRecipientIdentifier; | ||
89 | typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey; | ||
90 | typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier; | ||
91 | typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo; | ||
92 | typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo; | ||
93 | typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo; | ||
94 | typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom; | ||
95 | |||
96 | struct CMS_ContentInfo_st { | ||
97 | ASN1_OBJECT *contentType; | ||
98 | union { | ||
99 | ASN1_OCTET_STRING *data; | ||
100 | CMS_SignedData *signedData; | ||
101 | CMS_EnvelopedData *envelopedData; | ||
102 | CMS_DigestedData *digestedData; | ||
103 | CMS_EncryptedData *encryptedData; | ||
104 | CMS_AuthenticatedData *authenticatedData; | ||
105 | CMS_CompressedData *compressedData; | ||
106 | ASN1_TYPE *other; | ||
107 | /* Other types ... */ | ||
108 | void *otherData; | ||
109 | } d; | ||
110 | }; | ||
111 | |||
112 | struct CMS_SignedData_st { | ||
113 | long version; | ||
114 | STACK_OF(X509_ALGOR) *digestAlgorithms; | ||
115 | CMS_EncapsulatedContentInfo *encapContentInfo; | ||
116 | STACK_OF(CMS_CertificateChoices) *certificates; | ||
117 | STACK_OF(CMS_RevocationInfoChoice) *crls; | ||
118 | STACK_OF(CMS_SignerInfo) *signerInfos; | ||
119 | }; | ||
120 | |||
121 | struct CMS_EncapsulatedContentInfo_st { | ||
122 | ASN1_OBJECT *eContentType; | ||
123 | ASN1_OCTET_STRING *eContent; | ||
124 | /* Set to 1 if incomplete structure only part set up */ | ||
125 | int partial; | ||
126 | }; | ||
127 | |||
128 | struct CMS_SignerInfo_st { | ||
129 | long version; | ||
130 | CMS_SignerIdentifier *sid; | ||
131 | X509_ALGOR *digestAlgorithm; | ||
132 | STACK_OF(X509_ATTRIBUTE) *signedAttrs; | ||
133 | X509_ALGOR *signatureAlgorithm; | ||
134 | ASN1_OCTET_STRING *signature; | ||
135 | STACK_OF(X509_ATTRIBUTE) *unsignedAttrs; | ||
136 | /* Signing certificate and key */ | ||
137 | X509 *signer; | ||
138 | EVP_PKEY *pkey; | ||
139 | }; | ||
140 | |||
141 | struct CMS_SignerIdentifier_st { | ||
142 | int type; | ||
143 | union { | ||
144 | CMS_IssuerAndSerialNumber *issuerAndSerialNumber; | ||
145 | ASN1_OCTET_STRING *subjectKeyIdentifier; | ||
146 | } d; | ||
147 | }; | ||
148 | |||
149 | struct CMS_EnvelopedData_st { | ||
150 | long version; | ||
151 | CMS_OriginatorInfo *originatorInfo; | ||
152 | STACK_OF(CMS_RecipientInfo) *recipientInfos; | ||
153 | CMS_EncryptedContentInfo *encryptedContentInfo; | ||
154 | STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; | ||
155 | }; | ||
156 | |||
157 | struct CMS_OriginatorInfo_st { | ||
158 | STACK_OF(CMS_CertificateChoices) *certificates; | ||
159 | STACK_OF(CMS_RevocationInfoChoice) *crls; | ||
160 | }; | ||
161 | |||
162 | struct CMS_EncryptedContentInfo_st { | ||
163 | ASN1_OBJECT *contentType; | ||
164 | X509_ALGOR *contentEncryptionAlgorithm; | ||
165 | ASN1_OCTET_STRING *encryptedContent; | ||
166 | /* Content encryption algorithm and key */ | ||
167 | const EVP_CIPHER *cipher; | ||
168 | unsigned char *key; | ||
169 | size_t keylen; | ||
170 | /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */ | ||
171 | int debug; | ||
172 | }; | ||
173 | |||
174 | struct CMS_RecipientInfo_st { | ||
175 | int type; | ||
176 | union { | ||
177 | CMS_KeyTransRecipientInfo *ktri; | ||
178 | CMS_KeyAgreeRecipientInfo *kari; | ||
179 | CMS_KEKRecipientInfo *kekri; | ||
180 | CMS_PasswordRecipientInfo *pwri; | ||
181 | CMS_OtherRecipientInfo *ori; | ||
182 | } d; | ||
183 | }; | ||
184 | |||
185 | typedef CMS_SignerIdentifier CMS_RecipientIdentifier; | ||
186 | |||
187 | struct CMS_KeyTransRecipientInfo_st { | ||
188 | long version; | ||
189 | CMS_RecipientIdentifier *rid; | ||
190 | X509_ALGOR *keyEncryptionAlgorithm; | ||
191 | ASN1_OCTET_STRING *encryptedKey; | ||
192 | /* Recipient Key and cert */ | ||
193 | X509 *recip; | ||
194 | EVP_PKEY *pkey; | ||
195 | }; | ||
196 | |||
197 | struct CMS_KeyAgreeRecipientInfo_st { | ||
198 | long version; | ||
199 | CMS_OriginatorIdentifierOrKey *originator; | ||
200 | ASN1_OCTET_STRING *ukm; | ||
201 | X509_ALGOR *keyEncryptionAlgorithm; | ||
202 | STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys; | ||
203 | }; | ||
204 | |||
205 | struct CMS_OriginatorIdentifierOrKey_st { | ||
206 | int type; | ||
207 | union { | ||
208 | CMS_IssuerAndSerialNumber *issuerAndSerialNumber; | ||
209 | ASN1_OCTET_STRING *subjectKeyIdentifier; | ||
210 | CMS_OriginatorPublicKey *originatorKey; | ||
211 | } d; | ||
212 | }; | ||
213 | |||
214 | struct CMS_OriginatorPublicKey_st { | ||
215 | X509_ALGOR *algorithm; | ||
216 | ASN1_BIT_STRING *publicKey; | ||
217 | }; | ||
218 | |||
219 | struct CMS_RecipientEncryptedKey_st { | ||
220 | CMS_KeyAgreeRecipientIdentifier *rid; | ||
221 | ASN1_OCTET_STRING *encryptedKey; | ||
222 | }; | ||
223 | |||
224 | struct CMS_KeyAgreeRecipientIdentifier_st { | ||
225 | int type; | ||
226 | union { | ||
227 | CMS_IssuerAndSerialNumber *issuerAndSerialNumber; | ||
228 | CMS_RecipientKeyIdentifier *rKeyId; | ||
229 | } d; | ||
230 | }; | ||
231 | |||
232 | struct CMS_RecipientKeyIdentifier_st { | ||
233 | ASN1_OCTET_STRING *subjectKeyIdentifier; | ||
234 | ASN1_GENERALIZEDTIME *date; | ||
235 | CMS_OtherKeyAttribute *other; | ||
236 | }; | ||
237 | |||
238 | struct CMS_KEKRecipientInfo_st { | ||
239 | long version; | ||
240 | CMS_KEKIdentifier *kekid; | ||
241 | X509_ALGOR *keyEncryptionAlgorithm; | ||
242 | ASN1_OCTET_STRING *encryptedKey; | ||
243 | /* Extra info: symmetric key to use */ | ||
244 | unsigned char *key; | ||
245 | size_t keylen; | ||
246 | }; | ||
247 | |||
248 | struct CMS_KEKIdentifier_st { | ||
249 | ASN1_OCTET_STRING *keyIdentifier; | ||
250 | ASN1_GENERALIZEDTIME *date; | ||
251 | CMS_OtherKeyAttribute *other; | ||
252 | }; | ||
253 | |||
254 | struct CMS_PasswordRecipientInfo_st { | ||
255 | long version; | ||
256 | X509_ALGOR *keyDerivationAlgorithm; | ||
257 | X509_ALGOR *keyEncryptionAlgorithm; | ||
258 | ASN1_OCTET_STRING *encryptedKey; | ||
259 | /* Extra info: password to use */ | ||
260 | unsigned char *pass; | ||
261 | size_t passlen; | ||
262 | }; | ||
263 | |||
264 | struct CMS_OtherRecipientInfo_st { | ||
265 | ASN1_OBJECT *oriType; | ||
266 | ASN1_TYPE *oriValue; | ||
267 | }; | ||
268 | |||
269 | struct CMS_DigestedData_st { | ||
270 | long version; | ||
271 | X509_ALGOR *digestAlgorithm; | ||
272 | CMS_EncapsulatedContentInfo *encapContentInfo; | ||
273 | ASN1_OCTET_STRING *digest; | ||
274 | }; | ||
275 | |||
276 | struct CMS_EncryptedData_st { | ||
277 | long version; | ||
278 | CMS_EncryptedContentInfo *encryptedContentInfo; | ||
279 | STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs; | ||
280 | }; | ||
281 | |||
282 | struct CMS_AuthenticatedData_st { | ||
283 | long version; | ||
284 | CMS_OriginatorInfo *originatorInfo; | ||
285 | STACK_OF(CMS_RecipientInfo) *recipientInfos; | ||
286 | X509_ALGOR *macAlgorithm; | ||
287 | X509_ALGOR *digestAlgorithm; | ||
288 | CMS_EncapsulatedContentInfo *encapContentInfo; | ||
289 | STACK_OF(X509_ATTRIBUTE) *authAttrs; | ||
290 | ASN1_OCTET_STRING *mac; | ||
291 | STACK_OF(X509_ATTRIBUTE) *unauthAttrs; | ||
292 | }; | ||
293 | |||
294 | struct CMS_CompressedData_st { | ||
295 | long version; | ||
296 | X509_ALGOR *compressionAlgorithm; | ||
297 | STACK_OF(CMS_RecipientInfo) *recipientInfos; | ||
298 | CMS_EncapsulatedContentInfo *encapContentInfo; | ||
299 | }; | ||
300 | |||
301 | struct CMS_RevocationInfoChoice_st { | ||
302 | int type; | ||
303 | union { | ||
304 | X509_CRL *crl; | ||
305 | CMS_OtherRevocationInfoFormat *other; | ||
306 | } d; | ||
307 | }; | ||
308 | |||
309 | #define CMS_REVCHOICE_CRL 0 | ||
310 | #define CMS_REVCHOICE_OTHER 1 | ||
311 | |||
312 | struct CMS_OtherRevocationInfoFormat_st { | ||
313 | ASN1_OBJECT *otherRevInfoFormat; | ||
314 | ASN1_TYPE *otherRevInfo; | ||
315 | }; | ||
316 | |||
317 | struct CMS_CertificateChoices { | ||
318 | int type; | ||
319 | union { | ||
320 | X509 *certificate; | ||
321 | ASN1_STRING *extendedCertificate; /* Obsolete */ | ||
322 | ASN1_STRING *v1AttrCert; /* Left encoded for now */ | ||
323 | ASN1_STRING *v2AttrCert; /* Left encoded for now */ | ||
324 | CMS_OtherCertificateFormat *other; | ||
325 | } d; | ||
326 | }; | ||
327 | |||
328 | #define CMS_CERTCHOICE_CERT 0 | ||
329 | #define CMS_CERTCHOICE_EXCERT 1 | ||
330 | #define CMS_CERTCHOICE_V1ACERT 2 | ||
331 | #define CMS_CERTCHOICE_V2ACERT 3 | ||
332 | #define CMS_CERTCHOICE_OTHER 4 | ||
333 | |||
334 | struct CMS_OtherCertificateFormat_st { | ||
335 | ASN1_OBJECT *otherCertFormat; | ||
336 | ASN1_TYPE *otherCert; | ||
337 | }; | ||
338 | |||
339 | /* This is also defined in pkcs7.h but we duplicate it | ||
340 | * to allow the CMS code to be independent of PKCS#7 | ||
341 | */ | ||
342 | |||
343 | struct CMS_IssuerAndSerialNumber_st { | ||
344 | X509_NAME *issuer; | ||
345 | ASN1_INTEGER *serialNumber; | ||
346 | }; | ||
347 | |||
348 | struct CMS_OtherKeyAttribute_st { | ||
349 | ASN1_OBJECT *keyAttrId; | ||
350 | ASN1_TYPE *keyAttr; | ||
351 | }; | ||
352 | |||
353 | /* ESS structures */ | ||
354 | |||
355 | #ifdef HEADER_X509V3_H | ||
356 | |||
357 | struct CMS_ReceiptRequest_st { | ||
358 | ASN1_OCTET_STRING *signedContentIdentifier; | ||
359 | CMS_ReceiptsFrom *receiptsFrom; | ||
360 | STACK_OF(GENERAL_NAMES) *receiptsTo; | ||
361 | }; | ||
362 | |||
363 | |||
364 | struct CMS_ReceiptsFrom_st { | ||
365 | int type; | ||
366 | union | ||
367 | { | ||
368 | long allOrFirstTier; | ||
369 | STACK_OF(GENERAL_NAMES) *receiptList; | ||
370 | } d; | ||
371 | }; | ||
372 | #endif | ||
373 | |||
374 | struct CMS_Receipt_st { | ||
375 | long version; | ||
376 | ASN1_OBJECT *contentType; | ||
377 | ASN1_OCTET_STRING *signedContentIdentifier; | ||
378 | ASN1_OCTET_STRING *originatorSignatureValue; | ||
379 | }; | ||
380 | |||
381 | DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) | ||
382 | DECLARE_ASN1_ITEM(CMS_SignerInfo) | ||
383 | DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber) | ||
384 | DECLARE_ASN1_ITEM(CMS_Attributes_Sign) | ||
385 | DECLARE_ASN1_ITEM(CMS_Attributes_Verify) | ||
386 | DECLARE_ASN1_ITEM(CMS_RecipientInfo) | ||
387 | DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo) | ||
388 | DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber) | ||
389 | |||
390 | #define CMS_SIGNERINFO_ISSUER_SERIAL 0 | ||
391 | #define CMS_SIGNERINFO_KEYIDENTIFIER 1 | ||
392 | |||
393 | #define CMS_RECIPINFO_ISSUER_SERIAL 0 | ||
394 | #define CMS_RECIPINFO_KEYIDENTIFIER 1 | ||
395 | |||
396 | BIO *cms_content_bio(CMS_ContentInfo *cms); | ||
397 | |||
398 | CMS_ContentInfo *cms_Data_create(void); | ||
399 | |||
400 | CMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md); | ||
401 | BIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms); | ||
402 | int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify); | ||
403 | |||
404 | BIO *cms_SignedData_init_bio(CMS_ContentInfo *cms); | ||
405 | int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain); | ||
406 | int cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert, int type); | ||
407 | int cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid, | ||
408 | ASN1_OCTET_STRING **keyid, X509_NAME **issuer, ASN1_INTEGER **sno); | ||
409 | int cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert); | ||
410 | |||
411 | CMS_ContentInfo *cms_CompressedData_create(int comp_nid); | ||
412 | BIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms); | ||
413 | |||
414 | void cms_DigestAlgorithm_set(X509_ALGOR *alg, const EVP_MD *md); | ||
415 | BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm); | ||
416 | int cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain, | ||
417 | X509_ALGOR *mdalg); | ||
418 | |||
419 | BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec); | ||
420 | BIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms); | ||
421 | int cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec, | ||
422 | const EVP_CIPHER *cipher, const unsigned char *key, size_t keylen); | ||
423 | |||
424 | int cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms); | ||
425 | int cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src); | ||
426 | ASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si); | ||
427 | |||
428 | BIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms); | ||
429 | CMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms); | ||
430 | |||
431 | /* PWRI routines */ | ||
432 | int cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri, | ||
433 | int en_de); | ||
434 | |||
435 | #ifdef __cplusplus | ||
436 | } | ||
437 | #endif | ||
438 | #endif | ||