Lecture-4_Traditional Symmetric-Key Cipher
Lecture-4_Traditional Symmetric-Key Cipher
Traditional
Symmetric-Key Ciphers: Part 1
Department of Computer Science
and Technology (CSE)
Cryptographic Approaches
2
Symmetric Key Cipher:
General Structure
Secret shared key
Kerckhoff’s Principle
How many keys? m * (m – 1) / 2
Cryptanalysis
As cryptography is the science and art of creating secret codes, cryptanalysis is
the science and art of breaking those codes.
Important for finding how vulnerable our Cryptosystem is.
4 common types.
Cryptanalysis
Ciphertext-Only Attacks:
Adversary tries to find corresponding key. The types are:
Brute-force method or exhaustive-key-search method
Statistical Attack
Pattern Attack
Known-Plaintext Attack:
Adversary has access to plaintext/ciphertext pairs from previous sessions.
Chosen-Plaintext Attack:
Adversaries themselves choose the plaintext/ciphertext pairs by accessing the sender’s
computer.
Chosen-Ciphertext Attack:
Adversaries themselves choose the ciphertext/plaintext pairs by accessing the receiver’s
computer.
Categories of Traditional Ciphers
Traditional
Ciphers
Substitution Transposition
Cipher Cipher
Monoalphabetic Polyalphabetic
Keyless Keyed
If the symbols in the plaintext are alphabetic characters, we replace one character
with another.
For example, we can replace letter A with letter D, and letter T with letter Z.
If the symbols are digits (0 to 9), we can replace 3 with 7, and 2 with 6.
A character (or a symbol) in the plaintext is always changed to the same character
(or symbol) in the ciphertext regardless of its position in the text.
For example, if the algorithm says that letter A in the plaintext is changed to
letter D, every letter A is changed to letter D.
In other words, the relationship between letters in the plaintext and the
ciphertext is one-to-one.
Affine Cipher
Caesar/Additive Cipher
Caesar/Additive Cipher is
sometimes referred as Shift
Cipher.
Representation of Cipher and
Plaintext.
Encryption and Decryption are
inverse of each other.
Susceptible to Brute force &
Statical Attacks
Key Domain is small (26 keys)
Frequency of Character
occurrence like E, T, A etc.
Frequency of Character
Combination like “TH”, “THE”,
“HE”, “ING” etc.
Caesar/Additive Cipher
Example
With k = 15, encrypt the message “hello”.
The key for Decryption should be k-1 which is the multiplicative inverse.
Thus the selected key should have a multiplicative inverse modulo 26.
This is done to guarantee the encryption and decryption are inverses of each other.
Keys with multiplicative inverses under 26 are: (12 keys)
Affine Cipher
Combination of
Caesar/Additive Cipher and
Multiplicative Cipher
2 rules to follow:
Each key has an inverse at
the other side of the line
They are used in reverse
order in the encryption
and decryption.
If addition is the last
operation in encryption,
then subtraction should be
the first in decryption.
Attacking Caesar/Additive Cipher
Caesar cipher
Caesar can be broken if we only know one pair (plain letter, encrypted letter)
The difference between them is the key
Caesar can be broken even if we only have the encrypted text and no knowledge of the
plaintext
Brute-force attack is easy: there are only 25 keys possible
Try all 25 keys and check to see which key gives an intelligible message
Attacking Caesar/Additive Cipher
Key concept - monoalphabetic substitution ciphers do not change relative letter frequencies
Discovered by Arabs in the 9th century
Calculate letter frequencies for ciphertext
Compare counts/plots against known values
Most frequent letter in the ciphertext may well encrypt E
The next one could encrypt T or A
After relatively few tries the system is broken
If the ciphertext is relatively short (and so, the frequencies are not fully relevant) then more guesses
may be needed
Powerful tool: look at the frequency of two-letter combinations (digrams)
Example of cryptanalysis
Ciphertext:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAIZVUEPHZHMDZSHZOWSFPAPPDTSVPQUZ
WYMXUZUHSXEPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Count relative letter frequencies: P is the most frequent (13.33%), followed by Z (11.67), S (8.33), U
(8.33), O (7.5), M (6.67), H (5.83), etc.
Guess P and Z stand for E and T but the order is not clear because of small difference in the frequency
The next set of letters {S,U, O, M, H} may stand for {A, H, I, N, O, R, S} but again it is not completely clear
which is which
One may try to guess and see how the text translates
Also, a good guess is that ZW, the most common digram in the ciphertext, is TH, the most common digram in
English: thus, ZWP is THE
Proceed with trial and error and finally get after inserting the proper blanks:
it was disclosed yesterday that several informal but direct contacts have been made with
political representatives of the viet cong in moscow
Some conclusions after this
cryptanalysis
Monoalphabetic ciphers are easy to break because they reflect the frequency of the original alphabet
Essential to know the original alphabet
Wrong: Multiple-letter patterns (digrams, trigrams, etc) survive in the text providing a tool for cryptanalysis
Each element of the plaintext only affects one element in the ciphertext
Longer text needed for breaking the system
Measures to hide the structure of
the plaintext
This a polyalphabetic cipher where the subkeys are automatically created from the
plaintext cipher characters during the encryption process.
The first subkey is a predetermined value secretly agreed upon by the sender-receiver.
The second subkey is the value of the first plaintext character (between 0 and 25).
The third subkey is the value of the second plaintext. And so on.
Cryptanalysis: Not affected by single-letter frequency Statistical attack but however
vulnerable to Brute-force Attack
Playfair Cipher
This is another polyalphabetic cipher used by the British army during World War I.
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).
Different arrangements of the letters in the matrix can create many different secret
keys.
Playfair Cipher
Before encryption, if the two letters in a pair are the same, a bogus letter is
inserted to separate them.
If the number of characters in the plaintext is odd, one extra bogus character is
added at the end to make the number of characters even.
The cipher uses three rules for encryption:
a) If the two letters in a pair are located in the same row of the secret key, the
corresponding encrypted character for each letter is the next letter to the right in the
same row (with wrapping to the beginning of the row if the plaintext letter is the last
character in the row).
b) If the two letters in a pair are located in the same column of the secret key, the
corresponding encrypted character for each letter is the letter beneath it in the same
column (with wrapping).
c) If the two letters in a pair are not in the same row or column, the corresponding encrypted
character for each letter is a letter that is in its own row but in the same column as the
other letter.
Playfair Cipher
Example
Encrypt “Hello” using the secret key:
When we group the letters in two-character pairs, we get:
“he, ll, o”
We need to insert an x between the two l’s, giving
“he, lx, lo”.
Even or odd?
“he” “EC”
“lx” “QZ”
“lo” “BX”
Vigenere Cipher
A transposition cipher does not substitute one symbol for another, instead it
changes the location of the symbols.
A symbol in the first position of the plaintext may appear in the tenth position of
the ciphertext.
A symbol in the eighth position in the plaintext may appear in the first position
of the ciphertext.
In a stream cipher, encryption and decryption are done one symbol (such as a
character or a bit) at a time.
In a block cipher, a single key is used to encrypt the whole block even if the key
is made of multiple values.
For example: Playfair Ciphers, Hill Ciphers & Keyed Transposition Ciphers.
References
Main Reference:
Chapter-3 : Cryptography and Network Security- by Behrouz A. Forouzan
Supporting Reference:
Chapter -2 : Cryptography and Network Security: Principles and Practice- by William Stallings