1183234Ssimon/* crypto/cms/cms_lcl.h */
2183234Ssimon/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3183234Ssimon * project.
4183234Ssimon */
5183234Ssimon/* ====================================================================
6183234Ssimon * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.
7183234Ssimon *
8183234Ssimon * Redistribution and use in source and binary forms, with or without
9183234Ssimon * modification, are permitted provided that the following conditions
10183234Ssimon * are met:
11183234Ssimon *
12183234Ssimon * 1. Redistributions of source code must retain the above copyright
13183234Ssimon *    notice, this list of conditions and the following disclaimer.
14183234Ssimon *
15183234Ssimon * 2. Redistributions in binary form must reproduce the above copyright
16183234Ssimon *    notice, this list of conditions and the following disclaimer in
17183234Ssimon *    the documentation and/or other materials provided with the
18183234Ssimon *    distribution.
19183234Ssimon *
20183234Ssimon * 3. All advertising materials mentioning features or use of this
21183234Ssimon *    software must display the following acknowledgment:
22183234Ssimon *    "This product includes software developed by the OpenSSL Project
23183234Ssimon *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24183234Ssimon *
25183234Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26183234Ssimon *    endorse or promote products derived from this software without
27183234Ssimon *    prior written permission. For written permission, please contact
28183234Ssimon *    licensing@OpenSSL.org.
29183234Ssimon *
30183234Ssimon * 5. Products derived from this software may not be called "OpenSSL"
31183234Ssimon *    nor may "OpenSSL" appear in their names without prior written
32183234Ssimon *    permission of the OpenSSL Project.
33183234Ssimon *
34183234Ssimon * 6. Redistributions of any form whatsoever must retain the following
35183234Ssimon *    acknowledgment:
36183234Ssimon *    "This product includes software developed by the OpenSSL Project
37183234Ssimon *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38183234Ssimon *
39183234Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40183234Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41183234Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42183234Ssimon * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43183234Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44183234Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45183234Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46183234Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47183234Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48183234Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49183234Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50183234Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE.
51183234Ssimon * ====================================================================
52183234Ssimon */
53183234Ssimon
54183234Ssimon#ifndef HEADER_CMS_LCL_H
55183234Ssimon#define HEADER_CMS_LCL_H
56183234Ssimon
57183234Ssimon#ifdef __cplusplus
58183234Ssimonextern "C" {
59183234Ssimon#endif
60183234Ssimon
61183234Ssimon#include <openssl/x509.h>
62183234Ssimon
63183234Ssimon/* Cryptographic message syntax (CMS) structures: taken
64183234Ssimon * from RFC3852
65183234Ssimon */
66183234Ssimon
67183234Ssimon/* Forward references */
68183234Ssimon
69183234Ssimontypedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber;
70183234Ssimontypedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo;
71183234Ssimontypedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier;
72183234Ssimontypedef struct CMS_SignedData_st CMS_SignedData;
73183234Ssimontypedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat;
74183234Ssimontypedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo;
75183234Ssimontypedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo;
76183234Ssimontypedef struct CMS_EnvelopedData_st CMS_EnvelopedData;
77183234Ssimontypedef struct CMS_DigestedData_st CMS_DigestedData;
78183234Ssimontypedef struct CMS_EncryptedData_st CMS_EncryptedData;
79183234Ssimontypedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData;
80183234Ssimontypedef struct CMS_CompressedData_st CMS_CompressedData;
81183234Ssimontypedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat;
82183234Ssimontypedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo;
83183234Ssimontypedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey;
84183234Ssimontypedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey;
85183234Ssimontypedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo;
86183234Ssimontypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;
87183234Ssimontypedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier;
88183234Ssimontypedef struct CMS_KeyAgreeRecipientIdentifier_st CMS_KeyAgreeRecipientIdentifier;
89183234Ssimontypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
90183234Ssimontypedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier;
91183234Ssimontypedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo;
92183234Ssimontypedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo;
93183234Ssimontypedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo;
94183234Ssimontypedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom;
95183234Ssimon
96183234Ssimonstruct CMS_ContentInfo_st
97183234Ssimon	{
98183234Ssimon	ASN1_OBJECT *contentType;
99183234Ssimon	union	{
100183234Ssimon		ASN1_OCTET_STRING *data;
101183234Ssimon		CMS_SignedData *signedData;
102183234Ssimon		CMS_EnvelopedData *envelopedData;
103183234Ssimon		CMS_DigestedData *digestedData;
104183234Ssimon		CMS_EncryptedData *encryptedData;
105183234Ssimon		CMS_AuthenticatedData *authenticatedData;
106183234Ssimon		CMS_CompressedData *compressedData;
107183234Ssimon		ASN1_TYPE *other;
108183234Ssimon		/* Other types ... */
109183234Ssimon		void *otherData;
110183234Ssimon		} d;
111183234Ssimon	};
112183234Ssimon
113183234Ssimonstruct CMS_SignedData_st
114183234Ssimon	{
115183234Ssimon	long version;
116183234Ssimon	STACK_OF(X509_ALGOR) *digestAlgorithms;
117183234Ssimon	CMS_EncapsulatedContentInfo *encapContentInfo;
118183234Ssimon	STACK_OF(CMS_CertificateChoices) *certificates;
119183234Ssimon	STACK_OF(CMS_RevocationInfoChoice) *crls;
120183234Ssimon	STACK_OF(CMS_SignerInfo) *signerInfos;
121183234Ssimon	};
122183234Ssimon
123183234Ssimonstruct CMS_EncapsulatedContentInfo_st
124183234Ssimon	{
125183234Ssimon	ASN1_OBJECT *eContentType;
126183234Ssimon	ASN1_OCTET_STRING *eContent;
127183234Ssimon	/* Set to 1 if incomplete structure only part set up */
128183234Ssimon	int partial;
129183234Ssimon	};
130183234Ssimon
131183234Ssimonstruct CMS_SignerInfo_st
132183234Ssimon	{
133183234Ssimon	long version;
134183234Ssimon	CMS_SignerIdentifier *sid;
135183234Ssimon	X509_ALGOR *digestAlgorithm;
136183234Ssimon	STACK_OF(X509_ATTRIBUTE) *signedAttrs;
137183234Ssimon	X509_ALGOR *signatureAlgorithm;
138183234Ssimon	ASN1_OCTET_STRING *signature;
139183234Ssimon	STACK_OF(X509_ATTRIBUTE) *unsignedAttrs;
140183234Ssimon	/* Signing certificate and key */
141183234Ssimon	X509 *signer;
142183234Ssimon	EVP_PKEY *pkey;
143183234Ssimon	};
144183234Ssimon
145183234Ssimonstruct CMS_SignerIdentifier_st
146183234Ssimon	{
147183234Ssimon	int type;
148183234Ssimon	union	{
149183234Ssimon		CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
150183234Ssimon		ASN1_OCTET_STRING *subjectKeyIdentifier;
151183234Ssimon		} d;
152183234Ssimon	};
153183234Ssimon
154183234Ssimonstruct CMS_EnvelopedData_st
155183234Ssimon	{
156183234Ssimon	long version;
157183234Ssimon	CMS_OriginatorInfo *originatorInfo;
158183234Ssimon	STACK_OF(CMS_RecipientInfo) *recipientInfos;
159183234Ssimon	CMS_EncryptedContentInfo *encryptedContentInfo;
160183234Ssimon	STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
161183234Ssimon	};
162183234Ssimon
163183234Ssimonstruct CMS_OriginatorInfo_st
164183234Ssimon	{
165183234Ssimon	STACK_OF(CMS_CertificateChoices) *certificates;
166183234Ssimon	STACK_OF(CMS_RevocationInfoChoice) *crls;
167183234Ssimon	};
168183234Ssimon
169183234Ssimonstruct CMS_EncryptedContentInfo_st
170183234Ssimon	{
171183234Ssimon	ASN1_OBJECT *contentType;
172183234Ssimon	X509_ALGOR *contentEncryptionAlgorithm;
173183234Ssimon	ASN1_OCTET_STRING *encryptedContent;
174183234Ssimon	/* Content encryption algorithm and key */
175183234Ssimon	const EVP_CIPHER *cipher;
176183234Ssimon	unsigned char *key;
177183234Ssimon	size_t keylen;
178237657Sjkim	/* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
179237657Sjkim	int debug;
180183234Ssimon	};
181183234Ssimon
182183234Ssimonstruct CMS_RecipientInfo_st
183183234Ssimon	{
184183234Ssimon 	int type;
185183234Ssimon 	union	{
186183234Ssimon  	 	CMS_KeyTransRecipientInfo *ktri;
187183234Ssimon   		CMS_KeyAgreeRecipientInfo *kari;
188183234Ssimon   		CMS_KEKRecipientInfo *kekri;
189183234Ssimon		CMS_PasswordRecipientInfo *pwri;
190183234Ssimon		CMS_OtherRecipientInfo *ori;
191183234Ssimon		} d;
192183234Ssimon	};
193183234Ssimon
194183234Ssimontypedef CMS_SignerIdentifier CMS_RecipientIdentifier;
195183234Ssimon
196183234Ssimonstruct CMS_KeyTransRecipientInfo_st
197183234Ssimon	{
198183234Ssimon	long version;
199183234Ssimon	CMS_RecipientIdentifier *rid;
200183234Ssimon	X509_ALGOR *keyEncryptionAlgorithm;
201183234Ssimon	ASN1_OCTET_STRING *encryptedKey;
202183234Ssimon	/* Recipient Key and cert */
203183234Ssimon	X509 *recip;
204183234Ssimon	EVP_PKEY *pkey;
205183234Ssimon	};
206183234Ssimon
207183234Ssimonstruct CMS_KeyAgreeRecipientInfo_st
208183234Ssimon	{
209183234Ssimon	long version;
210183234Ssimon	CMS_OriginatorIdentifierOrKey *originator;
211183234Ssimon	ASN1_OCTET_STRING *ukm;
212183234Ssimon 	X509_ALGOR *keyEncryptionAlgorithm;
213183234Ssimon	STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys;
214183234Ssimon	};
215183234Ssimon
216183234Ssimonstruct CMS_OriginatorIdentifierOrKey_st
217183234Ssimon	{
218183234Ssimon	int type;
219183234Ssimon	union	{
220183234Ssimon		CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
221183234Ssimon		ASN1_OCTET_STRING *subjectKeyIdentifier;
222183234Ssimon		CMS_OriginatorPublicKey *originatorKey;
223183234Ssimon		} d;
224183234Ssimon	};
225183234Ssimon
226183234Ssimonstruct CMS_OriginatorPublicKey_st
227183234Ssimon	{
228183234Ssimon	X509_ALGOR *algorithm;
229183234Ssimon	ASN1_BIT_STRING *publicKey;
230183234Ssimon	};
231183234Ssimon
232183234Ssimonstruct CMS_RecipientEncryptedKey_st
233183234Ssimon	{
234183234Ssimon 	CMS_KeyAgreeRecipientIdentifier *rid;
235183234Ssimon 	ASN1_OCTET_STRING *encryptedKey;
236183234Ssimon	};
237183234Ssimon
238183234Ssimonstruct CMS_KeyAgreeRecipientIdentifier_st
239183234Ssimon	{
240183234Ssimon	int type;
241183234Ssimon	union	{
242183234Ssimon		CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
243183234Ssimon		CMS_RecipientKeyIdentifier *rKeyId;
244183234Ssimon		} d;
245183234Ssimon	};
246183234Ssimon
247183234Ssimonstruct CMS_RecipientKeyIdentifier_st
248183234Ssimon	{
249183234Ssimon 	ASN1_OCTET_STRING *subjectKeyIdentifier;
250183234Ssimon 	ASN1_GENERALIZEDTIME *date;
251183234Ssimon 	CMS_OtherKeyAttribute *other;
252183234Ssimon	};
253183234Ssimon
254183234Ssimonstruct CMS_KEKRecipientInfo_st
255183234Ssimon	{
256183234Ssimon 	long version;
257183234Ssimon 	CMS_KEKIdentifier *kekid;
258183234Ssimon 	X509_ALGOR *keyEncryptionAlgorithm;
259183234Ssimon 	ASN1_OCTET_STRING *encryptedKey;
260183234Ssimon	/* Extra info: symmetric key to use */
261183234Ssimon	unsigned char *key;
262183234Ssimon	size_t keylen;
263183234Ssimon	};
264183234Ssimon
265183234Ssimonstruct CMS_KEKIdentifier_st
266183234Ssimon	{
267183234Ssimon 	ASN1_OCTET_STRING *keyIdentifier;
268183234Ssimon 	ASN1_GENERALIZEDTIME *date;
269183234Ssimon 	CMS_OtherKeyAttribute *other;
270183234Ssimon	};
271183234Ssimon
272183234Ssimonstruct CMS_PasswordRecipientInfo_st
273183234Ssimon	{
274183234Ssimon 	long version;
275183234Ssimon 	X509_ALGOR *keyDerivationAlgorithm;
276183234Ssimon 	X509_ALGOR *keyEncryptionAlgorithm;
277183234Ssimon 	ASN1_OCTET_STRING *encryptedKey;
278238405Sjkim	/* Extra info: password to use */
279238405Sjkim	unsigned char *pass;
280238405Sjkim	size_t passlen;
281183234Ssimon	};
282183234Ssimon
283183234Ssimonstruct CMS_OtherRecipientInfo_st
284183234Ssimon	{
285183234Ssimon 	ASN1_OBJECT *oriType;
286183234Ssimon 	ASN1_TYPE *oriValue;
287183234Ssimon	};
288183234Ssimon
289183234Ssimonstruct CMS_DigestedData_st
290183234Ssimon	{
291183234Ssimon	long version;
292183234Ssimon	X509_ALGOR *digestAlgorithm;
293183234Ssimon	CMS_EncapsulatedContentInfo *encapContentInfo;
294183234Ssimon	ASN1_OCTET_STRING *digest;
295183234Ssimon	};
296183234Ssimon
297183234Ssimonstruct CMS_EncryptedData_st
298183234Ssimon	{
299183234Ssimon	long version;
300183234Ssimon	CMS_EncryptedContentInfo *encryptedContentInfo;
301183234Ssimon	STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
302183234Ssimon	};
303183234Ssimon
304183234Ssimonstruct CMS_AuthenticatedData_st
305183234Ssimon	{
306183234Ssimon	long version;
307183234Ssimon	CMS_OriginatorInfo *originatorInfo;
308183234Ssimon	STACK_OF(CMS_RecipientInfo) *recipientInfos;
309183234Ssimon	X509_ALGOR *macAlgorithm;
310183234Ssimon	X509_ALGOR *digestAlgorithm;
311183234Ssimon	CMS_EncapsulatedContentInfo *encapContentInfo;
312183234Ssimon	STACK_OF(X509_ATTRIBUTE) *authAttrs;
313183234Ssimon	ASN1_OCTET_STRING *mac;
314183234Ssimon	STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
315183234Ssimon	};
316183234Ssimon
317183234Ssimonstruct CMS_CompressedData_st
318183234Ssimon	{
319183234Ssimon	long version;
320183234Ssimon	X509_ALGOR *compressionAlgorithm;
321183234Ssimon	STACK_OF(CMS_RecipientInfo) *recipientInfos;
322183234Ssimon	CMS_EncapsulatedContentInfo *encapContentInfo;
323183234Ssimon	};
324183234Ssimon
325183234Ssimonstruct CMS_RevocationInfoChoice_st
326183234Ssimon	{
327183234Ssimon	int type;
328183234Ssimon	union	{
329183234Ssimon		X509_CRL *crl;
330183234Ssimon		CMS_OtherRevocationInfoFormat *other;
331183234Ssimon		} d;
332183234Ssimon	};
333183234Ssimon
334183234Ssimon#define CMS_REVCHOICE_CRL		0
335183234Ssimon#define CMS_REVCHOICE_OTHER		1
336183234Ssimon
337183234Ssimonstruct CMS_OtherRevocationInfoFormat_st
338183234Ssimon	{
339183234Ssimon	ASN1_OBJECT *otherRevInfoFormat;
340183234Ssimon 	ASN1_TYPE *otherRevInfo;
341183234Ssimon	};
342183234Ssimon
343183234Ssimonstruct CMS_CertificateChoices
344183234Ssimon	{
345183234Ssimon	int type;
346183234Ssimon		union {
347183234Ssimon		X509 *certificate;
348183234Ssimon		ASN1_STRING *extendedCertificate;	/* Obsolete */
349183234Ssimon		ASN1_STRING *v1AttrCert;	/* Left encoded for now */
350183234Ssimon		ASN1_STRING *v2AttrCert;	/* Left encoded for now */
351183234Ssimon		CMS_OtherCertificateFormat *other;
352183234Ssimon		} d;
353183234Ssimon	};
354183234Ssimon
355183234Ssimon#define CMS_CERTCHOICE_CERT		0
356183234Ssimon#define CMS_CERTCHOICE_EXCERT		1
357183234Ssimon#define CMS_CERTCHOICE_V1ACERT		2
358183234Ssimon#define CMS_CERTCHOICE_V2ACERT		3
359183234Ssimon#define CMS_CERTCHOICE_OTHER		4
360183234Ssimon
361183234Ssimonstruct CMS_OtherCertificateFormat_st
362183234Ssimon	{
363183234Ssimon	ASN1_OBJECT *otherCertFormat;
364183234Ssimon 	ASN1_TYPE *otherCert;
365183234Ssimon	};
366183234Ssimon
367183234Ssimon/* This is also defined in pkcs7.h but we duplicate it
368183234Ssimon * to allow the CMS code to be independent of PKCS#7
369183234Ssimon */
370183234Ssimon
371183234Ssimonstruct CMS_IssuerAndSerialNumber_st
372183234Ssimon	{
373183234Ssimon	X509_NAME *issuer;
374183234Ssimon	ASN1_INTEGER *serialNumber;
375183234Ssimon	};
376183234Ssimon
377183234Ssimonstruct CMS_OtherKeyAttribute_st
378183234Ssimon	{
379183234Ssimon	ASN1_OBJECT *keyAttrId;
380183234Ssimon 	ASN1_TYPE *keyAttr;
381183234Ssimon	};
382183234Ssimon
383183234Ssimon/* ESS structures */
384183234Ssimon
385183234Ssimon#ifdef HEADER_X509V3_H
386183234Ssimon
387183234Ssimonstruct CMS_ReceiptRequest_st
388183234Ssimon	{
389183234Ssimon	ASN1_OCTET_STRING *signedContentIdentifier;
390183234Ssimon	CMS_ReceiptsFrom *receiptsFrom;
391183234Ssimon	STACK_OF(GENERAL_NAMES) *receiptsTo;
392183234Ssimon	};
393183234Ssimon
394183234Ssimon
395183234Ssimonstruct CMS_ReceiptsFrom_st
396183234Ssimon	{
397183234Ssimon	int type;
398183234Ssimon	union
399183234Ssimon		{
400183234Ssimon		long allOrFirstTier;
401183234Ssimon		STACK_OF(GENERAL_NAMES) *receiptList;
402183234Ssimon		} d;
403183234Ssimon	};
404183234Ssimon#endif
405183234Ssimon
406183234Ssimonstruct CMS_Receipt_st
407183234Ssimon	{
408183234Ssimon	long version;
409183234Ssimon	ASN1_OBJECT *contentType;
410183234Ssimon	ASN1_OCTET_STRING *signedContentIdentifier;
411183234Ssimon	ASN1_OCTET_STRING *originatorSignatureValue;
412183234Ssimon	};
413183234Ssimon
414238405SjkimDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
415183234SsimonDECLARE_ASN1_ITEM(CMS_SignerInfo)
416183234SsimonDECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber)
417183234SsimonDECLARE_ASN1_ITEM(CMS_Attributes_Sign)
418183234SsimonDECLARE_ASN1_ITEM(CMS_Attributes_Verify)
419238405SjkimDECLARE_ASN1_ITEM(CMS_RecipientInfo)
420238405SjkimDECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo)
421183234SsimonDECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber)
422183234Ssimon
423183234Ssimon#define CMS_SIGNERINFO_ISSUER_SERIAL	0
424183234Ssimon#define CMS_SIGNERINFO_KEYIDENTIFIER	1
425183234Ssimon
426183234Ssimon#define CMS_RECIPINFO_ISSUER_SERIAL	0
427183234Ssimon#define CMS_RECIPINFO_KEYIDENTIFIER	1
428183234Ssimon
429183234SsimonBIO *cms_content_bio(CMS_ContentInfo *cms);
430183234Ssimon
431183234SsimonCMS_ContentInfo *cms_Data_create(void);
432183234Ssimon
433183234SsimonCMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md);
434183234SsimonBIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms);
435183234Ssimonint cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify);
436183234Ssimon
437183234SsimonBIO *cms_SignedData_init_bio(CMS_ContentInfo *cms);
438183234Ssimonint cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain);
439183234Ssimonint cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert, int type);
440183234Ssimonint cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid,
441183234Ssimon					ASN1_OCTET_STRING **keyid,
442183234Ssimon					X509_NAME **issuer, ASN1_INTEGER **sno);
443183234Ssimonint cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert);
444183234Ssimon
445183234SsimonCMS_ContentInfo *cms_CompressedData_create(int comp_nid);
446183234SsimonBIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms);
447183234Ssimon
448183234Ssimonvoid cms_DigestAlgorithm_set(X509_ALGOR *alg, const EVP_MD *md);
449183234SsimonBIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm);
450183234Ssimonint cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
451183234Ssimon					X509_ALGOR *mdalg);
452183234Ssimon
453183234SsimonBIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec);
454183234SsimonBIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms);
455183234Ssimonint cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
456183234Ssimon				const EVP_CIPHER *cipher,
457183234Ssimon				const unsigned char *key, size_t keylen);
458183234Ssimon
459183234Ssimonint cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms);
460183234Ssimonint cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src);
461183234SsimonASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si);
462183234Ssimon
463183234SsimonBIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms);
464238405SjkimCMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms);
465238405Sjkim
466238405Sjkim/* PWRI routines */
467238405Sjkimint cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
468238405Sjkim							int en_de);
469183234Ssimon
470183234Ssimon#ifdef  __cplusplus
471183234Ssimon}
472183234Ssimon#endif
473183234Ssimon#endif
474