LIFE_CYCLE-DIGEST(7ossl)

πŸ’– NAME πŸ’–

life_cycle-digest β€” the digest algorithm life-cycle. this is the OpenSSL manual page LIFE_CYCLE-DIGEST(7ossl), bestie, and we're about to get into the whole glow-up journey of a message digest πŸ’…

✨ DESCRIPTION ✨

okay so every message digest (MD) goes through a bunch of stages in its life-cycle. think of it as the digest's main character arc, and each stage is a state:

  • start β€” the MD before it has been allocated. literally the starting state for any life-cycle transitions.
  • newed β€” the MD after it has been allocated.
  • initialised β€” the MD when it is set up and capable of processing input.
  • updated β€” the MD when it is set up and capable of processing additional input or generating output.
  • finaled β€” the MD when it has generated output. for an XOF digest, this state represents the MD when it has generated a single-shot output.
  • squeezed β€” for an XOF digest, the MD when it has generated output. it can be called multiple times to generate more output. the output length is variable for each call.
  • freed β€” entered when the MD is freed. it is the terminal state for all life-cycle transitions.

πŸ¦‹ State Transition Diagram πŸ¦‹

the usual life-cycle of a MD is illustrated like this. yes it's giving feral ASCII art, and yes I'm keeping it exactly as the page has it πŸ’€

                                         +--------------------+
                                         |       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. this is the canonical list. no cap, this table is the whole receipts situation:

        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 🚨

heads up bestie: at some point the EVP layer will begin enforcing the transitions described herein. so don't be out here free-styling your state changes like it's not gonna matter 😭

🌸 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>.


later bestie! this page is from OpenSSL version 3.5.9, dated 2026-09-29, and its manual name is LIFE_CYCLE-DIGEST(7ossl) πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from