Skip to content

Commit badc8a7

Browse files
hunjyeongyijun-lee
andauthored
Docs/blockcipher.md (#84)
* docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/kzg.md * docs/smc.md * docs/smc.md * docs/smc.md * docs/smc.md * docs/smc.md * docs/smc.md * docs/ss.md * docs/ss.md * docs/ss.md * docs/ss.md * docs/ss.md * docs/ss.md * docs/ss.md * docs/ss.md * docs/blockcipher.md * docs/blockcipher.md * docs/blockcipher.md --------- Co-authored-by: Yijun Lee <119404328+yijun-lee@users.noreply.github.com>
1 parent 28771ee commit badc8a7

16 files changed

Lines changed: 180 additions & 1 deletion

content/Basic Cryptography/Block cipher.md renamed to content/Basic Cryptography/block cipher/Block cipher.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ If the length of the plaintext to be encrypted is longer than the block size, a
1818

1919
| Confidentiality only | Authenticated Encryption with Additional Data(AEAD) |
2020
| ------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
21-
| - ECB(Electric Codebook)<br>- CBC(Cipher-block Chaining)<br>- CFB(Cipher Feedback)<br>- OFB(Output Feedback)<br>- CTR(Counter) | - GCM(Galois counter)<br>- CCM(Counter with cipher block chaining message authentication code)<br>- SIV(Synthetic initialization vector)<br>- AES-GCM-SIV |
21+
| - [[ECB(Electric Codebook)]]<br>- [[CBC(Cipher-block Chaining)]]<br>- [[CFB(Cipher Feedback)]]<br>- [[OFB(Output Feedback)]]<br>- [[CTR(Counter)]] | - GCM(Galois counter)<br>- CCM(Counter with cipher block chaining message authentication code)<br>- SIV(Synthetic initialization vector)<br>- AES-GCM-SIV |
2222

2323
## Comparison with [[Stream cipher]]
2424
| | [[Stream Cipher]] | Block Cipher |
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## CBC(Cipher-block Chaining)
2+
3+
In CBC mode, each plaintext block is XORed with the previous ciphertext block before being encrypted.
4+
5+
As a result, each ciphertext block depends on all the plaintext blocks processed up to that point.
6+
7+
If the previous block is not encrypted, the next block cannot be encrypted, so encryption must be performed sequentially, making parallel processing impossible. Similarly, decryption cannot be performed in parallel.
8+
9+
By setting the IV (Initialization Vector) randomly, even if the same plaintext or key is used, different ciphertexts can be generated.
10+
11+
<br>
12+
13+
### CBC mode Encrytion
14+
![[block_cipher_CBC_Enc.png]]
15+
16+
17+
$C_i = E_K(P_i \oplus C_{i-1})$
18+
19+
$C_0 = IV$
20+
21+
22+
<br>
23+
24+
### CBC mode Decrytion
25+
![[block_cipher_CBC_Dec.png]]
26+
27+
28+
$P_i = D_K(C_i) \oplus C_{i-1}$
29+
30+
$C_0 = IV$
31+
32+
<br>
33+
34+
**Definitions**
35+
36+
- $P_i$: Plaintext block $i$
37+
- $C_i$: Ciphertext block $i$
38+
- $E_K$: Encryption function with key $K$
39+
- $D_K$: Decryption function with key $K$
40+
- $IV$: Initialization Vector
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## CFB(Cipher Feedback)
2+
3+
CFB mode makes a block cipher operate like a synchronous stream cipher. Since it functions as a stream cipher, padding is not required even if the data size does not align perfectly with the block size.
4+
5+
Because each block uses the previous ciphertext, encryption in CFB mode cannot be processed in parallel, similar to CBC.
6+
7+
While similar to CBC, CFB uses XOR with the encrypted feedback value. Unlike CBC, decryption in CFB mode can be performed in parallel.
8+
9+
<br>
10+
11+
### CFB mode Encrytion
12+
![[block_cipher_CFB_Enc.png]]
13+
14+
$C_i = \begin{cases} IV, & i = 0 \\ E_K(C_{i-1}) \oplus P_i, & \text{otherwise} \end{cases}$
15+
16+
<br>
17+
18+
### CBC mode Decrytion
19+
![[block_cipher_CFB_Dec.png]]
20+
21+
$P_i = E_K(C_{i-1}) \oplus C_i$
22+
23+
<br>
24+
25+
**Definitions**
26+
27+
- $P_i$: Plaintext block $i$
28+
- $C_i$: Ciphertext block $i$
29+
- $E_K$: Encryption function with key $K$
30+
- $IV$: Initialization Vector
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## CTR(Counter)
2+
3+
Like OFB, CTR mode makes a block cipher function as a stream cipher.
4+
5+
It uses an incrementing counter value for each block, encrypts it, and then XORs the result with the plaintext to generate the ciphertext.
6+
7+
CTR mode supports parallel processing and does not require padding, making it highly efficient.
8+
9+
Since each block is processed independently, any corruption or modification of a ciphertext block does not affect other blocks.
10+
11+
<br>
12+
13+
### CTR mode Encrytion
14+
![[block_cipher_CTR_Enc.png]]
15+
16+
$C_i = P_i \oplus E_K(\text{Nonce} \parallel \text{Counter}_i)$
17+
18+
$\text{Counter}_{i+1} = \text{Counter}_i + 1$
19+
20+
<br>
21+
22+
### CTR mode Decrytion
23+
![[block_cipher_CTR_Dec.png]]
24+
25+
$P_i = C_i \oplus E_K(\text{Nonce} \parallel \text{Counter}_i)$
26+
27+
$\text{Counter}_{i+1} = \text{Counter}_i + 1$
28+
29+
<br>
30+
31+
**Definitions**
32+
33+
- $P_i$: Plaintext block $i$
34+
- $C_i$: Ciphertext block $i$
35+
- $E_K$: Encryption function with key $K$
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## ECB(Electric Codebook)
2+
3+
ECB is a method that divides a message into multiple blocks and encrypts each block individually.
4+
5+
Since encryption and decryption operations are independent of each other, they can be processed in parallel.
6+
7+
However, because all blocks use the same encryption key, it is vulnerable to security risks.
8+
9+
<br>
10+
11+
### ECB mode Encrytion
12+
![[block_cipher_ECB_Enc.png]]
13+
14+
- Divide the plaintext $P$ into fixed block sizes (e.g., 128 bits).
15+
- Represent each block as $P_1, P_2, \dots, P_n$.
16+
- Encryption: $C_i = E_K(P_i)$
17+
- Combine all ciphertext blocks in order to generate the final ciphertext $C$.
18+
19+
<br>
20+
21+
### ECB mode Decrytion
22+
![[block_cipher_ECB_Dec.png]]
23+
24+
- Divide the ciphertext $C$ into fixed block sizes.
25+
- Represent each block as $C_1, C_2, \dots, C_n$.
26+
- Decryption: $P_i = D_K(C_i)$
27+
- Combine the decrypted plaintext blocks to generate the final plaintext $P$.
28+
29+
30+
<br>
31+
32+
**Definitions**
33+
34+
- $E_K$: Encryption function with key $K$
35+
- $D_K$: Decryption function with key $K$
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## OFB(Output Feedback)
2+
3+
OFB mode makes a block cipher operate like a synchronous stream cipher.
4+
5+
Unlike CBC or CFB, it performs encryption using only the encrypted feedback values, independent of the previous ciphertext or plaintext.
6+
7+
Both encryption and decryption can be processed in parallel.
8+
9+
<br>
10+
11+
### OFB mode Encrytion
12+
![[block_cipher_OFB_Enc.png]]
13+
14+
$C_i = P_i \oplus E_K(I_i)$
15+
16+
$I_i = E_K(I_{i-1})$
17+
18+
$I_0 = IV$
19+
20+
<br>
21+
22+
### OFB mode Decrytion
23+
![[block_cipher_OFB_Dec.png]]
24+
25+
$P_i = C_i \oplus E_K(I_i)$
26+
27+
$I_i = E_K(I_{i-1})$
28+
29+
$I_0 = IV$
30+
31+
<br>
32+
33+
**Definitions**
34+
35+
- $P_i$: Plaintext block $i$
36+
- $C_i$: Ciphertext block $i$
37+
- $E_K$: Encryption function with key $K$
38+
- $I_i$: Input block $i$
39+
- $IV$: Initialization Vector
56.4 KB
Loading
55.7 KB
Loading
62.1 KB
Loading
63 KB
Loading

0 commit comments

Comments
 (0)