xref: /openbsd-src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3 (revision 0e80ab9d860cba37a8cbaddb1f7b336158e7e901)
1.\" $OpenBSD: EVP_CIPHER_CTX_get_cipher_data.3,v 1.3 2023/08/26 15:12:04 schwarze Exp $
2.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\"
9.\" Permission to use, copy, modify, and distribute this software for any
10.\" purpose with or without fee is hereby granted, provided that the above
11.\" copyright notice and this permission notice appear in all copies.
12.\"
13.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20.\"
21.\" The original file was written by Matt Caswell <matt@openssl.org>.
22.\" Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
23.\"
24.\" Redistribution and use in source and binary forms, with or without
25.\" modification, are permitted provided that the following conditions
26.\" are met:
27.\"
28.\" 1. Redistributions of source code must retain the above copyright
29.\"    notice, this list of conditions and the following disclaimer.
30.\"
31.\" 2. Redistributions in binary form must reproduce the above copyright
32.\"    notice, this list of conditions and the following disclaimer in
33.\"    the documentation and/or other materials provided with the
34.\"    distribution.
35.\"
36.\" 3. All advertising materials mentioning features or use of this
37.\"    software must display the following acknowledgment:
38.\"    "This product includes software developed by the OpenSSL Project
39.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40.\"
41.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42.\"    endorse or promote products derived from this software without
43.\"    prior written permission. For written permission, please contact
44.\"    openssl-core@openssl.org.
45.\"
46.\" 5. Products derived from this software may not be called "OpenSSL"
47.\"    nor may "OpenSSL" appear in their names without prior written
48.\"    permission of the OpenSSL Project.
49.\"
50.\" 6. Redistributions of any form whatsoever must retain the following
51.\"    acknowledgment:
52.\"    "This product includes software developed by the OpenSSL Project
53.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54.\"
55.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
59.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\"
68.Dd $Mdocdate: August 26 2023 $
69.Dt EVP_CIPHER_CTX_GET_CIPHER_DATA 3
70.Os
71.Sh NAME
72.Nm EVP_CIPHER_CTX_get_cipher_data ,
73.Nm EVP_CIPHER_CTX_set_cipher_data ,
74.Nm EVP_CIPHER_CTX_buf_noconst
75.Nd inspect and modify EVP_CIPHER_CTX objects
76.Sh SYNOPSIS
77.In openssl/evp.h
78.Ft void *
79.Fo EVP_CIPHER_CTX_get_cipher_data
80.Fa "const EVP_CIPHER_CTX *ctx"
81.Fc
82.Ft void *
83.Fo EVP_CIPHER_CTX_set_cipher_data
84.Fa "EVP_CIPHER_CTX *ctx"
85.Fa "void *cipher_data"
86.Fc
87.Ft unsigned char *
88.Fo EVP_CIPHER_CTX_buf_noconst
89.Fa "EVP_CIPHER_CTX *ctx"
90.Fc
91.Sh DESCRIPTION
92.Fn EVP_CIPHER_CTX_get_cipher_data
93returns a pointer to the cipher data of
94.Fa ctx .
95The format and content of this data is specific to the algorithm
96and to the particular implementation of the cipher.
97For example, this data can be used by engines
98to store engine specific information.
99The data is automatically allocated and freed by OpenSSL, so
100applications and engines should not normally free this directly (but see
101below).
102.Pp
103.Fn EVP_CIPHER_CTX_set_cipher_data
104allows an application or engine to replace the existing cipher data
105with new data, transferring ownership of
106.Fa cipher_data
107to the
108.Fa ctx
109object.
110A pointer to any existing cipher data is returned from this function.
111If the old data is no longer required,
112it should be freed through a call to
113.Xr free 3 .
114.Pp
115.Fn EVP_CIPHER_CTX_buf_noconst
116provides engines and custom cipher implementations
117with access to the internal buffer that
118.Xr EVP_EncryptUpdate 3
119copies input data into before encrypting it.
120This function can for example be used
121inside callback functions installed with
122.Xr EVP_CIPHER_meth_set_do_cipher 3 .
123.Sh RETURN VALUES
124.Fn EVP_CIPHER_CTX_get_cipher_data
125returns an internal pointer owned by
126.Fa ctx .
127.Pp
128.Fn EVP_CIPHER_CTX_set_cipher_data
129returns a pointer to the old cipher data of
130.Fa ctx
131and transfers ownership to the caller.
132.Pp
133.Fn EVP_CIPHER_CTX_buf_noconst
134returns a pointer to an internal buffer owned by
135.Fa ctx .
136.Sh SEE ALSO
137.Xr evp 3 ,
138.Xr EVP_CIPHER_meth_new 3 ,
139.Xr EVP_EncryptInit 3
140.Sh HISTORY
141.Fn EVP_CIPHER_CTX_get_cipher_data ,
142.Fn EVP_CIPHER_CTX_set_cipher_data ,
143and
144.Fn EVP_CIPHER_CTX_buf_noconst
145first appeared in OpenSSL 1.1.0 and have been available since
146.Ox 7.1 .
147