LIFE_CYCLE-DIGEST(7SSL)

✨ NAME ✨

life_cycle-digest β€” it's the digest algorithm life-cycle πŸ¦‹ (section 7SSL, OpenSSL manual, you're in the right place bestie)

🌸 DESCRIPTION 🌸

Okay so listen. Every single message digest β€” MD, for short, we're on nickname basis β€” goes through a whole arc. A journey. Several stages, in order, no skipping. Here's the entire glow-up timeline:

  • start β€” this is the MD before it has been allocated. It's the starting state for any life-cycle transitions. Literally "not yet born but already iconic" energy ✨
  • newed β€” the MD after it has been allocated. It exists now!! πŸŽ‰
  • initialised β€” the MD is set up and fully capable of processing input. Slay. πŸ’…
  • updated β€” the MD is set up and capable of processing additional input, or generating output. Multitasking queen, we love to see it πŸ‘‘
  • finaled β€” the MD has generated output. And for an XOF digest? This state means it has generated a single-shot output. 🫢
  • squeezed β€” XOF digests only, bestie: the MD has generated output, and you can call it multiple times to generate more output. The output length is variable for each call. Endless content machine πŸ“
  • freed β€” the MD has been freed. This is the terminal state for all life-cycle transitions. RIP girl, you ate πŸ’€βœ¨

πŸŽ€ State Transition Diagram πŸŽ€

Here's the usual life-cycle of an MD, all drawn out πŸ¦‹ Ngl the ASCII art renders a little scrambled in this format 😭 but every line is load-bearing so I'm giving it to you exactly as it comes, no edits, no thoughts:

                                         +--------------------+
                                         |       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. Like, this is the canonical list β€” the receipts, the source of truth, periodt:

 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

⭐ NOTES ⭐

At some point the EVP layer will begin enforcing the transitions described herein. So like… be normal about it πŸ™ˆ It's coming, and it's not a drill.

πŸ”₯ SEE ALSO πŸ”₯

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, mwah πŸ’– this lil masterpiece rode in on OpenSSL 4.0.3, dated 2026-09-29, filed under LIFE_CYCLE-DIGEST(7SSL) 🫢 go forth and respect the state machine ✨

πŸ“¦ where this page comes from