03. Classical Encryption

Terminology

Cryptography transforms data based on a secret called the key. It provides confidentiality and authentication:

Cryptosystems:

Symmetric key cipher (secret key cipher):

Asymmetric key cipher (public key cipher):

Notation for Symmetric Encryption Algorithms

Encryption: C=E(M,K)C = E(M, K)

Decryption: M=D(C,K)M = D(C, K)

Methods of Cryptanalysis

What resources are available to the adversary? Computational capabilities, inputs/outputs to the systems, etc.

What is the adversary aiming to achieve? Retrieving the whole secret key? Distinguishing between two messages?

Adversary tries all possible keys. Impossible to prevent such attacks; can only ensure there are enough keys to make exhaustive search too difficult computationally.

Note that the adversary may find the key without exhaustive search or even break the cryptosystem without finding the key.

Preventing exhaustive key search is a minimum standard.

Attack Classification

Ciphertext only attack: the attacker has access only to intercepted ciphertexts.

A cryptosystem is highly insecure if it can be practically attacked using only intercepted ciphertexts.

Known plaintext attack: the attacker knows a small amount of plaintexts and their corresponding ciphertexts.

Chosen plaintext attack: the attacker can obtain the ciphertext from some plaintext it has selected (attacker has ‘inside encryptor’).

Chosen ciphertext attack: the attacker can obtain the plaintext from some ciphertext it has selected (attacker has ‘inside decryptor’).

A cryptosystem should be secure against chosen plaintext and ciphertext attacks.

Kerckhoff’s Principle

Kerckoff’s Principle states the that the attacker has complete knowledge of the cipher; the decryption key is the only item unknown to the attacker.

Secret, non-standard algorithms are often flawed, providing mainly security through obscurity.

Alphabets

Historical ciphers: define alphabet for the plaintext and ciphertext

Roman alphabet: A,B,C,,ZA, B, C, \dots, Z

Statistical attacks depend on using the redundancy of the alphabet:

Basic Cipher Operations

Transposition: characters in plaintext are mixed up with each other (permutations)

Substitution: each character is replaced by a different character

Transposition Cipher

Permuting characters in a fixed period dd and permutation ff.

The plaintext is seen as a matrix with dd columns. For each row, the characters are mixed up in the order given by ff. The same permutation is used by each row.

Key is (d,f)(d, f), each block of dd characters being re-ordered using the permutation ff.

There are d!d! permutations of length dd.

Cryptanalysis

Frequency distribution of ciphertext and plaintext characters are the same.

If dd is small, transposition ciphers can be solved by hand using anagramming.

Knowledge of plaintext language digram/trigrams can help to optimize trials.

Simple Substitution Ciphers

Each character in plaintext alphabet replaced by character in ciphertext alphabet using a substitution table.

This is called a monoaphabetic substitution cipher.

Caesar cipher:

Random simple substitution cipher:

Polyalphabetic Substitution

Multiple mappings from plaintext to ciphertext: smoothens frequency distribution.

Typically periodic substitution ciphers based on a period dd.

Given dd ciphertext alphabets C0,C1,,cd1C_0, C_1, \dots, c_{d - 1}, let fi:ACif_i: A \rightarrow C_i.

A plaintext message:

M=M0Md1MdM2d1M2d M = M_0 \dots M_{d-1}M_d \dots M_{2d-1}M_{2d} \dots

it is encrypted to:

(K,M)=f0(M0)f1(M1)fd1(Md1)f0(Md)fd1(M2d1) (K, M) = f_0(M_0)f_1(M_1) \dots f_{d-1}(M_{d - 1})f_0(M_d) \dots f_{d - 1}(M_{2d - 1}) \dots

If d=1d = 1, the cipher is monoalphabetic - a simple substitution cipher.

Key generation:

Encryption: encrypt the iith character using the jjth substitution table such that ij(modd)i \equiv j \pmod d.

Decryption: use the same substitution table as encryption.

Vigenère Cipher

Based on shifted alphabets.

