# man > life_cycle-cipher(7)

---
type: CommandReference
command: life_cycle-cipher
mode: man
section: 7SSL
source: man-pages
---

## Quick Reference
- `EVP_CIPHER_CTX_new()` — allocate context: `start` → `newed`
- `EVP_CipherInit()`, `EVP_DecryptInit()`, `EVP_EncryptInit()` — initialise cipher for operation: from `newed` or any `initialised`/`updated` state → corresponding `initialised` state
- `EVP_CipherUpdate()`, `EVP_DecryptUpdate()`, `EVP_EncryptUpdate()` — process data: from corresponding `initialised` or `updated` state → `updated`
- `EVP_CipherFinal()`, `EVP_DecryptFinal()`, `EVP_EncryptFinal()` — finalise: from `updated` → `finaled`
- `EVP_CIPHER_CTX_free()` — free context: any state → `freed`
- `EVP_CIPHER_CTX_reset()` — re‑initialise: any state except `start`/`freed` → `newed`

## Name
life_cycle-cipher — The cipher algorithm life-cycle

## Synopsis
All symmetric ciphers (CIPHERs) transition through these states:

1. **start** – before allocation  
2. **newed** – after `EVP_CIPHER_CTX_new()`  
3. **initialised** – ready for processing (three variants: via `EVP_CipherInit`, `EVP_DecryptInit`, or `EVP_EncryptInit`)  
4. **updated** – processing data (one variant for each initialised stream)  
5. **finaled** – output generated, no more input  
6. **freed** – terminal state after `EVP_CIPHER_CTX_free()`

The three initialised/updated streams (decryption, encryption, generic) must not be mixed.

## Options (State Transitions)
The following table lists the legal state transitions for each function call. States are abbreviated:  
`S` = start, `N` = newed,  
`I` = initialised, `Id` = initialised (decryption), `Ie` = initialised (encryption),  
`U` = updated, `Ud` = updated (decryption), `Ue` = updated (encryption),  
`F` = finaled, `Fr` = freed.

- `EVP_CIPHER_CTX_new()`: **S → N**
- `EVP_CipherInit()`: from **N**, **I**, **Id**, **Ie**, **U**, **Ud**, **Ue** → **I**
- `EVP_DecryptInit()`: from **N**, **I**, **Id**, **Ie**, **U**, **Ud**, **Ue** → **Id**
- `EVP_EncryptInit()`: from **N**, **I**, **Id**, **Ie**, **U**, **Ud**, **Ue** → **Ie**
- `EVP_CipherUpdate()`: from **I** → **U**; from **U** → **U**
- `EVP_DecryptUpdate()`: from **Id** → **Ud**; from **Ud** → **Ud**; also from **U** → **Ud** (via `EVP_CipherUpdate` path)
- `EVP_EncryptUpdate()`: from **Ie** → **Ue**; from **Ue** → **Ue**; also from **U** → **Ue** (via `EVP_CipherUpdate` path)
- `EVP_CipherFinal()`: from **U** → **F**
- `EVP_DecryptFinal()`: from **Ud** → **F**
- `EVP_EncryptFinal()`: from **Ue** → **F**
- `EVP_CIPHER_CTX_free()`: from any state → **Fr**
- `EVP_CIPHER_CTX_reset()`: from any state except **S**/**Fr** → **N**
- `EVP_CIPHER_CTX_get_params()`, `EVP_CIPHER_CTX_set_params()`, `EVP_CIPHER_CTX_gettable_params()`, `EVP_CIPHER_CTX_settable_params()`: allowed from **N**, **I**, **Id**, **Ie**, **U**, **Ud**, **Ue** (no state change)

## See Also
- [provider-cipher(7)](http://localhost/phpMan.php/man/provider-cipher/7/markdown)
- [EVP_EncryptInit(3)](http://localhost/phpMan.php/man/EncryptInit/3/markdown)