Stream and Block Ciphers




CS166

Chris Pollett

Sep. 5, 2012

Outline

Symmetric Key Crypto

Stream Ciphers

A5/1: Shift Registers

A5/1 uses three shift registers

A5/1: Keystream

A5/1

Schematic of A5/1 algorithm

A5/1 Example

Example of A5/1 schematic filled with bit values

Shift Register Crypto

RC4

RC4 Initialization

for (i = 0 ; i < 256; i++) {
    S[i] = i;
    K[i] = key[i % N];
}
j = 0;
for (i = 0 ; i < 256; i++) {
    j = (j + S[i] + K[i]) % 256;
    swap(S[i], S[j]);
}
i = 0;
j = 0; //these used in keystream

RC4 Keystream

Stream Ciphers

HW Problem

Exercise Ch2, 23: Consider the ciphertext QJKES REOGH GXXRE OXEO, which was generated using an affine cipher (mod 26). Determine the constants `a` and `b` and decipher the message. Hint: "t" (coded as 19) encrypts to "H" (coded as 7) and "o" (coded as 14) encrypts to "E" (coded as 4).

Solution. Using the hint, we know `a(19)+b = 7 mod 26` and `a(14)+b = 4 mod 26`. Subtracting these two equations gives `5a = 3 mod 26`. i.e., `5a = 26m + 3` for some `m` a natural number less than 26. Notice `5a = 26m + 3 = m + 3 = 0 mod 5`, so we see `m=2` works. So `a = 11` and substituting back into the equation gives `11(19) +b = 7 mod 26`. Solving for `b`, we have `b = 7 - 209 =-20 mod 26 = 6 mod 26`. Using this, we can decode the message. Starting with, `y = 11x+6 mod 26`, and solving for `x`, we get `y - 6 = 11x mod 26`. The multiplicative inverse of `11 mod 26` is a number `z` such `11z = 1 mod 26`. Now `11z = 26m + 1 = 4m+1 = 0 mod 11` and so `m=8`, giving `11z = 26(8) + 1` and `z=19`. Hence, `19(y-6) = x mod 26`. Q (coded as `16`) comes from `19(16-6)mod 26 = 8` which is i. Continuing we get: ifyou bowat allbo wlow

(Iterated) Block Cipher

Feistel Cipher: Encryption

Feistel Cipher: Decryption

Data Encryption Standard

About DES