# Block Encryption procedure

To encrypt, AES applies 4 distinct functions to the Plain Text in a specific and repetitive order, each of which is reversible (in order to be able to decrypt later)

{% @mermaid/diagram content="graph LR
Plain(PlainText)
addKey(Key Addition Layer)
Cipher(CypherText)
subgraph round
Sub(Byte Substitution Layer)
Shift(Diffusion : Shift Row Layer)
Mix(Diffusion : Mix Column Layer)
addKey2(Key Addition Layer)
Sub --> Shift --> Mix --> addKey2
end
Plain --> addKey  --> round --- repet(\[Repetition n times]) --> round
round --> Cipher" %}

{% hint style="info" %}
Every rounds made these four operations except the last one where the Mix Column is skipped
{% endhint %}

## Resources

* <https://www.angelfire.com/biz7/atleast/mix_columns.pdf>
* <https://engineering.purdue.edu/kak/compsec/NewLectures/Lecture8.pdf>

{% embed url="<https://github.com/francisrstokes/githublog/blob/main/2022/6/15/rolling-your-own-crypto-aes.md>" %}

{% embed url="<https://www.utc.fr/~wschon/sr06/txPHP/aes/MixColumn/MixColumn.php>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.ctfrecipes.com/cryptography/symmetric-cryptography/aes/block-encryption-procedure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