The key KK is a sequence of characters K=K0K1Kd1K = K_0 K_1 \dots K_{d - 1}.

Let MM be the plaintext character. for 0id10 \le i \le d - 1, KK gives the amount of shift in the iith character e.g. fi(M)=(M+Ki)modnf_i(M) = (M + K_i) \bmod n.

e.g. if K=LOCK={11,14,2,10}K= LOCK = \{ 11, 14, 2, 10 \}, the first character is shifted by 1111, the second is shifted by 1414, …, the fifth is shifted by 1111.

Cryptanalysis

Identifying period length:

Once period identified, the dd substitution tables can be attacked separately - there needs to be sufficient ciphertext to do this.

Autocorrelation

Given ciphertext CC, computed the correlation between CC and its shift CiC_i for all values ii of the period.

English is non-random; there is better correlation between two texts with the same shift size.

Find peaks in the value of CiC_i when ii is a multiple of the period; results can be plotted on a histogram.

Kasiski Method

If you identify sequences of characters that occur multiple times, find the distance between them; the period is likely to be a multiple of the period.

If you find multiple sequences with different distances, the period is likely to be a common divisor.

Once the period is found, the separate alphabets can be attacked separately; at this point, it is just a Caesar cipher.

Other Ciphers (for use by hand)

Beaufort cipher: like Vigenère, but fi(M)=(KiM)modnf_i(M) = (K_i - M) \bmod n

Autokey: starts off as the Vigenère cipher, but the plaintext defines the subsequent alphabet. Hence, the cipher is not periodic.

Running key cipher: practically infinite set of alphabets generated from a shared key. This is ofen an extract from a book called the book cipher.

Rotor Machines

Enigma: each character encrypted with a different alphabet with a period of ~17,000; would never repeat in the same message (in practice).

Hill Cipher

Polygram/polygraphic cipher: simple substitution of an extended alphabet consisting of multiple characters.

Has linearity, making known plaintext attacks easy.

Given dd plaintext characters:

Encryption: multiplying the d×dd \times d matrix KK by the block of plaintext MM: C=KMC = KM.

Decryption: multiplying the matrix K1K^{-1} by the block of ciphertext CC: M=K1CM = K^{-1}C.

Example

d=2d = 2; takes digrams as input/output blocks.

Each plaintext pair written as column vector. If there are insufficient letters, they are filled with uncommon letters (e.g. ZZ).

K=(4617),K1=(4121110) K = \begin{pmatrix} 4 & 6 \\ 1 & 7 \end{pmatrix}, K^{-1} = \begin{pmatrix} 4 & 12 \\ 11 & 10 \end{pmatrix}

Plaintext:

M=(EG)=(46) M = (EG) = \begin{pmatrix} 4 \\ 6 \end{pmatrix}

Encryption:

C=KM=(4617)(46)=(52mod2746mod27)=(2519)=ZT \begin{aligned} C &= KM \\ &= \begin{pmatrix} 4 & 6 \\ 1 & 7 \end{pmatrix} \begin{pmatrix} 4 \\ 6 \end{pmatrix} \\ &= \begin{pmatrix} 52 \bmod{27} \\ 46 \bmod{27} \end{pmatrix} \\ &= \begin{pmatrix} 25 \\ 19 \end{pmatrix} \\ &= ZT \\ \end{aligned}

Decryption:

M=K1C=(4121110)(2519)=(46)=(EG) \begin{aligned} M &= K^{-1}C \\ &= \begin{pmatrix} 4 & 12 \\ 11 & 10 \end{pmatrix} \begin{pmatrix} 25 \\ 19 \end{pmatrix} \\ &= \begin{pmatrix} 4 \\ 6 \end{pmatrix} \\ &= (EG) \end{aligned}

Cryptanalysis

Known plaintext attacks possible given dd plaintext-ciphertext matching blocks: given blocks (column vectors) MiM_i and CiC_i, 0id10 \le i \le d - 1:

CC , MM and KK are all d×dd \times d vectors

Then K1K^{-1} can be found to decrypt the ciphertext.

Comments: