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