1183234Ssimon/* crypto/cms/cms_lcl.h */
2296341Sdelphij/*
3296341Sdelphij * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4183234Ssimon * project.
5183234Ssimon */
6183234Ssimon/* ====================================================================
7183234Ssimon * Copyright (c) 2008 The OpenSSL Project.  All rights reserved.
8183234Ssimon *
9183234Ssimon * Redistribution and use in source and binary forms, with or without
10183234Ssimon * modification, are permitted provided that the following conditions
11183234Ssimon * are met:
12183234Ssimon *
13183234Ssimon * 1. Redistributions of source code must retain the above copyright
14296341Sdelphij *    notice, this list of conditions and the following disclaimer.
15183234Ssimon *
16183234Ssimon * 2. Redistributions in binary form must reproduce the above copyright
17183234Ssimon *    notice, this list of conditions and the following disclaimer in
18183234Ssimon *    the documentation and/or other materials provided with the
19183234Ssimon *    distribution.
20183234Ssimon *
21183234Ssimon * 3. All advertising materials mentioning features or use of this
22183234Ssimon *    software must display the following acknowledgment:
23183234Ssimon *    "This product includes software developed by the OpenSSL Project
24183234Ssimon *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25183234Ssimon *
26183234Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27183234Ssimon *    endorse or promote products derived from this software without
28183234Ssimon *    prior written permission. For written permission, please contact
29183234Ssimon *    licensing@OpenSSL.org.
30183234Ssimon *
31183234Ssimon * 5. Products derived from this software may not be called "OpenSSL"
32183234Ssimon *    nor may "OpenSSL" appear in their names without prior written
33183234Ssimon *    permission of the OpenSSL Project.
34183234Ssimon *
35183234Ssimon * 6. Redistributions of any form whatsoever must retain the following
36183234Ssimon *    acknowledgment:
37183234Ssimon *    "This product includes software developed by the OpenSSL Project
38183234Ssimon *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39183234Ssimon *
40183234Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41183234Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42183234Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43183234Ssimon * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
44183234Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45183234Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46183234Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47183234Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48183234Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49183234Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50183234Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51183234Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE.
52183234Ssimon * ====================================================================
53183234Ssimon */
54183234Ssimon
55183234Ssimon#ifndef HEADER_CMS_LCL_H
56296341Sdelphij# define HEADER_CMS_LCL_H
57183234Ssimon
58183234Ssimon#ifdef __cplusplus
59183234Ssimonextern "C" {
60183234Ssimon#endif
61183234Ssimon
62296341Sdelphij# include <openssl/x509.h>
63183234Ssimon
64296341Sdelphij/*
65296341Sdelphij * Cryptographic message syntax (CMS) structures: taken from RFC3852
66183234Ssimon */
67183234Ssimon
68183234Ssimon/* Forward references */
69183234Ssimon
70183234Ssimontypedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber;
71183234Ssimontypedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo;
72183234Ssimontypedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier;
73183234Ssimontypedef struct CMS_SignedData_st CMS_SignedData;
74183234Ssimontypedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat;
75183234Ssimontypedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo;
76183234Ssimontypedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo;
77183234Ssimontypedef struct CMS_EnvelopedData_st CMS_EnvelopedData;
78183234Ssimontypedef struct CMS_DigestedData_st CMS_DigestedData;
79183234Ssimontypedef struct CMS_EncryptedData_st CMS_EncryptedData;
80183234Ssimontypedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData;
81183234Ssimontypedef struct CMS_CompressedData_st CMS_CompressedData;
82183234Ssimontypedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat;
83183234Ssimontypedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo;
84183234Ssimontypedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey;
85183234Ssimontypedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey;
86183234Ssimontypedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo;
87183234Ssimontypedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;
88183234Ssimontypedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier;
89296341Sdelphijtypedef struct CMS_KeyAgreeRecipientIdentifier_st
90296341Sdelphij    CMS_KeyAgreeRecipientIdentifier;
91183234Ssimontypedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
92183234Ssimontypedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier;
93183234Ssimontypedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo;
94183234Ssimontypedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo;
95183234Ssimontypedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo;
96183234Ssimontypedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom;
97183234Ssimon
98296341Sdelphijstruct CMS_ContentInfo_st {
99296341Sdelphij    ASN1_OBJECT *contentType;
100296341Sdelphij    union {
101296341Sdelphij        ASN1_OCTET_STRING *data;
102296341Sdelphij        CMS_SignedData *signedData;
103296341Sdelphij        CMS_EnvelopedData *envelopedData;
104296341Sdelphij        CMS_DigestedData *digestedData;
105296341Sdelphij        CMS_EncryptedData *encryptedData;
106296341Sdelphij        CMS_AuthenticatedData *authenticatedData;
107296341Sdelphij        CMS_CompressedData *compressedData;
108296341Sdelphij        ASN1_TYPE *other;
109296341Sdelphij        /* Other types ... */
110296341Sdelphij        void *otherData;
111296341Sdelphij    } d;
112296341Sdelphij};
113183234Ssimon
114296341Sdelphijstruct CMS_SignedData_st {
115296341Sdelphij    long version;
116296341Sdelphij    STACK_OF(X509_ALGOR) *digestAlgorithms;
117296341Sdelphij    CMS_EncapsulatedContentInfo *encapContentInfo;
118296341Sdelphij    STACK_OF(CMS_CertificateChoices) *certificates;
119296341Sdelphij    STACK_OF(CMS_RevocationInfoChoice) *crls;
120296341Sdelphij    STACK_OF(CMS_SignerInfo) *signerInfos;
121296341Sdelphij};
122183234Ssimon
123296341Sdelphijstruct CMS_EncapsulatedContentInfo_st {
124296341Sdelphij    ASN1_OBJECT *eContentType;
125296341Sdelphij    ASN1_OCTET_STRING *eContent;
126296341Sdelphij    /* Set to 1 if incomplete structure only part set up */
127296341Sdelphij    int partial;
128296341Sdelphij};
129183234Ssimon
130296341Sdelphijstruct CMS_SignerInfo_st {
131296341Sdelphij    long version;
132296341Sdelphij    CMS_SignerIdentifier *sid;
133296341Sdelphij    X509_ALGOR *digestAlgorithm;
134296341Sdelphij    STACK_OF(X509_ATTRIBUTE) *signedAttrs;
135296341Sdelphij    X509_ALGOR *signatureAlgorithm;
136296341Sdelphij    ASN1_OCTET_STRING *signature;
137296341Sdelphij    STACK_OF(X509_ATTRIBUTE) *unsignedAttrs;
138296341Sdelphij    /* Signing certificate and key */
139296341Sdelphij    X509 *signer;
140296341Sdelphij    EVP_PKEY *pkey;
141296341Sdelphij};
142183234Ssimon
143296341Sdelphijstruct CMS_SignerIdentifier_st {
144296341Sdelphij    int type;
145296341Sdelphij    union {
146296341Sdelphij        CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
147296341Sdelphij        ASN1_OCTET_STRING *subjectKeyIdentifier;
148296341Sdelphij    } d;
149296341Sdelphij};
150183234Ssimon
151296341Sdelphijstruct CMS_EnvelopedData_st {
152296341Sdelphij    long version;
153296341Sdelphij    CMS_OriginatorInfo *originatorInfo;
154296341Sdelphij    STACK_OF(CMS_RecipientInfo) *recipientInfos;
155296341Sdelphij    CMS_EncryptedContentInfo *encryptedContentInfo;
156296341Sdelphij    STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
157296341Sdelphij};
158183234Ssimon
159296341Sdelphijstruct CMS_OriginatorInfo_st {
160296341Sdelphij    STACK_OF(CMS_CertificateChoices) *certificates;
161296341Sdelphij    STACK_OF(CMS_RevocationInfoChoice) *crls;
162296341Sdelphij};
163183234Ssimon
164296341Sdelphijstruct CMS_EncryptedContentInfo_st {
165296341Sdelphij    ASN1_OBJECT *contentType;
166296341Sdelphij    X509_ALGOR *contentEncryptionAlgorithm;
167296341Sdelphij    ASN1_OCTET_STRING *encryptedContent;
168296341Sdelphij    /* Content encryption algorithm and key */
169296341Sdelphij    const EVP_CIPHER *cipher;
170296341Sdelphij    unsigned char *key;
171296341Sdelphij    size_t keylen;
172296341Sdelphij    /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
173296341Sdelphij    int debug;
174296341Sdelphij};
175183234Ssimon
176296341Sdelphijstruct CMS_RecipientInfo_st {
177296341Sdelphij    int type;
178296341Sdelphij    union {
179296341Sdelphij        CMS_KeyTransRecipientInfo *ktri;
180296341Sdelphij        CMS_KeyAgreeRecipientInfo *kari;
181296341Sdelphij        CMS_KEKRecipientInfo *kekri;
182296341Sdelphij        CMS_PasswordRecipientInfo *pwri;
183296341Sdelphij        CMS_OtherRecipientInfo *ori;
184296341Sdelphij    } d;
185296341Sdelphij};
186296341Sdelphij
187183234Ssimontypedef CMS_SignerIdentifier CMS_RecipientIdentifier;
188183234Ssimon
189296341Sdelphijstruct CMS_KeyTransRecipientInfo_st {
190296341Sdelphij    long version;
191296341Sdelphij    CMS_RecipientIdentifier *rid;
192296341Sdelphij    X509_ALGOR *keyEncryptionAlgorithm;
193296341Sdelphij    ASN1_OCTET_STRING *encryptedKey;
194296341Sdelphij    /* Recipient Key and cert */
195296341Sdelphij    X509 *recip;
196296341Sdelphij    EVP_PKEY *pkey;
197296341Sdelphij};
198183234Ssimon
199296341Sdelphijstruct CMS_KeyAgreeRecipientInfo_st {
200296341Sdelphij    long version;
201296341Sdelphij    CMS_OriginatorIdentifierOrKey *originator;
202296341Sdelphij    ASN1_OCTET_STRING *ukm;
203296341Sdelphij    X509_ALGOR *keyEncryptionAlgorithm;
204296341Sdelphij    STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys;
205296341Sdelphij};
206183234Ssimon
207296341Sdelphijstruct CMS_OriginatorIdentifierOrKey_st {
208296341Sdelphij    int type;
209296341Sdelphij    union {
210296341Sdelphij        CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
211296341Sdelphij        ASN1_OCTET_STRING *subjectKeyIdentifier;
212296341Sdelphij        CMS_OriginatorPublicKey *originatorKey;
213296341Sdelphij    } d;
214296341Sdelphij};
215183234Ssimon
216296341Sdelphijstruct CMS_OriginatorPublicKey_st {
217296341Sdelphij    X509_ALGOR *algorithm;
218296341Sdelphij    ASN1_BIT_STRING *publicKey;
219296341Sdelphij};
220183234Ssimon
221296341Sdelphijstruct CMS_RecipientEncryptedKey_st {
222296341Sdelphij    CMS_KeyAgreeRecipientIdentifier *rid;
223296341Sdelphij    ASN1_OCTET_STRING *encryptedKey;
224296341Sdelphij};
225183234Ssimon
226296341Sdelphijstruct CMS_KeyAgreeRecipientIdentifier_st {
227296341Sdelphij    int type;
228296341Sdelphij    union {
229296341Sdelphij        CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
230296341Sdelphij        CMS_RecipientKeyIdentifier *rKeyId;
231296341Sdelphij    } d;
232296341Sdelphij};
233183234Ssimon
234296341Sdelphijstruct CMS_RecipientKeyIdentifier_st {
235296341Sdelphij    ASN1_OCTET_STRING *subjectKeyIdentifier;
236296341Sdelphij    ASN1_GENERALIZEDTIME *date;
237296341Sdelphij    CMS_OtherKeyAttribute *other;
238296341Sdelphij};
239183234Ssimon
240296341Sdelphijstruct CMS_KEKRecipientInfo_st {
241296341Sdelphij    long version;
242296341Sdelphij    CMS_KEKIdentifier *kekid;
243296341Sdelphij    X509_ALGOR *keyEncryptionAlgorithm;
244296341Sdelphij    ASN1_OCTET_STRING *encryptedKey;
245296341Sdelphij    /* Extra info: symmetric key to use */
246296341Sdelphij    unsigned char *key;
247296341Sdelphij    size_t keylen;
248296341Sdelphij};
249183234Ssimon
250296341Sdelphijstruct CMS_KEKIdentifier_st {
251296341Sdelphij    ASN1_OCTET_STRING *keyIdentifier;
252296341Sdelphij    ASN1_GENERALIZEDTIME *date;
253296341Sdelphij    CMS_OtherKeyAttribute *other;
254296341Sdelphij};
255183234Ssimon
256296341Sdelphijstruct CMS_PasswordRecipientInfo_st {
257296341Sdelphij    long version;
258296341Sdelphij    X509_ALGOR *keyDerivationAlgorithm;
259296341Sdelphij    X509_ALGOR *keyEncryptionAlgorithm;
260296341Sdelphij    ASN1_OCTET_STRING *encryptedKey;
261296341Sdelphij    /* Extra info: password to use */
262296341Sdelphij    unsigned char *pass;
263296341Sdelphij    size_t passlen;
264296341Sdelphij};
265183234Ssimon
266296341Sdelphijstruct CMS_OtherRecipientInfo_st {
267296341Sdelphij    ASN1_OBJECT *oriType;
268296341Sdelphij    ASN1_TYPE *oriValue;
269296341Sdelphij};
270183234Ssimon
271296341Sdelphijstruct CMS_DigestedData_st {
272296341Sdelphij    long version;
273296341Sdelphij    X509_ALGOR *digestAlgorithm;
274296341Sdelphij    CMS_EncapsulatedContentInfo *encapContentInfo;
275296341Sdelphij    ASN1_OCTET_STRING *digest;
276296341Sdelphij};
277183234Ssimon
278296341Sdelphijstruct CMS_EncryptedData_st {
279296341Sdelphij    long version;
280296341Sdelphij    CMS_EncryptedContentInfo *encryptedContentInfo;
281296341Sdelphij    STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
282296341Sdelphij};
283183234Ssimon
284296341Sdelphijstruct CMS_AuthenticatedData_st {
285296341Sdelphij    long version;
286296341Sdelphij    CMS_OriginatorInfo *originatorInfo;
287296341Sdelphij    STACK_OF(CMS_RecipientInfo) *recipientInfos;
288296341Sdelphij    X509_ALGOR *macAlgorithm;
289296341Sdelphij    X509_ALGOR *digestAlgorithm;
290296341Sdelphij    CMS_EncapsulatedContentInfo *encapContentInfo;
291296341Sdelphij    STACK_OF(X509_ATTRIBUTE) *authAttrs;
292296341Sdelphij    ASN1_OCTET_STRING *mac;
293296341Sdelphij    STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
294296341Sdelphij};
295183234Ssimon
296296341Sdelphijstruct CMS_CompressedData_st {
297296341Sdelphij    long version;
298296341Sdelphij    X509_ALGOR *compressionAlgorithm;
299296341Sdelphij    STACK_OF(CMS_RecipientInfo) *recipientInfos;
300296341Sdelphij    CMS_EncapsulatedContentInfo *encapContentInfo;
301296341Sdelphij};
302183234Ssimon
303296341Sdelphijstruct CMS_RevocationInfoChoice_st {
304296341Sdelphij    int type;
305296341Sdelphij    union {
306296341Sdelphij        X509_CRL *crl;
307296341Sdelphij        CMS_OtherRevocationInfoFormat *other;
308296341Sdelphij    } d;
309296341Sdelphij};
310183234Ssimon
311296341Sdelphij# define CMS_REVCHOICE_CRL               0
312296341Sdelphij# define CMS_REVCHOICE_OTHER             1
313183234Ssimon
314296341Sdelphijstruct CMS_OtherRevocationInfoFormat_st {
315296341Sdelphij    ASN1_OBJECT *otherRevInfoFormat;
316296341Sdelphij    ASN1_TYPE *otherRevInfo;
317296341Sdelphij};
318183234Ssimon
319296341Sdelphijstruct CMS_CertificateChoices {
320296341Sdelphij    int type;
321296341Sdelphij    union {
322296341Sdelphij        X509 *certificate;
323296341Sdelphij        ASN1_STRING *extendedCertificate; /* Obsolete */
324296341Sdelphij        ASN1_STRING *v1AttrCert; /* Left encoded for now */
325296341Sdelphij        ASN1_STRING *v2AttrCert; /* Left encoded for now */
326296341Sdelphij        CMS_OtherCertificateFormat *other;
327296341Sdelphij    } d;
328296341Sdelphij};
329183234Ssimon
330296341Sdelphij# define CMS_CERTCHOICE_CERT             0
331296341Sdelphij# define CMS_CERTCHOICE_EXCERT           1
332296341Sdelphij# define CMS_CERTCHOICE_V1ACERT          2
333296341Sdelphij# define CMS_CERTCHOICE_V2ACERT          3
334296341Sdelphij# define CMS_CERTCHOICE_OTHER            4
335183234Ssimon
336296341Sdelphijstruct CMS_OtherCertificateFormat_st {
337296341Sdelphij    ASN1_OBJECT *otherCertFormat;
338296341Sdelphij    ASN1_TYPE *otherCert;
339296341Sdelphij};
340183234Ssimon
341296341Sdelphij/*
342296341Sdelphij * This is also defined in pkcs7.h but we duplicate it to allow the CMS code
343296341Sdelphij * to be independent of PKCS#7
344183234Ssimon */
345183234Ssimon
346296341Sdelphijstruct CMS_IssuerAndSerialNumber_st {
347296341Sdelphij    X509_NAME *issuer;
348296341Sdelphij    ASN1_INTEGER *serialNumber;
349296341Sdelphij};
350183234Ssimon
351296341Sdelphijstruct CMS_OtherKeyAttribute_st {
352296341Sdelphij    ASN1_OBJECT *keyAttrId;
353296341Sdelphij    ASN1_TYPE *keyAttr;
354296341Sdelphij};
355183234Ssimon
356183234Ssimon/* ESS structures */
357183234Ssimon
358296341Sdelphij# ifdef HEADER_X509V3_H
359183234Ssimon
360296341Sdelphijstruct CMS_ReceiptRequest_st {
361296341Sdelphij    ASN1_OCTET_STRING *signedContentIdentifier;
362296341Sdelphij    CMS_ReceiptsFrom *receiptsFrom;
363296341Sdelphij    STACK_OF(GENERAL_NAMES) *receiptsTo;
364296341Sdelphij};
365183234Ssimon
366296341Sdelphijstruct CMS_ReceiptsFrom_st {
367296341Sdelphij    int type;
368296341Sdelphij    union {
369296341Sdelphij        long allOrFirstTier;
370296341Sdelphij        STACK_OF(GENERAL_NAMES) *receiptList;
371296341Sdelphij    } d;
372296341Sdelphij};
373296341Sdelphij# endif
374183234Ssimon
375296341Sdelphijstruct CMS_Receipt_st {
376296341Sdelphij    long version;
377296341Sdelphij    ASN1_OBJECT *contentType;
378296341Sdelphij    ASN1_OCTET_STRING *signedContentIdentifier;
379296341Sdelphij    ASN1_OCTET_STRING *originatorSignatureValue;
380296341Sdelphij};
381183234Ssimon
382238405SjkimDECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
383183234SsimonDECLARE_ASN1_ITEM(CMS_SignerInfo)
384183234SsimonDECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber)
385183234SsimonDECLARE_ASN1_ITEM(CMS_Attributes_Sign)
386183234SsimonDECLARE_ASN1_ITEM(CMS_Attributes_Verify)
387238405SjkimDECLARE_ASN1_ITEM(CMS_RecipientInfo)
388238405SjkimDECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo)
389183234SsimonDECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber)
390183234Ssimon
391296341Sdelphij# define CMS_SIGNERINFO_ISSUER_SERIAL    0
392296341Sdelphij# define CMS_SIGNERINFO_KEYIDENTIFIER    1
393183234Ssimon
394296341Sdelphij# define CMS_RECIPINFO_ISSUER_SERIAL     0
395296341Sdelphij# define CMS_RECIPINFO_KEYIDENTIFIER     1
396183234Ssimon
397183234SsimonBIO *cms_content_bio(CMS_ContentInfo *cms);
398183234Ssimon
399183234SsimonCMS_ContentInfo *cms_Data_create(void);
400183234Ssimon
401183234SsimonCMS_ContentInfo *cms_DigestedData_create(const EVP_MD *md);
402183234SsimonBIO *cms_DigestedData_init_bio(CMS_ContentInfo *cms);
403183234Ssimonint cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify);
404183234Ssimon
405183234SsimonBIO *cms_SignedData_init_bio(CMS_ContentInfo *cms);
406183234Ssimonint cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain);
407296341Sdelphijint cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert,
408296341Sdelphij                              int type);
409183234Ssimonint cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid,
410296341Sdelphij                                        ASN1_OCTET_STRING **keyid,
411296341Sdelphij                                        X509_NAME **issuer,
412296341Sdelphij                                        ASN1_INTEGER **sno);
413183234Ssimonint cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert);
414183234Ssimon
415183234SsimonCMS_ContentInfo *cms_CompressedData_create(int comp_nid);
416183234SsimonBIO *cms_CompressedData_init_bio(CMS_ContentInfo *cms);
417183234Ssimon
418183234Ssimonvoid cms_DigestAlgorithm_set(X509_ALGOR *alg, const EVP_MD *md);
419183234SsimonBIO *cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm);
420183234Ssimonint cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
421296341Sdelphij                                 X509_ALGOR *mdalg);
422183234Ssimon
423183234SsimonBIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec);
424183234SsimonBIO *cms_EncryptedData_init_bio(CMS_ContentInfo *cms);
425296341Sdelphijint cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
426296341Sdelphij                              const EVP_CIPHER *cipher,
427296341Sdelphij                              const unsigned char *key, size_t keylen);
428183234Ssimon
429183234Ssimonint cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms);
430183234Ssimonint cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src);
431183234SsimonASN1_OCTET_STRING *cms_encode_Receipt(CMS_SignerInfo *si);
432183234Ssimon
433183234SsimonBIO *cms_EnvelopedData_init_bio(CMS_ContentInfo *cms);
434238405SjkimCMS_EnvelopedData *cms_get0_enveloped(CMS_ContentInfo *cms);
435238405Sjkim
436238405Sjkim/* PWRI routines */
437238405Sjkimint cms_RecipientInfo_pwri_crypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri,
438296341Sdelphij                                 int en_de);
439296341Sdelphij
440183234Ssimon#ifdef  __cplusplus
441183234Ssimon}
442183234Ssimon#endif
443183234Ssimon#endif
444