85 min total

Information Security

Block ciphers: DES, 3DES, and AES

Block ciphers: DES, 3DES, and AES

Notation: DES accepts a 64-bit key representation with eight parity bits, leaving 56 effective key bits; each round key has 48 bits. Three-key 3DES has 168 nominal key bits but roughly 112-bit security. DES and 3DES are retained here as historical teaching examples.

Algorithm-transition context: NIST SP 800-131A Rev. 2

Block ciphers, such as DES, 3DES, and AES, are widely used symmetric encryption algorithms, processing plaintext input in fixed-size blocks, producing equal-sized ciphertext blocks.

Data Encryption Standard (DES)

Uses 64-bit plaintext and 56-bit keys, with 16 rounds of processing.

The plaintext is 64 bits in length and the key is 56 bits in length. Longer plaintext amounts are processed in 64-bit blocks. There are 16 rounds of processing. From the original 56-bit key, 16 subkeys are generated, one of which is used for each round. The process of decryption with DES is the same as the encryption, Use the ciphertext as input to the DES algorithm, but use the subkeys Ki in reverse order.

Triple DES

3DES uses three keys and three executions of the DES algorithm. The function follows an encrypt-decrypt-encrypt (EDE) sequence

Triple DES encrypt-decrypt-encrypt construction

Decryption is with keys reversed

Three-key 3DES has 168 nominal key bits and roughly 112-bit security

Confusion

(Principle introduced by Claude shannon)

Aims to mask relationship between encryption and ciphertext to make it difficult for attacker to perform cryptanalysis

Diffusion

Spreads influence of each plaintext bit across multiple ciphertext bits to make patterns in plaintext less noticeable. (small change in plaintext results in huge changes in ciphertext)

Data Encryption Standard (DES)

Adopted by NIST in 1977

Symmetric block cipher

Input: 64 bits

Output: 64 bits

Main key: 64 bits

Sub key: 56 bits

Round key: 48 bits

No of rounds: 16

DES is criticized for key length too short

Whole process:

Initial permutation:

DES initial permutation

Original input bit positions:

12345678
910111213141516
1718192021222324
2526272829303132
3334353637383940
4142434445464748
4950515253545556
5758596061626364

Output selects input positions in this order:

585042342618102
605244362820124
625446383022146
645648403224168
57494133251791
595143352719113
615345372921135
635547393123157

The first DES round

DES encryption: initial permutation, sixteen Feistel rounds, key schedule, and inverse permutation

After the initial permutation, split the 64-bit input into L₀ and R₀. Expand R₀ from 32 to 48 bits, XOR with K₁, apply eight S-boxes to return to 32 bits, and apply P. Then L₁ = R₀ and R₁ = L₀ XOR F(R₀, K₁). The same structure repeats for 16 rounds.

Final permutation

/ Inverse permutation

DES inverse initial permutation

408481656246432
397471555236331
386461454226230
375451353216129
364441252206028
353431151195927
342421050185826
33141949175725

Single round of DES algorithm

DES round with expansion, S-box substitution, permutation, and key scheduling

Expansion Permutation

DES expansion: 32 bits to 48 bits

Arrange the 32 input positions into eight groups of four:

1234
5678
9101112
13141516
17181920
21222324
25262728
29303132

Duplicate boundary bits to obtain eight groups of six:

3212345
456789
8910111213
121314151617
161718192021
202122232425
242526272829
28293031321

New expanded block 32 → 48

F is the mangler Function

DES expansion from 32 to 48 bits, XOR with the round key, eight S-boxes, and P permutation

Keyed Substitution

BOX

S-boxes in DES provide non-linearity in encryption, creating confusion in ciphertext and making it more secure.

DES S₁ substitution table

Row / column0000000100100011010001010110011110001001101010111100110111101111
001441312151183106125907
010157414213110612119538
104114813621115129731050
111512824917511314100613

The outer two input bits select the row; the middle four bits select the column. For 101010, the row is 10 and the column is 0101, giving 6 = 0110. The source screenshot has a typo at row 01, column 1100; the DES value is 9.

DES tables: FIPS 46-3 (historical standard)

S-boxes

Transposition / Permutation Function (P Box)

DES P permutation

167202129122817
11523265183110
282414322739
19133062211425

Permutation involves rearranging input bits, distributing the influence of each bit, ensuring that a small change in input affects multiple bits in the output. Carries out diffusion process

Key scheduling in DES

Idea is to take original 56-bit key and derive a different keys to use at each encryption round.

Ensures that encryption process uses different keys in each round

DES encryption: initial permutation, sixteen Feistel rounds, key schedule, and inverse permutation

S-boxes introduce confusion through nonlinearity. P-boxes distribute bit influence and contribute to diffusion across rounds. After 16 Feistel rounds, DES is intended to behave like a pseudorandom keyed permutation of the plaintext.

56-bit key is permuted using a table called PC-1 , which rearranges the bits and discards 8 of the parity bits, leaving the key as a 56-bit value. The result is divided into two halves: a left half (C0) and a right half (D0) , each with 28 bits.

= 1 left shift for i: 1, 2, 9, 16  = 2 left shift for i: other rounds

The PC-2 table is then used to permute this combined 56-bit key, selecting 48 bits to form the subkey for that particular round.

DES Decryption

Since DES is a symmetric key algorithm, the same key is used for both encryption and decryption.

DES decryption with the round keys used in reverse order

How can we so easily decrypt DES algorithm?

  • Symmetric key algorithm, same key for encryption and decryption
    in decryption round 1, subkey 16 needed
    in decryption round 2, subkey 15 needed
    in decryption round 3, subkey 14 needed
  • Uses Feistel structure, which allows encryption and decryption to use same operations with only difference of order of subkeys
  • Uses initial permutation and final permutation that are inverses of each other, so applying final permutation during decryption reverses the initial permutation during encryption

