xref: /openbsd-src/lib/libcrypto/man/EVP_CIPHER_CTX_get_cipher_data.3 (revision 0e80ab9d860cba37a8cbaddb1f7b336158e7e901)
1*0e80ab9dSschwarze.\" $OpenBSD: EVP_CIPHER_CTX_get_cipher_data.3,v 1.3 2023/08/26 15:12:04 schwarze Exp $
2550a68d8Sschwarze.\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
3550a68d8Sschwarze.\"
4*0e80ab9dSschwarze.\" This file is a derived work.
5*0e80ab9dSschwarze.\" The changes are covered by the following Copyright and license:
6*0e80ab9dSschwarze.\"
7*0e80ab9dSschwarze.\" Copyright (c) 2023 Ingo Schwarze <schwarze@openbsd.org>
8*0e80ab9dSschwarze.\"
9*0e80ab9dSschwarze.\" Permission to use, copy, modify, and distribute this software for any
10*0e80ab9dSschwarze.\" purpose with or without fee is hereby granted, provided that the above
11*0e80ab9dSschwarze.\" copyright notice and this permission notice appear in all copies.
12*0e80ab9dSschwarze.\"
13*0e80ab9dSschwarze.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14*0e80ab9dSschwarze.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15*0e80ab9dSschwarze.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16*0e80ab9dSschwarze.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17*0e80ab9dSschwarze.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18*0e80ab9dSschwarze.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19*0e80ab9dSschwarze.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20*0e80ab9dSschwarze.\"
21*0e80ab9dSschwarze.\" The original file was written by Matt Caswell <matt@openssl.org>.
22550a68d8Sschwarze.\" Copyright (c) 2016 The OpenSSL Project.  All rights reserved.
23550a68d8Sschwarze.\"
24550a68d8Sschwarze.\" Redistribution and use in source and binary forms, with or without
25550a68d8Sschwarze.\" modification, are permitted provided that the following conditions
26550a68d8Sschwarze.\" are met:
27550a68d8Sschwarze.\"
28550a68d8Sschwarze.\" 1. Redistributions of source code must retain the above copyright
29550a68d8Sschwarze.\"    notice, this list of conditions and the following disclaimer.
30550a68d8Sschwarze.\"
31550a68d8Sschwarze.\" 2. Redistributions in binary form must reproduce the above copyright
32550a68d8Sschwarze.\"    notice, this list of conditions and the following disclaimer in
33550a68d8Sschwarze.\"    the documentation and/or other materials provided with the
34550a68d8Sschwarze.\"    distribution.
35550a68d8Sschwarze.\"
36550a68d8Sschwarze.\" 3. All advertising materials mentioning features or use of this
37550a68d8Sschwarze.\"    software must display the following acknowledgment:
38550a68d8Sschwarze.\"    "This product includes software developed by the OpenSSL Project
39550a68d8Sschwarze.\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
40550a68d8Sschwarze.\"
41550a68d8Sschwarze.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
42550a68d8Sschwarze.\"    endorse or promote products derived from this software without
43550a68d8Sschwarze.\"    prior written permission. For written permission, please contact
44550a68d8Sschwarze.\"    openssl-core@openssl.org.
45550a68d8Sschwarze.\"
46550a68d8Sschwarze.\" 5. Products derived from this software may not be called "OpenSSL"
47550a68d8Sschwarze.\"    nor may "OpenSSL" appear in their names without prior written
48550a68d8Sschwarze.\"    permission of the OpenSSL Project.
49550a68d8Sschwarze.\"
50550a68d8Sschwarze.\" 6. Redistributions of any form whatsoever must retain the following
51550a68d8Sschwarze.\"    acknowledgment:
52550a68d8Sschwarze.\"    "This product includes software developed by the OpenSSL Project
53550a68d8Sschwarze.\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
54550a68d8Sschwarze.\"
55550a68d8Sschwarze.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
56550a68d8Sschwarze.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57550a68d8Sschwarze.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58550a68d8Sschwarze.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
59550a68d8Sschwarze.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
60550a68d8Sschwarze.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
61550a68d8Sschwarze.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
62550a68d8Sschwarze.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63550a68d8Sschwarze.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64550a68d8Sschwarze.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
65550a68d8Sschwarze.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66550a68d8Sschwarze.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67550a68d8Sschwarze.\"
68143c7089Sjsg.Dd $Mdocdate: August 26 2023 $
69550a68d8Sschwarze.Dt EVP_CIPHER_CTX_GET_CIPHER_DATA 3
70550a68d8Sschwarze.Os
71550a68d8Sschwarze.Sh NAME
72550a68d8Sschwarze.Nm EVP_CIPHER_CTX_get_cipher_data ,
73*0e80ab9dSschwarze.Nm EVP_CIPHER_CTX_set_cipher_data ,
74*0e80ab9dSschwarze.Nm EVP_CIPHER_CTX_buf_noconst
75550a68d8Sschwarze.Nd inspect and modify EVP_CIPHER_CTX objects
76550a68d8Sschwarze.Sh SYNOPSIS
77550a68d8Sschwarze.In openssl/evp.h
78550a68d8Sschwarze.Ft void *
79550a68d8Sschwarze.Fo EVP_CIPHER_CTX_get_cipher_data
80550a68d8Sschwarze.Fa "const EVP_CIPHER_CTX *ctx"
81550a68d8Sschwarze.Fc
82550a68d8Sschwarze.Ft void *
83550a68d8Sschwarze.Fo EVP_CIPHER_CTX_set_cipher_data
84550a68d8Sschwarze.Fa "EVP_CIPHER_CTX *ctx"
85550a68d8Sschwarze.Fa "void *cipher_data"
86550a68d8Sschwarze.Fc
87*0e80ab9dSschwarze.Ft unsigned char *
88*0e80ab9dSschwarze.Fo EVP_CIPHER_CTX_buf_noconst
89*0e80ab9dSschwarze.Fa "EVP_CIPHER_CTX *ctx"
90*0e80ab9dSschwarze.Fc
91550a68d8Sschwarze.Sh DESCRIPTION
92550a68d8Sschwarze.Fn EVP_CIPHER_CTX_get_cipher_data
93550a68d8Sschwarzereturns a pointer to the cipher data of
94550a68d8Sschwarze.Fa ctx .
95550a68d8SschwarzeThe format and content of this data is specific to the algorithm
96550a68d8Sschwarzeand to the particular implementation of the cipher.
97550a68d8SschwarzeFor example, this data can be used by engines
98550a68d8Sschwarzeto store engine specific information.
99550a68d8SschwarzeThe data is automatically allocated and freed by OpenSSL, so
100550a68d8Sschwarzeapplications and engines should not normally free this directly (but see
101550a68d8Sschwarzebelow).
102550a68d8Sschwarze.Pp
103550a68d8Sschwarze.Fn EVP_CIPHER_CTX_set_cipher_data
104550a68d8Sschwarzeallows an application or engine to replace the existing cipher data
105143c7089Sjsgwith new data, transferring ownership of
106550a68d8Sschwarze.Fa cipher_data
107550a68d8Sschwarzeto the
108550a68d8Sschwarze.Fa ctx
109550a68d8Sschwarzeobject.
110550a68d8SschwarzeA pointer to any existing cipher data is returned from this function.
111550a68d8SschwarzeIf the old data is no longer required,
112550a68d8Sschwarzeit should be freed through a call to
113550a68d8Sschwarze.Xr free 3 .
114*0e80ab9dSschwarze.Pp
115*0e80ab9dSschwarze.Fn EVP_CIPHER_CTX_buf_noconst
116*0e80ab9dSschwarzeprovides engines and custom cipher implementations
117*0e80ab9dSschwarzewith access to the internal buffer that
118*0e80ab9dSschwarze.Xr EVP_EncryptUpdate 3
119*0e80ab9dSschwarzecopies input data into before encrypting it.
120*0e80ab9dSschwarzeThis function can for example be used
121*0e80ab9dSschwarzeinside callback functions installed with
122*0e80ab9dSschwarze.Xr EVP_CIPHER_meth_set_do_cipher 3 .
123550a68d8Sschwarze.Sh RETURN VALUES
124550a68d8Sschwarze.Fn EVP_CIPHER_CTX_get_cipher_data
125550a68d8Sschwarzereturns an internal pointer owned by
126550a68d8Sschwarze.Fa ctx .
127550a68d8Sschwarze.Pp
128550a68d8Sschwarze.Fn EVP_CIPHER_CTX_set_cipher_data
129550a68d8Sschwarzereturns a pointer to the old cipher data of
130550a68d8Sschwarze.Fa ctx
131550a68d8Sschwarzeand transfers ownership to the caller.
132*0e80ab9dSschwarze.Pp
133*0e80ab9dSschwarze.Fn EVP_CIPHER_CTX_buf_noconst
134*0e80ab9dSschwarzereturns a pointer to an internal buffer owned by
135*0e80ab9dSschwarze.Fa ctx .
136550a68d8Sschwarze.Sh SEE ALSO
137550a68d8Sschwarze.Xr evp 3 ,
138*0e80ab9dSschwarze.Xr EVP_CIPHER_meth_new 3 ,
139550a68d8Sschwarze.Xr EVP_EncryptInit 3
140550a68d8Sschwarze.Sh HISTORY
141*0e80ab9dSschwarze.Fn EVP_CIPHER_CTX_get_cipher_data ,
142*0e80ab9dSschwarze.Fn EVP_CIPHER_CTX_set_cipher_data ,
143550a68d8Sschwarzeand
144*0e80ab9dSschwarze.Fn EVP_CIPHER_CTX_buf_noconst
145550a68d8Sschwarzefirst appeared in OpenSSL 1.1.0 and have been available since
146550a68d8Sschwarze.Ox 7.1 .
147