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