LIFE_CYCLE-CIPHER(7ossl)

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

πŸ’… LIFE_CYCLE-CIPHER(7ossl) β€” the cipher algorithm life-cycle, bestie ✨

okay so this is a page from the OpenSSL manual, and it's about how symmetric ciphers (CIPHERs) live their whole little lives πŸŽ€


🌸 NAME

life_cycle-cipher β€” the cipher algorithm life-cycle, fr fr


✨ DESCRIPTION

So basically every single symmetric cipher (aka a CIPHER) goes through a bunch of stages in its life-cycle, like a whole character arc πŸ’– here's the tea:

  • start β€” this is the CIPHER before it's even been allocated. it's giving "not yet born," the starting state for every life-cycle transition πŸ’«
  • newed β€” this is the CIPHER after it's been allocated. freshly newed, main character energy πŸ‘‘
  • initialised β€” these states are when the CIPHER is set up and ready to process 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 when it's set up and capable of processing additional input or generating output. the three possible states directly correspond to those for initialised above. and listen β€” the three different streams should not be mixed πŸ™…β€β™€οΈ like don't cross the streams, that's not the vibe
  • finaled β€” this state is when the CIPHER has generated output. it's done, it ate, periodt πŸ’…
  • freed β€” entered when the CIPHER is freed. it's the terminal state for all life-cycle transitions. rip little cipher 🫑

πŸ¦‹ State Transition Diagram

the usual life-cycle of a CIPHER is illustrated like this (ngl it's kind of a lot, but iykyk):

                                    +---------------------------+
                                    |                           |
                                    |           start           |
                                    |                           |
                                    +---------------------------+   + - - - - - - - - - - +
                                          |                         '  any of the initialised   '
                                          | EVP_CIPHER_CTX_new      '  updated or finaled states '
                                          v                         '                           '
                                    +---------------------------+   + - - - - - - - - - - +
                                    |                           |      |
                                    |           newed           |      |
                                    |                           | <----+
                                    +---------------------------+
                                       |   |                 |
                             +---------+   |                 +---------+
             EVP_DecryptInit |             | EVP_CipherInit            | EVP_EncryptInit
                             v             v                           v
    +---------------------------+   +---------------------------+   +---------------------------+
    |                           |   |                           |   |                           |
    |        initialised        |   |        initialised        |   |        initialised        |
    |       for decryption      |   |                           |   |       for encryption      |
    +---------------------------+   +---------------------------+   +---------------------------+
      |                                   |                           |
      | EVP_DecryptUpdate                 | EVP_CipherUpdate          | EVP_EncryptUpdate
      |                                   v                           |
      |                             +---------------------------+     |
      |                             |                           |-----+        |
      |                             |          updated          | EVP_CipherUpdate |        |
      |                             |                           | <------------------+        |
      v                             +---------------------------+     v
    +---------------------------+                         |   +---------------------------+
    |                           |---------------------+   |         |                           |
    |          updated          |   EVP_DecryptUpdate |   |         |          updated          |------+
    |       for decryption      | <-------------------+   |         |       for encryption      |      |
    +---------------------------+                         |   +---------------------------+      |
                             |            EVP_CipherFinal |            ^                   |
                             +-------+                    |   +--------+                   |
                    EVP_DecryptFinal |                    |   |   EVP_EncryptFinal   +-------------------+
                                     v                    v   v       EVP_EncryptUpdate
                                    +---------------------------+     |-----------------------------+
                                    |          finaled          |     |
                                    |                           | <---------------------------+
                                    +---------------------------+   EVP_CIPHER_CTX_get_params
                                          |                         (AEAD encryption)
                                          | EVP_CIPHER_CTX_free
                                          v
                                    +---------------------------+
                                    |                           |
                                    |           freed           |
                                    |                           |
                                    +---------------------------+

look, i know that diagram is a lot 😭 but it's iconic, we don't gatekeep πŸ’–


πŸŽ€ Formal State Transitions

this section defines all of the legal state transitions β€” it's the canonical list, no cap. here's the full table of which function call does what from which current state:

 Function Call
---------------------------------------------- Current State
-----------------------------------------------
                             start   newed    initialised   updated   finaled   initialised   updated    initialised   updated    freed
                                                                                   decryption  decryption   encryption  encryption
 EVP_CIPHER_CTX_new           newed
 EVP_CipherInit                    initialised initialised initialised initialised initialised initialised  initialised initialised
 EVP_DecryptInit                   initialised initialised initialised initialised initialised initialised  initialised initialised
                                   decryption  decryption  decryption  decryption  decryption  decryption  decryption  decryption
 EVP_EncryptInit                   initialised initialised initialised initialised initialised initialised  initialised initialised
                                   encryption  encryption  encryption  encryption  encryption  encryption  encryption  encryption
 EVP_CipherUpdate                                updated     updated
 EVP_DecryptUpdate
                             updated     updated
                                                                                   decryption  decryption
 EVP_EncryptUpdate
                             updated     updated
                                                                                                        encryption  encryption
 EVP_CipherFinal                                             finaled
 EVP_DecryptFinal
                             finaled
 EVP_EncryptFinal
                             finaled
 EVP_CIPHER_CTX_free          freed   freed       freed       freed       freed       freed       freed        freed       freed
 EVP_CIPHER_CTX_reset                 newed       newed       newed       newed       newed       newed        newed       newed
 EVP_CIPHER_CTX_get_params            newed    initialised   updated   initialised   updated    initialised   updated
                                                                                   decryption  decryption   encryption  encryption
 EVP_CIPHER_CTX_set_params            newed    initialised   updated   initialised   updated    initialised   updated
                                                                                   decryption  decryption   encryption  encryption
 EVP_CIPHER_CTX_gettable_params       newed    initialised   updated   initialised   updated    initialised   updated
                                                                                   decryption  decryption   encryption  encryption
 EVP_CIPHER_CTX_settable_params       newed    initialised   updated   initialised   updated    initialised   updated
                                                                                   decryption  decryption   encryption  encryption

bestie that table is A LOT but it's literally all the lore, every single transition, we keep it all πŸ’―


πŸ’€ NOTES

at some point the EVP layer will begin enforcing the transitions described herein. so like, these aren't just suggestions forever, okay? pay attention πŸ™ˆ


πŸ‘€ SEE ALSO


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


okay that's the whole thing, you understood it perfectly, i'm so proud of you bestie πŸ«ΆπŸ’œ version 3.5.0, dated 2026-09-25, and it's the LIFE_CYCLE-CIPHER(7ossl) page β€” slay, you now know cipher life-cycles better than most people ngl ✨

πŸ“¦ where this page comes from