diff options
author | schwarze <> | 2016-11-02 09:11:53 +0000 |
---|---|---|
committer | schwarze <> | 2016-11-02 09:11:53 +0000 |
commit | b50ac7faef96a45291b0c3201b82185f7579e826 (patch) | |
tree | 9166b196a2c833fc7a0154973d11551824a6bfb9 /src/lib/libcrypto/man/DES_set_key.3 | |
parent | 506350d1237710b9d86fdb3a794c6e6265f71221 (diff) | |
download | openbsd-b50ac7faef96a45291b0c3201b82185f7579e826.tar.gz openbsd-b50ac7faef96a45291b0c3201b82185f7579e826.tar.bz2 openbsd-b50ac7faef96a45291b0c3201b82185f7579e826.zip |
convert DES and DH manuals from pod to mdoc
Diffstat (limited to 'src/lib/libcrypto/man/DES_set_key.3')
-rw-r--r-- | src/lib/libcrypto/man/DES_set_key.3 | 697 |
1 files changed, 697 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/DES_set_key.3 b/src/lib/libcrypto/man/DES_set_key.3 new file mode 100644 index 0000000000..9c33bf29e6 --- /dev/null +++ b/src/lib/libcrypto/man/DES_set_key.3 | |||
@@ -0,0 +1,697 @@ | |||
1 | .Dd $Mdocdate: November 2 2016 $ | ||
2 | .Dt DES_SET_KEY 3 | ||
3 | .Os | ||
4 | .Sh NAME | ||
5 | .Nm DES_random_key , | ||
6 | .Nm DES_set_key , | ||
7 | .Nm DES_key_sched , | ||
8 | .Nm DES_set_key_checked , | ||
9 | .Nm DES_set_key_unchecked , | ||
10 | .Nm DES_set_odd_parity , | ||
11 | .Nm DES_is_weak_key , | ||
12 | .Nm DES_ecb_encrypt , | ||
13 | .Nm DES_ecb2_encrypt , | ||
14 | .Nm DES_ecb3_encrypt , | ||
15 | .Nm DES_ncbc_encrypt , | ||
16 | .Nm DES_cfb_encrypt , | ||
17 | .Nm DES_ofb_encrypt , | ||
18 | .Nm DES_pcbc_encrypt , | ||
19 | .Nm DES_cfb64_encrypt , | ||
20 | .Nm DES_ofb64_encrypt , | ||
21 | .Nm DES_xcbc_encrypt , | ||
22 | .Nm DES_ede2_cbc_encrypt , | ||
23 | .Nm DES_ede2_cfb64_encrypt , | ||
24 | .Nm DES_ede2_ofb64_encrypt , | ||
25 | .Nm DES_ede3_cbc_encrypt , | ||
26 | .Nm DES_ede3_cbcm_encrypt , | ||
27 | .Nm DES_ede3_cfb64_encrypt , | ||
28 | .Nm DES_ede3_ofb64_encrypt , | ||
29 | .Nm DES_cbc_cksum , | ||
30 | .Nm DES_quad_cksum , | ||
31 | .Nm DES_string_to_key , | ||
32 | .Nm DES_string_to_2keys , | ||
33 | .Nm DES_fcrypt , | ||
34 | .Nm DES_crypt , | ||
35 | .Nm DES_enc_read , | ||
36 | .Nm DES_enc_write | ||
37 | .Nd DES encryption | ||
38 | .Sh SYNOPSIS | ||
39 | .In openssl/des.h | ||
40 | .Ft void | ||
41 | .Fo DES_random_key | ||
42 | .Fa "DES_cblock *ret" | ||
43 | .Fc | ||
44 | .Ft int | ||
45 | .Fo DES_set_key | ||
46 | .Fa "const_DES_cblock *key" | ||
47 | .Fa "DES_key_schedule *schedule" | ||
48 | .Fc | ||
49 | .Ft int | ||
50 | .Fo DES_key_sched | ||
51 | .Fa "const_DES_cblock *key" | ||
52 | .Fa "DES_key_schedule *schedule" | ||
53 | .Fc | ||
54 | .Ft int | ||
55 | .Fo DES_set_key_checked | ||
56 | .Fa "const_DES_cblock *key" | ||
57 | .Fa "DES_key_schedule *schedule" | ||
58 | .Fc | ||
59 | .Ft void | ||
60 | .Fo DES_set_key_unchecked | ||
61 | .Fa "const_DES_cblock *key" | ||
62 | .Fa "DES_key_schedule *schedule" | ||
63 | .Fc | ||
64 | .Ft void | ||
65 | .Fo DES_set_odd_parity | ||
66 | .Fa "DES_cblock *key" | ||
67 | .Fc | ||
68 | .Ft int | ||
69 | .Fo DES_is_weak_key | ||
70 | .Fa "const_DES_cblock *key" | ||
71 | .Fc | ||
72 | .Ft void | ||
73 | .Fo DES_ecb_encrypt | ||
74 | .Fa "const_DES_cblock *input" | ||
75 | .Fa "DES_cblock *output" | ||
76 | .Fa "DES_key_schedule *ks" | ||
77 | .Fa "int enc" | ||
78 | .Fc | ||
79 | .Ft void | ||
80 | .Fo DES_ecb2_encrypt | ||
81 | .Fa "const_DES_cblock *input" | ||
82 | .Fa "DES_cblock *output" | ||
83 | .Fa "DES_key_schedule *ks1" | ||
84 | .Fa "DES_key_schedule *ks2" | ||
85 | .Fa "int enc" | ||
86 | .Fc | ||
87 | .Ft void | ||
88 | .Fo DES_ecb3_encrypt | ||
89 | .Fa "const_DES_cblock *input" | ||
90 | .Fa "DES_cblock *output" | ||
91 | .Fa "DES_key_schedule *ks1" | ||
92 | .Fa "DES_key_schedule *ks2" | ||
93 | .Fa "DES_key_schedule *ks3" | ||
94 | .Fa "int enc" | ||
95 | .Fc | ||
96 | .Ft void | ||
97 | .Fo DES_ncbc_encrypt | ||
98 | .Fa "const unsigned char *input" | ||
99 | .Fa "unsigned char *output" | ||
100 | .Fa "long length" | ||
101 | .Fa "DES_key_schedule *schedule" | ||
102 | .Fa "DES_cblock *ivec" | ||
103 | .Fa "int enc" | ||
104 | .Fc | ||
105 | .Ft void | ||
106 | .Fo DES_cfb_encrypt | ||
107 | .Fa "const unsigned char *in" | ||
108 | .Fa "unsigned char *out" | ||
109 | .Fa "int numbits" | ||
110 | .Fa "long length" | ||
111 | .Fa "DES_key_schedule *schedule" | ||
112 | .Fa "DES_cblock *ivec" | ||
113 | .Fa "int enc" | ||
114 | .Fc | ||
115 | .Ft void | ||
116 | .Fo DES_ofb_encrypt | ||
117 | .Fa "const unsigned char *in" | ||
118 | .Fa "unsigned char *out" | ||
119 | .Fa "int numbits" | ||
120 | .Fa "long length" | ||
121 | .Fa "DES_key_schedule *schedule" | ||
122 | .Fa "DES_cblock *ivec" | ||
123 | .Fc | ||
124 | .Ft void | ||
125 | .Fo DES_pcbc_encrypt | ||
126 | .Fa "const unsigned char *input" | ||
127 | .Fa "unsigned char *output" | ||
128 | .Fa "long length" | ||
129 | .Fa "DES_key_schedule *schedule" | ||
130 | .Fa "DES_cblock *ivec" | ||
131 | .Fa "int enc" | ||
132 | .Fc | ||
133 | .Ft void | ||
134 | .Fo DES_cfb64_encrypt | ||
135 | .Fa "const unsigned char *in" | ||
136 | .Fa "unsigned char *out" | ||
137 | .Fa "long length" | ||
138 | .Fa "DES_key_schedule *schedule" | ||
139 | .Fa "DES_cblock *ivec" | ||
140 | .Fa "int *num" | ||
141 | .Fa "int enc" | ||
142 | .Fc | ||
143 | .Ft void | ||
144 | .Fo DES_ofb64_encrypt | ||
145 | .Fa "const unsigned char *in" | ||
146 | .Fa "unsigned char *out" | ||
147 | .Fa "long length" | ||
148 | .Fa "DES_key_schedule *schedule" | ||
149 | .Fa "DES_cblock *ivec" | ||
150 | .Fa "int *num" | ||
151 | .Fc | ||
152 | .Ft void | ||
153 | .Fo DES_xcbc_encrypt | ||
154 | .Fa "const unsigned char *input" | ||
155 | .Fa "unsigned char *output" | ||
156 | .Fa "long length" | ||
157 | .Fa "DES_key_schedule *schedule" | ||
158 | .Fa "DES_cblock *ivec" | ||
159 | .Fa "const_DES_cblock *inw" | ||
160 | .Fa "const_DES_cblock *outw" | ||
161 | .Fa "int enc" | ||
162 | .Fc | ||
163 | .Ft void | ||
164 | .Fo DES_ede2_cbc_encrypt | ||
165 | .Fa "const unsigned char *input" | ||
166 | .Fa "unsigned char *output" | ||
167 | .Fa "long length" | ||
168 | .Fa "DES_key_schedule *ks1" | ||
169 | .Fa "DES_key_schedule *ks2" | ||
170 | .Fa "DES_cblock *ivec" | ||
171 | .Fa "int enc" | ||
172 | .Fc | ||
173 | .Ft void | ||
174 | .Fo DES_ede2_cfb64_encrypt | ||
175 | .Fa "const unsigned char *in" | ||
176 | .Fa "unsigned char *out" | ||
177 | .Fa "long length" | ||
178 | .Fa "DES_key_schedule *ks1" | ||
179 | .Fa "DES_key_schedule *ks2" | ||
180 | .Fa "DES_cblock *ivec" | ||
181 | .Fa "int *num" | ||
182 | .Fa "int enc" | ||
183 | .Fc | ||
184 | .Ft void | ||
185 | .Fo DES_ede2_ofb64_encrypt | ||
186 | .Fa "const unsigned char *in" | ||
187 | .Fa "unsigned char *out" | ||
188 | .Fa "long length" | ||
189 | .Fa "DES_key_schedule *ks1" | ||
190 | .Fa "DES_key_schedule *ks2" | ||
191 | .Fa "DES_cblock *ivec" | ||
192 | .Fa "int *num" | ||
193 | .Fc | ||
194 | .Ft void | ||
195 | .Fo DES_ede3_cbc_encrypt | ||
196 | .Fa "const unsigned char *input" | ||
197 | .Fa "unsigned char *output" | ||
198 | .Fa "long length" | ||
199 | .Fa "DES_key_schedule *ks1" | ||
200 | .Fa "DES_key_schedule *ks2" | ||
201 | .Fa "DES_key_schedule *ks3" | ||
202 | .Fa "DES_cblock *ivec" | ||
203 | .Fa "int enc" | ||
204 | .Fc | ||
205 | .Ft void | ||
206 | .Fo DES_ede3_cbcm_encrypt | ||
207 | .Fa "const unsigned char *in" | ||
208 | .Fa "unsigned char *out" | ||
209 | .Fa "long length" | ||
210 | .Fa "DES_key_schedule *ks1" | ||
211 | .Fa "DES_key_schedule *ks2" | ||
212 | .Fa "DES_key_schedule *ks3" | ||
213 | .Fa "DES_cblock *ivec1" | ||
214 | .Fa "DES_cblock *ivec2" | ||
215 | .Fa "int enc" | ||
216 | .Fc | ||
217 | .Ft void | ||
218 | .Fo DES_ede3_cfb64_encrypt | ||
219 | .Fa "const unsigned char *in" | ||
220 | .Fa "unsigned char *out" | ||
221 | .Fa "long length" | ||
222 | .Fa "DES_key_schedule *ks1" | ||
223 | .Fa "DES_key_schedule *ks2" | ||
224 | .Fa "DES_key_schedule *ks3" | ||
225 | .Fa "DES_cblock *ivec" | ||
226 | .Fa "int *num" | ||
227 | .Fa "int enc" | ||
228 | .Fc | ||
229 | .Ft void | ||
230 | .Fo DES_ede3_ofb64_encrypt | ||
231 | .Fa "const unsigned char *in" | ||
232 | .Fa "unsigned char *out" | ||
233 | .Fa "long length" | ||
234 | .Fa "DES_key_schedule *ks1" | ||
235 | .Fa "DES_key_schedule *ks2" | ||
236 | .Fa "DES_key_schedule *ks3" | ||
237 | .Fa "DES_cblock *ivec" | ||
238 | .Fa "int *num" | ||
239 | .Fc | ||
240 | .Ft DES_LONG | ||
241 | .Fo DES_cbc_cksum | ||
242 | .Fa "const unsigned char *input" | ||
243 | .Fa "DES_cblock *output" | ||
244 | .Fa "long length" | ||
245 | .Fa "DES_key_schedule *schedule" | ||
246 | .Fa "const_DES_cblock *ivec" | ||
247 | .Fc | ||
248 | .Ft DES_LONG | ||
249 | .Fo DES_quad_cksum | ||
250 | .Fa "const unsigned char *input" | ||
251 | .Fa "DES_cblock output[]" | ||
252 | .Fa "long length" | ||
253 | .Fa "int out_count" | ||
254 | .Fa "DES_cblock *seed" | ||
255 | .Fc | ||
256 | .Ft void | ||
257 | .Fo DES_string_to_key | ||
258 | .Fa "const char *str" | ||
259 | .Fa "DES_cblock *key" | ||
260 | .Fc | ||
261 | .Ft void | ||
262 | .Fo DES_string_to_2keys | ||
263 | .Fa "const char *str" | ||
264 | .Fa "DES_cblock *key1" | ||
265 | .Fa "DES_cblock *key2" | ||
266 | .Fc | ||
267 | .Ft char * | ||
268 | .Fo DES_fcrypt | ||
269 | .Fa "const char *buf" | ||
270 | .Fa "const char *salt" | ||
271 | .Fa "char *ret" | ||
272 | .Fc | ||
273 | .Ft char * | ||
274 | .Fo DES_crypt | ||
275 | .Fa "const char *buf" | ||
276 | .Fa "const char *salt" | ||
277 | .Fc | ||
278 | .Ft int | ||
279 | .Fo DES_enc_read | ||
280 | .Fa "int fd" | ||
281 | .Fa "void *buf" | ||
282 | .Fa "int len" | ||
283 | .Fa "DES_key_schedule *sched" | ||
284 | .Fa "DES_cblock *iv" | ||
285 | .Fc | ||
286 | .Ft int | ||
287 | .Fo DES_enc_write | ||
288 | .Fa "int fd" | ||
289 | .Fa "const void *buf" | ||
290 | .Fa "int len" | ||
291 | .Fa "DES_key_schedule *sched" | ||
292 | .Fa "DES_cblock *iv" | ||
293 | .Fc | ||
294 | .Sh DESCRIPTION | ||
295 | This library contains a fast implementation of the DES encryption | ||
296 | algorithm. | ||
297 | .Pp | ||
298 | There are two phases to the use of DES encryption. | ||
299 | The first is the generation of a | ||
300 | .Vt DES_key_schedule | ||
301 | from a key, the second is the actual encryption. | ||
302 | A DES key is of type | ||
303 | .Vt DES_cblock . | ||
304 | This type is consists of 8 bytes with odd parity. | ||
305 | The least significant bit in each byte is the parity bit. | ||
306 | The key schedule is an expanded form of the key; it is used to speed the | ||
307 | encryption process. | ||
308 | .Pp | ||
309 | .Fn DES_random_key | ||
310 | generates a random key in odd parity. | ||
311 | .Pp | ||
312 | Before a DES key can be used, it must be converted into the architecture | ||
313 | dependent | ||
314 | .Vt DES_key_schedule | ||
315 | via the | ||
316 | .Fn DES_set_key_checked | ||
317 | or | ||
318 | .Fn DES_set_key_unchecked | ||
319 | function. | ||
320 | .Pp | ||
321 | .Fn DES_set_key_checked | ||
322 | will check that the key passed is of odd parity and is not a week or | ||
323 | semi-weak key. | ||
324 | If the parity is wrong, then -1 is returned. | ||
325 | If the key is a weak key, then -2 is returned. | ||
326 | If an error is returned, the key schedule is not generated. | ||
327 | .Pp | ||
328 | .Fn DES_set_key | ||
329 | works like | ||
330 | .Fn DES_set_key_checked | ||
331 | if the | ||
332 | .Em DES_check_key | ||
333 | flag is non-zero, otherwise like | ||
334 | .Fn DES_set_key_unchecked . | ||
335 | These functions are available for compatibility; it is recommended to | ||
336 | use a function that does not depend on a global variable. | ||
337 | .Pp | ||
338 | .Fn DES_set_odd_parity | ||
339 | sets the parity of the passed | ||
340 | .Fa key | ||
341 | to odd. | ||
342 | .Pp | ||
343 | .Fn DES_is_weak_key | ||
344 | returns 1 is the passed key is a weak key, 0 if it is ok. | ||
345 | .Pp | ||
346 | The following routines mostly operate on an input and output stream of | ||
347 | .Vt DES_cblock Ns s. | ||
348 | .Pp | ||
349 | .Fn DES_ecb_encrypt | ||
350 | is the basic DES encryption routine that encrypts or decrypts a single | ||
351 | 8-byte | ||
352 | .Vt DES_cblock | ||
353 | in electronic code book (ECB) mode. | ||
354 | It always transforms the input data, pointed to by | ||
355 | .Fa input , | ||
356 | into the output data, pointed to by the | ||
357 | .Fa output | ||
358 | argument. | ||
359 | If the | ||
360 | .Fa enc | ||
361 | argument is non-zero | ||
362 | .Pq Dv DES_ENCRYPT , | ||
363 | the | ||
364 | .Fa input | ||
365 | (cleartext) is encrypted in to the | ||
366 | .Fa output | ||
367 | (ciphertext) using the key_schedule specified by the | ||
368 | .Fa schedule | ||
369 | argument, previously set via | ||
370 | .Fn DES_set_key . | ||
371 | If | ||
372 | .Fa enc | ||
373 | is zero | ||
374 | .Pq Dv DES_DECRYPT , | ||
375 | the | ||
376 | .Fa input | ||
377 | (now ciphertext) is decrypted into the | ||
378 | .Fa output | ||
379 | (now cleartext). | ||
380 | Input and output may overlap. | ||
381 | .Fn DES_ecb_encrypt | ||
382 | does not return a value. | ||
383 | .Pp | ||
384 | .Fn DES_ecb3_encrypt | ||
385 | encrypts/decrypts the | ||
386 | .Fa input | ||
387 | block by using three-key Triple-DES encryption in ECB mode. | ||
388 | This involves encrypting the input with | ||
389 | .Fa ks1 , | ||
390 | decrypting with the key schedule | ||
391 | .Fa ks2 , | ||
392 | and then encrypting with | ||
393 | .Fa ks3 . | ||
394 | This routine greatly reduces the chances of brute force breaking of DES | ||
395 | and has the advantage of if | ||
396 | .Fa ks1 , | ||
397 | .Fa ks2 , | ||
398 | and | ||
399 | .Fa ks3 | ||
400 | are the same, it is equivalent to just encryption using ECB mode and | ||
401 | .Fa ks1 | ||
402 | as the key. | ||
403 | .Pp | ||
404 | The macro | ||
405 | .Fn DES_ecb2_encrypt | ||
406 | is provided to perform two-key Triple-DES encryption by using | ||
407 | .Fa ks1 | ||
408 | for the final encryption. | ||
409 | .Pp | ||
410 | .Fn DES_ncbc_encrypt | ||
411 | encrypts/decrypts using the cipher-block-chaining (CBC) mode of DES. | ||
412 | If the | ||
413 | .Fa enc | ||
414 | argument is non-zero, the routine cipher-block-chain encrypts the | ||
415 | cleartext data pointed to by the | ||
416 | .Fa input | ||
417 | argument into the ciphertext pointed to by the | ||
418 | .Fa output | ||
419 | argument, using the key schedule provided by the | ||
420 | .Fa schedule | ||
421 | argument, and initialization vector provided by the | ||
422 | .Fa ivec | ||
423 | argument. | ||
424 | If the | ||
425 | .Fa length | ||
426 | argument is not an integral multiple of eight bytes, the last block is | ||
427 | copied to a temporary area and zero filled. | ||
428 | The output is always an integral multiple of eight bytes. | ||
429 | .Pp | ||
430 | .Fn DES_xcbc_encrypt | ||
431 | is RSA's DESX mode of DES. | ||
432 | It uses | ||
433 | .Fa inw | ||
434 | and | ||
435 | .Fa outw | ||
436 | to 'whiten' the encryption. | ||
437 | .Fa inw | ||
438 | and | ||
439 | .Fa outw | ||
440 | are secret (unlike the iv) and are as such, part of the key. | ||
441 | So the key is sort of 24 bytes. | ||
442 | This is much better than CBC DES. | ||
443 | .Pp | ||
444 | .Fn DES_ede3_cbc_encrypt | ||
445 | implements outer triple CBC DES encryption with three keys. | ||
446 | This means that each DES operation inside the CBC mode is really an | ||
447 | .Qq Li C=E(ks3,D(ks2,E(ks1,M))) . | ||
448 | This mode is used by SSL. | ||
449 | .Pp | ||
450 | The | ||
451 | .Fn DES_ede2_cbc_encrypt | ||
452 | macro implements two-key Triple-DES by reusing | ||
453 | .Fa ks1 | ||
454 | for the final encryption. | ||
455 | .Qq Li C=E(ks1,D(ks2,E(ks1,M))) . | ||
456 | This form of Triple-DES is used by the RSAREF library. | ||
457 | .Pp | ||
458 | .Fn DES_pcbc_encrypt | ||
459 | encrypt/decrypts using the propagating cipher block chaining mode used | ||
460 | by Kerberos v4. | ||
461 | Its parameters are the same as | ||
462 | .Fn DES_ncbc_encrypt . | ||
463 | .Pp | ||
464 | .Fn DES_cfb_encrypt | ||
465 | encrypt/decrypts using cipher feedback mode. | ||
466 | This method takes an array of characters as input and outputs and array | ||
467 | of characters. | ||
468 | It does not require any padding to 8 character groups. | ||
469 | Note: the | ||
470 | .Fa ivec | ||
471 | variable is changed and the new changed value needs to be passed to the | ||
472 | next call to this function. | ||
473 | Since this function runs a complete DES ECB encryption per | ||
474 | .Fa numbits , | ||
475 | this function is only suggested for use when sending small numbers of | ||
476 | characters. | ||
477 | .Pp | ||
478 | .Fn DES_cfb64_encrypt | ||
479 | implements CFB mode of DES with 64bit feedback. | ||
480 | Why is this useful you ask? | ||
481 | Because this routine will allow you to encrypt an arbitrary number of | ||
482 | bytes, no 8 byte padding. | ||
483 | Each call to this routine will encrypt the input bytes to output and | ||
484 | then update ivec and num. | ||
485 | num contains 'how far' we are though ivec. | ||
486 | If this does not make much sense, read more about cfb mode of DES :-). | ||
487 | .Pp | ||
488 | .Fn DES_ede3_cfb64_encrypt | ||
489 | and | ||
490 | .Fn DES_ede2_cfb64_encrypt | ||
491 | is the same as | ||
492 | .Fn DES_cfb64_encrypt | ||
493 | except that Triple-DES is used. | ||
494 | .Pp | ||
495 | .Fn DES_ofb_encrypt | ||
496 | encrypts using output feedback mode. | ||
497 | This method takes an array of characters as input and outputs and array | ||
498 | of characters. | ||
499 | It does not require any padding to 8 character groups. | ||
500 | Note: the | ||
501 | .Fa ivec | ||
502 | variable is changed and the new changed value needs to be passed to the | ||
503 | next call to this function. | ||
504 | Since this function runs a complete DES ECB encryption per numbits, this | ||
505 | function is only suggested for use when sending small numbers of | ||
506 | characters. | ||
507 | .Pp | ||
508 | .Fn DES_ofb64_encrypt | ||
509 | is the same as | ||
510 | .Fn DES_cfb64_encrypt | ||
511 | using Output Feed Back mode. | ||
512 | .Pp | ||
513 | .Fn DES_ede3_ofb64_encrypt | ||
514 | and | ||
515 | .Fn DES_ede2_ofb64_encrypt | ||
516 | is the same as | ||
517 | .Fn DES_ofb64_encrypt , | ||
518 | using Triple-DES. | ||
519 | .Pp | ||
520 | The following functions are included in the DES library for | ||
521 | compatibility with the MIT Kerberos library. | ||
522 | .Pp | ||
523 | .Fn DES_cbc_cksum | ||
524 | produces an 8 byte checksum based on the input stream (via CBC | ||
525 | encryption). | ||
526 | The last 4 bytes of the checksum are returned and the complete 8 bytes | ||
527 | are placed in | ||
528 | .Fa output . | ||
529 | This function is used by Kerberos v4. | ||
530 | Other applications should use | ||
531 | .Xr EVP_DigestInit 3 | ||
532 | etc. instead. | ||
533 | .Pp | ||
534 | .Fn DES_quad_cksum | ||
535 | is a Kerberos v4 function. | ||
536 | It returns a 4 byte checksum from the input bytes. | ||
537 | The algorithm can be iterated over the input, depending on | ||
538 | .Fa out_count , | ||
539 | 1, 2, 3 or 4 times. | ||
540 | If | ||
541 | .Fa output | ||
542 | is | ||
543 | .Pf non- Dv NULL , | ||
544 | the 8 bytes generated by each pass are written into | ||
545 | .Fa output . | ||
546 | .Pp | ||
547 | The following are DES-based transformations: | ||
548 | .Pp | ||
549 | .Fn DES_fcrypt | ||
550 | is a fast version of the Unix | ||
551 | .Xr crypt 3 | ||
552 | function. | ||
553 | This version takes only a small amount of space relative to other | ||
554 | fast crypt implementations. | ||
555 | This is different to the normal crypt in that the third parameter is the | ||
556 | buffer that the return value is written into. | ||
557 | It needs to be at least 14 bytes long. | ||
558 | This function is thread safe, unlike the normal crypt. | ||
559 | .Pp | ||
560 | .Fn DES_crypt | ||
561 | is a faster replacement for the normal system | ||
562 | .Xr crypt 3 . | ||
563 | This function calls | ||
564 | .Fn DES_fcrypt | ||
565 | with a static array passed as the third parameter. | ||
566 | This emulates the normal non-thread safe semantics of | ||
567 | .Xr crypt 3 . | ||
568 | .Pp | ||
569 | .Fn DES_enc_write | ||
570 | writes | ||
571 | .Fa len | ||
572 | bytes to file descriptor | ||
573 | .Fa fd | ||
574 | from buffer | ||
575 | .Fa buf . | ||
576 | The data is encrypted via | ||
577 | .Em pcbc_encrypt | ||
578 | (default) using | ||
579 | .Fa sched | ||
580 | for the key and | ||
581 | .Fa iv | ||
582 | as a starting vector. | ||
583 | The actual data send down | ||
584 | .Fa fd | ||
585 | consists of 4 bytes (in network byte order) containing the length of the | ||
586 | following encrypted data. | ||
587 | The encrypted data then follows, padded with random data out to a | ||
588 | multiple of 8 bytes. | ||
589 | .Pp | ||
590 | .Fn DES_enc_read | ||
591 | is used to read | ||
592 | .Fa len | ||
593 | bytes from file descriptor | ||
594 | .Fa fd | ||
595 | into buffer | ||
596 | .Fa buf . | ||
597 | The data being read from | ||
598 | .Fa fd | ||
599 | is assumed to have come from | ||
600 | .Fn DES_enc_write | ||
601 | and is decrypted using | ||
602 | .Fa sched | ||
603 | for the key schedule and | ||
604 | .Fa iv | ||
605 | for the initial vector. | ||
606 | .Pp | ||
607 | .Sy Warning: | ||
608 | The data format used by | ||
609 | .Fn DES_enc_write | ||
610 | and | ||
611 | .Fn DES_enc_read | ||
612 | has a cryptographic weakness: When asked to write more than | ||
613 | .Dv MAXWRITE | ||
614 | bytes, | ||
615 | .Fn DES_enc_write | ||
616 | will split the data into several chunks that are all encrypted using the | ||
617 | same IV. | ||
618 | So don't use these functions unless you are sure you know what | ||
619 | you do (in which case you might not want to use them anyway). | ||
620 | They cannot handle non-blocking sockets. | ||
621 | .Fn DES_enc_read | ||
622 | uses an internal state and thus cannot be used on multiple files. | ||
623 | .Pp | ||
624 | .Em DES_rw_mode | ||
625 | is used to specify the encryption mode to use with | ||
626 | .Fn DES_enc_read . | ||
627 | If set to | ||
628 | .Dv DES_PCBC_MODE | ||
629 | (the default), DES_pcbc_encrypt is used. | ||
630 | If set to | ||
631 | .Dv DES_CBC_MODE | ||
632 | DES_cbc_encrypt is used. | ||
633 | .Sh SEE ALSO | ||
634 | .Xr crypt 3 , | ||
635 | .Xr rand 3 | ||
636 | .Pp | ||
637 | The | ||
638 | .Xr evp 3 | ||
639 | library provides higher-level encryption functions. | ||
640 | .Sh STANDARDS | ||
641 | ANSI X3.106 | ||
642 | .Pp | ||
643 | The DES library was initially written to be source code compatible | ||
644 | with the MIT Kerberos library. | ||
645 | .Sh HISTORY | ||
646 | In OpenSSL 0.9.7, all des_ functions were renamed to DES_ to avoid | ||
647 | clashes with older versions of libdes. | ||
648 | .Pp | ||
649 | .Fn DES_set_key_checked | ||
650 | and | ||
651 | .Fn DES_set_key_unchecked | ||
652 | were added in OpenSSL 0.9.5. | ||
653 | .Pp | ||
654 | .Fn des_generate_random_block , | ||
655 | .Fn des_init_random_number_generator , | ||
656 | .Fn des_new_random_key , | ||
657 | .Fn des_set_random_generator_seed , | ||
658 | .Xr des_set_sequence_number , | ||
659 | and | ||
660 | .Fn des_rand_data 3 | ||
661 | are used in newer versions of Kerberos but are not implemented here. | ||
662 | .Pp | ||
663 | .Fn DES_random_key | ||
664 | generated cryptographically weak random data in SSLeay and in OpenSSL | ||
665 | prior version 0.9.5, as well as in the original MIT library. | ||
666 | .Sh AUTHORS | ||
667 | .An Eric Young Aq Mt eay@cryptsoft.com | ||
668 | .Sh CAVEATS | ||
669 | Single-key DES is insecure due to its short key size. | ||
670 | ECB mode is not suitable for most applications. | ||
671 | .Sh BUGS | ||
672 | .Xr DES_cbc_encrypt 3 | ||
673 | does not modify | ||
674 | .Fa ivec ; | ||
675 | use | ||
676 | .Fn DES_ncbc_encrypt | ||
677 | instead. | ||
678 | .Pp | ||
679 | .Fn DES_cfb_encrypt | ||
680 | and | ||
681 | .Fn DES_ofb_encrypt | ||
682 | operates on input of 8 bits. | ||
683 | What this means is that if you set numbits to 12, and length to 2, the | ||
684 | first 12 bits will come from the 1st input byte and the low half of the | ||
685 | second input byte. | ||
686 | The second 12 bits will have the low 8 bits taken from the 3rd input | ||
687 | byte and the top 4 bits taken from the 4th input byte. | ||
688 | The same holds for output. | ||
689 | This function has been implemented this way because most people will be | ||
690 | using a multiple of 8 and because once you get into pulling bytes input | ||
691 | bytes apart things get ugly! | ||
692 | .Pp | ||
693 | .Fn DES_string_to_key | ||
694 | is available for backward compatibility with the MIT library. | ||
695 | New applications should use a cryptographic hash function. | ||
696 | The same applies for | ||
697 | .Fn DES_string_to_2key . | ||