summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2023-12-26 19:09:08 +0000
committerschwarze <>2023-12-26 19:09:08 +0000
commit5819b47a5811023ede6a0f5e8dad4fcad600e467 (patch)
tree5da03066ee2b8cd9033f859ad8906283ea6af741 /src/lib
parentd9fc8c2bb8070dda582528ac18d1b7c5dbdbc66e (diff)
downloadopenbsd-5819b47a5811023ede6a0f5e8dad4fcad600e467.tar.gz
openbsd-5819b47a5811023ede6a0f5e8dad4fcad600e467.tar.bz2
openbsd-5819b47a5811023ede6a0f5e8dad4fcad600e467.zip
Close some major gaps in the documentation of EVP_Cipher(3),
and describe EVP_CIPHER_CTX_init(3) in a less misleading way. Joint work with and OK tb@.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_CTX_init.375
1 files changed, 65 insertions, 10 deletions
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3 b/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
index 3bb40018f5..50df2e764d 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_CTX_init.3
@@ -1,11 +1,11 @@
1.\" $OpenBSD: EVP_CIPHER_CTX_init.3,v 1.1 2023/12/01 10:40:21 schwarze Exp $ 1.\" $OpenBSD: EVP_CIPHER_CTX_init.3,v 1.2 2023/12/26 19:09:08 schwarze Exp $
2.\" full merge up to: 2.\" full merge up to:
3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100 3.\" OpenSSL EVP_EncryptInit.pod 0874d7f2 Oct 11 13:13:47 2022 +0100
4.\" 4.\"
5.\" This file is a derived work. 5.\" This file is a derived work.
6.\" The changes are covered by the following Copyright and license: 6.\" The changes are covered by the following Copyright and license:
7.\" 7.\"
8.\" Copyright (c) 2018, 2019 Ingo Schwarze <schwarze@openbsd.org> 8.\" Copyright (c) 2018, 2019, 2023 Ingo Schwarze <schwarze@openbsd.org>
9.\" 9.\"
10.\" Permission to use, copy, modify, and distribute this software for any 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 11.\" purpose with or without fee is hereby granted, provided that the above
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: December 1 2023 $ 71.Dd $Mdocdate: December 26 2023 $
72.Dt EVP_CIPHER_CTX_INIT 3 72.Dt EVP_CIPHER_CTX_INIT 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -95,11 +95,18 @@
95.Fc 95.Fc
96.Sh DESCRIPTION 96.Sh DESCRIPTION
97.Fn EVP_CIPHER_CTX_init 97.Fn EVP_CIPHER_CTX_init
98is a deprecated function to clear a cipher context on the stack 98is a deprecated function that could be used to clear a cipher context
99before use. 99on the stack before
100Do not use it on a cipher context returned from 100.Vt EVP_CIPHER_CTX
101was made opaque.
102Calling it on a cipher context just returned from
101.Xr EVP_CIPHER_CTX_new 3 103.Xr EVP_CIPHER_CTX_new 3
102or one that was already used. 104has no effect.
105Calling it on a cipher context that was already used leaks memory.
106Instead, use
107.Xr EVP_CIPHER_CTX_reset 3
108or
109.Xr EVP_CIPHER_CTX_free 3 .
103.Pp 110.Pp
104.Fn EVP_CIPHER_CTX_cleanup 111.Fn EVP_CIPHER_CTX_cleanup
105is a deprecated alias for 112is a deprecated alias for
@@ -111,7 +118,41 @@ and frees all allocated memory associated with it, except the
111object itself. 118object itself.
112.Pp 119.Pp
113.Fn EVP_Cipher 120.Fn EVP_Cipher
114encrypts or decrypts aligned blocks of data 121exposes implementation details of the functions
122.Xr EVP_CipherUpdate 3
123and
124.Xr EVP_CipherFinal 3
125that should never have become part of the public API.
126.Pp
127If the flag
128.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER
129is set for the cipher used by
130.Fa ctx ,
131behaviour depends on
132.Fa in .
133If that argument is
134.Dv NULL
135and
136.Fa inl
137is 0, behaviour is similar to
138.Xr EVP_CipherFinal 3 ;
139if
140.Fa inl
141is not 0, behaviour is undefined.
142If
143.Fa in
144is not
145.Dv NULL ,
146behaviour is similar to
147.Xr EVP_CipherUpdate 3 .
148In both cases, the exceptions to the similarity are that arguments
149and return values differ.
150.Pp
151If the flag
152.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER
153is not set for the cipher used by
154.Fa ctx ,
155it encrypts or decrypts aligned blocks of data
115whose lengths match the cipher block size. 156whose lengths match the cipher block size.
116It requires that the previous encryption or decryption operation 157It requires that the previous encryption or decryption operation
117using the same 158using the same
@@ -133,9 +174,17 @@ the overhead incurred by using
133is minimal. 174is minimal.
134.Sh RETURN VALUES 175.Sh RETURN VALUES
135.Fn EVP_CIPHER_CTX_cleanup 176.Fn EVP_CIPHER_CTX_cleanup
136and 177returns 1 for success or 0 for failure.
178.Pp
179With
180.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER ,
137.Fn EVP_Cipher 181.Fn EVP_Cipher
138return 1 for success or 0 for failure. 182returns the number of bytes written to
183.Fa out
184for success or \-1 for failure.
185Without
186.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER ,
187it returns 1 for success or 0 for failure.
139.Sh SEE ALSO 188.Sh SEE ALSO
140.Xr evp 3 , 189.Xr evp 3 ,
141.Xr EVP_EncryptInit 3 190.Xr EVP_EncryptInit 3
@@ -148,3 +197,9 @@ first appeared in SSLeay 0.8.0.
148first appeared in SSLeay 0.9.0. 197first appeared in SSLeay 0.9.0.
149All these functions have been available since 198All these functions have been available since
150.Ox 2.4 . 199.Ox 2.4 .
200.Sh CAVEATS
201Checking the return value of
202.Fn EVP_Cipher
203requires unusual caution: zero signals success if
204.Dv EVP_CIPH_FLAG_CUSTOM_CIPHER
205is set or failure otherwise.