summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/DES_set_key.3
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/man/DES_set_key.3')
-rw-r--r--src/lib/libcrypto/man/DES_set_key.3787
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
394This library contains a fast implementation of the DES encryption
395algorithm.
396.Pp
397There are two phases to the use of DES encryption.
398The first is the generation of a
399.Vt DES_key_schedule
400from a key, and the second is the actual encryption.
401A DES key is of type
402.Vt DES_cblock .
403This type consists of 8 bytes with odd parity.
404The least significant bit in each byte is the parity bit.
405The key schedule is an expanded form of the key; it is used to speed the
406encryption process.
407.Pp
408.Fn DES_random_key
409generates a random key in odd parity.
410.Pp
411Before a DES key can be used, it must be converted into the architecture
412dependent
413.Vt DES_key_schedule
414via the
415.Fn DES_set_key_checked
416or
417.Fn DES_set_key_unchecked
418function.
419.Pp
420.Fn DES_set_key_checked
421will check that the key passed is of odd parity and is not a weak or
422semi-weak key.
423If the parity is wrong, then -1 is returned.
424If the key is a weak key, then -2 is returned.
425If an error is returned, the key schedule is not generated.
426.Pp
427.Fn DES_set_key
428works like
429.Fn DES_set_key_checked
430if the
431.Em DES_check_key
432flag is non-zero, otherwise like
433.Fn DES_set_key_unchecked .
434These functions are available for compatibility; it is recommended to
435use a function that does not depend on a global variable.
436.Pp
437.Fn DES_set_odd_parity
438sets the parity of the passed
439.Fa key
440to odd.
441.Pp
442The following routines mostly operate on an input and output stream of
443.Vt DES_cblock Ns s .
444.Pp
445.Fn DES_ecb_encrypt
446is the basic DES encryption routine that encrypts or decrypts a single
4478-byte
448.Vt DES_cblock
449in electronic code book (ECB) mode.
450It always transforms the input data, pointed to by
451.Fa input ,
452into the output data, pointed to by the
453.Fa output
454argument.
455If the
456.Fa enc
457argument is non-zero
458.Pq Dv DES_ENCRYPT ,
459the
460.Fa input
461(cleartext) is encrypted into the
462.Fa output
463(ciphertext) using the key_schedule specified by the
464.Fa schedule
465argument, previously set via
466.Fn DES_set_key .
467If
468.Fa enc
469is zero
470.Pq Dv DES_DECRYPT ,
471the
472.Fa input
473(now ciphertext) is decrypted into the
474.Fa output
475(now cleartext).
476Input and output may overlap.
477.Fn DES_ecb_encrypt
478does not return a value.
479.Pp
480.Fn DES_ecb3_encrypt
481encrypts/decrypts the
482.Fa input
483block by using three-key Triple-DES encryption in ECB mode.
484This involves encrypting the input with
485.Fa ks1 ,
486decrypting with the key schedule
487.Fa ks2 ,
488and then encrypting with
489.Fa ks3 .
490This routine greatly reduces the chances of brute force breaking of DES
491and has the advantage of if
492.Fa ks1 ,
493.Fa ks2 ,
494and
495.Fa ks3
496are the same, it is equivalent to just encryption using ECB mode and
497.Fa ks1
498as the key.
499.Pp
500The macro
501.Fn DES_ecb2_encrypt
502is provided to perform two-key Triple-DES encryption by using
503.Fa ks1
504for the final encryption.
505.Pp
506.Fn DES_ncbc_encrypt
507encrypts/decrypts using the cipher-block-chaining (CBC) mode of DES.
508If the
509.Fa enc
510argument is non-zero, the routine cipher-block-chain encrypts the
511cleartext data pointed to by the
512.Fa input
513argument into the ciphertext pointed to by the
514.Fa output
515argument, using the key schedule provided by the
516.Fa schedule
517argument, and initialization vector provided by the
518.Fa ivec
519argument.
520If the
521.Fa length
522argument is not an integral multiple of eight bytes, the last block is
523copied to a temporary area and zero filled.
524The output is always an integral multiple of eight bytes.
525.Pp
526.Fn DES_xcbc_encrypt
527is RSA's DESX mode of DES.
528It uses
529.Fa inw
530and
531.Fa outw
532to "whiten" the encryption.
533.Fa inw
534and
535.Fa outw
536are secret (unlike the iv) and are as such, part of the key.
537So the key is sort of 24 bytes.
538This is much better than CBC DES.
539.Pp
540.Fn DES_ede3_cbc_encrypt
541implements outer triple CBC DES encryption with three keys.
542This means that each DES operation inside the CBC mode is
543.Qq Li C=E(ks3,D(ks2,E(ks1,M))) .
544This mode is used by SSL.
545.Pp
546The
547.Fn DES_ede2_cbc_encrypt
548macro implements two-key Triple-DES by reusing
549.Fa ks1
550for the final encryption.
551.Qq Li C=E(ks1,D(ks2,E(ks1,M))) .
552This form of Triple-DES is used by the RSAREF library.
553.Pp
554.Fn DES_pcbc_encrypt
555encrypts/decrypts using the propagating cipher block chaining mode used
556by Kerberos v4.
557Its parameters are the same as
558.Fn DES_ncbc_encrypt .
559.Pp
560.Fn DES_cfb_encrypt
561encrypts/decrypts using cipher feedback mode.
562This method takes an array of characters as input and outputs an array
563of characters.
564It does not require any padding to 8 character groups.
565Note: the
566.Fa ivec
567variable is changed and the new changed value needs to be passed to the
568next call to this function.
569Since this function runs a complete DES ECB encryption per
570.Fa numbits ,
571this function is only suggested for use when sending a small number of
572characters.
573.Pp
574.Fn DES_cfb64_encrypt
575implements CFB mode of DES with 64-bit feedback.
576Why is this useful you ask?
577Because this routine will allow you to encrypt an arbitrary number of
578bytes, without 8 byte padding.
579Each call to this routine will encrypt the input bytes to output and
580then update ivec and num.
581num contains "how far" we are though ivec.
582If this does not make much sense, read more about CFB mode of DES.
583.Pp
584The
585.Fn DES_ede3_cfb64_encrypt
586function and the
587.Fn DES_ede2_cfb64_encrypt
588macro are the same as
589.Fn DES_cfb64_encrypt
590except that Triple-DES is used.
591.Pp
592.Fn DES_ofb_encrypt
593encrypts using output feedback mode.
594This method takes an array of characters as input and outputs an array
595of characters.
596It does not require any padding to 8 character groups.
597Note: the
598.Fa ivec
599variable is changed and the new changed value needs to be passed to the
600next call to this function.
601Since this function runs a complete DES ECB encryption per
602.Fa numbits ,
603this function is only suggested for use when sending a small number
604of characters.
605.Pp
606.Fn DES_ofb64_encrypt
607is the same as
608.Fn DES_cfb64_encrypt
609using Output Feed Back mode.
610.Pp
611The
612.Fn DES_ede3_ofb64_encrypt
613function and the
614.Fn DES_ede2_ofb64_encrypt
615macro are the same as
616.Fn DES_ofb64_encrypt ,
617using Triple-DES.
618.Pp
619The following functions are included in the DES library for
620compatibility with the MIT Kerberos library.
621.Pp
622.Fn DES_cbc_cksum
623produces an 8-byte checksum based on the input stream (via CBC
624encryption).
625The last 4 bytes of the checksum are returned and the complete 8 bytes
626are placed in
627.Fa output .
628This function is used by Kerberos v4.
629Other applications should use
630.Xr EVP_DigestInit 3
631etc. instead.
632.Pp
633.Fn DES_quad_cksum
634is a Kerberos v4 function.
635It returns a 4-byte checksum from the input bytes.
636The algorithm can be iterated over the input, depending on
637.Fa out_count ,
6381, 2, 3 or 4 times.
639If
640.Fa output
641is
642.Pf non- Dv NULL ,
643the 8 bytes generated by each pass are written into
644.Fa output .
645.Pp
646The following are DES-based transformations:
647.Pp
648.Fn DES_fcrypt
649is a fast version of the Unix
650.Xr crypt 3
651function.
652The
653.Fa salt
654must be two ASCII characters.
655This version is different from the normal crypt in that the third
656parameter is the buffer that the return value is written into.
657It needs to be at least 14 bytes long.
658The fourteenth byte is set to NUL.
659This version takes only a small amount of space relative to other
660fast crypt implementations.
661It is thread safe, unlike the normal crypt.
662.Pp
663.Fn DES_crypt
664is a faster replacement for the normal system
665.Xr crypt 3 .
666This function calls
667.Fn DES_fcrypt
668with a static array passed as the third parameter.
669This 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 ,
674and
675.Fn DES_set_key_checked
676return 0 on success or a negative value on error.
677.Pp
678.Fn DES_is_weak_key
679returns 1 if the passed key is a weak key or 0 if it is ok.
680.Pp
681.Fn DES_cbc_cksum
682and
683.Fn DES_quad_cksum
684return a 4-byte integer representing the last 4 bytes of the checksum
685of the input.
686.Pp
687.Fn DES_fcrypt
688returns a pointer to the caller-provided buffer
689.Fa ret ,
690and
691.Fn DES_crypt
692returns a pointer to a static buffer.
693Both are allowed to return
694.Dv NULL
695to 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
701ANSI X3.106
702.Pp
703The DES library was initially written to be source code compatible
704with 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 ,
722and
723.Fn DES_crypt
724appeared in SSLeay 0.4 or earlier.
725.Fn DES_ncbc_encrypt
726first appeared in SSLeay 0.4.2.
727.Fn DES_ede2_cbc_encrypt
728first 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 ,
734and
735.Fn DES_ede3_ofb64_encrypt
736first appeared in SSLeay 0.5.1.
737.Fn DES_xcbc_encrypt
738first appeared in SSLeay 0.6.2.
739.Fn DES_fcrypt
740first appeared in SSLeay 0.6.5.
741These functions have been available since
742.Ox 2.4 .
743.Pp
744.Fn DES_set_key_checked
745and
746.Fn DES_set_key_unchecked
747first appeared in OpenSSL 0.9.5 and have been available since
748.Ox 2.7 .
749.Pp
750In OpenSSL 0.9.7 and
751.Ox 3.2 ,
752all
753.Sy des_
754functions were renamed to
755.Sy DES_
756to avoid clashes with older versions of libdes.
757.Sh AUTHORS
758.An Eric Young Aq Mt eay@cryptsoft.com
759.Sh CAVEATS
760Single-key DES is insecure due to its short key size.
761ECB mode is not suitable for most applications.
762.Sh BUGS
763DES_cbc_encrypt does not modify
764.Fa ivec ;
765use
766.Fn DES_ncbc_encrypt
767instead.
768.Pp
769.Fn DES_cfb_encrypt
770and
771.Fn DES_ofb_encrypt
772operates on input of 8 bits.
773What this means is that if you set numbits to 12, and length to 2, the
774first 12 bits will come from the 1st input byte and the low half of the
775second input byte.
776The second 12 bits will have the low 8 bits taken from the 3rd input
777byte and the top 4 bits taken from the 4th input byte.
778The same holds for output.
779This function has been implemented this way because most people will be
780using a multiple of 8 and because once you get into pulling input
781bytes apart things get ugly!
782.Pp
783.Fn DES_string_to_key
784is available for backward compatibility with the MIT library.
785New applications should use a cryptographic hash function.
786The same applies for
787.Fn DES_string_to_2key .