1=pod 2 3=for comment openssl_manual_section:7 4 5=head1 NAME 6 7des_modes - the variants of DES and other crypto algorithms of OpenSSL 8 9=head1 DESCRIPTION 10 11Several crypto algorithms for OpenSSL can be used in a number of modes. Those 12are used for using block ciphers in a way similar to stream ciphers, among 13other things. 14 15=head1 OVERVIEW 16 17=head2 Electronic Codebook Mode (ECB) 18 19Normally, this is found as the function I<algorithm>_ecb_encrypt(). 20 21=over 2 22 23=item * 24 2564 bits are enciphered at a time. 26 27=item * 28 29The order of the blocks can be rearranged without detection. 30 31=item * 32 33The same plaintext block always produces the same ciphertext block 34(for the same key) making it vulnerable to a 'dictionary attack'. 35 36=item * 37 38An error will only affect one ciphertext block. 39 40=back 41 42=head2 Cipher Block Chaining Mode (CBC) 43 44Normally, this is found as the function I<algorithm>_cbc_encrypt(). 45Be aware that des_cbc_encrypt() is not really DES CBC (it does 46not update the IV); use des_ncbc_encrypt() instead. 47 48=over 2 49 50=item * 51 52a multiple of 64 bits are enciphered at a time. 53 54=item * 55 56The CBC mode produces the same ciphertext whenever the same 57plaintext is encrypted using the same key and starting variable. 58 59=item * 60 61The chaining operation makes the ciphertext blocks dependent on the 62current and all preceding plaintext blocks and therefore blocks can not 63be rearranged. 64 65=item * 66 67The use of different starting variables prevents the same plaintext 68enciphering to the same ciphertext. 69 70=item * 71 72An error will affect the current and the following ciphertext blocks. 73 74=back 75 76=head2 Cipher Feedback Mode (CFB) 77 78Normally, this is found as the function I<algorithm>_cfb_encrypt(). 79 80=over 2 81 82=item * 83 84a number of bits (j) <= 64 are enciphered at a time. 85 86=item * 87 88The CFB mode produces the same ciphertext whenever the same 89plaintext is encrypted using the same key and starting variable. 90 91=item * 92 93The chaining operation makes the ciphertext variables dependent on the 94current and all preceding variables and therefore j-bit variables are 95chained together and can not be rearranged. 96 97=item * 98 99The use of different starting variables prevents the same plaintext 100enciphering to the same ciphertext. 101 102=item * 103 104The strength of the CFB mode depends on the size of k (maximal if 105j == k). In my implementation this is always the case. 106 107=item * 108 109Selection of a small value for j will require more cycles through 110the encipherment algorithm per unit of plaintext and thus cause 111greater processing overheads. 112 113=item * 114 115Only multiples of j bits can be enciphered. 116 117=item * 118 119An error will affect the current and the following ciphertext variables. 120 121=back 122 123=head2 Output Feedback Mode (OFB) 124 125Normally, this is found as the function I<algorithm>_ofb_encrypt(). 126 127=over 2 128 129 130=item * 131 132a number of bits (j) <= 64 are enciphered at a time. 133 134=item * 135 136The OFB mode produces the same ciphertext whenever the same 137plaintext enciphered using the same key and starting variable. More 138over, in the OFB mode the same key stream is produced when the same 139key and start variable are used. Consequently, for security reasons 140a specific start variable should be used only once for a given key. 141 142=item * 143 144The absence of chaining makes the OFB more vulnerable to specific attacks. 145 146=item * 147 148The use of different start variables values prevents the same 149plaintext enciphering to the same ciphertext, by producing different 150key streams. 151 152=item * 153 154Selection of a small value for j will require more cycles through 155the encipherment algorithm per unit of plaintext and thus cause 156greater processing overheads. 157 158=item * 159 160Only multiples of j bits can be enciphered. 161 162=item * 163 164OFB mode of operation does not extend ciphertext errors in the 165resultant plaintext output. Every bit error in the ciphertext causes 166only one bit to be in error in the deciphered plaintext. 167 168=item * 169 170OFB mode is not self-synchronizing. If the two operation of 171encipherment and decipherment get out of synchronism, the system needs 172to be re-initialized. 173 174=item * 175 176Each re-initialization should use a value of the start variable 177different from the start variable values used before with the same 178key. The reason for this is that an identical bit stream would be 179produced each time from the same parameters. This would be 180susceptible to a 'known plaintext' attack. 181 182=back 183 184=head2 Triple ECB Mode 185 186Normally, this is found as the function I<algorithm>_ecb3_encrypt(). 187 188=over 2 189 190=item * 191 192Encrypt with key1, decrypt with key2 and encrypt with key3 again. 193 194=item * 195 196As for ECB encryption but increases the key length to 168 bits. 197There are theoretic attacks that can be used that make the effective 198key length 112 bits, but this attack also requires 2^56 blocks of 199memory, not very likely, even for the NSA. 200 201=item * 202 203If both keys are the same it is equivalent to encrypting once with 204just one key. 205 206=item * 207 208If the first and last key are the same, the key length is 112 bits. 209There are attacks that could reduce the effective key strength 210to only slightly more than 56 bits, but these require a lot of memory. 211 212=item * 213 214If all 3 keys are the same, this is effectively the same as normal 215ecb mode. 216 217=back 218 219=head2 Triple CBC Mode 220 221Normally, this is found as the function I<algorithm>_ede3_cbc_encrypt(). 222 223=over 2 224 225 226=item * 227 228Encrypt with key1, decrypt with key2 and then encrypt with key3. 229 230=item * 231 232As for CBC encryption but increases the key length to 168 bits with 233the same restrictions as for triple ecb mode. 234 235=back 236 237=head1 NOTES 238 239This text was been written in large parts by Eric Young in his original 240documentation for SSLeay, the predecessor of OpenSSL. In turn, he attributed 241it to: 242 243 AS 2805.5.2 244 Australian Standard 245 Electronic funds transfer - Requirements for interfaces, 246 Part 5.2: Modes of operation for an n-bit block cipher algorithm 247 Appendix A 248 249=head1 SEE ALSO 250 251L<blowfish(3)|blowfish(3)>, L<des(3)|des(3)>, L<idea(3)|idea(3)>, 252L<rc2(3)|rc2(3)> 253 254=cut 255 256