LIFE_CYCLE-DIGEST(7ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ¦‹ LIFE_CYCLE-DIGEST(7ossl) β€” the digest algorithm life-cycle ✨

Okay bestie, welcome to life_cycle-digest from section 7ossl of the OpenSSL manual πŸ’… this one is a whole mood board of states β€” every message digest goes through a lil journey and this page is its ✨character arc✨.


πŸŽ€ NAME πŸŽ€

life_cycle-digest β€” the digest algorithm life-cycle. That's it, that's the whole name, she's simple but she's iconic 🫢


🌸 DESCRIPTION 🌸

okay so literally all message digests (MDs, for short) go through a handful of stages in their life-cycle, and here's the full roster πŸ‘‘

  • start β€” this is the MD before it's been allocated. It's the starting state for every single life-cycle transition, the "before they were famous" era πŸ’«
  • newed β€” this is the MD after it's been allocated. Fresh out the box, new phone who dis πŸ“±
  • initialised β€” the MD is all set up and ready to process input. She's ready, she's prepared, she's giving main character energy πŸ”₯
  • updated β€” the MD is set up and can process additional input or generate output. Multi-tasking queen πŸ’…
  • finaled β€” the MD has generated output. And ngl, for an XOF digest this state means the MD has generated a single-shot output 🎯
  • squeezed β€” okay so for an XOF digest, this is the state where it has generated output, and you can call it multiple times to generate more output πŸ‘€ the output length is variable for each call, no cap
  • freed β€” this is when the MD is freed. It's the terminal state for all life-cycle transitions, the final boss, the end of the era πŸ’€

🧚 State Transition Diagram

the usual life-cycle of a MD is illustrated here β€” fair warning, this diagram is a little cursed in the original, but we keep it 100% intact because every detail matters 🫢

                                         +--------------------+
                                         |       start        |
                                         +--------------------+
                                           |
       EVP_MD_CTX_reset
                                           | EVP_MD_CTX_new
       +-------------------------------------------------+
                                           v                          v
       |
                     EVP_MD_CTX_reset    + - - - - - - - - - - - - - - - - - -
       - - - - +    EVP_MD_CTX_reset            |
                   +-------------------> '                   newed
       ' <--------------------+         |
                   |                     + - - - - - - - - - - - - - - - - - -
       - - - - +                      |         |
                   |                       |
       |         |
                   |                       | EVP_DigestInit
       |         |
                   |                       v
       |         |
                   |   EVP_DigestInit    + - - - - - - - - - - - - - - - - - -
       - - - - +                      |         |
              +----+-------------------> '                initialised
       ' <+  EVP_DigestInit   |         |
              |    |                     + - - - - - - - - - - - - - - - - - -
       - - - - +  |                   |         |
              |    |                       |                     ^
       |                   |         |
              |    |                       | EVP_DigestUpdate    |
       EVP_DigestInit         |                   |         |
              |    |                       v                     |
       |                   |         |
              |    |
       +---------------------------------------------+  |                   |
       |
              |    +-------------------- |
       |  |                   |         |
              |                          |
       |  |                   |         |
              |      EVP_DigestUpdate    |
       |  |                   |         |
              |    +-------------------- |
       |  |                   |         |
              |    |                     |                   updated
       |  |                   |         |
              |    +-------------------> |
       |  |                   |         |
              |                          |
       |  |                   |         |
              |                          |
       |  |                   |         |
         +----+------------------------- |
       | -+-------------------+----+    |
         |    |
       +---------------------------------------------+  |                   |
       |    |
         |    |                            |
       |                   |    |    |
         |    |                            | EVP_DigestSqueeze
       +-------------------+                   |    |    |
         |    |                            v                          |
       |    |    |
         |    |      EVP_DigestSqueeze
       +---------------------------------------------+                      |
       |    |
         |    |    +-------------------- |
       |                      |    |    |
         |    |    |                     |                  squeezed
       |                      |    |    |
         |    |    +-------------------> |
       | ---------------------+    |    |
         |    |
       +---------------------------------------------+
       |    |
         |    |                                                       |
       |    |
         |    |
       +---------------------------------------+    |    |
         |    |
       |    |    |
         |    |
       +---------------------------------------------+  EVP_DigestFinalXOF  |
       |    |
         |    +------------------------- |             finaled
       | <--------------------+----+    |
         |
       +---------------------------------------------+                      |
       |
         |   EVP_DigestFinal               ^                     |    |
       |         |
         +---------------------------------+                     |    |
       EVP_MD_CTX_free                       |         |
                                                                 |    v
       |         |
                                                                 |
       +------------------+  EVP_MD_CTX_free     |         |
                                                                 |  |
       freed       | <--------------------+         |
                                                                 |
       +------------------+                                |
                                                                 |
       |
                                                                 +------------------------------------------------------+

🌈 Formal State Transitions

this section defines all of the legal state transitions β€” it's the canonical list, the source of truth, the moment of truth fr fr πŸ’–

 Function Call                --------------------- Current State
-----------------------------------
                              start   newed    initialised   updated
finaled     squeezed   freed
 EVP_MD_CTX_new               newed
 EVP_DigestInit                    initialised initialised initialised
initialised  initialised
 EVP_DigestUpdate                                updated     updated
 EVP_DigestFinal                                             finaled
 EVP_DigestFinalXOF                                          finaled
 EVP_DigestSqueeze                                           squeezed
squeezed
 EVP_MD_CTX_free              freed   freed       freed       freed
freed
 EVP_MD_CTX_reset                     newed       newed       newed
newed
 EVP_MD_CTX_get_params                newed    initialised   updated
 EVP_MD_CTX_set_params                newed    initialised   updated
 EVP_MD_CTX_gettable_params           newed    initialised   updated
 EVP_MD_CTX_settable_params           newed    initialised   updated
 EVP_MD_CTX_copy_ex                   newed    initialised   updated
squeezed

so like, reading down the function column and across the state columns is the whole game here 🎯 EVP_MD_CTX_new takes you to newed, EVP_MD_CTX_reset lands you in newed too, EVP_MD_CTX_free puts you in freed, and the EVP_DigestUpdate / EVP_DigestFinal / EVP_DigestFinalXOF / EVP_DigestSqueeze crew move you through updated, finaled and squeezed respectively. EVP_MD_CTX_get_params, EVP_MD_CTX_set_params, EVP_MD_CTX_gettable_params and EVP_MD_CTX_settable_params all chill in newed / initialised / updated, and EVP_MD_CTX_copy_ex hangs out in newed / initialised / updated / squeezed. The table above is the canonical one though β€” trust her, not my lil recap πŸ’…


⭐ NOTES ⭐

at some point the EVP layer will begin enforcing the transitions described herein πŸ‘€ so like… don't be messy about it, bestie


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, they're the supporting cast and they ate 🫢


Copyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie πŸŽ€βœ¨ this was LIFE_CYCLE-DIGEST(7ossl), version 3.5.0, dated 2026-09-25 β€” go forth and squeeze your XOFs responsibly πŸ’…πŸ¦‹πŸ’–

πŸ“¦ where this page comes from