diff options
Diffstat (limited to 'src/lib/libcrypto/man/DES_set_key.3')
| -rw-r--r-- | src/lib/libcrypto/man/DES_set_key.3 | 787 |
1 files changed, 0 insertions, 787 deletions
diff --git a/src/lib/libcrypto/man/DES_set_key.3 b/src/lib/libcrypto/man/DES_set_key.3 deleted file mode 100644 index fd09d77730..0000000000 --- a/src/lib/libcrypto/man/DES_set_key.3 +++ /dev/null | |||
| @@ -1,787 +0,0 @@ | |||
| 1 | .\" $OpenBSD: DES_set_key.3,v 1.17 2024/05/24 19:18:07 tb Exp $ | ||
| 2 | .\" full merge up to: | ||
| 3 | .\" OpenSSL man3/DES_random_key 521738e9 Oct 5 14:58:30 2018 -0400 | ||
| 4 | .\" | ||
| 5 | .\" -------------------------------------------------------------------------- | ||
| 6 | .\" Major patches to this file were contributed by | ||
| 7 | .\" Ulf Moeller <ulf@openssl.org>, Ben Laurie <ben@openssl.org>, | ||
| 8 | .\" and Richard Levitte <levitte@openssl.org>. | ||
| 9 | .\" -------------------------------------------------------------------------- | ||
| 10 | .\" Copyright (c) 2000, 2001, 2017 The OpenSSL Project. All rights reserved. | ||
| 11 | .\" | ||
| 12 | .\" Redistribution and use in source and binary forms, with or without | ||
| 13 | .\" modification, are permitted provided that the following conditions | ||
| 14 | .\" are met: | ||
| 15 | .\" | ||
| 16 | .\" 1. Redistributions of source code must retain the above copyright | ||
| 17 | .\" notice, this list of conditions and the following disclaimer. | ||
| 18 | .\" | ||
| 19 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 20 | .\" notice, this list of conditions and the following disclaimer in | ||
| 21 | .\" the documentation and/or other materials provided with the | ||
| 22 | .\" distribution. | ||
| 23 | .\" | ||
| 24 | .\" 3. All advertising materials mentioning features or use of this | ||
| 25 | .\" software must display the following acknowledgment: | ||
| 26 | .\" "This product includes software developed by the OpenSSL Project | ||
| 27 | .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)" | ||
| 28 | .\" | ||
| 29 | .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to | ||
| 30 | .\" endorse or promote products derived from this software without | ||
| 31 | .\" prior written permission. For written permission, please contact | ||
| 32 | .\" openssl-core@openssl.org. | ||
| 33 | .\" | ||
| 34 | .\" 5. Products derived from this software may not be called "OpenSSL" | ||
| 35 | .\" nor may "OpenSSL" appear in their names without prior written | ||
| 36 | .\" permission of the OpenSSL Project. | ||
| 37 | .\" | ||
| 38 | .\" 6. Redistributions of any form whatsoever must retain the following | ||
| 39 | .\" acknowledgment: | ||
| 40 | .\" "This product includes software developed by the OpenSSL Project | ||
| 41 | .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)" | ||
| 42 | .\" | ||
| 43 | .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY | ||
| 44 | .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 45 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 46 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR | ||
| 47 | .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| 48 | .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
| 49 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
| 50 | .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 51 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 52 | .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 53 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 54 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 55 | .\" | ||
| 56 | .\" -------------------------------------------------------------------------- | ||
| 57 | .\" Parts of this file are derived from SSLeay documentation, | ||
| 58 | .\" which is covered by the following Copyright and license: | ||
| 59 | .\" -------------------------------------------------------------------------- | ||
| 60 | .\" | ||
| 61 | .\" Copyright (C) 1995-1998 Tim Hudson (tjh@cryptsoft.com) | ||
| 62 | .\" All rights reserved. | ||
| 63 | .\" | ||
| 64 | .\" This package is an SSL implementation written | ||
| 65 | .\" by Eric Young (eay@cryptsoft.com). | ||
| 66 | .\" The implementation was written so as to conform with Netscapes SSL. | ||
| 67 | .\" | ||
| 68 | .\" This library is free for commercial and non-commercial use as long as | ||
| 69 | .\" the following conditions are aheared to. The following conditions | ||
| 70 | .\" apply to all code found in this distribution, be it the RC4, RSA, | ||
| 71 | .\" lhash, DES, etc., code; not just the SSL code. The SSL documentation | ||
| 72 | .\" included with this distribution is covered by the same copyright terms | ||
| 73 | .\" except that the holder is Tim Hudson (tjh@cryptsoft.com). | ||
| 74 | .\" | ||
| 75 | .\" Copyright remains Eric Young's, and as such any Copyright notices in | ||
| 76 | .\" the code are not to be removed. | ||
| 77 | .\" If this package is used in a product, Eric Young should be given | ||
| 78 | .\" attribution as the author of the parts of the library used. | ||
| 79 | .\" This can be in the form of a textual message at program startup or | ||
| 80 | .\" in documentation (online or textual) provided with the package. | ||
| 81 | .\" | ||
| 82 | .\" Redistribution and use in source and binary forms, with or without | ||
| 83 | .\" modification, are permitted provided that the following conditions | ||
| 84 | .\" are met: | ||
| 85 | .\" 1. Redistributions of source code must retain the copyright | ||
| 86 | .\" notice, this list of conditions and the following disclaimer. | ||
| 87 | .\" 2. Redistributions in binary form must reproduce the above copyright | ||
| 88 | .\" notice, this list of conditions and the following disclaimer in the | ||
| 89 | .\" documentation and/or other materials provided with the distribution. | ||
| 90 | .\" 3. All advertising materials mentioning features or use of this software | ||
| 91 | .\" must display the following acknowledgement: | ||
| 92 | .\" "This product includes cryptographic software written by | ||
| 93 | .\" Eric Young (eay@cryptsoft.com)" | ||
| 94 | .\" The word 'cryptographic' can be left out if the rouines from the | ||
| 95 | .\" library being used are not cryptographic related :-). | ||
| 96 | .\" 4. If you include any Windows specific code (or a derivative thereof) | ||
| 97 | .\" from the apps directory (application code) you must include an | ||
| 98 | .\" acknowledgement: "This product includes software written by | ||
| 99 | .\" Tim Hudson (tjh@cryptsoft.com)" | ||
| 100 | .\" | ||
| 101 | .\" THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | ||
| 102 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 103 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 104 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | ||
| 105 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 106 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 107 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 108 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 109 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 110 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 111 | .\" SUCH DAMAGE. | ||
| 112 | .\" | ||
| 113 | .\" The licence and distribution terms for any publically available version or | ||
| 114 | .\" derivative of this code cannot be changed. i.e. this code cannot simply be | ||
| 115 | .\" copied and put under another distribution licence | ||
| 116 | .\" [including the GNU Public Licence.] | ||
| 117 | .\" | ||
| 118 | .Dd $Mdocdate: May 24 2024 $ | ||
| 119 | .Dt DES_SET_KEY 3 | ||
| 120 | .Os | ||
| 121 | .Sh NAME | ||
| 122 | .Nm DES_random_key , | ||
| 123 | .Nm DES_set_key , | ||
| 124 | .Nm DES_key_sched , | ||
| 125 | .Nm DES_set_key_checked , | ||
| 126 | .Nm DES_set_key_unchecked , | ||
| 127 | .Nm DES_set_odd_parity , | ||
| 128 | .Nm DES_is_weak_key , | ||
| 129 | .Nm DES_ecb_encrypt , | ||
| 130 | .Nm DES_ecb2_encrypt , | ||
| 131 | .Nm DES_ecb3_encrypt , | ||
| 132 | .Nm DES_ncbc_encrypt , | ||
| 133 | .Nm DES_cfb_encrypt , | ||
| 134 | .Nm DES_ofb_encrypt , | ||
| 135 | .Nm DES_pcbc_encrypt , | ||
| 136 | .Nm DES_cfb64_encrypt , | ||
| 137 | .Nm DES_ofb64_encrypt , | ||
| 138 | .Nm DES_xcbc_encrypt , | ||
| 139 | .Nm DES_ede2_cbc_encrypt , | ||
| 140 | .Nm DES_ede2_cfb64_encrypt , | ||
| 141 | .Nm DES_ede2_ofb64_encrypt , | ||
| 142 | .Nm DES_ede3_cbc_encrypt , | ||
| 143 | .Nm DES_ede3_cbcm_encrypt , | ||
| 144 | .Nm DES_ede3_cfb64_encrypt , | ||
| 145 | .Nm DES_ede3_ofb64_encrypt , | ||
| 146 | .Nm DES_cbc_cksum , | ||
| 147 | .Nm DES_quad_cksum , | ||
| 148 | .Nm DES_string_to_key , | ||
| 149 | .Nm DES_string_to_2keys , | ||
| 150 | .Nm DES_fcrypt , | ||
| 151 | .Nm DES_crypt | ||
| 152 | .Nd DES encryption | ||
| 153 | .Sh SYNOPSIS | ||
| 154 | .In openssl/des.h | ||
| 155 | .Ft void | ||
| 156 | .Fo DES_random_key | ||
| 157 | .Fa "DES_cblock *ret" | ||
| 158 | .Fc | ||
| 159 | .Ft int | ||
| 160 | .Fo DES_set_key | ||
| 161 | .Fa "const_DES_cblock *key" | ||
| 162 | .Fa "DES_key_schedule *schedule" | ||
| 163 | .Fc | ||
| 164 | .Ft int | ||
| 165 | .Fo DES_key_sched | ||
| 166 | .Fa "const_DES_cblock *key" | ||
| 167 | .Fa "DES_key_schedule *schedule" | ||
| 168 | .Fc | ||
| 169 | .Ft int | ||
| 170 | .Fo DES_set_key_checked | ||
| 171 | .Fa "const_DES_cblock *key" | ||
| 172 | .Fa "DES_key_schedule *schedule" | ||
| 173 | .Fc | ||
| 174 | .Ft void | ||
| 175 | .Fo DES_set_key_unchecked | ||
| 176 | .Fa "const_DES_cblock *key" | ||
| 177 | .Fa "DES_key_schedule *schedule" | ||
| 178 | .Fc | ||
| 179 | .Ft void | ||
| 180 | .Fo DES_set_odd_parity | ||
| 181 | .Fa "DES_cblock *key" | ||
| 182 | .Fc | ||
| 183 | .Ft int | ||
| 184 | .Fo DES_is_weak_key | ||
| 185 | .Fa "const_DES_cblock *key" | ||
| 186 | .Fc | ||
| 187 | .Ft void | ||
| 188 | .Fo DES_ecb_encrypt | ||
| 189 | .Fa "const_DES_cblock *input" | ||
| 190 | .Fa "DES_cblock *output" | ||
| 191 | .Fa "DES_key_schedule *ks" | ||
| 192 | .Fa "int enc" | ||
| 193 | .Fc | ||
| 194 | .Ft void | ||
| 195 | .Fo DES_ecb2_encrypt | ||
| 196 | .Fa "const_DES_cblock *input" | ||
| 197 | .Fa "DES_cblock *output" | ||
| 198 | .Fa "DES_key_schedule *ks1" | ||
| 199 | .Fa "DES_key_schedule *ks2" | ||
| 200 | .Fa "int enc" | ||
| 201 | .Fc | ||
| 202 | .Ft void | ||
| 203 | .Fo DES_ecb3_encrypt | ||
| 204 | .Fa "const_DES_cblock *input" | ||
| 205 | .Fa "DES_cblock *output" | ||
| 206 | .Fa "DES_key_schedule *ks1" | ||
| 207 | .Fa "DES_key_schedule *ks2" | ||
| 208 | .Fa "DES_key_schedule *ks3" | ||
| 209 | .Fa "int enc" | ||
| 210 | .Fc | ||
| 211 | .Ft void | ||
| 212 | .Fo DES_ncbc_encrypt | ||
| 213 | .Fa "const unsigned char *input" | ||
| 214 | .Fa "unsigned char *output" | ||
| 215 | .Fa "long length" | ||
| 216 | .Fa "DES_key_schedule *schedule" | ||
| 217 | .Fa "DES_cblock *ivec" | ||
| 218 | .Fa "int enc" | ||
| 219 | .Fc | ||
| 220 | .Ft void | ||
| 221 | .Fo DES_cfb_encrypt | ||
| 222 | .Fa "const unsigned char *in" | ||
| 223 | .Fa "unsigned char *out" | ||
| 224 | .Fa "int numbits" | ||
| 225 | .Fa "long length" | ||
| 226 | .Fa "DES_key_schedule *schedule" | ||
| 227 | .Fa "DES_cblock *ivec" | ||
| 228 | .Fa "int enc" | ||
| 229 | .Fc | ||
| 230 | .Ft void | ||
| 231 | .Fo DES_ofb_encrypt | ||
| 232 | .Fa "const unsigned char *in" | ||
| 233 | .Fa "unsigned char *out" | ||
| 234 | .Fa "int numbits" | ||
| 235 | .Fa "long length" | ||
| 236 | .Fa "DES_key_schedule *schedule" | ||
| 237 | .Fa "DES_cblock *ivec" | ||
| 238 | .Fc | ||
| 239 | .Ft void | ||
| 240 | .Fo DES_pcbc_encrypt | ||
| 241 | .Fa "const unsigned char *input" | ||
| 242 | .Fa "unsigned char *output" | ||
| 243 | .Fa "long length" | ||
| 244 | .Fa "DES_key_schedule *schedule" | ||
| 245 | .Fa "DES_cblock *ivec" | ||
| 246 | .Fa "int enc" | ||
| 247 | .Fc | ||
| 248 | .Ft void | ||
| 249 | .Fo DES_cfb64_encrypt | ||
| 250 | .Fa "const unsigned char *in" | ||
| 251 | .Fa "unsigned char *out" | ||
| 252 | .Fa "long length" | ||
| 253 | .Fa "DES_key_schedule *schedule" | ||
| 254 | .Fa "DES_cblock *ivec" | ||
| 255 | .Fa "int *num" | ||
| 256 | .Fa "int enc" | ||
| 257 | .Fc | ||
| 258 | .Ft void | ||
| 259 | .Fo DES_ofb64_encrypt | ||
| 260 | .Fa "const unsigned char *in" | ||
| 261 | .Fa "unsigned char *out" | ||
| 262 | .Fa "long length" | ||
| 263 | .Fa "DES_key_schedule *schedule" | ||
| 264 | .Fa "DES_cblock *ivec" | ||
| 265 | .Fa "int *num" | ||
| 266 | .Fc | ||
| 267 | .Ft void | ||
| 268 | .Fo DES_xcbc_encrypt | ||
| 269 | .Fa "const unsigned char *input" | ||
| 270 | .Fa "unsigned char *output" | ||
| 271 | .Fa "long length" | ||
| 272 | .Fa "DES_key_schedule *schedule" | ||
| 273 | .Fa "DES_cblock *ivec" | ||
| 274 | .Fa "const_DES_cblock *inw" | ||
| 275 | .Fa "const_DES_cblock *outw" | ||
| 276 | .Fa "int enc" | ||
| 277 | .Fc | ||
| 278 | .Ft void | ||
| 279 | .Fo DES_ede2_cbc_encrypt | ||
| 280 | .Fa "const unsigned char *input" | ||
| 281 | .Fa "unsigned char *output" | ||
| 282 | .Fa "long length" | ||
| 283 | .Fa "DES_key_schedule *ks1" | ||
| 284 | .Fa "DES_key_schedule *ks2" | ||
| 285 | .Fa "DES_cblock *ivec" | ||
| 286 | .Fa "int enc" | ||
| 287 | .Fc | ||
| 288 | .Ft void | ||
| 289 | .Fo DES_ede2_cfb64_encrypt | ||
| 290 | .Fa "const unsigned char *in" | ||
| 291 | .Fa "unsigned char *out" | ||
| 292 | .Fa "long length" | ||
| 293 | .Fa "DES_key_schedule *ks1" | ||
| 294 | .Fa "DES_key_schedule *ks2" | ||
| 295 | .Fa "DES_cblock *ivec" | ||
| 296 | .Fa "int *num" | ||
| 297 | .Fa "int enc" | ||
| 298 | .Fc | ||
| 299 | .Ft void | ||
| 300 | .Fo DES_ede2_ofb64_encrypt | ||
| 301 | .Fa "const unsigned char *in" | ||
| 302 | .Fa "unsigned char *out" | ||
| 303 | .Fa "long length" | ||
| 304 | .Fa "DES_key_schedule *ks1" | ||
| 305 | .Fa "DES_key_schedule *ks2" | ||
| 306 | .Fa "DES_cblock *ivec" | ||
| 307 | .Fa "int *num" | ||
| 308 | .Fc | ||
| 309 | .Ft void | ||
| 310 | .Fo DES_ede3_cbc_encrypt | ||
| 311 | .Fa "const unsigned char *input" | ||
| 312 | .Fa "unsigned char *output" | ||
| 313 | .Fa "long length" | ||
| 314 | .Fa "DES_key_schedule *ks1" | ||
| 315 | .Fa "DES_key_schedule *ks2" | ||
| 316 | .Fa "DES_key_schedule *ks3" | ||
| 317 | .Fa "DES_cblock *ivec" | ||
| 318 | .Fa "int enc" | ||
| 319 | .Fc | ||
| 320 | .Ft void | ||
| 321 | .Fo DES_ede3_cbcm_encrypt | ||
| 322 | .Fa "const unsigned char *in" | ||
| 323 | .Fa "unsigned char *out" | ||
| 324 | .Fa "long length" | ||
| 325 | .Fa "DES_key_schedule *ks1" | ||
| 326 | .Fa "DES_key_schedule *ks2" | ||
| 327 | .Fa "DES_key_schedule *ks3" | ||
| 328 | .Fa "DES_cblock *ivec1" | ||
| 329 | .Fa "DES_cblock *ivec2" | ||
| 330 | .Fa "int enc" | ||
| 331 | .Fc | ||
| 332 | .Ft void | ||
| 333 | .Fo DES_ede3_cfb64_encrypt | ||
| 334 | .Fa "const unsigned char *in" | ||
| 335 | .Fa "unsigned char *out" | ||
| 336 | .Fa "long length" | ||
| 337 | .Fa "DES_key_schedule *ks1" | ||
| 338 | .Fa "DES_key_schedule *ks2" | ||
| 339 | .Fa "DES_key_schedule *ks3" | ||
| 340 | .Fa "DES_cblock *ivec" | ||
| 341 | .Fa "int *num" | ||
| 342 | .Fa "int enc" | ||
| 343 | .Fc | ||
| 344 | .Ft void | ||
| 345 | .Fo DES_ede3_ofb64_encrypt | ||
| 346 | .Fa "const unsigned char *in" | ||
| 347 | .Fa "unsigned char *out" | ||
| 348 | .Fa "long length" | ||
| 349 | .Fa "DES_key_schedule *ks1" | ||
| 350 | .Fa "DES_key_schedule *ks2" | ||
| 351 | .Fa "DES_key_schedule *ks3" | ||
| 352 | .Fa "DES_cblock *ivec" | ||
| 353 | .Fa "int *num" | ||
| 354 | .Fc | ||
| 355 | .Ft DES_LONG | ||
| 356 | .Fo DES_cbc_cksum | ||
| 357 | .Fa "const unsigned char *input" | ||
| 358 | .Fa "DES_cblock *output" | ||
| 359 | .Fa "long length" | ||
| 360 | .Fa "DES_key_schedule *schedule" | ||
| 361 | .Fa "const_DES_cblock *ivec" | ||
| 362 | .Fc | ||
| 363 | .Ft DES_LONG | ||
| 364 | .Fo DES_quad_cksum | ||
| 365 | .Fa "const unsigned char *input" | ||
| 366 | .Fa "DES_cblock output[]" | ||
| 367 | .Fa "long length" | ||
| 368 | .Fa "int out_count" | ||
| 369 | .Fa "DES_cblock *seed" | ||
| 370 | .Fc | ||
| 371 | .Ft void | ||
| 372 | .Fo DES_string_to_key | ||
| 373 | .Fa "const char *str" | ||
| 374 | .Fa "DES_cblock *key" | ||
| 375 | .Fc | ||
| 376 | .Ft void | ||
| 377 | .Fo DES_string_to_2keys | ||
| 378 | .Fa "const char *str" | ||
| 379 | .Fa "DES_cblock *key1" | ||
| 380 | .Fa "DES_cblock *key2" | ||
| 381 | .Fc | ||
| 382 | .Ft char * | ||
| 383 | .Fo DES_fcrypt | ||
| 384 | .Fa "const char *buf" | ||
| 385 | .Fa "const char *salt" | ||
| 386 | .Fa "char *ret" | ||
| 387 | .Fc | ||
| 388 | .Ft char * | ||
| 389 | .Fo DES_crypt | ||
| 390 | .Fa "const char *buf" | ||
| 391 | .Fa "const char *salt" | ||
| 392 | .Fc | ||
| 393 | .Sh DESCRIPTION | ||
| 394 | This library contains a fast implementation of the DES encryption | ||
| 395 | algorithm. | ||
| 396 | .Pp | ||
| 397 | There are two phases to the use of DES encryption. | ||
| 398 | The first is the generation of a | ||
| 399 | .Vt DES_key_schedule | ||
| 400 | from a key, and the second is the actual encryption. | ||
| 401 | A DES key is of type | ||
| 402 | .Vt DES_cblock . | ||
| 403 | This type consists of 8 bytes with odd parity. | ||
| 404 | The least significant bit in each byte is the parity bit. | ||
| 405 | The key schedule is an expanded form of the key; it is used to speed the | ||
| 406 | encryption process. | ||
| 407 | .Pp | ||
| 408 | .Fn DES_random_key | ||
| 409 | generates a random key in odd parity. | ||
| 410 | .Pp | ||
| 411 | Before a DES key can be used, it must be converted into the architecture | ||
| 412 | dependent | ||
| 413 | .Vt DES_key_schedule | ||
| 414 | via the | ||
| 415 | .Fn DES_set_key_checked | ||
| 416 | or | ||
| 417 | .Fn DES_set_key_unchecked | ||
| 418 | function. | ||
| 419 | .Pp | ||
| 420 | .Fn DES_set_key_checked | ||
| 421 | will check that the key passed is of odd parity and is not a weak or | ||
| 422 | semi-weak key. | ||
| 423 | If the parity is wrong, then -1 is returned. | ||
| 424 | If the key is a weak key, then -2 is returned. | ||
| 425 | If an error is returned, the key schedule is not generated. | ||
| 426 | .Pp | ||
| 427 | .Fn DES_set_key | ||
| 428 | works like | ||
| 429 | .Fn DES_set_key_checked | ||
| 430 | if the | ||
| 431 | .Em DES_check_key | ||
| 432 | flag is non-zero, otherwise like | ||
| 433 | .Fn DES_set_key_unchecked . | ||
| 434 | These functions are available for compatibility; it is recommended to | ||
| 435 | use a function that does not depend on a global variable. | ||
| 436 | .Pp | ||
| 437 | .Fn DES_set_odd_parity | ||
| 438 | sets the parity of the passed | ||
| 439 | .Fa key | ||
| 440 | to odd. | ||
| 441 | .Pp | ||
| 442 | The following routines mostly operate on an input and output stream of | ||
| 443 | .Vt DES_cblock Ns s . | ||
| 444 | .Pp | ||
| 445 | .Fn DES_ecb_encrypt | ||
| 446 | is the basic DES encryption routine that encrypts or decrypts a single | ||
| 447 | 8-byte | ||
| 448 | .Vt DES_cblock | ||
| 449 | in electronic code book (ECB) mode. | ||
| 450 | It always transforms the input data, pointed to by | ||
| 451 | .Fa input , | ||
| 452 | into the output data, pointed to by the | ||
| 453 | .Fa output | ||
| 454 | argument. | ||
| 455 | If the | ||
| 456 | .Fa enc | ||
| 457 | argument is non-zero | ||
| 458 | .Pq Dv DES_ENCRYPT , | ||
| 459 | the | ||
| 460 | .Fa input | ||
| 461 | (cleartext) is encrypted into the | ||
| 462 | .Fa output | ||
| 463 | (ciphertext) using the key_schedule specified by the | ||
| 464 | .Fa schedule | ||
| 465 | argument, previously set via | ||
| 466 | .Fn DES_set_key . | ||
| 467 | If | ||
| 468 | .Fa enc | ||
| 469 | is zero | ||
| 470 | .Pq Dv DES_DECRYPT , | ||
| 471 | the | ||
| 472 | .Fa input | ||
| 473 | (now ciphertext) is decrypted into the | ||
| 474 | .Fa output | ||
| 475 | (now cleartext). | ||
| 476 | Input and output may overlap. | ||
| 477 | .Fn DES_ecb_encrypt | ||
| 478 | does not return a value. | ||
| 479 | .Pp | ||
| 480 | .Fn DES_ecb3_encrypt | ||
| 481 | encrypts/decrypts the | ||
| 482 | .Fa input | ||
| 483 | block by using three-key Triple-DES encryption in ECB mode. | ||
| 484 | This involves encrypting the input with | ||
| 485 | .Fa ks1 , | ||
| 486 | decrypting with the key schedule | ||
| 487 | .Fa ks2 , | ||
| 488 | and then encrypting with | ||
| 489 | .Fa ks3 . | ||
| 490 | This routine greatly reduces the chances of brute force breaking of DES | ||
| 491 | and has the advantage of if | ||
| 492 | .Fa ks1 , | ||
| 493 | .Fa ks2 , | ||
| 494 | and | ||
| 495 | .Fa ks3 | ||
| 496 | are the same, it is equivalent to just encryption using ECB mode and | ||
| 497 | .Fa ks1 | ||
| 498 | as the key. | ||
| 499 | .Pp | ||
| 500 | The macro | ||
| 501 | .Fn DES_ecb2_encrypt | ||
| 502 | is provided to perform two-key Triple-DES encryption by using | ||
| 503 | .Fa ks1 | ||
| 504 | for the final encryption. | ||
| 505 | .Pp | ||
| 506 | .Fn DES_ncbc_encrypt | ||
| 507 | encrypts/decrypts using the cipher-block-chaining (CBC) mode of DES. | ||
| 508 | If the | ||
| 509 | .Fa enc | ||
| 510 | argument is non-zero, the routine cipher-block-chain encrypts the | ||
| 511 | cleartext data pointed to by the | ||
| 512 | .Fa input | ||
| 513 | argument into the ciphertext pointed to by the | ||
| 514 | .Fa output | ||
| 515 | argument, using the key schedule provided by the | ||
| 516 | .Fa schedule | ||
| 517 | argument, and initialization vector provided by the | ||
| 518 | .Fa ivec | ||
| 519 | argument. | ||
| 520 | If the | ||
| 521 | .Fa length | ||
| 522 | argument is not an integral multiple of eight bytes, the last block is | ||
| 523 | copied to a temporary area and zero filled. | ||
| 524 | The output is always an integral multiple of eight bytes. | ||
| 525 | .Pp | ||
| 526 | .Fn DES_xcbc_encrypt | ||
| 527 | is RSA's DESX mode of DES. | ||
| 528 | It uses | ||
| 529 | .Fa inw | ||
| 530 | and | ||
| 531 | .Fa outw | ||
| 532 | to "whiten" the encryption. | ||
| 533 | .Fa inw | ||
| 534 | and | ||
| 535 | .Fa outw | ||
| 536 | are secret (unlike the iv) and are as such, part of the key. | ||
| 537 | So the key is sort of 24 bytes. | ||
| 538 | This is much better than CBC DES. | ||
| 539 | .Pp | ||
| 540 | .Fn DES_ede3_cbc_encrypt | ||
| 541 | implements outer triple CBC DES encryption with three keys. | ||
| 542 | This means that each DES operation inside the CBC mode is | ||
| 543 | .Qq Li C=E(ks3,D(ks2,E(ks1,M))) . | ||
| 544 | This mode is used by SSL. | ||
| 545 | .Pp | ||
| 546 | The | ||
| 547 | .Fn DES_ede2_cbc_encrypt | ||
| 548 | macro implements two-key Triple-DES by reusing | ||
| 549 | .Fa ks1 | ||
| 550 | for the final encryption. | ||
| 551 | .Qq Li C=E(ks1,D(ks2,E(ks1,M))) . | ||
| 552 | This form of Triple-DES is used by the RSAREF library. | ||
| 553 | .Pp | ||
| 554 | .Fn DES_pcbc_encrypt | ||
| 555 | encrypts/decrypts using the propagating cipher block chaining mode used | ||
| 556 | by Kerberos v4. | ||
| 557 | Its parameters are the same as | ||
| 558 | .Fn DES_ncbc_encrypt . | ||
| 559 | .Pp | ||
| 560 | .Fn DES_cfb_encrypt | ||
| 561 | encrypts/decrypts using cipher feedback mode. | ||
| 562 | This method takes an array of characters as input and outputs an array | ||
| 563 | of characters. | ||
| 564 | It does not require any padding to 8 character groups. | ||
| 565 | Note: the | ||
| 566 | .Fa ivec | ||
| 567 | variable is changed and the new changed value needs to be passed to the | ||
| 568 | next call to this function. | ||
| 569 | Since this function runs a complete DES ECB encryption per | ||
| 570 | .Fa numbits , | ||
| 571 | this function is only suggested for use when sending a small number of | ||
| 572 | characters. | ||
| 573 | .Pp | ||
| 574 | .Fn DES_cfb64_encrypt | ||
| 575 | implements CFB mode of DES with 64-bit feedback. | ||
| 576 | Why is this useful you ask? | ||
| 577 | Because this routine will allow you to encrypt an arbitrary number of | ||
| 578 | bytes, without 8 byte padding. | ||
| 579 | Each call to this routine will encrypt the input bytes to output and | ||
| 580 | then update ivec and num. | ||
| 581 | num contains "how far" we are though ivec. | ||
| 582 | If this does not make much sense, read more about CFB mode of DES. | ||
| 583 | .Pp | ||
| 584 | The | ||
| 585 | .Fn DES_ede3_cfb64_encrypt | ||
| 586 | function and the | ||
| 587 | .Fn DES_ede2_cfb64_encrypt | ||
| 588 | macro are the same as | ||
| 589 | .Fn DES_cfb64_encrypt | ||
| 590 | except that Triple-DES is used. | ||
| 591 | .Pp | ||
| 592 | .Fn DES_ofb_encrypt | ||
| 593 | encrypts using output feedback mode. | ||
| 594 | This method takes an array of characters as input and outputs an array | ||
| 595 | of characters. | ||
| 596 | It does not require any padding to 8 character groups. | ||
| 597 | Note: the | ||
| 598 | .Fa ivec | ||
| 599 | variable is changed and the new changed value needs to be passed to the | ||
| 600 | next call to this function. | ||
| 601 | Since this function runs a complete DES ECB encryption per | ||
| 602 | .Fa numbits , | ||
| 603 | this function is only suggested for use when sending a small number | ||
| 604 | of characters. | ||
| 605 | .Pp | ||
| 606 | .Fn DES_ofb64_encrypt | ||
| 607 | is the same as | ||
| 608 | .Fn DES_cfb64_encrypt | ||
| 609 | using Output Feed Back mode. | ||
| 610 | .Pp | ||
| 611 | The | ||
| 612 | .Fn DES_ede3_ofb64_encrypt | ||
| 613 | function and the | ||
| 614 | .Fn DES_ede2_ofb64_encrypt | ||
| 615 | macro are the same as | ||
| 616 | .Fn DES_ofb64_encrypt , | ||
| 617 | using Triple-DES. | ||
| 618 | .Pp | ||
| 619 | The following functions are included in the DES library for | ||
| 620 | compatibility with the MIT Kerberos library. | ||
| 621 | .Pp | ||
| 622 | .Fn DES_cbc_cksum | ||
| 623 | produces an 8-byte checksum based on the input stream (via CBC | ||
| 624 | encryption). | ||
| 625 | The last 4 bytes of the checksum are returned and the complete 8 bytes | ||
| 626 | are placed in | ||
| 627 | .Fa output . | ||
| 628 | This function is used by Kerberos v4. | ||
| 629 | Other applications should use | ||
| 630 | .Xr EVP_DigestInit 3 | ||
| 631 | etc. instead. | ||
| 632 | .Pp | ||
| 633 | .Fn DES_quad_cksum | ||
| 634 | is a Kerberos v4 function. | ||
| 635 | It returns a 4-byte checksum from the input bytes. | ||
| 636 | The algorithm can be iterated over the input, depending on | ||
| 637 | .Fa out_count , | ||
| 638 | 1, 2, 3 or 4 times. | ||
| 639 | If | ||
| 640 | .Fa output | ||
| 641 | is | ||
| 642 | .Pf non- Dv NULL , | ||
| 643 | the 8 bytes generated by each pass are written into | ||
| 644 | .Fa output . | ||
| 645 | .Pp | ||
| 646 | The following are DES-based transformations: | ||
| 647 | .Pp | ||
| 648 | .Fn DES_fcrypt | ||
| 649 | is a fast version of the Unix | ||
| 650 | .Xr crypt 3 | ||
| 651 | function. | ||
| 652 | The | ||
| 653 | .Fa salt | ||
| 654 | must be two ASCII characters. | ||
| 655 | This version is different from the normal crypt in that the third | ||
| 656 | parameter is the buffer that the return value is written into. | ||
| 657 | It needs to be at least 14 bytes long. | ||
| 658 | The fourteenth byte is set to NUL. | ||
| 659 | This version takes only a small amount of space relative to other | ||
| 660 | fast crypt implementations. | ||
| 661 | It is thread safe, unlike the normal crypt. | ||
| 662 | .Pp | ||
| 663 | .Fn DES_crypt | ||
| 664 | is a faster replacement for the normal system | ||
| 665 | .Xr crypt 3 . | ||
| 666 | This function calls | ||
| 667 | .Fn DES_fcrypt | ||
| 668 | with a static array passed as the third parameter. | ||
| 669 | This emulates the normal non-thread safe semantics of | ||
| 670 | .Xr crypt 3 . | ||
| 671 | .Sh RETURN VALUES | ||
| 672 | .Fn DES_set_key , | ||
| 673 | .Fn DES_key_sched , | ||
| 674 | and | ||
| 675 | .Fn DES_set_key_checked | ||
| 676 | return 0 on success or a negative value on error. | ||
| 677 | .Pp | ||
| 678 | .Fn DES_is_weak_key | ||
| 679 | returns 1 if the passed key is a weak key or 0 if it is ok. | ||
| 680 | .Pp | ||
| 681 | .Fn DES_cbc_cksum | ||
| 682 | and | ||
| 683 | .Fn DES_quad_cksum | ||
| 684 | return a 4-byte integer representing the last 4 bytes of the checksum | ||
| 685 | of the input. | ||
| 686 | .Pp | ||
| 687 | .Fn DES_fcrypt | ||
| 688 | returns a pointer to the caller-provided buffer | ||
| 689 | .Fa ret , | ||
| 690 | and | ||
| 691 | .Fn DES_crypt | ||
| 692 | returns a pointer to a static buffer. | ||
| 693 | Both are allowed to return | ||
| 694 | .Dv NULL | ||
| 695 | to indicate failure, but currently, they cannot fail. | ||
| 696 | .Sh SEE ALSO | ||
| 697 | .Xr crypt 3 , | ||
| 698 | .Xr EVP_des_cbc 3 , | ||
| 699 | .Xr EVP_EncryptInit 3 | ||
| 700 | .Sh STANDARDS | ||
| 701 | ANSI X3.106 | ||
| 702 | .Pp | ||
| 703 | The DES library was initially written to be source code compatible | ||
| 704 | with the MIT Kerberos library. | ||
| 705 | .Sh HISTORY | ||
| 706 | .Fn DES_random_key , | ||
| 707 | .Fn DES_set_key , | ||
| 708 | .Fn DES_key_sched , | ||
| 709 | .Fn DES_set_odd_parity , | ||
| 710 | .Fn DES_is_weak_key , | ||
| 711 | .Fn DES_ecb_encrypt , | ||
| 712 | .Fn DES_cfb_encrypt , | ||
| 713 | .Fn DES_ofb_encrypt , | ||
| 714 | .Fn DES_pcbc_encrypt , | ||
| 715 | .Fn DES_cfb64_encrypt , | ||
| 716 | .Fn DES_ofb64_encrypt , | ||
| 717 | .Fn DES_ede3_cbc_encrypt , | ||
| 718 | .Fn DES_cbc_cksum , | ||
| 719 | .Fn DES_quad_cksum , | ||
| 720 | .Fn DES_string_to_key , | ||
| 721 | .Fn DES_string_to_2keys , | ||
| 722 | and | ||
| 723 | .Fn DES_crypt | ||
| 724 | appeared in SSLeay 0.4 or earlier. | ||
| 725 | .Fn DES_ncbc_encrypt | ||
| 726 | first appeared in SSLeay 0.4.2. | ||
| 727 | .Fn DES_ede2_cbc_encrypt | ||
| 728 | first appeared in SSLeay 0.4.4. | ||
| 729 | .Fn DES_ecb2_encrypt , | ||
| 730 | .Fn DES_ecb3_encrypt , | ||
| 731 | .Fn DES_ede2_cfb64_encrypt , | ||
| 732 | .Fn DES_ede2_ofb64_encrypt , | ||
| 733 | .Fn DES_ede3_cfb64_encrypt , | ||
| 734 | and | ||
| 735 | .Fn DES_ede3_ofb64_encrypt | ||
| 736 | first appeared in SSLeay 0.5.1. | ||
| 737 | .Fn DES_xcbc_encrypt | ||
| 738 | first appeared in SSLeay 0.6.2. | ||
| 739 | .Fn DES_fcrypt | ||
| 740 | first appeared in SSLeay 0.6.5. | ||
| 741 | These functions have been available since | ||
| 742 | .Ox 2.4 . | ||
| 743 | .Pp | ||
| 744 | .Fn DES_set_key_checked | ||
| 745 | and | ||
| 746 | .Fn DES_set_key_unchecked | ||
| 747 | first appeared in OpenSSL 0.9.5 and have been available since | ||
| 748 | .Ox 2.7 . | ||
| 749 | .Pp | ||
| 750 | In OpenSSL 0.9.7 and | ||
| 751 | .Ox 3.2 , | ||
| 752 | all | ||
| 753 | .Sy des_ | ||
| 754 | functions were renamed to | ||
| 755 | .Sy DES_ | ||
| 756 | to avoid clashes with older versions of libdes. | ||
| 757 | .Sh AUTHORS | ||
| 758 | .An Eric Young Aq Mt eay@cryptsoft.com | ||
| 759 | .Sh CAVEATS | ||
| 760 | Single-key DES is insecure due to its short key size. | ||
| 761 | ECB mode is not suitable for most applications. | ||
| 762 | .Sh BUGS | ||
| 763 | DES_cbc_encrypt does not modify | ||
| 764 | .Fa ivec ; | ||
| 765 | use | ||
| 766 | .Fn DES_ncbc_encrypt | ||
| 767 | instead. | ||
| 768 | .Pp | ||
| 769 | .Fn DES_cfb_encrypt | ||
| 770 | and | ||
| 771 | .Fn DES_ofb_encrypt | ||
| 772 | operates on input of 8 bits. | ||
| 773 | What this means is that if you set numbits to 12, and length to 2, the | ||
| 774 | first 12 bits will come from the 1st input byte and the low half of the | ||
| 775 | second input byte. | ||
| 776 | The second 12 bits will have the low 8 bits taken from the 3rd input | ||
| 777 | byte and the top 4 bits taken from the 4th input byte. | ||
| 778 | The same holds for output. | ||
| 779 | This function has been implemented this way because most people will be | ||
| 780 | using a multiple of 8 and because once you get into pulling input | ||
| 781 | bytes apart things get ugly! | ||
| 782 | .Pp | ||
| 783 | .Fn DES_string_to_key | ||
| 784 | is available for backward compatibility with the MIT library. | ||
| 785 | New applications should use a cryptographic hash function. | ||
| 786 | The same applies for | ||
| 787 | .Fn DES_string_to_2key . | ||
