xref: /freebsd/crypto/openssl/doc/man3/CMS_EnvelopedData_create.pod (revision e7be843b4a162e68651d3911f0357ed464915629)
1=pod
2
3=head1 NAME
4
5CMS_EnvelopedData_create_ex, CMS_EnvelopedData_create,
6CMS_AuthEnvelopedData_create, CMS_AuthEnvelopedData_create_ex
7- Create CMS envelope
8
9=head1 SYNOPSIS
10
11 #include <openssl/cms.h>
12
13 CMS_ContentInfo *
14 CMS_EnvelopedData_create_ex(const EVP_CIPHER *cipher, OSSL_LIB_CTX *libctx,
15                             const char *propq);
16 CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher);
17
18 CMS_ContentInfo *
19 CMS_AuthEnvelopedData_create_ex(const EVP_CIPHER *cipher, OSSL_LIB_CTX *libctx,
20                                 const char *propq);
21 CMS_ContentInfo *CMS_AuthEnvelopedData_create(const EVP_CIPHER *cipher);
22
23=head1 DESCRIPTION
24
25CMS_EnvelopedData_create_ex() creates a B<CMS_ContentInfo> structure
26with a type B<NID_pkcs7_enveloped>. I<cipher> is the symmetric cipher to use.
27The library context I<libctx> and the property query I<propq> are used when
28retrieving algorithms from providers.
29
30CMS_AuthEnvelopedData_create_ex() creates a B<CMS_ContentInfo>
31structure with a type B<NID_id_smime_ct_authEnvelopedData>. B<cipher> is the
32symmetric AEAD cipher to use. Currently only AES variants with GCM mode are
33supported. The library context I<libctx> and the property query I<propq> are
34used when retrieving algorithms from providers.
35
36The algorithm passed in the I<cipher> parameter must support ASN1 encoding of
37its parameters.
38
39The recipients can be added later using L<CMS_add1_recipient_cert(3)> or
40L<CMS_add0_recipient_key(3)>.
41
42The B<CMS_ContentInfo> structure needs to be finalized using L<CMS_final(3)>
43and then freed using L<CMS_ContentInfo_free(3)>.
44
45CMS_EnvelopedData_create() and CMS_AuthEnvelopedData_create() are similar to
46CMS_EnvelopedData_create_ex() and CMS_AuthEnvelopedData_create_ex()
47but use default values of NULL for
48the library context I<libctx> and the property query I<propq>.
49
50=head1 NOTES
51
52Although CMS_EnvelopedData_create_ex(), and CMS_EnvelopedData_create(),
53CMS_AuthEnvelopedData_create_ex(), and CMS_AuthEnvelopedData_create() allocate
54a new B<CMS_ContentInfo> structure, they are not usually used in applications.
55The wrappers L<CMS_encrypt(3)> and L<CMS_decrypt(3)> are often used instead.
56
57=head1 RETURN VALUES
58
59If the allocation fails, CMS_EnvelopedData_create_ex(),
60CMS_EnvelopedData_create(), CMS_AuthEnvelopedData_create_ex(),
61CMS_AuthEnvelopedData_create(), CMS_AuthEnvelopedData_create(),
62and CMS_AuthEnvelopedData_create_ex() return NULL and set an
63error code that can be obtained by L<ERR_get_error(3)>.
64Otherwise, they return a pointer to the newly allocated structure.
65
66=head1 SEE ALSO
67
68L<ERR_get_error(3)>, L<CMS_encrypt(3)>, L<CMS_decrypt(3)>, L<CMS_final(3)>,
69L<CMS_sign_ex(3)>, L<CMS_encrypt_ex(3)>
70
71=head1 HISTORY
72
73The CMS_EnvelopedData_create_ex() method was added in OpenSSL 3.0.
74
75CMS_AuthEnvelopedData_create() and CMS_AuthEnvelopedData_create_ex()
76were added in OpenSSL 3.5.
77
78=head1 COPYRIGHT
79
80Copyright 2020-2025 The OpenSSL Project Authors. All Rights Reserved.
81
82Licensed under the Apache License 2.0 (the "License").  You may not use
83this file except in compliance with the License.  You can obtain a copy
84in the file LICENSE in the source distribution or at
85L<https://www.openssl.org/source/license.html>.
86
87=cut
88