OpenSSL  1.0.1c
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
cms_lcl.h
Go to the documentation of this file.
1 /* crypto/cms/cms_lcl.h */
2 /* Written by Dr Stephen N Henson ([email protected]) 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
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 
94 typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom;
95 
97  {
99  union {
108  /* Other types ... */
109  void *otherData;
110  } d;
111  };
112 
114  {
115  long version;
116  STACK_OF(X509_ALGOR) *digestAlgorithms;
118  STACK_OF(CMS_CertificateChoices) *certificates;
120  STACK_OF(CMS_SignerInfo) *signerInfos;
121  };
122 
124  {
127  /* Set to 1 if incomplete structure only part set up */
128  int partial;
129  };
130 
132  {
133  long version;
136  STACK_OF(X509_ATTRIBUTE) *signedAttrs;
139  STACK_OF(X509_ATTRIBUTE) *unsignedAttrs;
140  /* Signing certificate and key */
143  };
144 
146  {
147  int type;
148  union {
151  } d;
152  };
153 
155  {
156  long version;
158  STACK_OF(CMS_RecipientInfo) *recipientInfos;
160  STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
161  };
162 
164  {
165  STACK_OF(CMS_CertificateChoices) *certificates;
167  };
168 
170  {
174  /* Content encryption algorithm and key */
176  unsigned char *key;
177  size_t keylen;
178  /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
179  int debug;
180  };
181 
183  {
184  int type;
185  union {
191  } d;
192  };
193 
195 
197  {
198  long version;
199  CMS_RecipientIdentifier *rid;
202  /* Recipient Key and cert */
205  };
206 
208  {
209  long version;
213  STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys;
214  };
215 
217  {
218  int type;
219  union {
223  } d;
224  };
225 
227  {
230  };
231 
233  {
236  };
237 
239  {
240  int type;
241  union {
244  } d;
245  };
246 
248  {
252  };
253 
255  {
256  long version;
260  /* Extra info: symmetric key to use */
261  unsigned char *key;
262  size_t keylen;
263  };
264 
266  {
270  };
271 
273  {
274  long version;
278  /* Extra info: password to use */
279  unsigned char *pass;
280  size_t passlen;
281  };
282 
284  {
287  };
288 
290  {
291  long version;
295  };
296 
298  {
299  long version;
301  STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
302  };
303 
305  {
306  long version;
308  STACK_OF(CMS_RecipientInfo) *recipientInfos;
312  STACK_OF(X509_ATTRIBUTE) *authAttrs;
314  STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
315  };
316 
318  {
319  long version;
321  STACK_OF(CMS_RecipientInfo) *recipientInfos;
323  };
324 
326  {
327  int type;
328  union {
331  } d;
332  };
333 
334 #define CMS_REVCHOICE_CRL 0
335 #define CMS_REVCHOICE_OTHER 1
336 
338  {
341  };
342 
344  {
345  int type;
346  union {
349  ASN1_STRING *v1AttrCert; /* Left encoded for now */
350  ASN1_STRING *v2AttrCert; /* Left encoded for now */
352  } d;
353  };
354 
355 #define CMS_CERTCHOICE_CERT 0
356 #define CMS_CERTCHOICE_EXCERT 1
357 #define CMS_CERTCHOICE_V1ACERT 2
358 #define CMS_CERTCHOICE_V2ACERT 3
359 #define CMS_CERTCHOICE_OTHER 4
360 
362  {
365  };
366 
367 /* This is also defined in pkcs7.h but we duplicate it
368  * to allow the CMS code to be independent of PKCS#7
369  */
370 
372  {
375  };
376 
378  {
381  };
382 
383 /* ESS structures */
384 
385 #ifdef HEADER_X509V3_H
386 
387 struct CMS_ReceiptRequest_st
388  {
389  ASN1_OCTET_STRING *signedContentIdentifier;
390  CMS_ReceiptsFrom *receiptsFrom;
391  STACK_OF(GENERAL_NAMES) *receiptsTo;
392  };
393 
394 
395 struct CMS_ReceiptsFrom_st
396  {
397  int type;
398  union
399  {
400  long allOrFirstTier;
401  STACK_OF(GENERAL_NAMES) *receiptList;
402  } d;
403  };
404 #endif
405 
407  {
408  long version;
412  };
413 
417 DECLARE_ASN1_ITEM(CMS_Attributes_Sign)
418 DECLARE_ASN1_ITEM(CMS_Attributes_Verify)
422 
423 #define CMS_SIGNERINFO_ISSUER_SERIAL 0
424 #define CMS_SIGNERINFO_KEYIDENTIFIER 1
425 
426 #define CMS_RECIPINFO_ISSUER_SERIAL 0
427 #define CMS_RECIPINFO_KEYIDENTIFIER 1
428 
430 
432 
435 int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify);
436 
438 int cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain);
441  ASN1_OCTET_STRING **keyid,
442  X509_NAME **issuer, ASN1_INTEGER **sno);
444 
447 
448 void cms_DigestAlgorithm_set(X509_ALGOR *alg, const EVP_MD *md);
449 BIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm);
451  X509_ALGOR *mdalg);
452 
456  const EVP_CIPHER *cipher,
457  const unsigned char *key, size_t keylen);
458 
462 
465 
466 /* PWRI routines */
468  int en_de);
469 
470 #ifdef __cplusplus
471 }
472 #endif
473 #endif