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