xref: /freebsd-src/crypto/openssl/doc/man3/CMS_EncryptedData_encrypt.pod (revision b077aed33b7b6aefca7b17ddb250cf521f938613)
1*b077aed3SPierre Pronchery=pod
2*b077aed3SPierre Pronchery
3*b077aed3SPierre Pronchery=head1 NAME
4*b077aed3SPierre Pronchery
5*b077aed3SPierre ProncheryCMS_EncryptedData_encrypt_ex, CMS_EncryptedData_encrypt
6*b077aed3SPierre Pronchery- Create CMS EncryptedData
7*b077aed3SPierre Pronchery
8*b077aed3SPierre Pronchery=head1 SYNOPSIS
9*b077aed3SPierre Pronchery
10*b077aed3SPierre Pronchery #include <openssl/cms.h>
11*b077aed3SPierre Pronchery
12*b077aed3SPierre Pronchery CMS_ContentInfo *CMS_EncryptedData_encrypt_ex(BIO *in,
13*b077aed3SPierre Pronchery                                               const EVP_CIPHER *cipher,
14*b077aed3SPierre Pronchery                                               const unsigned char *key,
15*b077aed3SPierre Pronchery                                               size_t keylen,
16*b077aed3SPierre Pronchery                                               unsigned int flags,
17*b077aed3SPierre Pronchery                                               OSSL_LIB_CTX *ctx,
18*b077aed3SPierre Pronchery                                               const char *propq);
19*b077aed3SPierre Pronchery
20*b077aed3SPierre Pronchery CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in,
21*b077aed3SPierre Pronchery     const EVP_CIPHER *cipher, const unsigned char *key, size_t keylen,
22*b077aed3SPierre Pronchery     unsigned int flags);
23*b077aed3SPierre Pronchery
24*b077aed3SPierre Pronchery=head1 DESCRIPTION
25*b077aed3SPierre Pronchery
26*b077aed3SPierre ProncheryCMS_EncryptedData_encrypt_ex() creates a B<CMS_ContentInfo> structure
27*b077aed3SPierre Proncherywith a type B<NID_pkcs7_encrypted>. I<in> is a BIO containing the data to
28*b077aed3SPierre Proncheryencrypt using I<cipher> and the encryption key I<key> of size I<keylen> bytes.
29*b077aed3SPierre ProncheryThe library context I<libctx> and the property query I<propq> are used when
30*b077aed3SPierre Proncheryretrieving algorithms from providers. I<flags> is a set of optional flags.
31*b077aed3SPierre Pronchery
32*b077aed3SPierre ProncheryThe I<flags> field supports the options B<CMS_DETACHED>, B<CMS_STREAM> and
33*b077aed3SPierre ProncheryB<CMS_PARTIAL>. Internally CMS_final() is called unless B<CMS_STREAM> and/or
34*b077aed3SPierre ProncheryB<CMS_PARTIAL> is specified.
35*b077aed3SPierre Pronchery
36*b077aed3SPierre ProncheryThe algorithm passed in the I<cipher> parameter must support ASN1 encoding of
37*b077aed3SPierre Proncheryits parameters.
38*b077aed3SPierre Pronchery
39*b077aed3SPierre ProncheryThe B<CMS_ContentInfo> structure can be freed using L<CMS_ContentInfo_free(3)>.
40*b077aed3SPierre Pronchery
41*b077aed3SPierre ProncheryCMS_EncryptedData_encrypt() is similar to CMS_EncryptedData_encrypt_ex()
42*b077aed3SPierre Proncherybut uses default values of NULL for the library context I<libctx> and the
43*b077aed3SPierre Proncheryproperty query I<propq>.
44*b077aed3SPierre Pronchery
45*b077aed3SPierre Pronchery=head1 RETURN VALUES
46*b077aed3SPierre Pronchery
47*b077aed3SPierre ProncheryIf the allocation fails, CMS_EncryptedData_encrypt_ex() and
48*b077aed3SPierre ProncheryCMS_EncryptedData_encrypt() return NULL and set an error code that can be
49*b077aed3SPierre Proncheryobtained by L<ERR_get_error(3)>. Otherwise they return a pointer to the newly
50*b077aed3SPierre Proncheryallocated structure.
51*b077aed3SPierre Pronchery
52*b077aed3SPierre Pronchery=head1 SEE ALSO
53*b077aed3SPierre Pronchery
54*b077aed3SPierre ProncheryL<ERR_get_error(3)>, L<CMS_final(3)>, L<CMS_EncryptedData_decrypt(3)>
55*b077aed3SPierre Pronchery
56*b077aed3SPierre Pronchery=head1 HISTORY
57*b077aed3SPierre Pronchery
58*b077aed3SPierre ProncheryThe CMS_EncryptedData_encrypt_ex() method was added in OpenSSL 3.0.
59*b077aed3SPierre Pronchery
60*b077aed3SPierre Pronchery=head1 COPYRIGHT
61*b077aed3SPierre Pronchery
62*b077aed3SPierre ProncheryCopyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
63*b077aed3SPierre Pronchery
64*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License").  You may not use
65*b077aed3SPierre Proncherythis file except in compliance with the License.  You can obtain a copy
66*b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at
67*b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>.
68*b077aed3SPierre Pronchery
69*b077aed3SPierre Pronchery=cut
70