des_modes.7ossl 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "DES_MODES 7ossl"
  58. .TH DES_MODES 7ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. des_modes \- the variants of DES and other crypto algorithms of OpenSSL
  65. .SH DESCRIPTION
  66. .IX Header "DESCRIPTION"
  67. Several crypto algorithms for OpenSSL can be used in a number of modes. Those
  68. are used for using block ciphers in a way similar to stream ciphers, among
  69. other things.
  70. .SH OVERVIEW
  71. .IX Header "OVERVIEW"
  72. .SS "Electronic Codebook Mode (ECB)"
  73. .IX Subsection "Electronic Codebook Mode (ECB)"
  74. Normally, this is found as the function \fIalgorithm\fR\fB_ecb_encrypt()\fR.
  75. .IP \(bu 2
  76. 64 bits are enciphered at a time.
  77. .IP \(bu 2
  78. The order of the blocks can be rearranged without detection.
  79. .IP \(bu 2
  80. The same plaintext block always produces the same ciphertext block
  81. (for the same key) making it vulnerable to a 'dictionary attack'.
  82. .IP \(bu 2
  83. An error will only affect one ciphertext block.
  84. .SS "Cipher Block Chaining Mode (CBC)"
  85. .IX Subsection "Cipher Block Chaining Mode (CBC)"
  86. Normally, this is found as the function \fIalgorithm\fR\fB_cbc_encrypt()\fR.
  87. Be aware that \fBdes_cbc_encrypt()\fR is not really DES CBC (it does
  88. not update the IV); use \fBdes_ncbc_encrypt()\fR instead.
  89. .IP \(bu 2
  90. a multiple of 64 bits are enciphered at a time.
  91. .IP \(bu 2
  92. The CBC mode produces the same ciphertext whenever the same
  93. plaintext is encrypted using the same key and starting variable.
  94. .IP \(bu 2
  95. The chaining operation makes the ciphertext blocks dependent on the
  96. current and all preceding plaintext blocks and therefore blocks can not
  97. be rearranged.
  98. .IP \(bu 2
  99. The use of different starting variables prevents the same plaintext
  100. enciphering to the same ciphertext.
  101. .IP \(bu 2
  102. An error will affect the current and the following ciphertext blocks.
  103. .SS "Cipher Feedback Mode (CFB)"
  104. .IX Subsection "Cipher Feedback Mode (CFB)"
  105. Normally, this is found as the function \fIalgorithm\fR\fB_cfb_encrypt()\fR.
  106. .IP \(bu 2
  107. a number of bits (j) <= 64 are enciphered at a time.
  108. .IP \(bu 2
  109. The CFB mode produces the same ciphertext whenever the same
  110. plaintext is encrypted using the same key and starting variable.
  111. .IP \(bu 2
  112. The chaining operation makes the ciphertext variables dependent on the
  113. current and all preceding variables and therefore j\-bit variables are
  114. chained together and can not be rearranged.
  115. .IP \(bu 2
  116. The use of different starting variables prevents the same plaintext
  117. enciphering to the same ciphertext.
  118. .IP \(bu 2
  119. The strength of the CFB mode depends on the size of k (maximal if
  120. j == k). In my implementation this is always the case.
  121. .IP \(bu 2
  122. Selection of a small value for j will require more cycles through
  123. the encipherment algorithm per unit of plaintext and thus cause
  124. greater processing overheads.
  125. .IP \(bu 2
  126. Only multiples of j bits can be enciphered.
  127. .IP \(bu 2
  128. An error will affect the current and the following ciphertext variables.
  129. .SS "Output Feedback Mode (OFB)"
  130. .IX Subsection "Output Feedback Mode (OFB)"
  131. Normally, this is found as the function \fIalgorithm\fR\fB_ofb_encrypt()\fR.
  132. .IP \(bu 2
  133. a number of bits (j) <= 64 are enciphered at a time.
  134. .IP \(bu 2
  135. The OFB mode produces the same ciphertext whenever the same
  136. plaintext enciphered using the same key and starting variable. More
  137. over, in the OFB mode the same key stream is produced when the same
  138. key and start variable are used. Consequently, for security reasons
  139. a specific start variable should be used only once for a given key.
  140. .IP \(bu 2
  141. The absence of chaining makes the OFB more vulnerable to specific attacks.
  142. .IP \(bu 2
  143. The use of different start variables values prevents the same
  144. plaintext enciphering to the same ciphertext, by producing different
  145. key streams.
  146. .IP \(bu 2
  147. Selection of a small value for j will require more cycles through
  148. the encipherment algorithm per unit of plaintext and thus cause
  149. greater processing overheads.
  150. .IP \(bu 2
  151. Only multiples of j bits can be enciphered.
  152. .IP \(bu 2
  153. OFB mode of operation does not extend ciphertext errors in the
  154. resultant plaintext output. Every bit error in the ciphertext causes
  155. only one bit to be in error in the deciphered plaintext.
  156. .IP \(bu 2
  157. OFB mode is not self-synchronizing. If the two operation of
  158. encipherment and decipherment get out of synchronism, the system needs
  159. to be re-initialized.
  160. .IP \(bu 2
  161. Each re-initialization should use a value of the start variable
  162. different from the start variable values used before with the same
  163. key. The reason for this is that an identical bit stream would be
  164. produced each time from the same parameters. This would be
  165. susceptible to a 'known plaintext' attack.
  166. .SS "Triple ECB Mode"
  167. .IX Subsection "Triple ECB Mode"
  168. Normally, this is found as the function \fIalgorithm\fR\fB_ecb3_encrypt()\fR.
  169. .IP \(bu 2
  170. Encrypt with key1, decrypt with key2 and encrypt with key3 again.
  171. .IP \(bu 2
  172. As for ECB encryption but increases the key length to 168 bits.
  173. There are theoretic attacks that can be used that make the effective
  174. key length 112 bits, but this attack also requires 2^56 blocks of
  175. memory, not very likely, even for the NSA.
  176. .IP \(bu 2
  177. If both keys are the same it is equivalent to encrypting once with
  178. just one key.
  179. .IP \(bu 2
  180. If the first and last key are the same, the key length is 112 bits.
  181. There are attacks that could reduce the effective key strength
  182. to only slightly more than 56 bits, but these require a lot of memory.
  183. .IP \(bu 2
  184. If all 3 keys are the same, this is effectively the same as normal
  185. ecb mode.
  186. .SS "Triple CBC Mode"
  187. .IX Subsection "Triple CBC Mode"
  188. Normally, this is found as the function \fIalgorithm\fR\fB_ede3_cbc_encrypt()\fR.
  189. .IP \(bu 2
  190. Encrypt with key1, decrypt with key2 and then encrypt with key3.
  191. .IP \(bu 2
  192. As for CBC encryption but increases the key length to 168 bits with
  193. the same restrictions as for triple ecb mode.
  194. .SH NOTES
  195. .IX Header "NOTES"
  196. This text was been written in large parts by Eric Young in his original
  197. documentation for SSLeay, the predecessor of OpenSSL. In turn, he attributed
  198. it to:
  199. .PP
  200. .Vb 5
  201. \& AS 2805.5.2
  202. \& Australian Standard
  203. \& Electronic funds transfer \- Requirements for interfaces,
  204. \& Part 5.2: Modes of operation for an n\-bit block cipher algorithm
  205. \& Appendix A
  206. .Ve
  207. .SH "SEE ALSO"
  208. .IX Header "SEE ALSO"
  209. \&\fBBF_encrypt\fR\|(3), \fBDES_crypt\fR\|(3)
  210. .SH COPYRIGHT
  211. .IX Header "COPYRIGHT"
  212. Copyright 2000\-2017 The OpenSSL Project Authors. All Rights Reserved.
  213. .PP
  214. Licensed under the Apache License 2.0 (the "License"). You may not use
  215. this file except in compliance with the License. You can obtain a copy
  216. in the file LICENSE in the source distribution or at
  217. <https://www.openssl.org/source/license.html>.