Professional Documents
Culture Documents
Historical Ciphers
Historical Ciphers
Historical Ciphers
• General definitions
– Additive ciphers
– Affine ciphers
– Vigenère ciphers
1
Cryptosystem: definitions
– P: Plaintext space
– C: Ciphertext space
– K: key space
2
Cryptosystem: process
3
Monoalphabetic ciphers
A B C D E F G H I J K L M
0 1 2 3 4 5 6 7 8 9 10 11 12
N O P Q R S T U V W X Y Z
13 14 15 16 17 18 19 20 21 22 23 24 25
4
Additive ciphers: Caesar
cipher
• Mathematical description:
– a → 0, b → 1, . . ., y → 24, z → 25
5
Review: modular arithmetic
• Congruences:
– a≡b (mod m) if m | b − a.
• Arithmetic modulo m:
6
More modular arithmetic
– d | a and d | b,
– if c | a and c | b then c | d.
7
Additive ciphers: definition
8
Additive ciphers: example
Plaintext: c a e s a r
2 0 4 18 0 17
+10 mod 26 12 10 14 2 10 1
Ciphertext: M K O C K B
9
Additive ciphers: security
10
Affine ciphers: definitions
• Key space
K = {(a, b) ∈ Z26 × Z26 | (a, 26) = 1}
– |K| = 12 × 26 = 312
11
Affine ciphers: example
– ek (x) = 7x + 3 mod 26
– To encrypt:
ek (22) = 7 × 22 + 3 = 1 mod 26 etc
– To decrypt:
dk (1) = 15 × 1 − 19 = 22 mod 26 etc
12
Affine ciphers: security
a × 1 + b = 4 mod 26
a × 0 + b = 1 mod 26.
– a = 3, b = 1, so k = (3, 1),
e(x) = 3x + 1 mod 26
d(x) = 9(x − 1) mod 26
13
Key phrase ciphers
• Example:
P: a b c d e f g h i j k l m n o ... z
C: M Y L I T E F N G R
• Secure?
14
Substitution ciphers:
definition
• P = C = Z26
• K = Sym(26)
• Example:
abcdefghijklmnopqrstuvwxyz
QUGRAHCKBTEINJDYFPMWXSLZOV
15
Substitution ciphers:
weakness
16
Substitution ciphers:
cryptanalysis
– Intercept ciphertext
17
Substitution ciphers:
example cryptanlysis
HNZ MZKXZ AG U GHUKYAKE TBWZ
LAHN UIGHFUOAUK FUVVAHG. A UR
XZFHUAK HNUH AG XOZUF AK GQYKZQ.
18
Substitution ciphers:
example cryptanlysis
19
Substitution ciphers:
example cryptanlysis
20
Substitution ciphers:
example cryptanlysis
21
Substitution ciphers:
example cryptanlysis
a b c d e f g h i j k l m
U V X Y Z M E N A T W O R
n o p q r s t u v w x y z
K B C D F G H I J L P Q S
22
Polyalphabetic ciphers
• Polyalphabetic cipher
23
Vigenère ciphers: definitions
• Keyword of m letters
• P = C = K = (Z26)m
• |K| = 26m
24
Vigenère ciphers: example
Plaintext m e e t a t
12 4 4 19 0 19
Keystream 4 12 20 4 12 20
16 16 24 23 12 13
Ciphertext Q Q Y X M N
m i d n i g h t
12 8 3 13 8 6 7 19
4 12 20 4 12 20 4 12
16 20 23 17 20 0 11 5
Q U X R U A L F
25
Vigenère ciphers: some
insight
26
Vigenère ciphers:
cryptanalysis
– Kasiski test
– Index of coincidence
27
Vigenère ciphers: Kasiski
test
• Ad hoc technique:
28
Vigenère ciphers: index of
coincidence
• Random text:
Ic(x) = 26(1/26)2 ≈ 0.038
29
Vigenère ciphers: index of
coincidence
³ ´
• There are n
2 pairs of letters
³ ´
• There are f2i pairs of letter i
• Index of coincidence
P25 ³fi´ P25
i=0 2 i=0 fi(fi − 1)
Ic(x) = ³
n
´ =
n(n − 1)
2
30
Vigenère ciphers: determine
m
n
• Write ciphertext y = y1y2 . . . yn as m × m
array (assuming m divides n)
Row y1 y1 ym+1 . . . y( n −1)m+1
m
Row y2 y2 ym+2 . . . y( n −1)m+2
m
... ... ... ...
Row ym ym y2m . . . y( n −1)m+m
m
31
Vigenère ciphers: determine
m
32
Vigenère ciphers: determine
m
– Same row:
µ ¶
1 n
n − 1 × 0.065
2 m
– Different rows:
µ ¶
1 n
n n− × 0.038
2 m
33
Vigenère ciphers: determine
m
Equation for keyword length m:
µ ¶
1 1 n
n(n − 1)Ic = n − 1 × 0.065
2 2 m
µ ¶
1 n
+ n n− × 0.038
2 m
0.027n
m≈
Ic(n − 1) − 0.038n + 0.065
34
Vigenère ciphers: determine
keyword shift
Suppose y1 and y2 were obtained using k1 and
k2
0
• Encrypt y2 using k1 − k2 to get y2
35
Vigenère ciphers: determine
keyword
Suppose keyword shifts are known:
• Additive cipher:
• Affine cipher:
• Vigenère cipher
37