5 Modes of DES and other crypto algorithms of OpenSSL
9 Several crypto algorithms fo OpenSSL can be used in a number of modes. The
10 following text has been written in large parts by Eric Young in his original
11 documentation for SSLeay, the predecessor of OpenSSL. In turn, he attributed
16 Electronic funds transfer - Requirements for interfaces,
17 Part 5.2: Modes of operation for an n-bit block cipher algorithm
22 =head2 Electronic Codebook Mode (ECB)
24 Normally, this is found as the function I<algorithm>_ecb_encrypt().
30 64 bits are enciphered at a time.
34 The order of the blocks can be rearranged without detection.
38 The same plaintext block always produces the same ciphertext block
39 (for the same key) making it vulnerable to a 'dictionary attack'.
43 An error will only affect one ciphertext block.
47 =head2 Cipher Block Chaining Mode (CBC)
49 Normally, this is found as the function I<algorithm>_cbc_encrypt().
50 Be aware that des_cbc_encrypt() is not really DES CBC (it does
51 not update the IV); use des_ncbc_encrypt() instead.
57 a multiple of 64 bits are enciphered at a time.
61 The CBC mode produces the same ciphertext whenever the same
62 plaintext is encrypted using the same key and starting variable.
66 The chaining operation makes the ciphertext blocks dependent on the
67 current and all preceding plaintext blocks and therefore blocks can not
72 The use of different starting variables prevents the same plaintext
73 enciphering to the same ciphertext.
77 An error will affect the current and the following ciphertext blocks.
81 =head2 Cipher Feedback Mode (CFB)
83 Normally, this is found as the function I<algorithm>_cfb_encrypt().
89 a number of bits (j) <= 64 are enciphered at a time.
93 The CFB mode produces the same ciphertext whenever the same
94 plaintext is encrypted using the same key and starting variable.
98 The chaining operation makes the ciphertext variables dependent on the
99 current and all preceding variables and therefore j-bit variables are
100 chained together and can not be rearranged.
104 The use of different starting variables prevents the same plaintext
105 enciphering to the same ciphertext.
109 The strength of the CFB mode depends on the size of k (maximal if
110 j == k). In my implementation this is always the case.
114 Selection of a small value for j will require more cycles through
115 the encipherment algorithm per unit of plaintext and thus cause
116 greater processing overheads.
120 Only multiples of j bits can be enciphered.
124 An error will affect the current and the following ciphertext variables.
128 =head2 Output Feedback Mode (OFB)
130 Normally, this is found as the function I<algorithm>_ofb_encrypt().
137 a number of bits (j) <= 64 are enciphered at a time.
141 The OFB mode produces the same ciphertext whenever the same
142 plaintext enciphered using the same key and starting variable. More
143 over, in the OFB mode the same key stream is produced when the same
144 key and start variable are used. Consequently, for security reasons
145 a specific start variable should be used only once for a given key.
149 The absence of chaining makes the OFB more vulnerable to specific attacks.
153 The use of different start variables values prevents the same
154 plaintext enciphering to the same ciphertext, by producing different
159 Selection of a small value for j will require more cycles through
160 the encipherment algorithm per unit of plaintext and thus cause
161 greater processing overheads.
165 Only multiples of j bits can be enciphered.
169 OFB mode of operation does not extend ciphertext errors in the
170 resultant plaintext output. Every bit error in the ciphertext causes
171 only one bit to be in error in the deciphered plaintext.
175 OFB mode is not self-synchronising. If the two operation of
176 encipherment and decipherment get out of synchronism, the system needs
177 to be re-initialised.
181 Each re-initialisation should use a value of the start variable
182 different from the start variable values used before with the same
183 key. The reason for this is that an identical bit stream would be
184 produced each time from the same parameters. This would be
185 susceptible to a 'known plaintext' attack.
189 =head2 Triple ECB Mode
191 Normally, this is found as the function I<algorithm>_ecb3_encrypt().
197 Encrypt with key1, decrypt with key2 and encrypt with key3 again.
201 As for ECB encryption but increases the key length to 168 bits.
202 There are theoretic attacks that can be used that make the effective
203 key length 112 bits, but this attack also requires 2^56 blocks of
204 memory, not very likely, even for the NSA.
208 If both keys are the same it is equivalent to encrypting once with
213 If the first and last key are the same, the key length is 112 bits.
214 There are attacks that could reduce the key space to 55 bit's but it
215 requires 2^56 blocks of memory.
219 If all 3 keys are the same, this is effectively the same as normal
224 =head2 Triple CBC Mode
226 Normally, this is found as the function I<algorithm>_ede3_cbc_encrypt().
233 Encrypt with key1, decrypt with key2 and then encrypt with key3.
237 As for CBC encryption but increases the key length to 168 bits with
238 the same restrictions as for triple ecb mode.
244 L<blowfish(3)|blowfish(3)>, L<des(3)|des(3)>, L<idea(3)|idea(3)>,