Import OpenSSL-0.9.8i.
[dragonfly.git] / crypto / openssl-0.9.7d / doc / crypto / des_modes.pod
blobda75e8007d454d1956a1c0153b1dc1cf691f9f88
1 =pod
3 =head1 NAME
5 Modes of DES - the variants of DES and other crypto algorithms of OpenSSL
7 =head1 DESCRIPTION
9 Several crypto algorithms for OpenSSL can be used in a number of modes.  Those
10 are used for using block ciphers in a way similar to stream ciphers, among
11 other things.
13 =head1 OVERVIEW
15 =head2 Electronic Codebook Mode (ECB)
17 Normally, this is found as the function I<algorithm>_ecb_encrypt().
19 =over 2
21 =item *
23 64 bits are enciphered at a time.
25 =item *
27 The order of the blocks can be rearranged without detection.
29 =item *
31 The same plaintext block always produces the same ciphertext block
32 (for the same key) making it vulnerable to a 'dictionary attack'.
34 =item *
36 An error will only affect one ciphertext block.
38 =back
40 =head2 Cipher Block Chaining Mode (CBC)
42 Normally, this is found as the function I<algorithm>_cbc_encrypt().
43 Be aware that des_cbc_encrypt() is not really DES CBC (it does
44 not update the IV); use des_ncbc_encrypt() instead.
46 =over 2
48 =item *
50 a multiple of 64 bits are enciphered at a time.
52 =item *
54 The CBC mode produces the same ciphertext whenever the same
55 plaintext is encrypted using the same key and starting variable.
57 =item *
59 The chaining operation makes the ciphertext blocks dependent on the
60 current and all preceding plaintext blocks and therefore blocks can not
61 be rearranged.
63 =item *
65 The use of different starting variables prevents the same plaintext
66 enciphering to the same ciphertext.
68 =item *
70 An error will affect the current and the following ciphertext blocks.
72 =back
74 =head2 Cipher Feedback Mode (CFB)
76 Normally, this is found as the function I<algorithm>_cfb_encrypt().
78 =over 2
80 =item *
82 a number of bits (j) <= 64 are enciphered at a time.
84 =item *
86 The CFB mode produces the same ciphertext whenever the same
87 plaintext is encrypted using the same key and starting variable.
89 =item *
91 The chaining operation makes the ciphertext variables dependent on the
92 current and all preceding variables and therefore j-bit variables are
93 chained together and can not be rearranged.
95 =item *
97 The use of different starting variables prevents the same plaintext
98 enciphering to the same ciphertext.
100 =item *
102 The strength of the CFB mode depends on the size of k (maximal if
103 j == k).  In my implementation this is always the case.
105 =item *
107 Selection of a small value for j will require more cycles through
108 the encipherment algorithm per unit of plaintext and thus cause
109 greater processing overheads.
111 =item *
113 Only multiples of j bits can be enciphered.
115 =item *
117 An error will affect the current and the following ciphertext variables.
119 =back
121 =head2 Output Feedback Mode (OFB)
123 Normally, this is found as the function I<algorithm>_ofb_encrypt().
125 =over 2
128 =item *
130 a number of bits (j) <= 64 are enciphered at a time.
132 =item *
134 The OFB mode produces the same ciphertext whenever the same
135 plaintext enciphered using the same key and starting variable.  More
136 over, in the OFB mode the same key stream is produced when the same
137 key and start variable are used.  Consequently, for security reasons
138 a specific start variable should be used only once for a given key.
140 =item *
142 The absence of chaining makes the OFB more vulnerable to specific attacks.
144 =item *
146 The use of different start variables values prevents the same
147 plaintext enciphering to the same ciphertext, by producing different
148 key streams.
150 =item *
152 Selection of a small value for j will require more cycles through
153 the encipherment algorithm per unit of plaintext and thus cause
154 greater processing overheads.
156 =item *
158 Only multiples of j bits can be enciphered.
160 =item *
162 OFB mode of operation does not extend ciphertext errors in the
163 resultant plaintext output.  Every bit error in the ciphertext causes
164 only one bit to be in error in the deciphered plaintext.
166 =item *
168 OFB mode is not self-synchronizing.  If the two operation of
169 encipherment and decipherment get out of synchronism, the system needs
170 to be re-initialized.
172 =item *
174 Each re-initialization should use a value of the start variable
175 different from the start variable values used before with the same
176 key.  The reason for this is that an identical bit stream would be
177 produced each time from the same parameters.  This would be
178 susceptible to a 'known plaintext' attack.
180 =back
182 =head2 Triple ECB Mode
184 Normally, this is found as the function I<algorithm>_ecb3_encrypt().
186 =over 2
188 =item *
190 Encrypt with key1, decrypt with key2 and encrypt with key3 again.
192 =item *
194 As for ECB encryption but increases the key length to 168 bits.
195 There are theoretic attacks that can be used that make the effective
196 key length 112 bits, but this attack also requires 2^56 blocks of
197 memory, not very likely, even for the NSA.
199 =item *
201 If both keys are the same it is equivalent to encrypting once with
202 just one key.
204 =item *
206 If the first and last key are the same, the key length is 112 bits.
207 There are attacks that could reduce the effective key strength
208 to only slightly more than 56 bits, but these require a lot of memory.
210 =item *
212 If all 3 keys are the same, this is effectively the same as normal
213 ecb mode.
215 =back
217 =head2 Triple CBC Mode
219 Normally, this is found as the function I<algorithm>_ede3_cbc_encrypt().
221 =over 2
224 =item *
226 Encrypt with key1, decrypt with key2 and then encrypt with key3.
228 =item *
230 As for CBC encryption but increases the key length to 168 bits with
231 the same restrictions as for triple ecb mode.
233 =back
235 =head1 NOTES
237 This text was been written in large parts by Eric Young in his original
238 documentation for SSLeay, the predecessor of OpenSSL.  In turn, he attributed
239 it to:
241         AS 2805.5.2
242         Australian Standard
243         Electronic funds transfer - Requirements for interfaces,
244         Part 5.2: Modes of operation for an n-bit block cipher algorithm
245         Appendix A
247 =head1 SEE ALSO
249 L<blowfish(3)|blowfish(3)>, L<des(3)|des(3)>, L<idea(3)|idea(3)>,
250 L<rc2(3)|rc2(3)>
252 =cut