]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/cms.h
Update source files for deprecation at 3.0
[thirdparty/openssl.git] / include / openssl / cms.h
CommitLineData
0f113f3e 1/*
e85d19c6 2 * Copyright 2008-2019 The OpenSSL Project Authors. All Rights Reserved.
8931b30d 3 *
48f4ad77 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
21dcbebc
RS
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
8931b30d
DSH
8 */
9
ae4186b0
DMSP
10#ifndef OPENSSL_CMS_H
11# define OPENSSL_CMS_H
d86167ec
DMSP
12# pragma once
13
14# include <openssl/macros.h>
936c2b9e 15# ifndef OPENSSL_NO_DEPRECATED_3_0
d86167ec
DMSP
16# define HEADER_CMS_H
17# endif
8931b30d 18
3c27208f
RS
19# include <openssl/opensslconf.h>
20
21# ifndef OPENSSL_NO_CMS
0f113f3e 22# include <openssl/x509.h>
4a640fb6 23# include <openssl/x509v3.h>
52df25cf 24# include <openssl/cmserr.h>
3c27208f 25# ifdef __cplusplus
8931b30d 26extern "C" {
3c27208f 27# endif
8931b30d 28
8931b30d
DSH
29typedef struct CMS_ContentInfo_st CMS_ContentInfo;
30typedef struct CMS_SignerInfo_st CMS_SignerInfo;
31typedef struct CMS_CertificateChoices CMS_CertificateChoices;
32typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice;
4f1aa191 33typedef struct CMS_RecipientInfo_st CMS_RecipientInfo;
be86c7fc
DSH
34typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest;
35typedef struct CMS_Receipt_st CMS_Receipt;
17c2764d
DSH
36typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey;
37typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute;
8931b30d 38
85885715
DSH
39DEFINE_STACK_OF(CMS_SignerInfo)
40DEFINE_STACK_OF(CMS_RecipientEncryptedKey)
41DEFINE_STACK_OF(CMS_RecipientInfo)
42DEFINE_STACK_OF(CMS_RevocationInfoChoice)
8931b30d 43DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo)
f4cc56f4 44DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest)
8931b30d
DSH
45DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo)
46
0f113f3e
MC
47# define CMS_SIGNERINFO_ISSUER_SERIAL 0
48# define CMS_SIGNERINFO_KEYIDENTIFIER 1
8931b30d 49
0f113f3e
MC
50# define CMS_RECIPINFO_NONE -1
51# define CMS_RECIPINFO_TRANS 0
52# define CMS_RECIPINFO_AGREE 1
53# define CMS_RECIPINFO_KEK 2
54# define CMS_RECIPINFO_PASS 3
55# define CMS_RECIPINFO_OTHER 4
4f1aa191 56
8931b30d
DSH
57/* S/MIME related flags */
58
0f113f3e
MC
59# define CMS_TEXT 0x1
60# define CMS_NOCERTS 0x2
61# define CMS_NO_CONTENT_VERIFY 0x4
62# define CMS_NO_ATTR_VERIFY 0x8
63# define CMS_NOSIGS \
64 (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY)
65# define CMS_NOINTERN 0x10
66# define CMS_NO_SIGNER_CERT_VERIFY 0x20
67# define CMS_NOVERIFY 0x20
68# define CMS_DETACHED 0x40
69# define CMS_BINARY 0x80
70# define CMS_NOATTR 0x100
71# define CMS_NOSMIMECAP 0x200
72# define CMS_NOOLDMIMETYPE 0x400
73# define CMS_CRLFEOL 0x800
74# define CMS_STREAM 0x1000
75# define CMS_NOCRL 0x2000
76# define CMS_PARTIAL 0x4000
77# define CMS_REUSE_DIGEST 0x8000
78# define CMS_USE_KEYID 0x10000
79# define CMS_DEBUG_DECRYPT 0x20000
80# define CMS_KEY_PARAM 0x40000
81# define CMS_ASCIICRLF 0x80000
e85d19c6 82# define CMS_CADES 0x100000
8931b30d 83
dc423f89 84const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms);
8931b30d
DSH
85
86BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont);
87int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio);
88
89ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms);
90int CMS_is_detached(CMS_ContentInfo *cms);
91int CMS_set_detached(CMS_ContentInfo *cms, int detached);
92
ae4186b0 93# ifdef OPENSSL_PEM_H
8931b30d 94DECLARE_PEM_rw_const(CMS, CMS_ContentInfo)
0f113f3e 95# endif
8931b30d
DSH
96int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms);
97CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms);
98int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms);
99
100BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms);
101int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags);
0f113f3e
MC
102int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in,
103 int flags);
8931b30d
DSH
104CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont);
105int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags);
106
0f113f3e
MC
107int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont,
108 unsigned int flags);
8931b30d 109
0f113f3e
MC
110CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey,
111 STACK_OF(X509) *certs, BIO *data,
112 unsigned int flags);
8931b30d 113
36309aa2 114CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si,
0f113f3e
MC
115 X509 *signcert, EVP_PKEY *pkey,
116 STACK_OF(X509) *certs, unsigned int flags);
36309aa2 117
8931b30d
DSH
118int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags);
119CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags);
120
121int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
0f113f3e 122 unsigned int flags);
8931b30d 123CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md,
0f113f3e 124 unsigned int flags);
8931b30d 125
b820455c 126int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms,
0f113f3e
MC
127 const unsigned char *key, size_t keylen,
128 BIO *dcont, BIO *out, unsigned int flags);
b820455c 129
d9f5f07e 130CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher,
0f113f3e
MC
131 const unsigned char *key,
132 size_t keylen, unsigned int flags);
d9f5f07e 133
320bfc1b 134int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph,
0f113f3e 135 const unsigned char *key, size_t keylen);
b820455c 136
8931b30d 137int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
0f113f3e 138 X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags);
8931b30d 139
eb9d8d8c 140int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms,
0f113f3e
MC
141 STACK_OF(X509) *certs,
142 X509_STORE *store, unsigned int flags);
eb9d8d8c 143
8931b30d
DSH
144STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms);
145
146CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in,
0f113f3e 147 const EVP_CIPHER *cipher, unsigned int flags);
8931b30d 148
4f1aa191 149int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert,
0f113f3e
MC
150 BIO *dcont, BIO *out, unsigned int flags);
151
eeb9cdfc 152int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert);
0f113f3e
MC
153int CMS_decrypt_set1_key(CMS_ContentInfo *cms,
154 unsigned char *key, size_t keylen,
c17dd597 155 const unsigned char *id, size_t idlen);
0f113f3e
MC
156int CMS_decrypt_set1_password(CMS_ContentInfo *cms,
157 unsigned char *pass, ossl_ssize_t passlen);
8931b30d 158
4f1aa191
DSH
159STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms);
160int CMS_RecipientInfo_type(CMS_RecipientInfo *ri);
e365352d 161EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri);
761ffa72
DSH
162CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);
163CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms,
0f113f3e 164 X509 *recip, unsigned int flags);
6e3bc4f0 165int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey);
4f1aa191
DSH
166int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert);
167int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri,
0f113f3e
MC
168 EVP_PKEY **pk, X509 **recip,
169 X509_ALGOR **palg);
4f1aa191 170int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri,
0f113f3e
MC
171 ASN1_OCTET_STRING **keyid,
172 X509_NAME **issuer,
173 ASN1_INTEGER **sno);
4f1aa191 174
ab124380 175CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid,
0f113f3e
MC
176 unsigned char *key, size_t keylen,
177 unsigned char *id, size_t idlen,
178 ASN1_GENERALIZEDTIME *date,
179 ASN1_OBJECT *otherTypeId,
180 ASN1_TYPE *otherType);
eeb9cdfc 181
f5e2354c 182int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri,
0f113f3e
MC
183 X509_ALGOR **palg,
184 ASN1_OCTET_STRING **pid,
185 ASN1_GENERALIZEDTIME **pdate,
186 ASN1_OBJECT **potherid,
187 ASN1_TYPE **pothertype);
f5e2354c 188
0f113f3e
MC
189int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri,
190 unsigned char *key, size_t keylen);
eeb9cdfc 191
0f113f3e
MC
192int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri,
193 const unsigned char *id, size_t idlen);
eeb9cdfc 194
0f113f3e
MC
195int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri,
196 unsigned char *pass,
197 ossl_ssize_t passlen);
d2a53c22
DSH
198
199CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms,
0f113f3e
MC
200 int iter, int wrap_nid,
201 int pbe_nid,
202 unsigned char *pass,
203 ossl_ssize_t passlen,
204 const EVP_CIPHER *kekciph);
d2a53c22 205
6e3bc4f0 206int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
9fdcc21f 207int CMS_RecipientInfo_encrypt(const CMS_ContentInfo *cms, CMS_RecipientInfo *ri);
0f113f3e 208
a5db50d0 209int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out,
0f113f3e 210 unsigned int flags);
8931b30d
DSH
211CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags);
212
213int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);
214const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms);
215
216CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms);
217int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert);
218int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert);
219STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms);
220
221CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms);
222int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl);
19048b5c 223int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl);
8931b30d
DSH
224STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms);
225
226int CMS_SignedData_init(CMS_ContentInfo *cms);
227CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms,
0f113f3e
MC
228 X509 *signer, EVP_PKEY *pk, const EVP_MD *md,
229 unsigned int flags);
e365352d
DSH
230EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si);
231EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si);
8931b30d
DSH
232STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms);
233
234void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer);
235int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si,
0f113f3e
MC
236 ASN1_OCTET_STRING **keyid,
237 X509_NAME **issuer, ASN1_INTEGER **sno);
8931b30d
DSH
238int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert);
239int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs,
0f113f3e
MC
240 unsigned int flags);
241void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk,
242 X509 **signer, X509_ALGOR **pdig,
243 X509_ALGOR **psig);
da15c616 244ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si);
8931b30d
DSH
245int CMS_SignerInfo_sign(CMS_SignerInfo *si);
246int CMS_SignerInfo_verify(CMS_SignerInfo *si);
247int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain);
248
249int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs);
250int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs,
0f113f3e 251 int algnid, int keysize);
8931b30d
DSH
252int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap);
253
254int CMS_signed_get_attr_count(const CMS_SignerInfo *si);
255int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
0f113f3e 256 int lastpos);
c47ba4e9 257int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj,
0f113f3e 258 int lastpos);
8931b30d
DSH
259X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc);
260X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc);
261int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
262int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si,
0f113f3e
MC
263 const ASN1_OBJECT *obj, int type,
264 const void *bytes, int len);
8931b30d 265int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si,
0f113f3e
MC
266 int nid, int type,
267 const void *bytes, int len);
8931b30d 268int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si,
0f113f3e
MC
269 const char *attrname, int type,
270 const void *bytes, int len);
c47ba4e9 271void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid,
0f113f3e 272 int lastpos, int type);
8931b30d
DSH
273
274int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si);
275int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid,
0f113f3e 276 int lastpos);
c47ba4e9
F
277int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si,
278 const ASN1_OBJECT *obj, int lastpos);
8931b30d
DSH
279X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc);
280X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc);
281int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr);
282int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si,
0f113f3e
MC
283 const ASN1_OBJECT *obj, int type,
284 const void *bytes, int len);
8931b30d 285int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si,
0f113f3e
MC
286 int nid, int type,
287 const void *bytes, int len);
8931b30d 288int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si,
0f113f3e
MC
289 const char *attrname, int type,
290 const void *bytes, int len);
8931b30d 291void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid,
0f113f3e 292 int lastpos, int type);
8931b30d 293
f4cc56f4 294int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr);
f5e2354c 295CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen,
0f113f3e
MC
296 int allorfirst,
297 STACK_OF(GENERAL_NAMES)
298 *receiptList, STACK_OF(GENERAL_NAMES)
299 *receiptsTo);
f5e2354c 300int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr);
f4cc56f4 301void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr,
0f113f3e
MC
302 ASN1_STRING **pcid,
303 int *pallorfirst,
304 STACK_OF(GENERAL_NAMES) **plist,
305 STACK_OF(GENERAL_NAMES) **prto);
17c2764d 306int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri,
0f113f3e
MC
307 X509_ALGOR **palg,
308 ASN1_OCTET_STRING **pukm);
309STACK_OF(CMS_RecipientEncryptedKey)
310*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri);
17c2764d
DSH
311
312int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri,
0f113f3e
MC
313 X509_ALGOR **pubalg,
314 ASN1_BIT_STRING **pubkey,
315 ASN1_OCTET_STRING **keyid,
316 X509_NAME **issuer,
317 ASN1_INTEGER **sno);
17c2764d
DSH
318
319int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert);
0f113f3e 320
17c2764d 321int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek,
0f113f3e
MC
322 ASN1_OCTET_STRING **keyid,
323 ASN1_GENERALIZEDTIME **tm,
324 CMS_OtherKeyAttribute **other,
325 X509_NAME **issuer, ASN1_INTEGER **sno);
17c2764d 326int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek,
0f113f3e 327 X509 *cert);
17c2764d
DSH
328int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk);
329EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri);
0f113f3e
MC
330int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms,
331 CMS_RecipientInfo *ri,
332 CMS_RecipientEncryptedKey *rek);
f4cc56f4 333
0f113f3e
MC
334int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg,
335 ASN1_OCTET_STRING *ukm, int keylen);
dc1ce3bc 336
52df25cf
RS
337/* Backward compatibility for spelling errors. */
338# define CMS_R_UNKNOWN_DIGEST_ALGORITM CMS_R_UNKNOWN_DIGEST_ALGORITHM
339# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE \
340 CMS_R_UNSUPPORTED_RECIPIENTINFO_TYPE
0cd0a820 341
0cd0a820 342# ifdef __cplusplus
8931b30d 343}
0cd0a820 344# endif
3c27208f 345# endif
8931b30d 346#endif