Unit - Ii: Traditional Symmetric-Key Ciphers
Unit - Ii: Traditional Symmetric-Key Ciphers
Based on Kerckhoff’s principle, one should always assume that the opponent, Eve, knows
the encryption/decryption algorithm.
The resistance of the cipher to attack must be based only on the secrecy of the key.
Cryptanalysis
As cryptography is the science and art of creating secret codes, cryptanalysis is the
science and art of breaking those codes.
Cryptanalysis attacks
Ciphertext-Only Attack
In the ‘cipher-only’ attack, the attacker knows the ciphertext of various messages which have
been encrypted using the same encryption algorithm.
The attacker’s challenge is to figure the ‘key’ which can then be used to decrypt all messages.
The ‘cipher-only’ attack is probably one of the easiest attacks to commit since it is easy to capture
the ciphertext (by sniffing) but difficult to implement since the knowledge about the encryption
process is limited.
Known-Plaintext Attack
In the ‘known-plaintext’ attack, the attacker knows some of the plaintext and the
ciphertext.
He then has to figure the ‘key’ by reverse engineering and he can decipher other messages
which use the same ‘key’ and algorithm.
The ‘known-plaintext’ attack was effective against simple ciphers such as the ‘substitution
cipher’.
It was popular for breaking ciphers used during the Second World War.
Chosen-Plaintext Attack
The ‘chosen-plaintext’ attack is similar to the ‘known-plaintext’ attack, but here the attacker
experiments by choosing his own plaintext and with the generated ciphertext he can figure the
‘key’.
Once he figures the ‘key’ he can learn more about the whole encryption process and understand
how the ‘key’ is being used.
With this information, he can decrypt other messages.
Chosen-Ciphertext Attack
In the ‘chosen ciphertext’ attack, the attacker chooses a portion of the decrypted ciphertext.
He then compares the decrypted ciphertext with the plaintext and figures out the key.
This is relatively a harder type of attack and earlier versions of RSA were subject to these
types of attacks.
I.SUBSTITUTION CIPHERS
When the cipher is additive, the plaintext, ciphertext, and key are integers in Z26.
Examples
I. Use the additive cipher with key = 15 to encrypt the message “hello”.
Solution
II. Use the additive cipher with key=15 to decrypt the message “WTAAD”.
Solution
In a multiplicative cipher, the plaintext and ciphertext are integers in Z26; the key is an
integer in Z26*
Examples
I. What is the key domain for any multiplicative cipher?
The key needs to be in Z26 *. This set has only 12 members: 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25.
II. We use a multiplicative cipher to encrypt the message “hello” with a key of 7. The ciphertext
is “XCZZU”.
Monoalphabetic Substitution Cipher
Because additive and multiplicative ciphers have small key domains, they are very vulnerable to
brute-force attack.
A better solution is to create a mapping between each plaintext character and the corresponding
ciphertext character.
In monoalphabetic substitution, the relationship between a symbol in the plaintext to a symbol in
the ciphertext is always one-to-one.
Alice and Bob can agree on a table showing the mapping for each character.
The ciphertext is
Polyalphabetic Ciphers
In polyalphabetic substitution, each occurrence of a character may have a different substitute.
The relationship between a character in the plaintext to a character in the ciphertext is one-to-
many.
Features are:
1. A set of related monoalphabetic substitution rules is used.
2. A key determines which particular rule is chosen for a given transformation.
Example
Assume that Alice and Bob agreed to use an autokey cipher with initial key value k1 = 12. Now
Alice wants to send Bob the message “Attack is today”. Enciphering is done character by character.
Playfair Cipher
Used by British army during world war I.
Secret key in this cypher is made of 25 characters arranged in 5X5 matrix.
Letters I and J are counts as one while encrypting.
An example of a secret key in the Playfair cipher
The Playfair Cipher Encryption Algorithm:
The Algorithm consists of 2 steps:
1. Generate the key Square(5×5):
The key square is a 5×5 grid of alphabets that acts as the key for encrypting the plaintext. Each of
the 25 alphabets must be unique and one letter of the alphabet (usually J) is omitted from the table
(as the table can hold only 25 alphabets). If the plaintext contains J, then it is replaced by I.
The initial alphabets in the key square are the unique alphabets of the key in the order in which they
appear followed by the remaining letters of the alphabet in order.
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
Playfair Cipher
2. Algorithm to encrypt the plain text:
The plaintext is split into pairs of two letters (digraphs). If there is an odd number of letters, a z is
added to the last letter.
For example:
PlainText: "instruments" After Split: 'in' 'st' 'ru' 'me' 'nt' 'sz'
Pair cannot be made with same letter. Break the letter in single and add a bogus letter to the
previous letter.
Plain Text: “hello”
After Split: ‘he’ ‘lx’ ‘lo’
Here ‘x’ is the bogus letter.
If the letter is standing alone in the process of pairing, then add an extra bogus letter with the
alone letter
Plain Text: “helloe”
AfterSplit: ‘he’ ‘lx’ ‘lo’ ‘ez’
Here ‘z’ is the bogus letter.
Rules for Encryption:
If both the letters are in If both the letters are in If neither of the above
the same row: the same column rules is true
Take the letter to the right Take the letter below each Each plaintext is replaced
of each one (going back to one (going back to the top by the letter that lies in its
the leftmost if at the if at the bottom). own row & column
rightmost position) occupied by the other
plaintext
Diagraph: "st" Encrypted Diagraph: "me" Diagraph: "nt" Encrypted
Text: tl Encrypted Text: cl Text: rq
Example
Plain Text: "instrumentsz"
Encrypted Text: gatlmzclrqtx
Playfair Cipher
In Decryption ,the key letter again identifies the row. The position of the cipher text letter in
that row determines the column, and the plaintext letter is at the top of that column.
Strength of Vigenere cipher
• There are multiple cipher text letters for each plaintext letter.
• Letter frequency information is concealed.
Vigenere tableau
the additive cipher is a special case of Vigenere cipher in which m = 1
One-Time Pad
One of the goals of cryptography is perfect secrecy.
A study by Shannon has shown that perfect secrecy can be achieved if each plaintext symbol is
encrypted with a key randomly chosen from a key domain.
This idea is used in a cipher called one-time pad, invented by Vernam.
It is an unbreakable cryptosystem. It represents the message as a sequence of 0’s and 1’s.
This can be accomplished by writing all numbers in binary or by using ASCII.
The key is a random sequence of 0"s and 1"s of same length as the message. Once a key is
used, it is discarded and never used again. The system can be expressed as follows:
Ci = Pi Ki
Ci - ith binary digit of ciphertext
Pi- ith binary digit of plaintext
Ki - ith binary digit of key
One-Time Pad
Exclusive
OR
Ciphertext is generated by performing the bitwise XOR of the plaintext and the key.
Decryption also uses the same key. Because of the properties of XOR, decryption simply involves the same
bitwise operation:
Advantage
Encryption method is completely unbreakable for ciphertext only attack.
Disadvantages
It requires a very long key which is expensive to produce and expensive to transmit.
Once a key is used, it is dangerous to reuse it for a second message; any knowledge on the first message would
give knowledge of the second.
Example
Plaintext – Hello and a pad – uBV,; will give you a cipher text- =‘:@T
1001000
1110101
0111101 = 61
II.TRANSPOSITION CIPHERS
A transposition cipher does not substitute one symbol for another, instead it changes the location
of the symbols.
A transposition cipher reorders symbols.
A symbol in the first position may appear in tenth position of the cyphertext.
Three types
Keyless Transposition Ciphers
Keyed Transposition Ciphers
Combining Two Approaches
1. Keyless Transposition Ciphers
Simple transposition ciphers, which were used in the past, are keyless.
I. A good example of a keyless cipher using the first method is the rail fence cipher. The ciphertext is
created reading the pattern row by row. For example, to send the message “Meet me at the park” to Bob,
Alice writes.
She then creates the ciphertext “MEMATEAKETETHPR” by sending first row followed by second row.
Bob receives the cypher text and divides it into half.
First half forms first row and second half second row.
Bob reads the result in zig zag.
Disadvantage
Cryptanalysis of cyphertext would be very easy.
Keyless Transposition Ciphers
II. Alice and Bob can agree on the number of columns and use the second method. Alice writes
the same plaintext, row by row, in a table of four columns.
The second character in the plaintext has moved to the fifth position in the ciphertext; the
third character has moved to the ninth position; and so on. Although the characters are
permuted, there is a pattern in the permutation: (01, 05, 09, 13), (02, 06, 10, 13), (03, 07,
11, 15), and (08, 12). In each section, the difference between the two adjacent numbers is
4.
2. Keyed Transposition Ciphers
The keyless ciphers permute the characters by using writing plaintext in one way and reading it in another
way
The permutation is done on the whole plaintext to create the whole ciphertext.
Another method is to divide the plaintext into groups of predetermined size, called blocks, and then use a
key to permute the characters in each block separately.
Example
Alice needs to send the message “Enemy attacks tonight” to Bob..
The key used for encryption and decryption is a permutation key, which shows how the character are
permuted.
Bob divides the cyphertext into 5-character groups and using the key in reverse order, finds the plaintext.
3. Combining Two Approaches
Figure shows the encryption process. Multiplying the 4 × 5 plaintext matrix by the 5 × 5
encryption key gives the 4 × 5 ciphertext matrix.
Double Transposition Ciphers
• The transposition cipher can be made significantly more secure by performing more than one stage
of transposition.
• The result is a more complex permutation that is not easily reconstructed.
Vernam Cipher
The Verna m Cipher is based on the principle that each plaintext character from a message
is 'mixed' with one character from a key stream.
If a truly random key stream is used, the result will be a truly ' random ' ciphertext which
bears no relation to the original plaintext.
In that case the cipher is similar to the unbreakable One -Time Pad (OTP).
As it was generally used with tele printers and 5-level punched tape, the system is also
known as One-Time Tape or OTT.
8. Hill Cipher
The literature divides the symmetric ciphers into two broad categories: stream ciphers and
block ciphers.
Although the definitions are normally applied to modern ciphers, this categorization also
applies to traditional ciphers.
1. Stream Ciphers
1. Block Ciphers
2. Combination
1.Stream Ciphers
the plaintext is processed one bit at a time i.e. one bit of plaintext is taken, and a series of
operations is performed on it to generate one bit of ciphertext.
Technically, stream ciphers are block ciphers with a block size of one bit.
Continued..
Additive ciphers can be categorized as stream ciphers in which the key stream is the repeated
value of the key. In other words, the key stream is considered as a predetermined stream of keys
or K = (k, k, …, k). In this cipher, however, each character in the ciphertext depends only on the
corresponding character in the plaintext, because the key stream is generated independently
The monoalphabetic substitution ciphers discussed in this chapter are also stream ciphers.
However, each value of the key stream in this case is the mapping of the current plaintext
character to the corresponding ciphertext character in the mapping table.
Vigenere ciphers are also stream ciphers according to the definition. In this case, the key stream
is a repetition of m values, where m is the size of the keyword. In other words,
2. Block Ciphers
In this scheme, the plain binary text is processed in blocks (groups) of bits at a time; i.e. a
block of plaintext bits is selected, a series of operations is performed on this block to
generate a block of ciphertext bits.
The number of bits in a block is fixed.
For example, the schemes DES and AES have block sizes of 64 and 128, respectively.I
Examples
Playfair ciphers are block ciphers. The size of the block is m = 2. Two characters are
encrypted together.
Hill ciphers are block ciphers. A block of plaintext, of size 2 or more is encrypted together
using a single key (a matrix). In these ciphers, the value of each character in the ciphertext
depends on all the values of the characters in the plaintext. Although the key is made of m
× m values, it is considered as a single key.
Digital Encryption Standard (DES), Triple DES, Advanced Encryption Standard (AES),
Twofish, Serpent etc. are also examples of block cypher.
Padding in Block Cipher
Block ciphers process blocks of fixed sizes (say 64 bits).
The length of plaintexts is mostly not a multiple of the block size.
For example, a 150-bit plaintext provides two blocks of 64 bits each with third block of
balance 22 bits.
The last block of bits needs to be padded up with redundant information so that the length
of the final block equal to block size of the scheme.
In our example, the remaining 22 bits need to have additional 42 redundant bits added to
provide a complete block.
The process of adding bits to the last block to make fixed size block is referred to
as padding.
Stream Cipher vs Block Cipher
3. The complexity of block cipher is simple. While stream cipher is more complex.
Block cipher is slow as compared to stream While stream cipher is fast in comparison
6
cipher. to block cipher.
The encryption process uses the Feistel structure consisting multiple rounds of processing of the plaintext,
each round consisting of a “substitution” step followed by a permutation step.
The input block to each round is divided into two halves that can be denoted as L and R for the left half and
the right half.
In each round, the right half of the block, R, goes through unchanged. But the left half, L, goes through an
operation that depends on R and the encryption key. First, we apply an encrypting function ‘f’ that takes two
input − the key K and R. The function produces the output f(R,K). Then, we XOR the output of the
mathematical function with L.
In real implementation of the Feistel Cipher, such as DES, instead of using the whole encryption key during
each round, a round-dependent key (a subkey) is derived from the encryption key. This means that each
round uses a different key, although all these subkeys are related to the original key.
The permutation step at the end of each round swaps the modified L and unmodified R. Therefore, the L for
the next round would be R of the current round. And R for the next round be the output L of the current
round.
Above substitution and permutation steps form a ‘round’. The number of rounds are specified by the
algorithm design.
Once the last round is completed then the two sub blocks, ‘R’ and ‘L’ are concatenated in this order to form
the ciphertext block.
Decryption Process
Instead of starting with a block of plaintext, the ciphertext block is fed into the start of the
Feistel structure and then the process thereafter is exactly the same as described in the
given illustration.
In the case of decryption, the only difference is that the subkeys used in encryption are
used in the reverse order.
The final swapping of ‘L’ and ‘R’ in last step of the Feistel Cipher is essential. If these are
not swapped then the resulting ciphertext could not be decrypted using the same algorithm.
Encryption n Decryption
Data Encryption Standard
(DES)
Module II-Objectives
❏ To analyze DES
INTRODUCTION
The Data Encryption Standard (DES) is a symmetric- key block cipher published by the National Institute of Standards
and Technology (NIST).
In 1973, NIST published a request of proposals for a national symmetric-key cryptosystem.
A proposal from IBM, a modification of a project called Lucifer, was accepted as DES.
DES was published in the Federal Register in March 1975 as a draft of the Federal Information Processing Standard (FIPS).
DES is a symmetric key block cypher which encrypts data in the blocks of size 64 bits and includes 16 rounds and each
round is a Feistel round.
DES is based on the two fundamental attributes of cryptography: substitution (also called as confusion) and transposition
(also called as diffusion).
Overview
Although the relationship between the input and output can be defined mathematically, DES
uses following table to define this P-box.
Example
D O N T G I V E T H E M O N E Y
Y D O N T G T G I V E T E T H E M O M O N E Y D
After the expansion permutation, DES uses the XOR operation on the expanded right section
and the round key.
Note that both the right section and the key are 48-bits in length. Also note that the round key
is used only in this operation.
S-Boxes
The S-boxes do the real mixing (confusion).
DES uses 8 S- boxes, each with a 6-bit input and a 4-bit output.
Using mixers and swappers, we can create the cipher and reverse cipher, each having 16 rounds.
Cipher is used at the encryption site and reverse cipher is used at decryption site.
First approach
To achieve this goal, one approach is to make the last round (round 16) different from the
others; it has only a mixer and no swapper
Alternate approach
We can make all 16 rounds the same by including one swapper to the 16th round and add
an extra swapper after that
Two swappers cancel the effect of each other
DES cipher and reverse cipher for the first approach
DES ANALYSIS
Two desired properties of a block cipher are the avalanche effect and the completeness.
Avalanche effect- A small change in plaintext should create a significant change in cyphertext.
Example-To check the avalanche effect in DES, let us encrypt two plaintext blocks (with the same key)
that differ only in one bit and observe the differences in the number of bits in each round.
Although the two plaintext block differ only in the rightmost bit, the ciphertext block differ in 29 bits.
Changing 1.5% of plaintext create a change of approximately 45% in cyphertext.
Completeness effect means that each bit of the ciphertext needs to depend on many bits on the plaintext.
The diffusion and confusion produced by P-boxes and S-boxes in DES, show a very strong completeness
effect
Design Criteria
S-Boxes-The design provides confusion and diffusion of bits from each round to
the next.
P-Boxes- They provide diffusion of bits.
Number of Rounds- DES uses sixteen rounds of Feistel ciphers. the ciphertext is
thoroughly a random function of plaintext and ciphertext
DES Weaknesses
During the last few years critics have found some weaknesses in cypher design.
1. Weaknesses in Cipher Design
S-boxes
i)In S-box 4, the last three output can be derived in the same ways the first
output bit by complimenting some of the input bits.
ii) two specifically chosen inputs to an S-box array can create the same output.
iii) It is possible to obtain the same output in a single round by changing bits in only three
neighboring S-boxes
P-boxes
i) It is not clear why designers of DES used the initial and final permutations; these have no security
benefits.
ii) In the expansion permutation , the first and fourth bits of every 4-bit series are repeated.
DES Weaknesses
For decryption, first decrypted using k2, and the 64-bit middle text is decrypted using k1.
• This attack involves encryption from one end and decryption from the other end and matching
the result in the middle, hence the name.
• The goal of a meet-in-the-middle attack, is to use the intermediate values -- the values between
the encryption stages -- to solve for all used encryption keys; which for a double DES, is two.
• Using a known-plaintext attack called meet-in- the-middle attack proves that double DES
improves this vulnerability slightly (to 257 tests), but not tremendously (to 2112).
Meet-in-the-Middle Attack
A meet-in-the-middle attack targets block cipher cryptographic functions.
The intruder applies brute-force techniques to both the plaintext, which is ordinary text before
it is encrypted, and the ciphertext, or encrypted text that has been transformed from plaintext,
of a block cipher.
The intruder then attempts to encrypt the plaintext according to various keys to achieve an
intermediate ciphertext, or text that has only been encrypted by one key.
Simultaneously, the intruder attempts to decrypt the ciphertext according to various keys,
seeking a block of intermediate ciphertext that is the same as the one created by encrypting the
plaintext.
If there is a match of intermediate ciphertext, it is highly probable that the key used to encrypt
the plaintext and the key used to decrypt the ciphertext are the two encryption keys used for
the block cipher.
Triple DES
2 or 3 keys are used
much stronger than double DES
AES is a non-Feistel cipher that encrypts and decrypts a data block of 128 bits.
AES has defined three versions, with 10, 12, and 14 rounds.
Each version uses a different cipher key size (128, 192, or 256), but the round keys are
always 128 bits.
ShiftRows transformation
Example
Mixing
We need an interbyte transformation that changes the bits inside a byte, based on the bits inside
the neighboring bytes.
We need to mix bytes to provide diffusion at the bit level.
Take each word or column(4 X 1) from previous state matrix, multiply a constant matrix( 4 X 1)
and the output (4 X 1) which is 4 bytes, stored in output state matrix.
The MixColumns transformation operates at the column level; it transforms each column of the
state to a new column.