Ch2 Traditional Symmetric-Key Ciphers
Ch2 Traditional Symmetric-Key Ciphers
Key Ciphers
Chapter 2
Traditional Symmetric-Key
Ciphers
Introduction
3
Introduction
4
Cryptanalysis
• The science and art of breaking those codes.
• Beside cryptography techniques, we also need to know cryptanalysis
techniques.
• Not to break other people’s codes, but to know how vulnerable our
cryptosystem is.
• Cryptanalysis helps us create better secret codes.
5
Ciphertext-Only Attack
• Eve has access to only some ciphertext.
• Eve trying to find both key and plain text.
• Methods can be used in ciphertext-only attack:
• Brute-Force Attack
• Statistical Attack
• Pattern Attack
6
Ciphertext-Only Attack
Methods can be used in ciphertext-only attack:
• Brute-Force Attack
• Eve tries to use all possible keys.
• Eve decrypts the ciphertext with every possible key until the plaintext makes
sense.
• To prevent this type of attack, the number of possible keys must be very large.
7
Ciphertext-Only Attack
Methods can be used in ciphertext-only attack: (cont.)
• Statistical Attack
• The cryptanalyst can benefit from the characteristics of the plaintext language.
• Letter E is the most frequently used letter in English text.
• The cryptanalyst finds the mostly-used character in the ciphertext and assumes
that the corresponding plaintext character is E.
• To prevent this type of attack, the cipher should hide the characteristics of the
language.
• Digram
• Two-letter combination
• Most common is th , in , to , an, is , ed.
• Trigram
• Three-letter combination
• Most frequent is the , for , ing , was , are
8
Ciphertext-Only Attack
Methods can be used in ciphertext-only attack: (cont.)
• Statistical Attack
9
Ciphertext-Only Attack
Methods can be used in ciphertext-only attack: (cont.)
• Pattern Attack
• Some ciphers may create a pattern in the ciphertext.
• A cryptanalyst may use a pattern attack to break the cipher.
• To prevent this type of attack, use ciphers that make the ciphertext look as
random as possible.
10
Known-Plaintext Attack
• Eve has access to some previous plaintext/ciphertext pairs.
• Ex. Alice has sent a secret message to Bob, but she has later made
the contents of the message public.
• Eve has kept both the ciphertext and the plaintext.
• Assuming that Alice has not changed her key.
• Less likely to happen because Alice may have changed her key or
may have not disclosed the contents of any previous messages.
11
Chosen-Plaintext Attack
• Similar to the known-plaintext attack, but the plaintext/ciphertext pairs have
been chosen by the attacker herself.
• Ex. if Eve has access to Alice’s computer. She can choose a plaintext and
intercept the created ciphertext, without knowing the key.
• This attack is much easier to implement, but it is much less likely to happen.
12
Chosen-Ciphertext Attack
• Eve chooses some ciphertext and decrypts it to form a
ciphertext/plaintext pair.
• This can happen if Eve has access to Bob’s computer.
13
Cryptanalysis
14
Categories of Traditional Ciphers
• Symmetric-key ciphers is divided into two categories:
• substitution ciphers and transposition ciphers.
• Substitution cipher
• replace one symbol in the ciphertext with another symbol.
• Transposition cipher
• reorder the position of symbols in the plaintext.
15
Substitution ciphers
• Substitution ciphers can be categorized as:
• monoalphabetic ciphers or polyalphabetic ciphers.
16
Monoalphabetic Ciphers
• The relationship between a symbol in the plaintext to a symbol in
the ciphertext is always one-to-one.
• The cipher is monoalphabetic because both L’s are encrypted as O’s.
18
Additive Cipher
Example:
• Use the additive cipher with key = 15 to encrypt the message “hello”.
• K=15
• P=hello
• C=?
19
Additive Cipher
Example: (Solution)
• Use the additive cipher with key = 15 to encrypt the message “hello”.
• K=15
• P=hello
• C=WTAAD
20
Additive Cipher
Example:
• Use the additive cipher with key = 15 to decrypt the message
“WTAAD”.
• K=15
• C=WTAAD
• P=?
21
Additive Cipher
Example: (Solution)
• Use the additive cipher with key = 15 to decrypt the message
“WTAAD”.
• K=15
• C=WTAAD
• P=hello
22
Additive Cipher
Cryptanalysis
• Vulnerable to ciphertext-only attacks using brute-force attacks.
• The key domain is very small; there are only 26 keys.
Example:
• Eve has intercepted the ciphertext “UVACLYFZLJBYL”. Show how
she can use a brute-force attack to break the cipher.
• C= UVACLYFZLJBYL
• K=?
• P=?
23
Additive Cipher
Cryptanalysis
Example: (Solution)
• Eve has intercepted the ciphertext “UVACLYFZLJBYL”. Show how
she can use a brute-force attack to break the cipher.
• C= UVACLYFZLJBYL
• K=?
• P=?
• P = (C − k) mod 26
24
Multiplicative Ciphers
25
Multiplicative Ciphers
Example:
• Use a multiplicative cipher to encrypt the message “hello” with a key of 7.
• K=7
• P=hello
• C=?
26
Multiplicative Ciphers
Example: (Solution)
• Use a multiplicative cipher to encrypt the message “hello” with a key of 7.
• K=7
• P=hello
• C=XCZZU
27
Affine Cipher
• Combination between the additive and multiplicative ciphers.
• Uses a pair of keys.
28
Affine Cipher
Example:
• Use an affine cipher to encrypt the message “hello” with the key (7, 2).
• K=7,2
• P=hello
• C=?
29
Affine Cipher
Example: (Solution)
• Use the affine cipher to encrypt the message “hello” with the key (7, 2).
• K=7,2
• P=hello
• C=ZEBBW
30
Polyalphabetic Ciphers
• The relationship between a character in the plaintext to a character in
the ciphertext is one-to-many.
• The cipher is monoalphabetic because both L’s are encrypted as O’s.
31
Playfair Cipher
• The secret key in this cipher is made of 25 alphabet letters.
• Arranged in a 5*5 matrix.
• Letters I and J are considered the same when encrypting.
• Repeating plaintext letters that are in the same pair should be
separated with a filler letter x.
• If two plaintext letters that fall in the same row of the matrix are
each replaced by the letter to the right.
• If two plaintext letters that fall in the same column are each replaced
by the letter beneath.
32
Playfair Cipher
Example:
• Use the playfair cipher to encrypt the message “hello” with the key
“monarchy”.
• K=monarchy
• P=hello
• C=?
33
Playfair Cipher
Example: (Solution)
• Use the playfair cipher to encrypt the message “hello” with the key
“monarchy”.
• K=monarchy
• P=hello
• hecf
• lxsu
• lopm
• C=cfsupm
34
Playfair Cipher
Example:
• Use the playfair cipher to encrypt the message “saudi” with the key
“College of computer”.
• K= Collegeofcomputer
• P= saudi
• C=?
35
Playfair Cipher
Example: (Solution)
• Use the playfair cipher to encrypt the message “saudi” with the key
“College of computer”.
• K= Collegeofcomputer
• P= saudi
• sakh
• uddq
• ixnv
• C=khdqnv
36
Playfair Cipher
Cryptanalysis
• Brute-force attack on a Playfair cipher is very difficult.
• The size of the key domain is 25!
• (factorial 25=15,511,210,043,330,985,984,000,000).
• Cryptanalyst can use a ciphertext-only attack (Statistical Attack) based
on the digram frequency test to find the key.
• Digram
• Two-letter combination
• Most common is th
37
Vigenere Cipher
• Uses a different strategy to create the key stream.
• The key stream is a repetition of an initial secret key stream of length n.
Example:
• Use the Vigenere cipher to encrypt the message “She is listening” with
the key “PASCAL”.
• K= PASCAL
• P= Sheislistening
• C=?
38
39
Vigenere Cipher
Example: (Solution)
• Use the Vigenere cipher to encrypt the message “She is listening” with
the key “PASCAL”.
• K= PASCAL
• P= Sheislistening
• C=HHWKSWXSLGNTCG
40
One-Time Pad
• The key has the same length as the plaintext.
• Key is chosen completely in random.
• Key is used to encrypt and decrypt a single message and then is discarded.
• Each new message requires a new key of the same length as the new message.
• The one-time pad offers complete security but has difficulties:
• Long messages (1-2 pages) must use long keys.
• Making large number of random keys.
41
Transposition Ciphers
• Does not substitute one symbol for another.
• It changes the location of the symbols.
• Transposition cipher include:
• Keyless Transposition Ciphers
• Keyed Transposition Ciphers
42
Keyless Transposition Ciphers
There are two methods for it:
• In the first method, the text is written into a table column by column
and then transmitted row by row,
• Ex. Rail fence cipher.
• In the second method, the text is written into the table row by row
and then transmitted column by column.
43
Keyless Transposition Ciphers
Method 1 (Rail fence)
• The plaintext is arranged in two lines as a zigzag pattern (which
means column by column)
• The ciphertext is created reading the pattern row by row.
Example:
• Use the Rail fence cipher to encrypt the message “Meet me at the
park” with depth 2.
• P= Meetmeatthepark
• C=?
44
Keyless Transposition Ciphers
Method 1 (Rail fence)
Example: (Solution)
• Use the Rail fence cipher to encrypt the message “Meet me at the
park” with depth 2.
• P= Meetmeatthepark
• C=MEMATEAKETETHPR
45
Keyless Transposition Ciphers
Method 1 (Rail fence)
Example:
• Use the Rail fence cipher to encrypt the message “Meet me at the
park” with depth 3.
• P= Meetmeatthepark
• C=?
46
Keyless Transposition Ciphers
Method 1 (Rail fence)
Example: (Solution)
• Use the Rail fence cipher to encrypt the message “Meet me at the
park” with depth 3.
• P= Meetmeatthepark
• C=MTAHAEMTEREETPK
47
Keyless Transposition Ciphers
Method 2
• Both sender and receiver agree on the number of columns.
• The plaintext is arranged row by row.
• The ciphertext is created reading the pattern column by column.
Example:
• Use the Keyless Transposition cipher to encrypt the message “Meet
me at the park” with depth 4.
• P= Meetmeatthepark
• C=?
48
Keyless Transposition Ciphers
Method 2
Example: (Solution)
• Use the Keyless Transposition cipher to encrypt the message “Meet
me at the park” with depth 4.
• P= Meetmeatthepark
• C=MMTAEEHREAEKTTP
49
Keyed Transposition Ciphers
Example:
• Use the Keyed Transposition cipher to encrypt the message “Enemy
attacks tonight” using key 31452.
• K= 31452
• P= Enemyattackstonight
• C=?
50
Keyed Transposition Ciphers
Example: (Solution)
• Use the Keyed Transposition cipher to encrypt the message “Enemy
attacks tonight” using key 31452.
• K= 31452
• P= Enemyattackstonight
• Row C=NYEEMTCATASNKTOGZIHT
• Column C=NTSGYCNZEAKIETTHMAOT
51
Transposition Ciphers
Cryptanalysis
Transposition ciphers are vulnerable to several kinds of ciphertext-only
attacks:
• Statistical Attack
• Using single-letter frequency analysis.
• Brute-Force Attack
• By guessing the number of columns.
• Pattern Attack
• keyed transposition ciphertext has some repeated patterns.
52
Stream and Block Ciphers
Symmetric ciphers are divided into two categories:
• Stream ciphers
• encryption and decryption are done character by character.
• It has a plaintext stream, a ciphertext stream, and a key stream.
• Block ciphers
• group of plaintext symbols of size n are encrypted together creating a
group of ciphertext of the same size.
• single key is used to encrypt the whole block.
53
End of Chapter
54