summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3260
1 files changed, 260 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
new file mode 100644
index 0000000000..40ed524ffa
--- /dev/null
+++ b/src/lib/libcrypto/man/EVP_CIPHER_CTX_ctrl.3
@@ -0,0 +1,260 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_ctrl.3,v 1.1 2023/08/31 17:27:41 schwarze Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800
3.\"
4.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license:
6.\"
7.\" Copyright (c) 2018, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\" Copyright (c) 2018 Damien Miller <djm@openbsd.org>
9.\"
10.\" Permission to use, copy, modify, and distribute this software for any
11.\" purpose with or without fee is hereby granted, provided that the above
12.\" copyright notice and this permission notice appear in all copies.
13.\"
14.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21.\"
22.\" The original file was written by Dr. Stephen Henson <steve@openssl.org>.
23.\" Copyright (c) 2000, 2001, 2016 The OpenSSL Project.
24.\" All rights reserved.
25.\"
26.\" Redistribution and use in source and binary forms, with or without
27.\" modification, are permitted provided that the following conditions
28.\" are met:
29.\"
30.\" 1. Redistributions of source code must retain the above copyright
31.\" notice, this list of conditions and the following disclaimer.
32.\"
33.\" 2. Redistributions in binary form must reproduce the above copyright
34.\" notice, this list of conditions and the following disclaimer in
35.\" the documentation and/or other materials provided with the
36.\" distribution.
37.\"
38.\" 3. All advertising materials mentioning features or use of this
39.\" software must display the following acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42.\"
43.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44.\" endorse or promote products derived from this software without
45.\" prior written permission. For written permission, please contact
46.\" openssl-core@openssl.org.
47.\"
48.\" 5. Products derived from this software may not be called "OpenSSL"
49.\" nor may "OpenSSL" appear in their names without prior written
50.\" permission of the OpenSSL Project.
51.\"
52.\" 6. Redistributions of any form whatsoever must retain the following
53.\" acknowledgment:
54.\" "This product includes software developed by the OpenSSL Project
55.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56.\"
57.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
61.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68.\" OF THE POSSIBILITY OF SUCH DAMAGE.
69.\"
70.Dd $Mdocdate: August 31 2023 $
71.Dt EVP_CIPHER_CTX_CTRL 3
72.Os
73.Sh NAME
74.Nm EVP_CIPHER_CTX_ctrl ,
75.Nm EVP_CIPHER_CTX_set_padding ,
76.Nm EVP_CIPHER_CTX_set_key_length ,
77.Nm EVP_CIPHER_CTX_key_length ,
78.Nm EVP_CIPHER_key_length ,
79.Nm EVP_CIPHER_CTX_iv_length ,
80.Nm EVP_CIPHER_iv_length ,
81.Nm EVP_CIPHER_CTX_set_iv ,
82.Nm EVP_CIPHER_CTX_get_iv
83.Nd configure EVP cipher contexts
84.Sh SYNOPSIS
85.In openssl/evp.h
86.Ft int
87.Fo EVP_CIPHER_CTX_ctrl
88.Fa "EVP_CIPHER_CTX *ctx"
89.Fa "int type"
90.Fa "int arg"
91.Fa "void *ptr"
92.Fc
93.Ft int
94.Fo EVP_CIPHER_CTX_set_padding
95.Fa "EVP_CIPHER_CTX *x"
96.Fa "int padding"
97.Fc
98.Ft int
99.Fo EVP_CIPHER_CTX_set_key_length
100.Fa "EVP_CIPHER_CTX *x"
101.Fa "int keylen"
102.Fc
103.Ft int
104.Fo EVP_CIPHER_CTX_key_length
105.Fa "const EVP_CIPHER_CTX *ctx"
106.Fc
107.Ft int
108.Fo EVP_CIPHER_key_length
109.Fa "const EVP_CIPHER *e"
110.Fc
111.Ft int
112.Fo EVP_CIPHER_CTX_iv_length
113.Fa "const EVP_CIPHER_CTX *ctx"
114.Fc
115.Ft int
116.Fo EVP_CIPHER_iv_length
117.Fa "const EVP_CIPHER *e"
118.Fc
119.Ft int
120.Fo EVP_CIPHER_CTX_set_iv
121.Fa "EVP_CIPHER_CTX *ctx"
122.Fa "const unsigned char *iv"
123.Fa "size_t len"
124.Fc
125.Ft int
126.Fo EVP_CIPHER_CTX_get_iv
127.Fa "const EVP_CIPHER_CTX *ctx"
128.Fa "unsigned char *iv"
129.Fa "size_t len"
130.Fc
131.Sh DESCRIPTION
132.Fn EVP_CIPHER_CTX_ctrl
133allows various cipher specific parameters to be determined and set.
134Currently only the RC2 effective key length can be set.
135.Pp
136.Fn EVP_CIPHER_CTX_set_padding
137enables or disables padding.
138This function should be called after the context is set up for
139encryption or decryption with
140.Xr EVP_EncryptInit_ex 3 ,
141.Xr EVP_DecryptInit_ex 3 ,
142or
143.Xr EVP_CipherInit_ex 3 .
144By default encryption operations are padded using standard block padding
145and the padding is checked and removed when decrypting.
146If the
147.Fa padding
148parameter is zero, then no padding is performed, the total amount of data
149encrypted or decrypted must then be a multiple of the block size or an
150error will occur.
151.Pp
152.Fn EVP_CIPHER_CTX_set_key_length
153sets the key length of the cipher ctx.
154If the cipher is a fixed length cipher, then attempting to set the key
155length to any value other than the fixed value is an error.
156.Pp
157.Fn EVP_CIPHER_CTX_key_length
158and
159.Fn EVP_CIPHER_key_length
160return the key length of a cipher when passed an
161.Vt EVP_CIPHER_CTX
162or
163.Vt EVP_CIPHER
164structure.
165The constant
166.Dv EVP_MAX_KEY_LENGTH
167is the maximum key length for all ciphers.
168Note: although
169.Fn EVP_CIPHER_key_length
170is fixed for a given cipher, the value of
171.Fn EVP_CIPHER_CTX_key_length
172may be different for variable key length ciphers.
173.Pp
174.Fn EVP_CIPHER_CTX_iv_length
175and
176.Fn EVP_CIPHER_iv_length
177return the IV length of a cipher when passed an
178.Vt EVP_CIPHER_CTX
179or
180.Vt EVP_CIPHER .
181It will return zero if the cipher does not use an IV.
182The constant
183.Dv EVP_MAX_IV_LENGTH
184is the maximum IV length for all ciphers.
185.Pp
186.Fn EVP_CIPHER_CTX_set_iv
187and
188.Fn EVP_CIPHER_CTX_get_iv
189set and retrieve the IV for an
190.Vt EVP_CIPHER_CTX ,
191respectively.
192In both cases, the specified IV length must exactly equal the expected
193IV length for the context as returned by
194.Fn EVP_CIPHER_CTX_iv_length .
195.Sh RETURN VALUES
196.Fn EVP_CIPHER_CTX_ctrl
197usually returns 1 for success, 0 for failure, or \-1 if the
198.Fa type
199is not supported by the
200.Fa ctx ,
201but there may be exceptions for some
202.Fa type
203arguments.
204.Pp
205.Fn EVP_CIPHER_CTX_set_padding
206always returns 1.
207.Pp
208.Fn EVP_CIPHER_CTX_set_key_length ,
209.Fn EVP_CIPHER_CTX_set_iv ,
210and
211.Fn EVP_CIPHER_CTX_get_iv
212return 1 for success or 0 for failure.
213.Pp
214.Fn EVP_CIPHER_CTX_key_length
215and
216.Fn EVP_CIPHER_key_length
217return the key length.
218.Pp
219.Fn EVP_CIPHER_CTX_iv_length
220and
221.Fn EVP_CIPHER_iv_length
222return the IV length or zero if the cipher does not use an IV.
223.Sh SEE ALSO
224.Xr evp 3 ,
225.Xr EVP_CIPHER_nid 3 ,
226.Xr EVP_EncryptInit 3
227.Sh HISTORY
228.Fn EVP_CIPHER_CTX_key_length ,
229.Fn EVP_CIPHER_key_length ,
230.Fn EVP_CIPHER_CTX_iv_length ,
231and
232.Fn EVP_CIPHER_iv_length
233first appeared in SSLeay 0.6.5 and have been available since
234.Ox 2.4 .
235.Pp
236.Fn EVP_CIPHER_CTX_ctrl
237and
238.Fn EVP_CIPHER_CTX_set_key_length
239first appeared in OpenSSL 0.9.6 and have been available since
240.Ox 2.9 .
241.Pp
242.Fn EVP_CIPHER_CTX_set_padding
243first appeared in OpenSSL 0.9.7 and has been available since
244.Ox 3.2 .
245.Pp
246.Fn EVP_CIPHER_CTX_set_iv
247and
248.Fn EVP_CIPHER_CTX_get_iv
249first appeared in LibreSSL 2.8.1 and have been available since
250.Ox 6.4 .
251.Sh BUGS
252.Dv EVP_MAX_KEY_LENGTH
253and
254.Dv EVP_MAX_IV_LENGTH
255only refer to the internal ciphers with default key lengths.
256If custom ciphers exceed these values, the results are unpredictable.
257This is because it has become standard practice to define a generic key
258as a fixed unsigned char array containing
259.Dv EVP_MAX_KEY_LENGTH
260bytes.