life_cycle-digest.pod 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. =pod
  2. =head1 NAME
  3. life_cycle-digest - The digest algorithm life-cycle
  4. =head1 DESCRIPTION
  5. All message digests (MDs) go through a number of stages in their life-cycle:
  6. =over 4
  7. =item start
  8. This state represents the MD before it has been allocated. It is the
  9. starting state for any life-cycle transitions.
  10. =item newed
  11. This state represents the MD after it has been allocated.
  12. =item initialised
  13. This state represents the MD when it is set up and capable of processing
  14. input.
  15. =item updated
  16. This state represents the MD when it is set up and capable of processing
  17. additional input or generating output.
  18. =item finaled
  19. This state represents the MD when it has generated output.
  20. For an XOF digest, this state represents the MD when it has generated a
  21. single-shot output.
  22. =item squeezed
  23. For an XOF digest, this state represents the MD when it has generated output.
  24. It can be called multiple times to generate more output. The output length is
  25. variable for each call.
  26. =item freed
  27. This state is entered when the MD is freed. It is the terminal state
  28. for all life-cycle transitions.
  29. =back
  30. =head2 State Transition Diagram
  31. The usual life-cycle of a MD is illustrated:
  32. =begin man
  33. +--------------------+
  34. | start |
  35. +--------------------+
  36. | EVP_MD_CTX_reset
  37. | EVP_MD_CTX_new +-------------------------------------------------+
  38. v v |
  39. EVP_MD_CTX_reset + - - - - - - - - - - - - - - - - - - - - - - + EVP_MD_CTX_reset |
  40. +-------------------> ' newed ' <--------------------+ |
  41. | + - - - - - - - - - - - - - - - - - - - - - - + | |
  42. | | | |
  43. | | EVP_DigestInit | |
  44. | v | |
  45. | EVP_DigestInit + - - - - - - - - - - - - - - - - - - - - - - + | |
  46. +----+-------------------> ' initialised ' <+ EVP_DigestInit | |
  47. | | + - - - - - - - - - - - - - - - - - - - - - - + | | |
  48. | | | ^ | | |
  49. | | | EVP_DigestUpdate | EVP_DigestInit | | |
  50. | | v | | | |
  51. | | +---------------------------------------------+ | | |
  52. | +-------------------- | | | | |
  53. | | | | | |
  54. | EVP_DigestUpdate | | | | |
  55. | +-------------------- | | | | |
  56. | | | updated | | | |
  57. | +-------------------> | | | | |
  58. | | | | | |
  59. | | | | | |
  60. +----+------------------------- | | -+-------------------+----+ |
  61. | | +---------------------------------------------+ | | | |
  62. | | | | | | |
  63. | | | EVP_DigestSqueeze +-------------------+ | | |
  64. | | v | | | |
  65. | | EVP_DigestSqueeze +---------------------------------------------+ | | |
  66. | | +-------------------- | | | | |
  67. | | | | squeezed | | | |
  68. | | +-------------------> | | ---------------------+ | |
  69. | | +---------------------------------------------+ | |
  70. | | | | |
  71. | | +---------------------------------------+ | |
  72. | | | | |
  73. | | +---------------------------------------------+ EVP_DigestFinalXOF | | |
  74. | +------------------------- | finaled | <--------------------+----+ |
  75. | +---------------------------------------------+ | |
  76. | EVP_DigestFinal ^ | | | |
  77. +---------------------------------+ | | EVP_MD_CTX_free | |
  78. | v | |
  79. | +------------------+ EVP_MD_CTX_free | |
  80. | | freed | <--------------------+ |
  81. | +------------------+ |
  82. | |
  83. +------------------------------------------------------+
  84. =end man
  85. =for html <img src="img/digest.png">
  86. =head2 Formal State Transitions
  87. This section defines all of the legal state transitions.
  88. This is the canonical list.
  89. =begin man
  90. Function Call --------------------- Current State -----------------------------------
  91. start newed initialised updated finaled squeezed freed
  92. EVP_MD_CTX_new newed
  93. EVP_DigestInit initialised initialised initialised initialised initialised
  94. EVP_DigestUpdate updated updated
  95. EVP_DigestFinal finaled
  96. EVP_DigestFinalXOF finaled
  97. EVP_DigestSqueeze squeezed squeezed
  98. EVP_MD_CTX_free freed freed freed freed freed
  99. EVP_MD_CTX_reset newed newed newed newed
  100. EVP_MD_CTX_get_params newed initialised updated
  101. EVP_MD_CTX_set_params newed initialised updated
  102. EVP_MD_CTX_gettable_params newed initialised updated
  103. EVP_MD_CTX_settable_params newed initialised updated
  104. EVP_MD_CTX_copy_ex newed initialised updated squeezed
  105. =end man
  106. =begin html
  107. <table style="border:1px solid; border-collapse:collapse">
  108. <tr><th style="border:1px solid" align="left">Function Call</th>
  109. <th style="border:1px solid" colspan="6">Current State</th></tr>
  110. <tr><th style="border:1px solid"></th>
  111. <th style="border:1px solid" align="center">start</th>
  112. <th style="border:1px solid" align="center">newed</th>
  113. <th style="border:1px solid" align="center">initialised</th>
  114. <th style="border:1px solid" align="center">updated</th>
  115. <th style="border:1px solid" align="center">finaled</th>
  116. <th style="border:1px solid" align="center">squeezed</th>
  117. <th style="border:1px solid" align="center">freed</th></tr>
  118. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_new</th>
  119. <td style="border:1px solid" align="center">newed</td>
  120. <td style="border:1px solid" align="center"></td>
  121. <td style="border:1px solid" align="center"></td>
  122. <td style="border:1px solid" align="center"></td>
  123. <td style="border:1px solid" align="center"></td>
  124. <td style="border:1px solid" align="center"></td>
  125. <td style="border:1px solid" align="center"></td></tr>
  126. <tr><th style="border:1px solid" align="left">EVP_DigestInit</th>
  127. <td style="border:1px solid" align="center"></td>
  128. <td style="border:1px solid" align="center">initialised</td>
  129. <td style="border:1px solid" align="center">initialised</td>
  130. <td style="border:1px solid" align="center">initialised</td>
  131. <td style="border:1px solid" align="center">initialised</td>
  132. <td style="border:1px solid" align="center">initialised</td>
  133. <td style="border:1px solid" align="center"></td></tr>
  134. <tr><th style="border:1px solid" align="left">EVP_DigestUpdate</th>
  135. <td style="border:1px solid" align="center"></td>
  136. <td style="border:1px solid" align="center"></td>
  137. <td style="border:1px solid" align="center">updated</td>
  138. <td style="border:1px solid" align="center">updated</td>
  139. <td style="border:1px solid" align="center"></td>
  140. <td style="border:1px solid" align="center"></td>
  141. <td style="border:1px solid" align="center"></td></tr>
  142. <tr><th style="border:1px solid" align="left">EVP_DigestFinal</th>
  143. <td style="border:1px solid" align="center"></td>
  144. <td style="border:1px solid" align="center"></td>
  145. <td style="border:1px solid" align="center"></td>
  146. <td style="border:1px solid" align="center">finaled</td>
  147. <td style="border:1px solid" align="center"></td>
  148. <td style="border:1px solid" align="center"></td>
  149. <td style="border:1px solid" align="center"></td></tr>
  150. <tr><th style="border:1px solid" align="left">EVP_DigestSqueeze</th>
  151. <td style="border:1px solid" align="center"></td>
  152. <td style="border:1px solid" align="center"></td>
  153. <td style="border:1px solid" align="center"></td>
  154. <td style="border:1px solid" align="center">squeezed</td>
  155. <td style="border:1px solid" align="center"></td>
  156. <td style="border:1px solid" align="center">squeezed</td>
  157. <td style="border:1px solid" align="center"></td></tr>
  158. <tr><th style="border:1px solid" align="left">EVP_DigestFinalXOF</th>
  159. <td style="border:1px solid" align="center"></td>
  160. <td style="border:1px solid" align="center"></td>
  161. <td style="border:1px solid" align="center"></td>
  162. <td style="border:1px solid" align="center">finaled</td>
  163. <td style="border:1px solid" align="center"></td>
  164. <td style="border:1px solid" align="center"></td>
  165. <td style="border:1px solid" align="center"></td></tr>
  166. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_free</th>
  167. <td style="border:1px solid" align="center">freed</td>
  168. <td style="border:1px solid" align="center">freed</td>
  169. <td style="border:1px solid" align="center">freed</td>
  170. <td style="border:1px solid" align="center">freed</td>
  171. <td style="border:1px solid" align="center">freed</td>
  172. <td style="border:1px solid" align="center"></td>
  173. <td style="border:1px solid" align="center"></td></tr>
  174. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_reset</th>
  175. <td style="border:1px solid" align="center"></td>
  176. <td style="border:1px solid" align="center">newed</td>
  177. <td style="border:1px solid" align="center">newed</td>
  178. <td style="border:1px solid" align="center">newed</td>
  179. <td style="border:1px solid" align="center">newed</td>
  180. <td style="border:1px solid" align="center"></td>
  181. <td style="border:1px solid" align="center"></td></tr>
  182. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_get_params</th>
  183. <td style="border:1px solid" align="center"></td>
  184. <td style="border:1px solid" align="center">newed</td>
  185. <td style="border:1px solid" align="center">initialised</td>
  186. <td style="border:1px solid" align="center">updated</td>
  187. <td style="border:1px solid" align="center"></td>
  188. <td style="border:1px solid" align="center"></td>
  189. <td style="border:1px solid" align="center"></td></tr>
  190. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_set_params</th>
  191. <td style="border:1px solid" align="center"></td>
  192. <td style="border:1px solid" align="center">newed</td>
  193. <td style="border:1px solid" align="center">initialised</td>
  194. <td style="border:1px solid" align="center">updated</td>
  195. <td style="border:1px solid" align="center"></td>
  196. <td style="border:1px solid" align="center"></td>
  197. <td style="border:1px solid" align="center"></td></tr>
  198. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_gettable_params</th>
  199. <td style="border:1px solid" align="center"></td>
  200. <td style="border:1px solid" align="center">newed</td>
  201. <td style="border:1px solid" align="center">initialised</td>
  202. <td style="border:1px solid" align="center">updated</td>
  203. <td style="border:1px solid" align="center"></td>
  204. <td style="border:1px solid" align="center"></td>
  205. <td style="border:1px solid" align="center"></td></tr>
  206. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_settable_params</th>
  207. <td style="border:1px solid" align="center"></td>
  208. <td style="border:1px solid" align="center">newed</td>
  209. <td style="border:1px solid" align="center">initialised</td>
  210. <td style="border:1px solid" align="center">updated</td>
  211. <td style="border:1px solid" align="center"></td>
  212. <td style="border:1px solid" align="center"></td>
  213. <td style="border:1px solid" align="center"></td></tr>
  214. <tr><th style="border:1px solid" align="left">EVP_MD_CTX_copy_ex</th>
  215. <td style="border:1px solid" align="center"></td>
  216. <td style="border:1px solid" align="center">newed</td>
  217. <td style="border:1px solid" align="center">initialised</td>
  218. <td style="border:1px solid" align="center">updated</td>
  219. <td style="border:1px solid" align="center"></td>
  220. <td style="border:1px solid" align="center">squeezed</td>
  221. <td style="border:1px solid" align="center"></td></tr>
  222. </table>
  223. =end html
  224. =head1 NOTES
  225. At some point the EVP layer will begin enforcing the transitions described
  226. herein.
  227. =head1 SEE ALSO
  228. L<provider-digest(7)>, L<EVP_DigestInit(3)>
  229. =head1 COPYRIGHT
  230. Copyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved.
  231. Licensed under the Apache License 2.0 (the "License"). You may not use
  232. this file except in compliance with the License. You can obtain a copy
  233. in the file LICENSE in the source distribution or at
  234. L<https://www.openssl.org/source/license.html>.
  235. =cut