Symmetric Cryptography ยท 2.3

๐Ÿงฎ Symmetric Algorithms: DES, 3DES, AES

From 56-bit failure to 256-bit gold standardโฑ ~4 min

DES โ€” Data Encryption Standard (1977, now broken)

DES was the first publicly standardized encryption algorithm, developed by IBM and adopted by NIST in 1977. It uses a 56-bit key and 16 rounds of a Feistel network structure.

PropertyValue
Key size56 bits effective (64-bit key, 8 bits are parity)
Block size64 bits (8 bytes)
Rounds16
StatusโŒ Broken โ€” 56-bit key brute-forced in 22 hours in 1999 (EFF DES Cracker)
โš  WarningNever use DES. A 56-bit key gives only 2^56 โ‰ˆ 72 quadrillion possible keys. A modern GPU cluster can try all of them in hours. DES is deprecated and prohibited in all modern security standards.

3DES (Triple DES) โ€” A Stopgap That Overstayed Its Welcome

3DES applies DES three times with different keys (Encrypt-Decrypt-Encrypt with keys K1, K2, K3). This extends the effective key length to 112 bits (in two-key mode) or 168 bits (three-key mode).

PropertyValue
Key size112 bits (2-key) or 168 bits (3-key)
Block size64 bits โ€” vulnerable to sweet32 birthday attack on long sessions
Speed3ร— slower than DES, roughly 12ร— slower than AES
Statusโš ๏ธ Deprecated by NIST in 2023 โ€” migrate to AES immediately

AES โ€” Advanced Encryption Standard (2001, current gold standard)

โ˜… FactAES was selected in 2001 after a 5-year public competition run by NIST. The winner โ€” Rijndael, designed by Belgian cryptographers Joan Daemen and Vincent Rijmen โ€” beat 14 other candidates through public cryptanalysis. No significant attack on AES has been found in 25 years of intense scrutiny.
VariantKey SizeRoundsUse
AES-128128 bits10General use โ€” considered secure for most purposes
AES-192192 bits12Rarely used; slight security margin increase
AES-256256 bits14High-security use: government, military, disk encryption

How AES Works Internally

  • โ€ขSubBytes โ€” each byte replaced via a non-linear S-box lookup table (confusion)
  • โ€ขShiftRows โ€” rows of the 4ร—4 state matrix are cyclically shifted left (diffusion)
  • โ€ขMixColumns โ€” each column multiplied by a fixed matrix over GF(2^8) (diffusion)
  • โ€ขAddRoundKey โ€” the state XORed with the round key derived from the main key (key injection)
  • โ€ขThese four steps repeat for 10/12/14 rounds; the final round skips MixColumns
๐Ÿ”’ SecurityAES-256 with a strong random key has never been practically broken. Even the best known theoretical attack (biclique cryptanalysis) only reduces the work factor from 2^256 to 2^254 โ€” still completely infeasible. For context, 2^256 operations would require more energy than exists in the observable universe.

Practical AES Usage

python
# Python โ€” AES-GCM encryption using cryptography library
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
import os
# Generate a random 256-bit key
key = os.urandom(32) # 32 bytes = 256 bits
# Generate a random 96-bit nonce (must NEVER be reused with same key)
nonce = os.urandom(12) # 12 bytes = 96 bits (standard for GCM)
aesgcm = AESGCM(key)
# Encrypt โ€” returns ciphertext + 16-byte authentication tag
ciphertext = aesgcm.encrypt(nonce, b'Hello, World!', None)
# Decrypt โ€” raises exception if tag verification fails
plaintext = aesgcm.decrypt(nonce, ciphertext, None)
print(plaintext) # b'Hello, World!'
๐Ÿง Quick Checkfirst try = +5 XP

Why is DES no longer used?

โญ 0 XP๐Ÿ”ฅ 0 days