diff options
| author | schwarze <> | 2023-09-01 17:28:21 +0000 |
|---|---|---|
| committer | schwarze <> | 2023-09-01 17:28:21 +0000 |
| commit | a8ebdf451a763e357fb64bba5a392fcb2e80953b (patch) | |
| tree | 0593e75021d7dc8663319267b2f09d01de8a86e0 /src | |
| parent | a49f74c21adee71abf506e87b32dcbdbe1b10bb7 (diff) | |
| download | openbsd-a8ebdf451a763e357fb64bba5a392fcb2e80953b.tar.gz openbsd-a8ebdf451a763e357fb64bba5a392fcb2e80953b.tar.bz2 openbsd-a8ebdf451a763e357fb64bba5a392fcb2e80953b.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 '')
| -rw-r--r-- | src/lib/libcrypto/man/EVP_CIPHER_nid.3 | 157 |
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 |
| 127 | and | 128 | returns the numerical identifier (NID) of the |
| 129 | .Fa cipher . | ||
| 130 | The NID is an internal value which may or may not have a corresponding | ||
| 131 | ASN.1 OBJECT IDENTIFIER; see | ||
| 132 | .Xr OBJ_nid2obj 3 | ||
| 133 | for details. | ||
| 134 | .Pp | ||
| 128 | .Fn EVP_CIPHER_CTX_nid | 135 | .Fn EVP_CIPHER_CTX_nid |
| 129 | return the NID of a cipher when passed an | 136 | returns the NID of the cipher that |
| 130 | .Vt EVP_CIPHER | 137 | .Fa ctx |
| 131 | or | 138 | is configured to use. |
| 132 | .Vt EVP_CIPHER_CTX | ||
| 133 | structure. | ||
| 134 | The actual NID value is an internal value which may not have a | ||
| 135 | corresponding OBJECT IDENTIFIER. | ||
| 136 | .Pp | 139 | .Pp |
| 137 | .Fn EVP_CIPHER_type | 140 | .Fn EVP_CIPHER_type |
| 141 | returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the | ||
| 142 | .Fa cipher , | ||
| 143 | ignoring the cipher parameters. | ||
| 144 | For example, | ||
| 145 | .Xr EVP_aes_256_cfb1 3 , | ||
| 146 | .Xr EVP_aes_256_cfb8 3 , | ||
| 138 | and | 147 | and |
| 148 | .Xr EVP_aes_256_cfb128 3 | ||
| 149 | all return the same NID, | ||
| 150 | .Dv NID_aes_256_cfb128 . | ||
| 151 | .Pp | ||
| 139 | .Fn EVP_CIPHER_CTX_type | 152 | .Fn EVP_CIPHER_CTX_type |
| 140 | return the type of the passed cipher or context. | 153 | returns the NID associated with the ASN.1 OBJECT IDENTIFIER of the cipher that |
| 141 | This "type" is the actual NID of the cipher OBJECT IDENTIFIER as such it | 154 | .Fa ctx |
| 142 | ignores the cipher parameters and 40-bit RC2 and 128-bit RC2 have the | 155 | is configured to use. |
| 143 | same NID. | ||
| 144 | If the cipher does not have an object identifier or does not | ||
| 145 | have 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 |
| 149 | and | 158 | returns the block size of the |
| 159 | .Fa cipher | ||
| 160 | in bytes. | ||
| 150 | .Fn EVP_CIPHER_CTX_block_size | 161 | .Fn EVP_CIPHER_CTX_block_size |
| 151 | return the block size of a cipher when passed an | 162 | returns the block size of the cipher that |
| 152 | .Vt EVP_CIPHER | 163 | .Fa ctx |
| 153 | or | 164 | is configured to use. |
| 154 | .Vt EVP_CIPHER_CTX | 165 | Block sizes are guaranteed to be less than or equal to the constant |
| 155 | structure. | 166 | .Dv EVP_MAX_BLOCK_LENGTH . |
| 156 | The constant | 167 | Currently, |
| 157 | .Dv EVP_MAX_BLOCK_LENGTH | 168 | .Xr EVP_CipherInit_ex 3 |
| 158 | is also the maximum block length for all ciphers. | 169 | and the other functions documented in the same manual page |
| 170 | only support block sizes of 1, 8, and 16 bytes. | ||
| 171 | .Pp | ||
| 172 | .Fn EVP_CIPHER_flags | ||
| 173 | returns the cipher flags used by the | ||
| 174 | .Fa cipher . | ||
| 175 | The meaning of the flags is described in the | ||
| 176 | .Xr EVP_CIPHER_meth_set_flags 3 | ||
| 177 | manual page. | ||
| 178 | .Pp | ||
| 179 | .Fn EVP_CIPHER_CTX_flags | ||
| 180 | returns the cipher flags of the cipher that | ||
| 181 | .Fa ctx | ||
| 182 | is configured to use. | ||
| 183 | Be careful to not confuse these with the unrelated cipher context flags | ||
| 184 | that 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 |
| 161 | and | 188 | returns the |
| 189 | .Fa cipher | ||
| 190 | mode, which is the logical AND of the constant | ||
| 191 | .Dv EVP_CIPH_MODE | ||
| 192 | and the return value of | ||
| 193 | .Fn EVP_CIPHER_flags . | ||
| 194 | .Pp | ||
| 162 | .Fn EVP_CIPHER_CTX_mode | 195 | .Fn EVP_CIPHER_CTX_mode |
| 163 | return the block cipher mode: | 196 | returns the cipher mode of the cipher that |
| 164 | .Dv EVP_CIPH_ECB_MODE , | 197 | .Fa ctx |
| 165 | .Dv EVP_CIPH_CBC_MODE , | 198 | is configured to use. |
| 166 | .Dv EVP_CIPH_CFB_MODE , | ||
| 167 | .Dv EVP_CIPH_OFB_MODE , | ||
| 168 | .Dv EVP_CIPH_CTR_MODE , | ||
| 169 | or | ||
| 170 | .Dv EVP_CIPH_XTS_MODE . | ||
| 171 | If the cipher is a stream cipher then | ||
| 172 | .Dv EVP_CIPH_STREAM_CIPHER | ||
| 173 | is returned. | ||
| 174 | .Sh RETURN VALUES | 199 | .Sh RETURN VALUES |
| 175 | .Fn EVP_CIPHER_nid | 200 | .Fn EVP_CIPHER_nid |
| 176 | and | 201 | and |
| 177 | .Fn EVP_CIPHER_CTX_nid | 202 | .Fn EVP_CIPHER_CTX_nid |
| 178 | return a NID. | 203 | return an NID. |
| 179 | .Pp | 204 | .Pp |
| 180 | .Fn EVP_CIPHER_type | 205 | .Fn EVP_CIPHER_type |
| 181 | and | 206 | and |
| 182 | .Fn EVP_CIPHER_CTX_type | 207 | .Fn EVP_CIPHER_CTX_type |
| 183 | return the NID of the cipher's OBJECT IDENTIFIER or | 208 | return the NID of the cipher's OBJECT IDENTIFIER or |
| 184 | .Dv NID_undef | 209 | .Dv NID_undef |
| 185 | if it has no defined OBJECT IDENTIFIER. | 210 | if it is not associated with an OBJECT IDENTIFIER. |
| 186 | .Pp | 211 | .Pp |
| 187 | .Fn EVP_CIPHER_block_size | 212 | .Fn EVP_CIPHER_block_size |
| 188 | and | 213 | and |
| 189 | .Fn EVP_CIPHER_CTX_block_size | 214 | .Fn EVP_CIPHER_CTX_block_size |
| 190 | return the block size. | 215 | return the block size in bytes. |
| 216 | .Pp | ||
| 217 | .Fn EVP_CIPHER_flags | ||
| 218 | and | ||
| 219 | .Fn EVP_CIPHER_CTX_flags | ||
| 220 | return one or more | ||
| 221 | .Dv EVP_CIPH_* | ||
| 222 | flag bits OR'ed together. | ||
| 223 | .Pp | ||
| 224 | .Fn EVP_CIPHER_mode | ||
| 225 | and | ||
| 226 | .Fn EVP_CIPHER_CTX_mode | ||
| 227 | return 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 , | ||
| 236 | or | ||
| 237 | .Dv EVP_CIPH_WRAP_MODE | ||
| 238 | to indicate a block cipher or | ||
| 239 | .Dv EVP_CIPH_STREAM_CIPHER | ||
| 240 | to 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 |
| 214 | first appeared in OpenSSL 0.9.6 and have been available since | 265 | first appeared in OpenSSL 0.9.6 and have been available since |
| 215 | .Ox 2.9 . | 266 | .Ox 2.9 . |
| 267 | .Sh CAVEATS | ||
| 268 | The behaviour of the functions taking an | ||
| 269 | .Vt EVP_CIPHER_CTX | ||
| 270 | argument is undefined if they are called on a | ||
| 271 | .Fa ctx | ||
| 272 | that has no cipher configured yet, for example one freshly returned from | ||
| 273 | .Xr EVP_CIPHER_CTX_new 3 . | ||
| 274 | In that case, the program may for example be terminated by a | ||
| 275 | .Dv NULL | ||
| 276 | pointer access. | ||
