Merge branch 'vendor/OPENSSL'
[dragonfly.git] / secure / lib / libcrypto / man / des.3
1 .\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05)
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
29 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
30 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
31 .\" nothing in troff, for use with C<>.
32 .tr \(*W-
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" Escape single quotes in literal strings from groff's Unicode transform.
52 .ie \n(.g .ds Aq \(aq
53 .el       .ds Aq '
54 .\"
55 .\" If the F register is turned on, we'll generate index entries on stderr for
56 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
57 .\" entries marked with X<> in POD.  Of course, you'll have to process the
58 .\" output yourself in some meaningful fashion.
59 .ie \nF \{\
60 .    de IX
61 .    tm Index:\\$1\t\\n%\t"\\$2"
62 ..
63 .    nr % 0
64 .    rr F
65 .\}
66 .el \{\
67 .    de IX
68 ..
69 .\}
70 .\"
71 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
72 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
73 .    \" fudge factors for nroff and troff
74 .if n \{\
75 .    ds #H 0
76 .    ds #V .8m
77 .    ds #F .3m
78 .    ds #[ \f1
79 .    ds #] \fP
80 .\}
81 .if t \{\
82 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
83 .    ds #V .6m
84 .    ds #F 0
85 .    ds #[ \&
86 .    ds #] \&
87 .\}
88 .    \" simple accents for nroff and troff
89 .if n \{\
90 .    ds ' \&
91 .    ds ` \&
92 .    ds ^ \&
93 .    ds , \&
94 .    ds ~ ~
95 .    ds /
96 .\}
97 .if t \{\
98 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
99 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
100 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
101 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
102 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
103 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
104 .\}
105 .    \" troff and (daisy-wheel) nroff accents
106 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
107 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
108 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
109 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
110 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
111 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
112 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
113 .ds ae a\h'-(\w'a'u*4/10)'e
114 .ds Ae A\h'-(\w'A'u*4/10)'E
115 .    \" corrections for vroff
116 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
117 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
118 .    \" for low resolution devices (crt and lpr)
119 .if \n(.H>23 .if \n(.V>19 \
120 \{\
121 .    ds : e
122 .    ds 8 ss
123 .    ds o a
124 .    ds d- d\h'-1'\(ga
125 .    ds D- D\h'-1'\(hy
126 .    ds th \o'bp'
127 .    ds Th \o'LP'
128 .    ds ae ae
129 .    ds Ae AE
130 .\}
131 .rm #[ #] #H #V #F C
132 .\" ========================================================================
133 .\"
134 .IX Title "des 3"
135 .TH des 3 "2010-02-27" "0.9.8m" "OpenSSL"
136 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
137 .\" way too many mistakes in technical documents.
138 .if n .ad l
139 .nh
140 .SH "NAME"
141 DES_random_key, DES_set_key, DES_key_sched, DES_set_key_checked,
142 DES_set_key_unchecked, DES_set_odd_parity, DES_is_weak_key,
143 DES_ecb_encrypt, DES_ecb2_encrypt, DES_ecb3_encrypt, DES_ncbc_encrypt,
144 DES_cfb_encrypt, DES_ofb_encrypt, DES_pcbc_encrypt, DES_cfb64_encrypt,
145 DES_ofb64_encrypt, DES_xcbc_encrypt, DES_ede2_cbc_encrypt,
146 DES_ede2_cfb64_encrypt, DES_ede2_ofb64_encrypt, DES_ede3_cbc_encrypt,
147 DES_ede3_cbcm_encrypt, DES_ede3_cfb64_encrypt, DES_ede3_ofb64_encrypt,
148 DES_cbc_cksum, DES_quad_cksum, DES_string_to_key, DES_string_to_2keys,
149 DES_fcrypt, DES_crypt, DES_enc_read, DES_enc_write \- DES encryption
150 .SH "SYNOPSIS"
151 .IX Header "SYNOPSIS"
152 .Vb 1
153 \& #include <openssl/des.h>
154 \&
155 \& void DES_random_key(DES_cblock *ret);
156 \&
157 \& int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule);
158 \& int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule);
159 \& int DES_set_key_checked(const_DES_cblock *key,
160 \&        DES_key_schedule *schedule);
161 \& void DES_set_key_unchecked(const_DES_cblock *key,
162 \&        DES_key_schedule *schedule);
163 \&
164 \& void DES_set_odd_parity(DES_cblock *key);
165 \& int DES_is_weak_key(const_DES_cblock *key);
166 \&
167 \& void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, 
168 \&        DES_key_schedule *ks, int enc);
169 \& void DES_ecb2_encrypt(const_DES_cblock *input, DES_cblock *output, 
170 \&        DES_key_schedule *ks1, DES_key_schedule *ks2, int enc);
171 \& void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, 
172 \&        DES_key_schedule *ks1, DES_key_schedule *ks2, 
173 \&        DES_key_schedule *ks3, int enc);
174 \&
175 \& void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, 
176 \&        long length, DES_key_schedule *schedule, DES_cblock *ivec, 
177 \&        int enc);
178 \& void DES_cfb_encrypt(const unsigned char *in, unsigned char *out,
179 \&        int numbits, long length, DES_key_schedule *schedule,
180 \&        DES_cblock *ivec, int enc);
181 \& void DES_ofb_encrypt(const unsigned char *in, unsigned char *out,
182 \&        int numbits, long length, DES_key_schedule *schedule,
183 \&        DES_cblock *ivec);
184 \& void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, 
185 \&        long length, DES_key_schedule *schedule, DES_cblock *ivec, 
186 \&        int enc);
187 \& void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out,
188 \&        long length, DES_key_schedule *schedule, DES_cblock *ivec,
189 \&        int *num, int enc);
190 \& void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out,
191 \&        long length, DES_key_schedule *schedule, DES_cblock *ivec,
192 \&        int *num);
193 \&
194 \& void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, 
195 \&        long length, DES_key_schedule *schedule, DES_cblock *ivec, 
196 \&        const_DES_cblock *inw, const_DES_cblock *outw, int enc);
197 \&
198 \& void DES_ede2_cbc_encrypt(const unsigned char *input,
199 \&        unsigned char *output, long length, DES_key_schedule *ks1,
200 \&        DES_key_schedule *ks2, DES_cblock *ivec, int enc);
201 \& void DES_ede2_cfb64_encrypt(const unsigned char *in,
202 \&        unsigned char *out, long length, DES_key_schedule *ks1,
203 \&        DES_key_schedule *ks2, DES_cblock *ivec, int *num, int enc);
204 \& void DES_ede2_ofb64_encrypt(const unsigned char *in,
205 \&        unsigned char *out, long length, DES_key_schedule *ks1,
206 \&        DES_key_schedule *ks2, DES_cblock *ivec, int *num);
207 \&
208 \& void DES_ede3_cbc_encrypt(const unsigned char *input,
209 \&        unsigned char *output, long length, DES_key_schedule *ks1,
210 \&        DES_key_schedule *ks2, DES_key_schedule *ks3, DES_cblock *ivec,
211 \&        int enc);
212 \& void DES_ede3_cbcm_encrypt(const unsigned char *in, unsigned char *out, 
213 \&        long length, DES_key_schedule *ks1, DES_key_schedule *ks2, 
214 \&        DES_key_schedule *ks3, DES_cblock *ivec1, DES_cblock *ivec2, 
215 \&        int enc);
216 \& void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, 
217 \&        long length, DES_key_schedule *ks1, DES_key_schedule *ks2,
218 \&        DES_key_schedule *ks3, DES_cblock *ivec, int *num, int enc);
219 \& void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, 
220 \&        long length, DES_key_schedule *ks1, 
221 \&        DES_key_schedule *ks2, DES_key_schedule *ks3, 
222 \&        DES_cblock *ivec, int *num);
223 \&
224 \& DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, 
225 \&        long length, DES_key_schedule *schedule, 
226 \&        const_DES_cblock *ivec);
227 \& DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], 
228 \&        long length, int out_count, DES_cblock *seed);
229 \& void DES_string_to_key(const char *str, DES_cblock *key);
230 \& void DES_string_to_2keys(const char *str, DES_cblock *key1,
231 \&        DES_cblock *key2);
232 \&
233 \& char *DES_fcrypt(const char *buf, const char *salt, char *ret);
234 \& char *DES_crypt(const char *buf, const char *salt);
235 \&
236 \& int DES_enc_read(int fd, void *buf, int len, DES_key_schedule *sched,
237 \&        DES_cblock *iv);
238 \& int DES_enc_write(int fd, const void *buf, int len,
239 \&        DES_key_schedule *sched, DES_cblock *iv);
240 .Ve
241 .SH "DESCRIPTION"
242 .IX Header "DESCRIPTION"
243 This library contains a fast implementation of the \s-1DES\s0 encryption
244 algorithm.
245 .PP
246 There are two phases to the use of \s-1DES\s0 encryption.  The first is the
247 generation of a \fIDES_key_schedule\fR from a key, the second is the
248 actual encryption.  A \s-1DES\s0 key is of type \fIDES_cblock\fR. This type is
249 consists of 8 bytes with odd parity.  The least significant bit in
250 each byte is the parity bit.  The key schedule is an expanded form of
251 the key; it is used to speed the encryption process.
252 .PP
253 \&\fIDES_random_key()\fR generates a random key.  The \s-1PRNG\s0 must be seeded
254 prior to using this function (see \fIrand\fR\|(3)).  If the \s-1PRNG\s0
255 could not generate a secure key, 0 is returned.
256 .PP
257 Before a \s-1DES\s0 key can be used, it must be converted into the
258 architecture dependent \fIDES_key_schedule\fR via the
259 \&\fIDES_set_key_checked()\fR or \fIDES_set_key_unchecked()\fR function.
260 .PP
261 \&\fIDES_set_key_checked()\fR will check that the key passed is of odd parity
262 and is not a week or semi-weak key.  If the parity is wrong, then \-1
263 is returned.  If the key is a weak key, then \-2 is returned.  If an
264 error is returned, the key schedule is not generated.
265 .PP
266 \&\fIDES_set_key()\fR works like
267 \&\fIDES_set_key_checked()\fR if the \fIDES_check_key\fR flag is non-zero,
268 otherwise like \fIDES_set_key_unchecked()\fR.  These functions are available
269 for compatibility; it is recommended to use a function that does not
270 depend on a global variable.
271 .PP
272 \&\fIDES_set_odd_parity()\fR sets the parity of the passed \fIkey\fR to odd.
273 .PP
274 \&\fIDES_is_weak_key()\fR returns 1 is the passed key is a weak key, 0 if it
275 is ok.  The probability that a randomly generated key is weak is
276 1/2^52, so it is not really worth checking for them.
277 .PP
278 The following routines mostly operate on an input and output stream of
279 \&\fIDES_cblock\fRs.
280 .PP
281 \&\fIDES_ecb_encrypt()\fR is the basic \s-1DES\s0 encryption routine that encrypts or
282 decrypts a single 8\-byte \fIDES_cblock\fR in \fIelectronic code book\fR
283 (\s-1ECB\s0) mode.  It always transforms the input data, pointed to by
284 \&\fIinput\fR, into the output data, pointed to by the \fIoutput\fR argument.
285 If the \fIencrypt\fR argument is non-zero (\s-1DES_ENCRYPT\s0), the \fIinput\fR
286 (cleartext) is encrypted in to the \fIoutput\fR (ciphertext) using the
287 key_schedule specified by the \fIschedule\fR argument, previously set via
288 \&\fIDES_set_key\fR. If \fIencrypt\fR is zero (\s-1DES_DECRYPT\s0), the \fIinput\fR (now
289 ciphertext) is decrypted into the \fIoutput\fR (now cleartext).  Input
290 and output may overlap.  \fIDES_ecb_encrypt()\fR does not return a value.
291 .PP
292 \&\fIDES_ecb3_encrypt()\fR encrypts/decrypts the \fIinput\fR block by using
293 three-key Triple-DES encryption in \s-1ECB\s0 mode.  This involves encrypting
294 the input with \fIks1\fR, decrypting with the key schedule \fIks2\fR, and
295 then encrypting with \fIks3\fR.  This routine greatly reduces the chances
296 of brute force breaking of \s-1DES\s0 and has the advantage of if \fIks1\fR,
297 \&\fIks2\fR and \fIks3\fR are the same, it is equivalent to just encryption
298 using \s-1ECB\s0 mode and \fIks1\fR as the key.
299 .PP
300 The macro \fIDES_ecb2_encrypt()\fR is provided to perform two-key Triple-DES
301 encryption by using \fIks1\fR for the final encryption.
302 .PP
303 \&\fIDES_ncbc_encrypt()\fR encrypts/decrypts using the \fIcipher-block-chaining\fR
304 (\s-1CBC\s0) mode of \s-1DES\s0.  If the \fIencrypt\fR argument is non-zero, the
305 routine cipher-block-chain encrypts the cleartext data pointed to by
306 the \fIinput\fR argument into the ciphertext pointed to by the \fIoutput\fR
307 argument, using the key schedule provided by the \fIschedule\fR argument,
308 and initialization vector provided by the \fIivec\fR argument.  If the
309 \&\fIlength\fR argument is not an integral multiple of eight bytes, the
310 last block is copied to a temporary area and zero filled.  The output
311 is always an integral multiple of eight bytes.
312 .PP
313 \&\fIDES_xcbc_encrypt()\fR is \s-1RSA\s0's \s-1DESX\s0 mode of \s-1DES\s0.  It uses \fIinw\fR and
314 \&\fIoutw\fR to 'whiten' the encryption.  \fIinw\fR and \fIoutw\fR are secret
315 (unlike the iv) and are as such, part of the key.  So the key is sort
316 of 24 bytes.  This is much better than \s-1CBC\s0 \s-1DES\s0.
317 .PP
318 \&\fIDES_ede3_cbc_encrypt()\fR implements outer triple \s-1CBC\s0 \s-1DES\s0 encryption with
319 three keys. This means that each \s-1DES\s0 operation inside the \s-1CBC\s0 mode is
320 really an \f(CW\*(C`C=E(ks3,D(ks2,E(ks1,M)))\*(C'\fR.  This mode is used by \s-1SSL\s0.
321 .PP
322 The \fIDES_ede2_cbc_encrypt()\fR macro implements two-key Triple-DES by
323 reusing \fIks1\fR for the final encryption.  \f(CW\*(C`C=E(ks1,D(ks2,E(ks1,M)))\*(C'\fR.
324 This form of Triple-DES is used by the \s-1RSAREF\s0 library.
325 .PP
326 \&\fIDES_pcbc_encrypt()\fR encrypt/decrypts using the propagating cipher block
327 chaining mode used by Kerberos v4. Its parameters are the same as
328 \&\fIDES_ncbc_encrypt()\fR.
329 .PP
330 \&\fIDES_cfb_encrypt()\fR encrypt/decrypts using cipher feedback mode.  This
331 method takes an array of characters as input and outputs and array of
332 characters.  It does not require any padding to 8 character groups.
333 Note: the \fIivec\fR variable is changed and the new changed value needs to
334 be passed to the next call to this function.  Since this function runs
335 a complete \s-1DES\s0 \s-1ECB\s0 encryption per \fInumbits\fR, this function is only
336 suggested for use when sending small numbers of characters.
337 .PP
338 \&\fIDES_cfb64_encrypt()\fR
339 implements \s-1CFB\s0 mode of \s-1DES\s0 with 64bit feedback.  Why is this
340 useful you ask?  Because this routine will allow you to encrypt an
341 arbitrary number of bytes, no 8 byte padding.  Each call to this
342 routine will encrypt the input bytes to output and then update ivec
343 and num.  num contains 'how far' we are though ivec.  If this does
344 not make much sense, read more about cfb mode of \s-1DES\s0 :\-).
345 .PP
346 \&\fIDES_ede3_cfb64_encrypt()\fR and \fIDES_ede2_cfb64_encrypt()\fR is the same as
347 \&\fIDES_cfb64_encrypt()\fR except that Triple-DES is used.
348 .PP
349 \&\fIDES_ofb_encrypt()\fR encrypts using output feedback mode.  This method
350 takes an array of characters as input and outputs and array of
351 characters.  It does not require any padding to 8 character groups.
352 Note: the \fIivec\fR variable is changed and the new changed value needs to
353 be passed to the next call to this function.  Since this function runs
354 a complete \s-1DES\s0 \s-1ECB\s0 encryption per numbits, this function is only
355 suggested for use when sending small numbers of characters.
356 .PP
357 \&\fIDES_ofb64_encrypt()\fR is the same as \fIDES_cfb64_encrypt()\fR using Output
358 Feed Back mode.
359 .PP
360 \&\fIDES_ede3_ofb64_encrypt()\fR and \fIDES_ede2_ofb64_encrypt()\fR is the same as
361 \&\fIDES_ofb64_encrypt()\fR, using Triple-DES.
362 .PP
363 The following functions are included in the \s-1DES\s0 library for
364 compatibility with the \s-1MIT\s0 Kerberos library.
365 .PP
366 \&\fIDES_cbc_cksum()\fR produces an 8 byte checksum based on the input stream
367 (via \s-1CBC\s0 encryption).  The last 4 bytes of the checksum are returned
368 and the complete 8 bytes are placed in \fIoutput\fR. This function is
369 used by Kerberos v4.  Other applications should use
370 \&\fIEVP_DigestInit\fR\|(3) etc. instead.
371 .PP
372 \&\fIDES_quad_cksum()\fR is a Kerberos v4 function.  It returns a 4 byte
373 checksum from the input bytes.  The algorithm can be iterated over the
374 input, depending on \fIout_count\fR, 1, 2, 3 or 4 times.  If \fIoutput\fR is
375 non-NULL, the 8 bytes generated by each pass are written into
376 \&\fIoutput\fR.
377 .PP
378 The following are DES-based transformations:
379 .PP
380 \&\fIDES_fcrypt()\fR is a fast version of the Unix \fIcrypt\fR\|(3) function.  This
381 version takes only a small amount of space relative to other fast
382 \&\fIcrypt()\fR implementations.  This is different to the normal crypt in
383 that the third parameter is the buffer that the return value is
384 written into.  It needs to be at least 14 bytes long.  This function
385 is thread safe, unlike the normal crypt.
386 .PP
387 \&\fIDES_crypt()\fR is a faster replacement for the normal system \fIcrypt()\fR.
388 This function calls \fIDES_fcrypt()\fR with a static array passed as the
389 third parameter.  This emulates the normal non-thread safe semantics
390 of \fIcrypt\fR\|(3).
391 .PP
392 \&\fIDES_enc_write()\fR writes \fIlen\fR bytes to file descriptor \fIfd\fR from
393 buffer \fIbuf\fR. The data is encrypted via \fIpcbc_encrypt\fR (default)
394 using \fIsched\fR for the key and \fIiv\fR as a starting vector.  The actual
395 data send down \fIfd\fR consists of 4 bytes (in network byte order)
396 containing the length of the following encrypted data.  The encrypted
397 data then follows, padded with random data out to a multiple of 8
398 bytes.
399 .PP
400 \&\fIDES_enc_read()\fR is used to read \fIlen\fR bytes from file descriptor
401 \&\fIfd\fR into buffer \fIbuf\fR. The data being read from \fIfd\fR is assumed to
402 have come from \fIDES_enc_write()\fR and is decrypted using \fIsched\fR for
403 the key schedule and \fIiv\fR for the initial vector.
404 .PP
405 \&\fBWarning:\fR The data format used by \fIDES_enc_write()\fR and \fIDES_enc_read()\fR
406 has a cryptographic weakness: When asked to write more than \s-1MAXWRITE\s0
407 bytes, \fIDES_enc_write()\fR will split the data into several chunks that
408 are all encrypted using the same \s-1IV\s0.  So don't use these functions
409 unless you are sure you know what you do (in which case you might not
410 want to use them anyway).  They cannot handle non-blocking sockets.
411 \&\fIDES_enc_read()\fR uses an internal state and thus cannot be used on
412 multiple files.
413 .PP
414 \&\fIDES_rw_mode\fR is used to specify the encryption mode to use with
415 \&\fIDES_enc_read()\fR and \fIDES_end_write()\fR.  If set to \fI\s-1DES_PCBC_MODE\s0\fR (the
416 default), DES_pcbc_encrypt is used.  If set to \fI\s-1DES_CBC_MODE\s0\fR
417 DES_cbc_encrypt is used.
418 .SH "NOTES"
419 .IX Header "NOTES"
420 Single-key \s-1DES\s0 is insecure due to its short key size.  \s-1ECB\s0 mode is
421 not suitable for most applications; see \fIdes_modes\fR\|(7).
422 .PP
423 The \fIevp\fR\|(3) library provides higher-level encryption functions.
424 .SH "BUGS"
425 .IX Header "BUGS"
426 \&\fIDES_3cbc_encrypt()\fR is flawed and must not be used in applications.
427 .PP
428 \&\fIDES_cbc_encrypt()\fR does not modify \fBivec\fR; use \fIDES_ncbc_encrypt()\fR
429 instead.
430 .PP
431 \&\fIDES_cfb_encrypt()\fR and \fIDES_ofb_encrypt()\fR operates on input of 8 bits.
432 What this means is that if you set numbits to 12, and length to 2, the
433 first 12 bits will come from the 1st input byte and the low half of
434 the second input byte.  The second 12 bits will have the low 8 bits
435 taken from the 3rd input byte and the top 4 bits taken from the 4th
436 input byte.  The same holds for output.  This function has been
437 implemented this way because most people will be using a multiple of 8
438 and because once you get into pulling bytes input bytes apart things
439 get ugly!
440 .PP
441 \&\fIDES_string_to_key()\fR is available for backward compatibility with the
442 \&\s-1MIT\s0 library.  New applications should use a cryptographic hash function.
443 The same applies for \fIDES_string_to_2key()\fR.
444 .SH "CONFORMING TO"
445 .IX Header "CONFORMING TO"
446 \&\s-1ANSI\s0 X3.106
447 .PP
448 The \fBdes\fR library was written to be source code compatible with
449 the \s-1MIT\s0 Kerberos library.
450 .SH "SEE ALSO"
451 .IX Header "SEE ALSO"
452 \&\fIcrypt\fR\|(3), \fIdes_modes\fR\|(7), \fIevp\fR\|(3), \fIrand\fR\|(3)
453 .SH "HISTORY"
454 .IX Header "HISTORY"
455 In OpenSSL 0.9.7, all des_ functions were renamed to \s-1DES_\s0 to avoid
456 clashes with older versions of libdes.  Compatibility des_ functions
457 are provided for a short while, as well as \fIcrypt()\fR.
458 Declarations for these are in <openssl/des_old.h>. There is no \s-1DES_\s0
459 variant for \fIdes_random_seed()\fR.
460 This will happen to other functions
461 as well if they are deemed redundant (\fIdes_random_seed()\fR just calls
462 \&\fIRAND_seed()\fR and is present for backward compatibility only), buggy or
463 already scheduled for removal.
464 .PP
465 \&\fIdes_cbc_cksum()\fR, \fIdes_cbc_encrypt()\fR, \fIdes_ecb_encrypt()\fR,
466 \&\fIdes_is_weak_key()\fR, \fIdes_key_sched()\fR, \fIdes_pcbc_encrypt()\fR,
467 \&\fIdes_quad_cksum()\fR, \fIdes_random_key()\fR and \fIdes_string_to_key()\fR
468 are available in the \s-1MIT\s0 Kerberos library;
469 \&\fIdes_check_key_parity()\fR, \fIdes_fixup_key_parity()\fR and \fIdes_is_weak_key()\fR
470 are available in newer versions of that library.
471 .PP
472 \&\fIdes_set_key_checked()\fR and \fIdes_set_key_unchecked()\fR were added in
473 OpenSSL 0.9.5.
474 .PP
475 \&\fIdes_generate_random_block()\fR, \fIdes_init_random_number_generator()\fR,
476 \&\fIdes_new_random_key()\fR, \fIdes_set_random_generator_seed()\fR and
477 \&\fIdes_set_sequence_number()\fR and \fIdes_rand_data()\fR are used in newer
478 versions of Kerberos but are not implemented here.
479 .PP
480 \&\fIdes_random_key()\fR generated cryptographically weak random data in
481 SSLeay and in OpenSSL prior version 0.9.5, as well as in the original
482 \&\s-1MIT\s0 library.
483 .SH "AUTHOR"
484 .IX Header "AUTHOR"
485 Eric Young (eay@cryptsoft.com). Modified for the OpenSSL project
486 (http://www.openssl.org).