summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2023-09-01 17:28:21 +0000
committerschwarze <>2023-09-01 17:28:21 +0000
commiteb76f486c446e046f3c48cadb03df3e7429b0c74 (patch)
tree0593e75021d7dc8663319267b2f09d01de8a86e0 /src/lib
parentabdfffa700bd5aee245bda51f0e77f879960b534 (diff)
downloadopenbsd-eb76f486c446e046f3c48cadb03df3e7429b0c74.tar.gz
openbsd-eb76f486c446e046f3c48cadb03df3e7429b0c74.tar.bz2
openbsd-eb76f486c446e046f3c48cadb03df3e7429b0c74.zip
Many improvements, almost amounting to a partial rewrite:
* more precision what the CIPHER_CTX functions do * more precision what an NID is * avoid talking about RC2, use AES-256 for an example instead * clarify that block sizes are measured in bytes * mention additional restrictions regarding valid block sizes * add the missing description of the *_flags(3) functions * mention the public mask constant EVP_CIPH_MODE * add three missing modes that can occur as return values * add the missing entries for *_flags(3) and *_mode(3) below RETURN VALUES * tweak various wordings for precision and conciseness
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/EVP_CIPHER_nid.3157
1 files changed, 109 insertions, 48 deletions
diff --git a/src/lib/libcrypto/man/EVP_CIPHER_nid.3 b/src/lib/libcrypto/man/EVP_CIPHER_nid.3
index 3a3c42d0b4..1c0683980b 100644
--- a/src/lib/libcrypto/man/EVP_CIPHER_nid.3
+++ b/src/lib/libcrypto/man/EVP_CIPHER_nid.3
@@ -1,10 +1,11 @@
1.\" $OpenBSD: EVP_CIPHER_nid.3,v 1.1 2023/08/31 17:27:41 schwarze Exp $ 1.\" $OpenBSD: EVP_CIPHER_nid.3,v 1.2 2023/09/01 17:28:21 schwarze Exp $
2.\" full merge up to: OpenSSL 5211e094 Nov 11 14:39:11 2014 -0800 2.\" full merge up to: OpenSSL man3/EVP_EncryptInit.pod
3.\" 0874d7f2 Oct 11 13:13:47 2022 +0100
3.\" 4.\"
4.\" This file is a derived work. 5.\" This file is a derived work.
5.\" The changes are covered by the following Copyright and license: 6.\" The changes are covered by the following Copyright and license:
6.\" 7.\"
7.\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> 8.\" Copyright (c) 2018, 2023 Ingo Schwarze <schwarze@openbsd.org>
8.\" 9.\"
9.\" Permission to use, copy, modify, and distribute this software for any 10.\" 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.\" purpose with or without fee is hereby granted, provided that the above
@@ -65,7 +66,7 @@
65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 66.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
66.\" OF THE POSSIBILITY OF SUCH DAMAGE. 67.\" OF THE POSSIBILITY OF SUCH DAMAGE.
67.\" 68.\"
68.Dd $Mdocdate: August 31 2023 $ 69.Dd $Mdocdate: September 1 2023 $
69.Dt EVP_CIPHER_NID 3 70.Dt EVP_CIPHER_NID 3
70.Os 71.Os
71.Sh NAME 72.Sh NAME
@@ -84,7 +85,7 @@
84.In openssl/evp.h 85.In openssl/evp.h
85.Ft int 86.Ft int
86.Fo EVP_CIPHER_nid 87.Fo EVP_CIPHER_nid
87.Fa "const EVP_CIPHER *e" 88.Fa "const EVP_CIPHER *cipher"
88.Fc 89.Fc
89.Ft int 90.Ft int
90.Fo EVP_CIPHER_CTX_nid 91.Fo EVP_CIPHER_CTX_nid
@@ -100,7 +101,7 @@
100.Fc 101.Fc
101.Ft int 102.Ft int
102.Fo EVP_CIPHER_block_size 103.Fo EVP_CIPHER_block_size
103.Fa "const EVP_CIPHER *e" 104.Fa "const EVP_CIPHER *cipher"
104.Fc 105.Fc
105.Ft int 106.Ft int
106.Fo EVP_CIPHER_CTX_block_size 107.Fo EVP_CIPHER_CTX_block_size
@@ -108,7 +109,7 @@
108.Fc 109.Fc
109.Ft unsigned long 110.Ft unsigned long
110.Fo EVP_CIPHER_flags 111.Fo EVP_CIPHER_flags
111.Fa "const EVP_CIPHER *e" 112.Fa "const EVP_CIPHER *cipher"
112.Fc 113.Fc
113.Ft unsigned long 114.Ft unsigned long
114.Fo EVP_CIPHER_CTX_flags 115.Fo EVP_CIPHER_CTX_flags
@@ -116,7 +117,7 @@
116.Fc 117.Fc
117.Ft unsigned long 118.Ft unsigned long
118.Fo EVP_CIPHER_mode 119.Fo EVP_CIPHER_mode
119.Fa "const EVP_CIPHER *e" 120.Fa "const EVP_CIPHER *cipher"
120.Fc 121.Fc
121.Ft unsigned long 122.Ft unsigned long
122.Fo EVP_CIPHER_CTX_mode 123.Fo EVP_CIPHER_CTX_mode
@@ -124,74 +125,124 @@
124.Fc 125.Fc
125.Sh DESCRIPTION 126.Sh DESCRIPTION
126.Fn EVP_CIPHER_nid 127.Fn EVP_CIPHER_nid
127and 128returns the numerical identifier (NID) of the
129.Fa cipher .
130The NID is an internal value which may or may not have a corresponding
131ASN.1 OBJECT IDENTIFIER; see
132.Xr OBJ_nid2obj 3
133for details.
134.Pp
128.Fn EVP_CIPHER_CTX_nid 135.Fn EVP_CIPHER_CTX_nid
129return the NID of a cipher when passed an 136returns the NID of the cipher that
130.Vt EVP_CIPHER 137.Fa ctx
131or 138is configured to use.
132.Vt EVP_CIPHER_CTX
133structure.
134The actual NID value is an internal value which may not have a
135corresponding OBJECT IDENTIFIER.
136.Pp 139.Pp
137.Fn EVP_CIPHER_type 140.Fn EVP_CIPHER_type
141returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the
142.Fa cipher ,
143ignoring the cipher parameters.
144For example,
145.Xr EVP_aes_256_cfb1 3 ,
146.Xr EVP_aes_256_cfb8 3 ,
138and 147and
148.Xr EVP_aes_256_cfb128 3
149all return the same NID,
150.Dv NID_aes_256_cfb128 .
151.Pp
139.Fn EVP_CIPHER_CTX_type 152.Fn EVP_CIPHER_CTX_type
140return the type of the passed cipher or context. 153returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the cipher that
141This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it 154.Fa ctx
142ignores the cipher parameters and 40-bit RC2 and 128-bit RC2 have the 155is configured to use.
143same NID.
144If the cipher does not have an object identifier or does not
145have ASN.1 support, this function will return
146.Dv NID_undef .
147.Pp 156.Pp
148.Fn EVP_CIPHER_block_size 157.Fn EVP_CIPHER_block_size
149and 158returns the block size of the
159.Fa cipher
160in bytes.
150.Fn EVP_CIPHER_CTX_block_size 161.Fn EVP_CIPHER_CTX_block_size
151return the block size of a cipher when passed an 162returns the block size of the cipher that
152.Vt EVP_CIPHER 163.Fa ctx
153or 164is configured to use.
154.Vt EVP_CIPHER_CTX 165Block sizes are guaranteed to be less than or equal to the constant
155structure. 166.Dv EVP_MAX_BLOCK_LENGTH .
156The constant 167Currently,
157.Dv EVP_MAX_BLOCK_LENGTH 168.Xr EVP_CipherInit_ex 3
158is also the maximum block length for all ciphers. 169and the other functions documented in the same manual page
170only support block sizes of 1, 8, and 16 bytes.
171.Pp
172.Fn EVP_CIPHER_flags
173returns the cipher flags used by the
174.Fa cipher .
175The meaning of the flags is described in the
176.Xr EVP_CIPHER_meth_set_flags 3
177manual page.
178.Pp
179.Fn EVP_CIPHER_CTX_flags
180returns the cipher flags of the cipher that
181.Fa ctx
182is configured to use.
183Be careful to not confuse these with the unrelated cipher context flags
184that can be inspected with
185.Xr EVP_CIPHER_CTX_test_flags 3 .
159.Pp 186.Pp
160.Fn EVP_CIPHER_mode 187.Fn EVP_CIPHER_mode
161and 188returns the
189.Fa cipher
190mode, which is the logical AND of the constant
191.Dv EVP_CIPH_MODE
192and the return value of
193.Fn EVP_CIPHER_flags .
194.Pp
162.Fn EVP_CIPHER_CTX_mode 195.Fn EVP_CIPHER_CTX_mode
163return the block cipher mode: 196returns the cipher mode of the cipher that
164.Dv EVP_CIPH_ECB_MODE , 197.Fa ctx
165.Dv EVP_CIPH_CBC_MODE , 198is configured to use.
166.Dv EVP_CIPH_CFB_MODE ,
167.Dv EVP_CIPH_OFB_MODE ,
168.Dv EVP_CIPH_CTR_MODE ,
169or
170.Dv EVP_CIPH_XTS_MODE .
171If the cipher is a stream cipher then
172.Dv EVP_CIPH_STREAM_CIPHER
173is returned.
174.Sh RETURN VALUES 199.Sh RETURN VALUES
175.Fn EVP_CIPHER_nid 200.Fn EVP_CIPHER_nid
176and 201and
177.Fn EVP_CIPHER_CTX_nid 202.Fn EVP_CIPHER_CTX_nid
178return a NID. 203return an NID.
179.Pp 204.Pp
180.Fn EVP_CIPHER_type 205.Fn EVP_CIPHER_type
181and 206and
182.Fn EVP_CIPHER_CTX_type 207.Fn EVP_CIPHER_CTX_type
183return the NID of the cipher's OBJECT IDENTIFIER or 208return the NID of the cipher's OBJECT IDENTIFIER or
184.Dv NID_undef 209.Dv NID_undef
185if it has no defined OBJECT IDENTIFIER. 210if it is not associated with an OBJECT IDENTIFIER.
186.Pp 211.Pp
187.Fn EVP_CIPHER_block_size 212.Fn EVP_CIPHER_block_size
188and 213and
189.Fn EVP_CIPHER_CTX_block_size 214.Fn EVP_CIPHER_CTX_block_size
190return the block size. 215return the block size in bytes.
216.Pp
217.Fn EVP_CIPHER_flags
218and
219.Fn EVP_CIPHER_CTX_flags
220return one or more
221.Dv EVP_CIPH_*
222flag bits OR'ed together.
223.Pp
224.Fn EVP_CIPHER_mode
225and
226.Fn EVP_CIPHER_CTX_mode
227return one of the constants
228.Dv EVP_CIPH_ECB_MODE ,
229.Dv EVP_CIPH_CBC_MODE ,
230.Dv EVP_CIPH_CFB_MODE ,
231.Dv EVP_CIPH_OFB_MODE ,
232.Dv EVP_CIPH_CTR_MODE ,
233.Dv EVP_CIPH_GCM_MODE ,
234.Dv EVP_CIPH_CCM_MODE ,
235.Dv EVP_CIPH_XTS_MODE ,
236or
237.Dv EVP_CIPH_WRAP_MODE
238to indicate a block cipher or
239.Dv EVP_CIPH_STREAM_CIPHER
240to indicate a stream cipher.
191.Sh SEE ALSO 241.Sh SEE ALSO
192.Xr evp 3 , 242.Xr evp 3 ,
193.Xr EVP_CIPHER_CTX_ctrl 3 , 243.Xr EVP_CIPHER_CTX_ctrl 3 ,
194.Xr EVP_EncryptInit 3 244.Xr EVP_EncryptInit 3 ,
245.Xr OBJ_nid2obj 3
195.Sh HISTORY 246.Sh HISTORY
196.Fn EVP_CIPHER_type , 247.Fn EVP_CIPHER_type ,
197.Fn EVP_CIPHER_CTX_type , 248.Fn EVP_CIPHER_CTX_type ,
@@ -213,3 +264,13 @@ and
213.Fn EVP_CIPHER_CTX_mode 264.Fn EVP_CIPHER_CTX_mode
214first appeared in OpenSSL 0.9.6 and have been available since 265first appeared in OpenSSL 0.9.6 and have been available since
215.Ox 2.9 . 266.Ox 2.9 .
267.Sh CAVEATS
268The behaviour of the functions taking an
269.Vt EVP_CIPHER_CTX
270argument is undefined if they are called on a
271.Fa ctx
272that has no cipher configured yet, for example one freshly returned from
273.Xr EVP_CIPHER_CTX_new 3 .
274In that case, the program may for example be terminated by a
275.Dv NULL
276pointer access.