LIFE_CYCLE-CIPHER(7ossl)

πŸŽ€ NAME πŸŽ€

life_cycle-cipher β€” The cipher algorithm life-cycle ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so literally all symmetric ciphers (the page calls them CIPHERs, all caps, main-character energy πŸ’…) go through a whole little journey of stages in their life-cycle. It's giving coming-of-age arc. Here's the lineup:

  • start β€” this state is the CIPHER before it has been allocated. It's the starting state for any life-cycle transitions. She doesn't exist yet, she's just potential πŸ¦‹
  • newed β€” this state is the CIPHER after it has been allocated. she's here. she's real.
  • initialised β€” these states are the CIPHER when it's set up and capable of processing input. There are three possible initialised states:
    • initialised using EVP_CipherInit
    • initialised for decryption using EVP_DecryptInit
    • initialised for encryption using EVP_EncryptInit
  • updated β€” these states are the CIPHER when it's set up and capable of processing additional input or generating output. The three possible states correspond directly to those for initialised above. ⚠️ The three different streams should not be mixed β€” not me warning you twice, it literally says that, do not mix them bestie 😭
  • finaled β€” this state is the CIPHER when it has generated output. she ate and left no crumbs πŸ“
  • freed β€” this state is entered when the CIPHER is freed. It is the terminal state for all life-cycle transitions. πŸ’€ rest in peace queen, no coming back from this one

🌈 State Transition Diagram 🌈

The usual life-cycle of a CIPHER is illustrated:

   start
     β”‚  EVP_CIPHER_CTX_new
     β–Ό
   newed ──────────────────────────────┐
     β”‚  EVP_CipherInit                 β”‚
     β”‚  EVP_DecryptInit                β”‚  EVP_CIPHER_CTX_reset
     β”‚  EVP_EncryptInit                β”‚
     β–Ό                                 β”‚
   initialised ─────────────────────────
     β”‚  EVP_CipherUpdate               β”‚
     β”‚  EVP_DecryptUpdate              β”‚
     β”‚  EVP_EncryptUpdate              β”‚
     β–Ό                                 β”‚
   updated ─────────────────────────────
     β”‚  EVP_CipherFinal                β”‚
     β”‚  EVP_DecryptFinal               β”‚
     β”‚  EVP_EncryptFinal               β”‚
     β–Ό                                 β”‚
   finaled β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚
     β”‚  EVP_CIPHER_CTX_free
     β–Ό
   freed

and the little dotted-arrow footnote from the original, iykyk: EVP_CIPHER_CTX_reset can swoop in from any of the initialised, updated or finaled states and drop her right back at newed. Also EVP_CIPHER_CTX_get_params shows up on the finaled β†’ freed stretch for AEAD encryption 🫢

🫢 Formal State Transitions 🫢

This section defines all of the legal state transitions. This is the canonical list. πŸ‘‘ (Translation below is just me being helpful β€” the list is the list.)

  • EVP_CIPHER_CTX_new β€” start β†’ newed
  • EVP_CipherInit β€” β†’ initialised
  • EVP_DecryptInit β€” β†’ initialised for decryption
  • EVP_EncryptInit β€” β†’ initialised for encryption
  • EVP_CipherUpdate β€” β†’ updated
  • EVP_DecryptUpdate β€” β†’ updated for decryption
  • EVP_EncryptUpdate β€” β†’ updated for encryption
  • EVP_CipherFinal β€” β†’ finaled
  • EVP_DecryptFinal β€” β†’ finaled
  • EVP_EncryptFinal β€” β†’ finaled
  • EVP_CIPHER_CTX_free β€” β†’ freed πŸ’€
  • EVP_CIPHER_CTX_reset β€” β†’ newed
  • EVP_CIPHER_CTX_get_params β€” β†’ newed, initialised, updated (plain, decryption and encryption flavours all in play)
  • EVP_CIPHER_CTX_set_params β€” β†’ newed, initialised, updated (plain, decryption and encryption flavours all in play)
  • EVP_CIPHER_CTX_gettable_params β€” β†’ newed, initialised, updated (plain, decryption and encryption flavours all in play)
  • EVP_CIPHER_CTX_settable_params β€” β†’ newed, initialised, updated (plain, decryption and encryption flavours all in play)
The full grid in the original is a big wide table of Function Call Γ— Current State (start, newed, initialised, updated, finaled, initialised decryption, updated decryption, initialised encryption, updated encryption, freed) β€” the bullets above are the same tea, just poured into a cup you can actually read πŸ“

⭐ NOTES ⭐

At some point the EVP layer will begin enforcing the transitions described herein. So like… behave now, bestie πŸ™ˆ

🌸 SEE ALSO 🌸

provider-cipher(7), EVP_EncryptInit(3)

Copyright 2021 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, no cap 🫢 kisses from OpenSSL 3.5.9, dated 2026-09-29 β€” this has been LIFE_CYCLE-CIPHER(7ossl), mwah πŸ’œβœ¨

πŸ“¦ where this page comes from