Merge from vendor branch DIFFUTILS:
[dragonfly.git] / secure / lib / libcrypto / man / des_modes.3
1 .\" Automatically generated by Pod::Man version 1.15
2 .\" Mon Jan 13 19:29:14 2003
3 .\"
4 .\" Standard preamble:
5 .\" ======================================================================
6 .de Sh \" Subsection heading
7 .br
8 .if t .Sp
9 .ne 5
10 .PP
11 \fB\\$1\fR
12 .PP
13 ..
14 .de Sp \" Vertical space (when we can't use .PP)
15 .if t .sp .5v
16 .if n .sp
17 ..
18 .de Ip \" List item
19 .br
20 .ie \\n(.$>=3 .ne \\$3
21 .el .ne 3
22 .IP "\\$1" \\$2
23 ..
24 .de Vb \" Begin verbatim text
25 .ft CW
26 .nf
27 .ne \\$1
28 ..
29 .de Ve \" End verbatim text
30 .ft R
31
32 .fi
33 ..
34 .\" Set up some character translations and predefined strings.  \*(-- will
35 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
36 .\" double quote, and \*(R" will give a right double quote.  | will give a
37 .\" real vertical bar.  \*(C+ will give a nicer C++.  Capital omega is used
38 .\" to do unbreakable dashes and therefore won't be available.  \*(C` and
39 .\" \*(C' expand to `' in nroff, nothing in troff, for use with C<>
40 .tr \(*W-|\(bv\*(Tr
41 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
42 .ie n \{\
43 .    ds -- \(*W-
44 .    ds PI pi
45 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
46 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
47 .    ds L" ""
48 .    ds R" ""
49 .    ds C` ""
50 .    ds C' ""
51 'br\}
52 .el\{\
53 .    ds -- \|\(em\|
54 .    ds PI \(*p
55 .    ds L" ``
56 .    ds R" ''
57 'br\}
58 .\"
59 .\" If the F register is turned on, we'll generate index entries on stderr
60 .\" for titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and
61 .\" index entries marked with X<> in POD.  Of course, you'll have to process
62 .\" the output yourself in some meaningful fashion.
63 .if \nF \{\
64 .    de IX
65 .    tm Index:\\$1\t\\n%\t"\\$2"
66 ..
67 .    nr % 0
68 .    rr F
69 .\}
70 .\"
71 .\" For nroff, turn off justification.  Always turn off hyphenation; it
72 .\" makes way too many mistakes in technical documents.
73 .hy 0
74 .if n .na
75 .\"
76 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
77 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
78 .bd B 3
79 .    \" fudge factors for nroff and troff
80 .if n \{\
81 .    ds #H 0
82 .    ds #V .8m
83 .    ds #F .3m
84 .    ds #[ \f1
85 .    ds #] \fP
86 .\}
87 .if t \{\
88 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
89 .    ds #V .6m
90 .    ds #F 0
91 .    ds #[ \&
92 .    ds #] \&
93 .\}
94 .    \" simple accents for nroff and troff
95 .if n \{\
96 .    ds ' \&
97 .    ds ` \&
98 .    ds ^ \&
99 .    ds , \&
100 .    ds ~ ~
101 .    ds /
102 .\}
103 .if t \{\
104 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
105 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
106 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
107 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
108 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
109 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
110 .\}
111 .    \" troff and (daisy-wheel) nroff accents
112 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
113 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
114 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
115 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
116 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
117 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
118 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
119 .ds ae a\h'-(\w'a'u*4/10)'e
120 .ds Ae A\h'-(\w'A'u*4/10)'E
121 .    \" corrections for vroff
122 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
123 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
124 .    \" for low resolution devices (crt and lpr)
125 .if \n(.H>23 .if \n(.V>19 \
126 \{\
127 .    ds : e
128 .    ds 8 ss
129 .    ds o a
130 .    ds d- d\h'-1'\(ga
131 .    ds D- D\h'-1'\(hy
132 .    ds th \o'bp'
133 .    ds Th \o'LP'
134 .    ds ae ae
135 .    ds Ae AE
136 .\}
137 .rm #[ #] #H #V #F C
138 .\" ======================================================================
139 .\"
140 .IX Title "des_modes 3"
141 .TH des_modes 3 "0.9.7" "2003-01-13" "OpenSSL"
142 .UC
143 .SH "NAME"
144 Modes of \s-1DES\s0 \- the variants of \s-1DES\s0 and other crypto algorithms of OpenSSL
145 .SH "DESCRIPTION"
146 .IX Header "DESCRIPTION"
147 Several crypto algorithms for OpenSSL can be used in a number of modes.  Those
148 are used for using block ciphers in a way similar to stream ciphers, among
149 other things.
150 .SH "OVERVIEW"
151 .IX Header "OVERVIEW"
152 .Sh "Electronic Codebook Mode (\s-1ECB\s0)"
153 .IX Subsection "Electronic Codebook Mode (ECB)"
154 Normally, this is found as the function \fIalgorithm\fR\fI_ecb_encrypt()\fR.
155 .Ip "\(bu" 2
156 64 bits are enciphered at a time.
157 .Ip "\(bu" 2
158 The order of the blocks can be rearranged without detection.
159 .Ip "\(bu" 2
160 The same plaintext block always produces the same ciphertext block
161 (for the same key) making it vulnerable to a 'dictionary attack'.
162 .Ip "\(bu" 2
163 An error will only affect one ciphertext block.
164 .Sh "Cipher Block Chaining Mode (\s-1CBC\s0)"
165 .IX Subsection "Cipher Block Chaining Mode (CBC)"
166 Normally, this is found as the function \fIalgorithm\fR\fI_cbc_encrypt()\fR.
167 Be aware that \fIdes_cbc_encrypt()\fR is not really \s-1DES\s0 \s-1CBC\s0 (it does
168 not update the \s-1IV\s0); use \fIdes_ncbc_encrypt()\fR instead.
169 .Ip "\(bu" 2
170 a multiple of 64 bits are enciphered at a time.
171 .Ip "\(bu" 2
172 The \s-1CBC\s0 mode produces the same ciphertext whenever the same
173 plaintext is encrypted using the same key and starting variable.
174 .Ip "\(bu" 2
175 The chaining operation makes the ciphertext blocks dependent on the
176 current and all preceding plaintext blocks and therefore blocks can not
177 be rearranged.
178 .Ip "\(bu" 2
179 The use of different starting variables prevents the same plaintext
180 enciphering to the same ciphertext.
181 .Ip "\(bu" 2
182 An error will affect the current and the following ciphertext blocks.
183 .Sh "Cipher Feedback Mode (\s-1CFB\s0)"
184 .IX Subsection "Cipher Feedback Mode (CFB)"
185 Normally, this is found as the function \fIalgorithm\fR\fI_cfb_encrypt()\fR.
186 .Ip "\(bu" 2
187 a number of bits (j) <= 64 are enciphered at a time.
188 .Ip "\(bu" 2
189 The \s-1CFB\s0 mode produces the same ciphertext whenever the same
190 plaintext is encrypted using the same key and starting variable.
191 .Ip "\(bu" 2
192 The chaining operation makes the ciphertext variables dependent on the
193 current and all preceding variables and therefore j-bit variables are
194 chained together and can not be rearranged.
195 .Ip "\(bu" 2
196 The use of different starting variables prevents the same plaintext
197 enciphering to the same ciphertext.
198 .Ip "\(bu" 2
199 The strength of the \s-1CFB\s0 mode depends on the size of k (maximal if
200 j == k).  In my implementation this is always the case.
201 .Ip "\(bu" 2
202 Selection of a small value for j will require more cycles through
203 the encipherment algorithm per unit of plaintext and thus cause
204 greater processing overheads.
205 .Ip "\(bu" 2
206 Only multiples of j bits can be enciphered.
207 .Ip "\(bu" 2
208 An error will affect the current and the following ciphertext variables.
209 .Sh "Output Feedback Mode (\s-1OFB\s0)"
210 .IX Subsection "Output Feedback Mode (OFB)"
211 Normally, this is found as the function \fIalgorithm\fR\fI_ofb_encrypt()\fR.
212 .Ip "\(bu" 2
213 a number of bits (j) <= 64 are enciphered at a time.
214 .Ip "\(bu" 2
215 The \s-1OFB\s0 mode produces the same ciphertext whenever the same
216 plaintext enciphered using the same key and starting variable.  More
217 over, in the \s-1OFB\s0 mode the same key stream is produced when the same
218 key and start variable are used.  Consequently, for security reasons
219 a specific start variable should be used only once for a given key.
220 .Ip "\(bu" 2
221 The absence of chaining makes the \s-1OFB\s0 more vulnerable to specific attacks.
222 .Ip "\(bu" 2
223 The use of different start variables values prevents the same
224 plaintext enciphering to the same ciphertext, by producing different
225 key streams.
226 .Ip "\(bu" 2
227 Selection of a small value for j will require more cycles through
228 the encipherment algorithm per unit of plaintext and thus cause
229 greater processing overheads.
230 .Ip "\(bu" 2
231 Only multiples of j bits can be enciphered.
232 .Ip "\(bu" 2
233 \&\s-1OFB\s0 mode of operation does not extend ciphertext errors in the
234 resultant plaintext output.  Every bit error in the ciphertext causes
235 only one bit to be in error in the deciphered plaintext.
236 .Ip "\(bu" 2
237 \&\s-1OFB\s0 mode is not self-synchronizing.  If the two operation of
238 encipherment and decipherment get out of synchronism, the system needs
239 to be re-initialized.
240 .Ip "\(bu" 2
241 Each re-initialization should use a value of the start variable
242 different from the start variable values used before with the same
243 key.  The reason for this is that an identical bit stream would be
244 produced each time from the same parameters.  This would be
245 susceptible to a 'known plaintext' attack.
246 .Sh "Triple \s-1ECB\s0 Mode"
247 .IX Subsection "Triple ECB Mode"
248 Normally, this is found as the function \fIalgorithm\fR\fI_ecb3_encrypt()\fR.
249 .Ip "\(bu" 2
250 Encrypt with key1, decrypt with key2 and encrypt with key3 again.
251 .Ip "\(bu" 2
252 As for \s-1ECB\s0 encryption but increases the key length to 168 bits.
253 There are theoretic attacks that can be used that make the effective
254 key length 112 bits, but this attack also requires 2^56 blocks of
255 memory, not very likely, even for the \s-1NSA\s0.
256 .Ip "\(bu" 2
257 If both keys are the same it is equivalent to encrypting once with
258 just one key.
259 .Ip "\(bu" 2
260 If the first and last key are the same, the key length is 112 bits.
261 There are attacks that could reduce the effective key strength
262 to only slightly more than 56 bits, but these require a lot of memory.
263 .Ip "\(bu" 2
264 If all 3 keys are the same, this is effectively the same as normal
265 ecb mode.
266 .Sh "Triple \s-1CBC\s0 Mode"
267 .IX Subsection "Triple CBC Mode"
268 Normally, this is found as the function \fIalgorithm\fR\fI_ede3_cbc_encrypt()\fR.
269 .Ip "\(bu" 2
270 Encrypt with key1, decrypt with key2 and then encrypt with key3.
271 .Ip "\(bu" 2
272 As for \s-1CBC\s0 encryption but increases the key length to 168 bits with
273 the same restrictions as for triple ecb mode.
274 .SH "NOTES"
275 .IX Header "NOTES"
276 This text was been written in large parts by Eric Young in his original
277 documentation for SSLeay, the predecessor of OpenSSL.  In turn, he attributed
278 it to:
279 .PP
280 .Vb 5
281 \&        AS 2805.5.2
282 \&        Australian Standard
283 \&        Electronic funds transfer - Requirements for interfaces,
284 \&        Part 5.2: Modes of operation for an n-bit block cipher algorithm
285 \&        Appendix A
286 .Ve
287 .SH "SEE ALSO"
288 .IX Header "SEE ALSO"
289 blowfish(3), des(3), idea(3),
290 rc2(3)