Avalanche effect and strength of DES

Is a desirable property in cryptographic algorithms, where a small input change significantly alters the output, ideally changing half of the bits.

DES has a very strong avalanche effect

1 bit change in plain text - 34 bits change in cipher text on average

1 bit change in cipher text - 34 bits change in plain text on average

Advanced Encryption Standard (AES) (20.3)

NIST in 2001

Symmetric block cipher 128 bit blocks

Supports three key sizes:

128-bit key = 10 rounds

192-bit key = 12 rounds

256-bit key = 14 rounds

AES encryption and the expanded round keys
AES encryption and decryption transformations

AES Transformation Functions

  • Substitute Bytes

It is responsible for introducing non-linearity into the encryption process

AES SubBytes transformation through the substitution table
  • Shift Rows

primary purpose is to provide diffusion. function operates on the state matrix, which is a 4x4 array of bytes

Row 0: No shift.

Row 1: Left shift by 1 byte.

Row 2: Left shift by 2 bytes.

Row 3: Left shift by 3 bytes.

AES ShiftRows: left rotation by zero, one, two, and three bytes
  • Mix Columns

purpose is to increase diffusion

Each column in state matrix is matmul by fixed matrix

AES MixColumns transforms each column using a fixed finite-field matrix
  • Add Round Key
AES AddRoundKey combines the state and round key using XOR

AES Key expansion

1 word = 4 bytes

AES-128 round-key words

RoundKey words
Initial keyw0, w1, w2, w3
1w4, w5, w6, w7
2w8, w9, w10, w11
3w12, w13, w14, w15
4w16, w17, w18, w19
5w20, w21, w22, w23
6w24, w25, w26, w27
7w28, w29, w30, w31
8w32, w33, w34, w35
9w36, w37, w38, w39
10w40, w41, w42, w43
AES key expansion with RotWord, SubWord, round constants, and XOR

S-Box in AES

AES S-box

Row / column0123456789ABCDEF
0637C777BF26B6FC53001672BFED7AB76
1CA82C97DFA5947F0ADD4A2AF9CA472C0
2B7FD9326363FF7CC34A5E5F171D83115
304C723C31896059A071280E2EB27B275
409832C1A1B6E5AA0523BD6B329E32F84
553D100ED20FCB15B6ACBBE394A4C58CF
6D0EFAAFB434D338545F9027F503C9FA8
751A3408F929D38F5BCB6DA2110FFF3D2
8CD0C13EC5F974417C4A77E3D645D1973
960814FDC222A908846EEB814DE5E0BDB
AE0323A0A4906245CC2D3AC629195E479
BE7C8376D8DD54EA96C56F4EA657AAE08
CBA78252E1CA6B4C6E8DD741F4BBD8B8A
D703EB5664803F60E613557B986C11D9E
EE1F8981169D98E949B1E87E9CE5528DF
F8CA1890DBFE6426841992D0FB054BB16

Use the high hexadecimal nibble as the row and the low nibble as the column. For C2, row C and column 2 contain 25.

AES-128 round constants

RoundRcon word
101000000
202000000
304000000
408000000
510000000
620000000
740000000
880000000
91B000000
1036000000

The initial round uses the original key directly. The source labels its round constant 00000000; no round-constant transformation is needed for that initial key.

Decryption in AES

Whats different:

  • Inverse transformation
    uses inverse AES S-Box

Inverse AES S-box

Row / column0123456789ABCDEF
052096AD53036A538BF40A39E81F3D7FB
17CE339829B2FFF87348E4344C4DEE9CB
2547B9432A6C2233DEE4C950B42FAC34E
3082EA16628D924B2765BA2496D8BD125
472F8F66486689816D4A45CCC5D65B692
56C704850FDEDB9DA5E154657A78D9D84
690D8AB008CBCD30AF7E45805B8B34506
7D02C1E8FCA3F0F02C1AFBD0301138A6B
83A9111414F67DCEA97F2CFCEF0B4E673
996AC7422E7AD3585E2F937E81C75DF6E
A47F11A711D29C5896FB7620EAA18BE1B
BFC563E4BC6D279209ADBC0FE78CD5AF4
C1FDDA8338807C731B11210592780EC5F
D60517FA919B54A0D2DE57A9F93C99CEF
EA0E03B4DAE2AF5B0C8EBBB3C83539961
F172B047EBA77D626E169146355210C7D
  • Inverse Shiftrows
    the rows that were shifted left in encryption are now shifted right using Inverse ShiftRows.

Inverse ShiftRows

RowBeforeAfter right rotation
0B0 B4 B8 B12B0 B4 B8 B12
1B1 B5 B9 B13B13 B1 B5 B9
2B2 B6 B10 B14B10 B14 B2 B6
3B3 B7 B11 B15B7 B11 B15 B3

Rows 0, 1, 2, and 3 rotate right by 0, 1, 2, and 3 positions, respectively.

  • Inverse Mix Columns

Inverse of mix columns is matmul to reverse mixing of columns during encryption

MixColumns and its inverse

Entries are hexadecimal bytes; multiplication and addition take place in GF(2⁸), not ordinary integer arithmetic.

  • Add Round Key

Operation is identical but order in which round keys is in reverse order like DES

  • Order of operations
    in encryption order of transformations is:
  • SubBytes
  • ShiftRows
  • MixColumns
  • AddRoundKey

in decryption order of transformations is:

  • AddRoundKey
  • Inverse ShiftRows
  • Inverse SubBytes
  • Inverse MixColumns