LIFE_CYCLE-DIGEST(7ossl)
π LIFE_CYCLE-DIGEST
okay so first things first β the manual name is LIFE_CYCLE-DIGEST (section 7ossl), and it's an OpenSSL page, and it is entirely about the life-cycle of a message digest. no tea, no drama, just a whole glow-up journey from "doesn't exist" to "freed". it's giving caterpillar-to-butterfly but for cryptographic hash objects. π¦β¨
π NAME
life_cycle-digest β the digest algorithm life-cycle. yes bestie, that's the whole name. short and iconic.
πΈ DESCRIPTION
Every single message digest (MD) moves through a bunch of stages in its life, like a little character arc. here's the whole cast, in order: π
startβ this is the MD before it has been allocated. the blank slate, the pre-canon era. it's the starting state for any life-cycle transition.newedβ the MD after it has been allocated. it exists now!! it has a home. πinitialisedβ the MD is set up and capable of processing input. it's got its outfit on and it's ready.updatedβ the MD is set up and capable of processing additional input or generating output. multitasking queen behavior, honestly.finaledβ the MD has generated output. for an XOF digest, this state means it has generated a single-shot output.squeezedβ for an XOF digest, the MD has generated output and, key detail, it can be called multiple times to generate more output. also the output length is variable for each call. so it just keeps giving, we love that for it. πfreedβ this state is entered when the MD is freed. it is the terminal state for all life-cycle transitions. goodbye, we hardly knew ye. π
β¨ State Transition Diagram β¨
the usual life-cycle of a MD is illustrated like this (the ASCII art has been through some things, lowkey β it's scrambled in transmission, but here it is exactly as-is, so squint and vibe):
+--------------------+
| 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_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 improvising, bestie β this is the source of truth:
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
and here's what each of those rows is actually saying, in human: π
EVP_MD_CTX_newβ lands you innewed.EVP_MD_CTX_resetβ sends you back tonewed(the table showsnewedfour times across the columns, so yeah, it resets you right back to the freshly-allocated vibe).EVP_DigestInitβ ends you ininitialised. the row listsinitialisedfive times, which is the "from basically anywhere, you can init" energy.EVP_DigestUpdateβ takes you toupdated.EVP_DigestFinalβ takes you tofinaled.EVP_DigestFinalXOFβ takes you tofinaledtoo.EVP_DigestSqueezeβ takes you tosqueezed, and it's listed twice because you can squeeze and squeeze again. iconic honestly.EVP_MD_CTX_freeβ takes you tofreed. that's the end of the line, periodt.EVP_MD_CTX_get_paramsβ leaves you innewed,initialisedorupdated(no state change, just peeking π).EVP_MD_CTX_set_paramsβ again,newed,initialisedorupdated.EVP_MD_CTX_gettable_paramsβnewed,initialisedorupdated.EVP_MD_CTX_settable_paramsβnewed,initialisedorupdated.EVP_MD_CTX_copy_exβnewed,initialised,updatedorsqueezed.
π NOTES
at some point, the EVP layer will begin enforcing the transitions described herein. so like... these aren't just suggestions forever. be on your best behavior. π
π«Ά SEE ALSO
π COPYRIGHT
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>.
okay and finally the cute sign-off: this whole thing is version 3.5.6, dated 2026-04-07, and the page is LIFE_CYCLE-DIGEST(7ossl). that's it, that's the page, thanks for coming to my ted talk, mwah ππβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms