des_modes.pod 5.8 KB

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