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().
55 a multiple of 64 bits are enciphered at a time.
59 The CBC mode produces the same ciphertext whenever the same
60 plaintext is encrypted using the same key and starting variable.
64 The chaining operation makes the ciphertext blocks dependent on the
65 current and all preceding plaintext blocks and therefore blocks can not
70 The use of different starting variables prevents the same plaintext
71 enciphering to the same ciphertext.
75 An error will affect the current and the following ciphertext blocks.
79 =head2 Cipher Feedback Mode (CFB)
81 Normally, this is found as the function I<algorithm>_cfb_encrypt().
87 a number of bits (j) <= 64 are enciphered at a time.
91 The CFB mode produces the same ciphertext whenever the same
92 plaintext is encrypted using the same key and starting variable.
96 The chaining operation makes the ciphertext variables dependent on the
97 current and all preceding variables and therefore j-bit variables are
98 chained together and can not be rearranged.
102 The use of different starting variables prevents the same plaintext
103 enciphering to the same ciphertext.
107 The strength of the CFB mode depends on the size of k (maximal if
108 j == k). In my implementation this is always the case.
112 Selection of a small value for j will require more cycles through
113 the encipherment algorithm per unit of plaintext and thus cause
114 greater processing overheads.
118 Only multiples of j bits can be enciphered.
122 An error will affect the current and the following ciphertext variables.
126 =head2 Output Feedback Mode (OFB)
128 Normally, this is found as the function I<algorithm>_ofb_encrypt().
135 a number of bits (j) <= 64 are enciphered at a time.
139 The OFB mode produces the same ciphertext whenever the same
140 plaintext enciphered using the same key and starting variable. More
141 over, in the OFB mode the same key stream is produced when the same
142 key and start variable are used. Consequently, for security reasons
143 a specific start variable should be used only once for a given key.
147 The absence of chaining makes the OFB more vulnerable to specific attacks.
151 The use of different start variables values prevents the same
152 plaintext enciphering to the same ciphertext, by producing different
157 Selection of a small value for j will require more cycles through
158 the encipherment algorithm per unit of plaintext and thus cause
159 greater processing overheads.
163 Only multiples of j bits can be enciphered.
167 OFB mode of operation does not extend ciphertext errors in the
168 resultant plaintext output. Every bit error in the ciphertext causes
169 only one bit to be in error in the deciphered plaintext.
173 OFB mode is not self-synchronising. If the two operation of
174 encipherment and decipherment get out of synchronism, the system needs
175 to be re-initialised.
179 Each re-initialisation should use a value of the start variable
180 different from the start variable values used before with the same
181 key. The reason for this is that an identical bit stream would be
182 produced each time from the same parameters. This would be
183 susceptible to a 'known plaintext' attack.
187 =head2 Triple ECB Mode
189 Normally, this is found as the function I<algorithm>_ecb3_encrypt().
195 Encrypt with key1, decrypt with key2 and encrypt with key3 again.
199 As for ECB encryption but increases the key length to 168 bits.
200 There are theoretic attacks that can be used that make the effective
201 key length 112 bits, but this attack also requires 2^56 blocks of
202 memory, not very likely, even for the NSA.
206 If both keys are the same it is equivalent to encrypting once with
211 If the first and last key are the same, the key length is 112 bits.
212 There are attacks that could reduce the key space to 55 bit's but it
213 requires 2^56 blocks of memory.
217 If all 3 keys are the same, this is effectively the same as normal
222 =head2 Triple CBC Mode
224 Normally, this is found as the function I<algorithm>_ede3_cbc_encrypt().
231 Encrypt with key1, decrypt with key2 and then encrypt with key3.
235 As for CBC encryption but increases the key length to 168 bits with
236 the same restrictions as for triple ecb mode.
242 L<blowfish(3)|blowfish(3)>, L<des(3)|des(3)>, L<idea(3)|idea(3)>,