1 /*
2  * Copyright 2008-2025 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9 
10 #ifndef OSSL_CRYPTO_CMS_LOCAL_H
11 # define OSSL_CRYPTO_CMS_LOCAL_H
12 
13 # include <openssl/x509.h>
14 
15 /*
16  * Cryptographic message syntax (CMS) structures: taken from RFC3852
17  */
18 
19 /* Forward references */
20 
21 typedef struct CMS_IssuerAndSerialNumber_st CMS_IssuerAndSerialNumber;
22 typedef struct CMS_EncapsulatedContentInfo_st CMS_EncapsulatedContentInfo;
23 typedef struct CMS_SignerIdentifier_st CMS_SignerIdentifier;
24 typedef struct CMS_OtherRevocationInfoFormat_st CMS_OtherRevocationInfoFormat;
25 typedef struct CMS_OriginatorInfo_st CMS_OriginatorInfo;
26 typedef struct CMS_EncryptedContentInfo_st CMS_EncryptedContentInfo;
27 typedef struct CMS_DigestedData_st CMS_DigestedData;
28 typedef struct CMS_EncryptedData_st CMS_EncryptedData;
29 typedef struct CMS_AuthenticatedData_st CMS_AuthenticatedData;
30 typedef struct CMS_AuthEnvelopedData_st CMS_AuthEnvelopedData;
31 typedef struct CMS_CompressedData_st CMS_CompressedData;
32 typedef struct CMS_OtherCertificateFormat_st CMS_OtherCertificateFormat;
33 typedef struct CMS_KeyTransRecipientInfo_st CMS_KeyTransRecipientInfo;
34 typedef struct CMS_OriginatorPublicKey_st CMS_OriginatorPublicKey;
35 typedef struct CMS_OriginatorIdentifierOrKey_st CMS_OriginatorIdentifierOrKey;
36 typedef struct CMS_KeyAgreeRecipientInfo_st CMS_KeyAgreeRecipientInfo;
37 typedef struct CMS_RecipientKeyIdentifier_st CMS_RecipientKeyIdentifier;
38 typedef struct CMS_KeyAgreeRecipientIdentifier_st
39     CMS_KeyAgreeRecipientIdentifier;
40 typedef struct CMS_KEKIdentifier_st CMS_KEKIdentifier;
41 typedef struct CMS_KEKRecipientInfo_st CMS_KEKRecipientInfo;
42 typedef struct CMS_PasswordRecipientInfo_st CMS_PasswordRecipientInfo;
43 typedef struct CMS_OtherRecipientInfo_st CMS_OtherRecipientInfo;
44 typedef struct CMS_KEMRecipientInfo_st CMS_KEMRecipientInfo;
45 typedef struct CMS_ReceiptsFrom_st CMS_ReceiptsFrom;
46 typedef struct CMS_CTX_st CMS_CTX;
47 
48 struct CMS_CTX_st {
49     OSSL_LIB_CTX *libctx;
50     char *propq;
51 };
52 
53 struct CMS_ContentInfo_st {
54     ASN1_OBJECT *contentType;
55     union {
56         ASN1_OCTET_STRING *data;
57         CMS_SignedData *signedData;
58         CMS_EnvelopedData *envelopedData;
59         CMS_DigestedData *digestedData;
60         CMS_EncryptedData *encryptedData;
61         CMS_AuthEnvelopedData *authEnvelopedData;
62         CMS_AuthenticatedData *authenticatedData;
63         CMS_CompressedData *compressedData;
64         ASN1_TYPE *other;
65         /* Other types ... */
66         void *otherData;
67     } d;
68     CMS_CTX ctx;
69 };
70 
71 DEFINE_STACK_OF(CMS_CertificateChoices)
72 
73 struct CMS_SignedData_st {
74     int32_t version;
75     STACK_OF(X509_ALGOR) *digestAlgorithms;
76     CMS_EncapsulatedContentInfo *encapContentInfo;
77     STACK_OF(CMS_CertificateChoices) *certificates;
78     STACK_OF(CMS_RevocationInfoChoice) *crls;
79     STACK_OF(CMS_SignerInfo) *signerInfos;
80 };
81 
82 struct CMS_EncapsulatedContentInfo_st {
83     ASN1_OBJECT *eContentType;
84     ASN1_OCTET_STRING *eContent;
85     /* Set to 1 if incomplete structure only part set up */
86     int partial;
87 };
88 
89 struct CMS_SignerInfo_st {
90     int32_t version;
91     CMS_SignerIdentifier *sid;
92     X509_ALGOR *digestAlgorithm;
93     STACK_OF(X509_ATTRIBUTE) *signedAttrs;
94     X509_ALGOR *signatureAlgorithm;
95     ASN1_OCTET_STRING *signature;
96     STACK_OF(X509_ATTRIBUTE) *unsignedAttrs;
97     /* Signing certificate and key */
98     X509 *signer;
99     EVP_PKEY *pkey;
100     /* Digest and public key context for alternative parameters */
101     EVP_MD_CTX *mctx;
102     EVP_PKEY_CTX *pctx;
103     const CMS_CTX *cms_ctx;
104     /* Set to 1 if signing time attribute is to be omitted */
105     int omit_signing_time;
106 };
107 
108 struct CMS_SignerIdentifier_st {
109     int type;
110     union {
111         CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
112         ASN1_OCTET_STRING *subjectKeyIdentifier;
113     } d;
114 };
115 
116 struct CMS_EnvelopedData_st {
117     int32_t version;
118     CMS_OriginatorInfo *originatorInfo;
119     STACK_OF(CMS_RecipientInfo) *recipientInfos;
120     CMS_EncryptedContentInfo *encryptedContentInfo;
121     STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
122 };
123 
124 struct CMS_OriginatorInfo_st {
125     STACK_OF(CMS_CertificateChoices) *certificates;
126     STACK_OF(CMS_RevocationInfoChoice) *crls;
127 };
128 
129 struct CMS_EncryptedContentInfo_st {
130     ASN1_OBJECT *contentType;
131     X509_ALGOR *contentEncryptionAlgorithm;
132     ASN1_OCTET_STRING *encryptedContent;
133     /* Content encryption algorithm, key and tag */
134     const EVP_CIPHER *cipher;
135     unsigned char *key;
136     size_t keylen;
137     unsigned char *tag;
138     size_t taglen;
139     /* Set to 1 if we are debugging decrypt and don't fake keys for MMA */
140     int debug;
141     /* Set to 1 if we have no cert and need extra safety measures for MMA */
142     int havenocert;
143 };
144 
145 struct CMS_RecipientInfo_st {
146     /*
147      * Type which the RecipientInfo is encoded with. OtherRecipientInfo
148      * encompasses different types, specified by 'type' below.
149      */
150     int encoded_type;
151     union {
152         CMS_KeyTransRecipientInfo *ktri;
153         CMS_KeyAgreeRecipientInfo *kari;
154         CMS_KEKRecipientInfo *kekri;
155         CMS_PasswordRecipientInfo *pwri;
156         CMS_OtherRecipientInfo *ori;
157     } d;
158     /* internal type, including ORI types */
159     int type;
160 };
161 
162 typedef CMS_SignerIdentifier CMS_RecipientIdentifier;
163 
164 struct CMS_KeyTransRecipientInfo_st {
165     int32_t version;
166     CMS_RecipientIdentifier *rid;
167     X509_ALGOR *keyEncryptionAlgorithm;
168     ASN1_OCTET_STRING *encryptedKey;
169     /* Recipient Key and cert */
170     X509 *recip;
171     EVP_PKEY *pkey;
172     /* Public key context for this operation */
173     EVP_PKEY_CTX *pctx;
174     const CMS_CTX *cms_ctx;
175 };
176 
177 struct CMS_KeyAgreeRecipientInfo_st {
178     int32_t version;
179     CMS_OriginatorIdentifierOrKey *originator;
180     ASN1_OCTET_STRING *ukm;
181     X509_ALGOR *keyEncryptionAlgorithm;
182     STACK_OF(CMS_RecipientEncryptedKey) *recipientEncryptedKeys;
183     /* Public key context associated with current operation */
184     EVP_PKEY_CTX *pctx;
185     /* Cipher context for CEK wrapping */
186     EVP_CIPHER_CTX *ctx;
187     const CMS_CTX *cms_ctx;
188 };
189 
190 struct CMS_OriginatorIdentifierOrKey_st {
191     int type;
192     union {
193         CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
194         ASN1_OCTET_STRING *subjectKeyIdentifier;
195         CMS_OriginatorPublicKey *originatorKey;
196     } d;
197 };
198 
199 struct CMS_OriginatorPublicKey_st {
200     X509_ALGOR *algorithm;
201     ASN1_BIT_STRING *publicKey;
202 };
203 
204 struct CMS_RecipientEncryptedKey_st {
205     CMS_KeyAgreeRecipientIdentifier *rid;
206     ASN1_OCTET_STRING *encryptedKey;
207     /* Public key associated with this recipient */
208     EVP_PKEY *pkey;
209 };
210 
211 struct CMS_KeyAgreeRecipientIdentifier_st {
212     int type;
213     union {
214         CMS_IssuerAndSerialNumber *issuerAndSerialNumber;
215         CMS_RecipientKeyIdentifier *rKeyId;
216     } d;
217 };
218 
219 struct CMS_RecipientKeyIdentifier_st {
220     ASN1_OCTET_STRING *subjectKeyIdentifier;
221     ASN1_GENERALIZEDTIME *date;
222     CMS_OtherKeyAttribute *other;
223 };
224 
225 struct CMS_KEKRecipientInfo_st {
226     int32_t version;
227     CMS_KEKIdentifier *kekid;
228     X509_ALGOR *keyEncryptionAlgorithm;
229     ASN1_OCTET_STRING *encryptedKey;
230     /* Extra info: symmetric key to use */
231     unsigned char *key;
232     size_t keylen;
233     const CMS_CTX *cms_ctx;
234 };
235 
236 struct CMS_KEKIdentifier_st {
237     ASN1_OCTET_STRING *keyIdentifier;
238     ASN1_GENERALIZEDTIME *date;
239     CMS_OtherKeyAttribute *other;
240 };
241 
242 struct CMS_PasswordRecipientInfo_st {
243     int32_t version;
244     X509_ALGOR *keyDerivationAlgorithm;
245     X509_ALGOR *keyEncryptionAlgorithm;
246     ASN1_OCTET_STRING *encryptedKey;
247     /* Extra info: password to use */
248     unsigned char *pass;
249     size_t passlen;
250     const CMS_CTX *cms_ctx;
251 };
252 
253 struct CMS_OtherRecipientInfo_st {
254     ASN1_OBJECT *oriType;
255     union {
256         /* NID_id_smime_ori_kem */
257         CMS_KEMRecipientInfo *kemri;
258         /* anything else */
259         ASN1_TYPE *other;
260     } d;
261 };
262 
263 struct CMS_KEMRecipientInfo_st {
264     int32_t version;
265     CMS_RecipientIdentifier *rid;
266     X509_ALGOR *kem;
267     ASN1_OCTET_STRING *kemct;
268     X509_ALGOR *kdf;
269     uint32_t kekLength;
270     ASN1_OCTET_STRING *ukm;
271     X509_ALGOR *wrap;
272     ASN1_OCTET_STRING *encryptedKey;
273     /* Public key context associated with current operation */
274     EVP_PKEY_CTX *pctx;
275     /* Cipher context for CEK wrapping */
276     EVP_CIPHER_CTX *ctx;
277     const CMS_CTX *cms_ctx;
278 };
279 
280 struct CMS_DigestedData_st {
281     int32_t version;
282     X509_ALGOR *digestAlgorithm;
283     CMS_EncapsulatedContentInfo *encapContentInfo;
284     ASN1_OCTET_STRING *digest;
285 };
286 
287 struct CMS_EncryptedData_st {
288     int32_t version;
289     CMS_EncryptedContentInfo *encryptedContentInfo;
290     STACK_OF(X509_ATTRIBUTE) *unprotectedAttrs;
291 };
292 
293 struct CMS_AuthenticatedData_st {
294     int32_t version;
295     CMS_OriginatorInfo *originatorInfo;
296     STACK_OF(CMS_RecipientInfo) *recipientInfos;
297     X509_ALGOR *macAlgorithm;
298     X509_ALGOR *digestAlgorithm;
299     CMS_EncapsulatedContentInfo *encapContentInfo;
300     STACK_OF(X509_ATTRIBUTE) *authAttrs;
301     ASN1_OCTET_STRING *mac;
302     STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
303 };
304 
305 struct CMS_AuthEnvelopedData_st {
306     int32_t version;
307     CMS_OriginatorInfo *originatorInfo;
308     STACK_OF(CMS_RecipientInfo) *recipientInfos;
309     CMS_EncryptedContentInfo *authEncryptedContentInfo;
310     STACK_OF(X509_ATTRIBUTE) *authAttrs;
311     ASN1_OCTET_STRING *mac;
312     STACK_OF(X509_ATTRIBUTE) *unauthAttrs;
313 };
314 
315 struct CMS_CompressedData_st {
316     int32_t version;
317     X509_ALGOR *compressionAlgorithm;
318     STACK_OF(CMS_RecipientInfo) *recipientInfos;
319     CMS_EncapsulatedContentInfo *encapContentInfo;
320 };
321 
322 struct CMS_RevocationInfoChoice_st {
323     int type;
324     union {
325         X509_CRL *crl;
326         CMS_OtherRevocationInfoFormat *other;
327     } d;
328 };
329 
330 # define CMS_REVCHOICE_CRL               0
331 # define CMS_REVCHOICE_OTHER             1
332 
333 struct CMS_OtherRevocationInfoFormat_st {
334     ASN1_OBJECT *otherRevInfoFormat;
335     ASN1_TYPE *otherRevInfo;
336 };
337 
338 struct CMS_CertificateChoices {
339     int type;
340     union {
341         X509 *certificate;
342         ASN1_STRING *extendedCertificate; /* Obsolete */
343         ASN1_STRING *v1AttrCert; /* Left encoded for now */
344         ASN1_STRING *v2AttrCert; /* Left encoded for now */
345         CMS_OtherCertificateFormat *other;
346     } d;
347 };
348 
349 # define CMS_CERTCHOICE_CERT             0
350 # define CMS_CERTCHOICE_EXCERT           1
351 # define CMS_CERTCHOICE_V1ACERT          2
352 # define CMS_CERTCHOICE_V2ACERT          3
353 # define CMS_CERTCHOICE_OTHER            4
354 
355 struct CMS_OtherCertificateFormat_st {
356     ASN1_OBJECT *otherCertFormat;
357     ASN1_TYPE *otherCert;
358 };
359 
360 /*
361  * This is also defined in pkcs7.h but we duplicate it to allow the CMS code
362  * to be independent of PKCS#7
363  */
364 
365 struct CMS_IssuerAndSerialNumber_st {
366     X509_NAME *issuer;
367     ASN1_INTEGER *serialNumber;
368 };
369 
370 struct CMS_OtherKeyAttribute_st {
371     ASN1_OBJECT *keyAttrId;
372     ASN1_TYPE *keyAttr;
373 };
374 
375 /* ESS structures */
376 
377 struct CMS_ReceiptRequest_st {
378     ASN1_OCTET_STRING *signedContentIdentifier;
379     CMS_ReceiptsFrom *receiptsFrom;
380     STACK_OF(GENERAL_NAMES) *receiptsTo;
381 };
382 
383 struct CMS_ReceiptsFrom_st {
384     int type;
385     union {
386         int32_t allOrFirstTier;
387         STACK_OF(GENERAL_NAMES) *receiptList;
388     } d;
389 };
390 
391 struct CMS_Receipt_st {
392     int32_t version;
393     ASN1_OBJECT *contentType;
394     ASN1_OCTET_STRING *signedContentIdentifier;
395     ASN1_OCTET_STRING *originatorSignatureValue;
396 };
397 
398 DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
399 DECLARE_ASN1_ITEM(CMS_SignerInfo)
400 DECLARE_ASN1_ITEM(CMS_EncryptedContentInfo)
401 DECLARE_ASN1_ITEM(CMS_IssuerAndSerialNumber)
402 DECLARE_ASN1_ITEM(CMS_Attributes_Sign)
403 DECLARE_ASN1_ITEM(CMS_Attributes_Verify)
404 DECLARE_ASN1_ITEM(CMS_RecipientInfo)
405 DECLARE_ASN1_ITEM(CMS_PasswordRecipientInfo)
406 DECLARE_ASN1_ALLOC_FUNCTIONS(CMS_IssuerAndSerialNumber)
407 
408 # define CMS_SIGNERINFO_ISSUER_SERIAL    0
409 # define CMS_SIGNERINFO_KEYIDENTIFIER    1
410 
411 # define CMS_RECIPINFO_ISSUER_SERIAL     0
412 # define CMS_RECIPINFO_KEYIDENTIFIER     1
413 
414 # define CMS_REK_ISSUER_SERIAL           0
415 # define CMS_REK_KEYIDENTIFIER           1
416 
417 # define CMS_OIK_ISSUER_SERIAL           0
418 # define CMS_OIK_KEYIDENTIFIER           1
419 # define CMS_OIK_PUBKEY                  2
420 
421 BIO *ossl_cms_content_bio(CMS_ContentInfo *cms);
422 const CMS_CTX *ossl_cms_get0_cmsctx(const CMS_ContentInfo *cms);
423 OSSL_LIB_CTX *ossl_cms_ctx_get0_libctx(const CMS_CTX *ctx);
424 const char *ossl_cms_ctx_get0_propq(const CMS_CTX *ctx);
425 void ossl_cms_resolve_libctx(CMS_ContentInfo *ci);
426 
427 CMS_ContentInfo *ossl_cms_Data_create(OSSL_LIB_CTX *ctx, const char *propq);
428 int ossl_cms_DataFinal(CMS_ContentInfo *cms, BIO *cmsbio,
429                        const unsigned char *precomp_md,
430                        unsigned int precomp_mdlen);
431 
432 CMS_ContentInfo *ossl_cms_DigestedData_create(const EVP_MD *md,
433                                               OSSL_LIB_CTX *libctx,
434                                               const char *propq);
435 BIO *ossl_cms_DigestedData_init_bio(const CMS_ContentInfo *cms);
436 int ossl_cms_DigestedData_do_final(const CMS_ContentInfo *cms,
437                                    BIO *chain, int verify);
438 
439 BIO *ossl_cms_SignedData_init_bio(CMS_ContentInfo *cms);
440 int ossl_cms_SignedData_final(CMS_ContentInfo *cms, BIO *chain,
441                               const unsigned char *precomp_md,
442                               unsigned int precomp_mdlen);
443 int ossl_cms_set1_SignerIdentifier(CMS_SignerIdentifier *sid, X509 *cert,
444                                    int type, const CMS_CTX *ctx);
445 int ossl_cms_SignerIdentifier_get0_signer_id(CMS_SignerIdentifier *sid,
446                                              ASN1_OCTET_STRING **keyid,
447                                              X509_NAME **issuer,
448                                              ASN1_INTEGER **sno);
449 int ossl_cms_SignerIdentifier_cert_cmp(CMS_SignerIdentifier *sid, X509 *cert);
450 
451 CMS_ContentInfo *ossl_cms_CompressedData_create(int comp_nid,
452                                                 OSSL_LIB_CTX *libctx,
453                                                 const char *propq);
454 BIO *ossl_cms_CompressedData_init_bio(const CMS_ContentInfo *cms);
455 
456 BIO *ossl_cms_DigestAlgorithm_init_bio(X509_ALGOR *digestAlgorithm,
457                                        const CMS_CTX *ctx);
458 int ossl_cms_DigestAlgorithm_find_ctx(EVP_MD_CTX *mctx, BIO *chain,
459                                       X509_ALGOR *mdalg);
460 
461 int ossl_cms_ias_cert_cmp(CMS_IssuerAndSerialNumber *ias, X509 *cert);
462 int ossl_cms_keyid_cert_cmp(ASN1_OCTET_STRING *keyid, X509 *cert);
463 int ossl_cms_set1_ias(CMS_IssuerAndSerialNumber **pias, X509 *cert);
464 int ossl_cms_set1_keyid(ASN1_OCTET_STRING **pkeyid, X509 *cert);
465 
466 BIO *ossl_cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec,
467                                         const CMS_CTX *ctx);
468 BIO *ossl_cms_EncryptedData_init_bio(const CMS_ContentInfo *cms);
469 int ossl_cms_EncryptedContent_init(CMS_EncryptedContentInfo *ec,
470                                    const EVP_CIPHER *cipher,
471                                    const unsigned char *key, size_t keylen,
472                                    const CMS_CTX *ctx);
473 
474 int ossl_cms_Receipt_verify(CMS_ContentInfo *cms, CMS_ContentInfo *req_cms);
475 int ossl_cms_msgSigDigest_add1(CMS_SignerInfo *dest, CMS_SignerInfo *src);
476 ASN1_OCTET_STRING *ossl_cms_encode_Receipt(CMS_SignerInfo *si);
477 
478 BIO *ossl_cms_EnvelopedData_init_bio(CMS_ContentInfo *cms);
479 int ossl_cms_EnvelopedData_final(CMS_ContentInfo *cms, BIO *chain);
480 BIO *ossl_cms_AuthEnvelopedData_init_bio(CMS_ContentInfo *cms);
481 int ossl_cms_AuthEnvelopedData_final(CMS_ContentInfo *cms, BIO *cmsbio);
482 CMS_EnvelopedData *ossl_cms_get0_enveloped(CMS_ContentInfo *cms);
483 CMS_AuthEnvelopedData *ossl_cms_get0_auth_enveloped(CMS_ContentInfo *cms);
484 CMS_EncryptedContentInfo *ossl_cms_get0_env_enc_content(const CMS_ContentInfo *cms);
485 
486 /* RecipientInfo routines */
487 int ossl_cms_env_asn1_ctrl(CMS_RecipientInfo *ri, int cmd);
488 int ossl_cms_pkey_get_ri_type(EVP_PKEY *pk);
489 int ossl_cms_pkey_is_ri_type_supported(EVP_PKEY *pk, int ri_type);
490 
491 void ossl_cms_RecipientInfos_set_cmsctx(CMS_ContentInfo *cms);
492 int ossl_cms_RecipientInfo_wrap_init(CMS_RecipientInfo *ri, const EVP_CIPHER *cipher);
493 
494 /* KARI routines */
495 int ossl_cms_RecipientInfo_kari_init(CMS_RecipientInfo *ri, X509 *recip,
496                                      EVP_PKEY *recipPubKey, X509 *originator,
497                                      EVP_PKEY *originatorPrivKey,
498                                      unsigned int flags,
499                                      const CMS_CTX *ctx);
500 int ossl_cms_RecipientInfo_kari_encrypt(const CMS_ContentInfo *cms,
501                                         CMS_RecipientInfo *ri);
502 
503 /* KEMRI routines */
504 int ossl_cms_RecipientInfo_kemri_get0_alg(CMS_RecipientInfo *ri,
505                                           uint32_t **pkekLength,
506                                           X509_ALGOR **pwrap);
507 int ossl_cms_RecipientInfo_kemri_init(CMS_RecipientInfo *ri, X509 *recip,
508                                       EVP_PKEY *recipPubKey, unsigned int flags,
509                                       const CMS_CTX *ctx);
510 int ossl_cms_RecipientInfo_kemri_encrypt(const CMS_ContentInfo *cms,
511                                          CMS_RecipientInfo *ri);
512 int ossl_cms_RecipientInfo_kemri_decrypt(const CMS_ContentInfo *cms,
513                                          CMS_RecipientInfo *ri);
514 int CMS_CMSORIforKEMOtherInfo_encode(unsigned char **pder, X509_ALGOR *wrap,
515                                      ASN1_OCTET_STRING *ukm, int keylen);
516 
517 /* PWRI routines */
518 int ossl_cms_RecipientInfo_pwri_crypt(const CMS_ContentInfo *cms,
519                                       CMS_RecipientInfo *ri, int en_de);
520 /* SignerInfo routines */
521 int ossl_cms_si_check_attributes(const CMS_SignerInfo *si);
522 void ossl_cms_SignerInfos_set_cmsctx(CMS_ContentInfo *cms);
523 
524 
525 /* ESS routines */
526 int ossl_cms_check_signing_certs(const CMS_SignerInfo *si,
527                                  const STACK_OF(X509) *chain);
528 
529 int ossl_cms_dh_envelope(CMS_RecipientInfo *ri, int decrypt);
530 int ossl_cms_ecdh_envelope(CMS_RecipientInfo *ri, int decrypt);
531 int ossl_cms_rsa_envelope(CMS_RecipientInfo *ri, int decrypt);
532 int ossl_cms_rsa_sign(CMS_SignerInfo *si, int verify);
533 int ossl_cms_kem_envelope(CMS_RecipientInfo *ri, int decrypt);
534 
535 int ossl_cms_get1_certs_ex(CMS_ContentInfo *cms, STACK_OF(X509) **certs);
536 int ossl_cms_get1_crls_ex(CMS_ContentInfo *cms, STACK_OF(X509_CRL) **crls);
537 
538 DECLARE_ASN1_ITEM(CMS_CertificateChoices)
539 DECLARE_ASN1_ITEM(CMS_DigestedData)
540 DECLARE_ASN1_ITEM(CMS_EncryptedData)
541 DECLARE_ASN1_ITEM(CMS_EnvelopedData)
542 DECLARE_ASN1_ITEM(CMS_AuthEnvelopedData)
543 DECLARE_ASN1_ITEM(CMS_KEKRecipientInfo)
544 DECLARE_ASN1_ITEM(CMS_KEMRecipientInfo)
545 DECLARE_ASN1_ITEM(CMS_KeyAgreeRecipientInfo)
546 DECLARE_ASN1_ITEM(CMS_KeyTransRecipientInfo)
547 DECLARE_ASN1_ITEM(CMS_OriginatorPublicKey)
548 DECLARE_ASN1_ITEM(CMS_OtherKeyAttribute)
549 DECLARE_ASN1_ITEM(CMS_OtherRecipientInfo)
550 DECLARE_ASN1_ITEM(CMS_Receipt)
551 DECLARE_ASN1_ITEM(CMS_ReceiptRequest)
552 DECLARE_ASN1_ITEM(CMS_RecipientEncryptedKey)
553 DECLARE_ASN1_ITEM(CMS_RecipientKeyIdentifier)
554 DECLARE_ASN1_ITEM(CMS_RevocationInfoChoice)
555 DECLARE_ASN1_ITEM(CMS_SignedData)
556 DECLARE_ASN1_ITEM(CMS_CompressedData)
557 
558 #endif
559