Module 1 Notes
Module 1 Notes
M O DU L E - 1
CLASSICAL ENCRYPTION TECHNIQUES AND BLOCK CIPHER
Classical Encryption Techniques: Symmetric cipher model, Substitution techniques (excluding Hill
cipher)
Block Ciphers: Traditional Block Cipher structure, The AES Cipher. Block Cipher Modes of Operation.
The receiver at the other ends decrypts the cipher text using the key.
X = 𝐷(𝐾, 𝑌)
Here D represents the decryption algorithm and it inverts the transformations of
encryption algorithm.
An opponent not having access to X or K may attempt to recover K or X or both.
It is assumed that the opponent knows the encryption (E) and decryption (D) algorithms.
If the opponent is interested in only this particular message, then the focus
of the effort is to recover by generating a plaintext estimate ^X .
If the opponent is interested in being able to read future messages as well
then he will attempt to recover the key by making an estimate ^𝐾 .
Based on the amount of information known to the cryptanalyst cryptanalytic attacks can be
categorized as:
Cipher text Only Attack: The attacker knows only cipher text only. It is easiest to defend.
Known plaintext Attack: In this type of attack, the opponent has some plaintext-cipher
text pairs. Or the analyst may know that certain plaintext patterns will appear in a message.
For example, there may be a standardized header or banner to an electronic funds transfer
message and the attacker can use that for generating plaintext-cipher text pairs.
Chosen plaintext: If the analyst is able somehow to get the source system to insert into the
system a message chosen by the analyst, then a chosen-plaintext attack is possible. In such
a case, the analyst will pick patterns that can be expected to reveal the structure of the key.
Chosen Cipher text: In this attack, the analyst has cipher text and some plaintext-cipher
text pairs where cipher text has been chosen by the analyst.
Chosen Text: Here, the attacker has got cipher text, chosen plaintext-cipher text pairs and
chosen cipher text-plaintext pairs.
An encryption scheme is unconditionally secure if the ciphertext generated by the
scheme does not contain enough information to determine uniquely the corresponding
plaintext, no matter how much ciphertext is available. That is, no matter how much
time an opponent has, it is impossible for him or her to decrypt the ciphertext simply
because the required information is not there. With the exception of a scheme known
as the one-time pad (described later in this chapter), there is no encryption algorithm
that is unconditionally secure. Therefore, all that the users of an encryption algorithm
can strive for is an algorithm that meets one or both of the following criteria:
1. The cost of breaking the cipher exceeds the value of the encrypted information.
2. The time required to break the cipher exceeds the useful lifetime of the
information.
4|Page Dr. Manjula Emmi. Dept. ECE SGBIT
Module-1 Data Security (BEC613B)
The two basic building blocks of all encryption techniques are substitution and transposition.
We examine these in the next two sections. Finally, we discuss a system that combines both
substitution and transposition.
A substitution technique is one in which the letters of plaintext are replaced by other letters or
by numbers or symbols.1 If the plaintext is viewed as a sequence of bits, then substitution
involves replacing plaintext bit patterns with ciphertext bit patterns.
Caesar cipher
The encryption rule is simple; replace each letter of the alphabet with the letter standing
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
Generally Plain text is in lower case and Cipher text is Upper Case.
Example 1:
Plaintext: meet me after the party
Ciphertext: PHHW PH DIWHU WKH SDUWB
where k takes on a value in the range 1 to 25. The decryption algorithm is simply
p = D(k, C) = (C - k) mod 26
Example 2:
Plaintext: HELLO
Shift: 3
Encryption:
H -> K
E -> H
L -> O
L -> O
O -> R
Ciphertext: KHOOR
Decryption:
K -> H
H -> E
O -> L
O -> L
R -> O
Plaintext: HELLO
Three important characteristics of this problem enabled us to use a brute- force
cryptanalysis:
1. The encryption and decryption algorithms are known.
2. There are only 25 keys to try.
3. The language of the plaintext is known and easily recognizable.
Monoalphabetic Ciphers
A Monoalphabetic Cipher is a type of substitution cipher where each letter of the plaintext is
replaced by a different letter, but the same letter is always replaced by the same letter.
Each letter of the plaintext is replaced by a different letter, but the same letter is always
replaced by the same letter. For example, the letter "H" is always replaced by "K", and the letter
"E" is always replaced by "H".
The relative frequency of the letters can be determined and compared
to a standard frequency distribution for English,
In English ‘e’ is the most common letter followed by ‘t’, ‘r’, ‘n’, ’o’, ‘a’ etc.
Letters like ‘q’, ‘x’, ‘j’ are less frequently used.
Moreover, digrams like ‘th’ and trigrams like ‘the’ are also more frequent.
Tables of frequency of these letters exist. These can be used to guess the
plaintext if the plaintext is in uncompressed English language.
The most common two letter combinations are called as digrams. e.g. th, in, er, re and
an.
CIPHERTEXT:
UZQSOVUOHXMOPVGPOZPEVSGZWSZOPFPESXUDBMETSXAI
ZVUEPHZHMDZSHZOWSFPAPPDTSVPQUZWYMXUZUHSX
EPYEPOPDZSZUFPOMBZWPFUPZHMDJUDTMOHMQ
Only four letters have been identified, but already we have quite a bit of the message.
Continued analysis of frequencies plus trial and error should easily yield a solution from this point.
The complete plaintext, with spaces added between words, follows:
it was disclosed yesterday that several informal but direct contacts have been made with
political representatives of the viet cong in Moscow
Monoalphabetic ciphers are easy to break because they reflect the frequency data of the
original alphabet
8|Page Dr. Manjula Emmi. Dept. ECE SGBIT
Module-1 Data Security (BEC613B)
Playfair Cipher
The best-known multiple-letter encryption cipher is the Playfair, which treats digrams in
the plaintext as single units and translates these units into ciphertext digrams.3
The Playfair algorithm is based on the use of a 5 × 5 matrix of letters constructed using
a keyword. Here is an example, solved by Lord Peter Wimsey in Dorothy Sayers’s Have
His Carcase:4
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
In this case, the keyword is monarchy. The matrix is constructed by filling in the letters
of the keyword (minus duplicates) from left to right and from top to bottom, and then
filling in the remainder of the matrix with the remaining letters in alphabetic order. The
letters I and J count as one letter. Plaintext is encrypted two letters at a time, according to
the following rules:
1. Repeating plaintext letters that are in the same pair are separated with a filler letter, such as
x, so that balloon would be treated as ba lx lo on.
2. Two plaintext letters that fall in the same row of the matrix are each replaced by the letter to
the right, with the first element of the row circularly following the last. For example, ar is
encrypted as RM.
3. Two plaintext letters that fall in the same column are each replaced by the let- ter beneath,
with the top element of the column circularly following the last. For example, mu is
encrypted as CM.
4. Otherwise, each plaintext letter in a pair is replaced by the letter that lies in its own row
and the column occupied by the other plaintext letter. Thus, hs becomes BP and ea becomes
IM (or JM, as the encipherer wishes).
The Playfair cipher is a great advance over simple monoalphabetic ciphers. For one
thing, whereas there are only 26 letters, there are 26 × 26 = 676 digrams,
Example 2:
Plaintext = meet me at the school house
Splitting two letters as a unit => me et me at th es ch ox ol ho us ex
Corresponding cipher text => CL KL CL RS PD IL HY AV MP HF XL IU
A block cipher is one in which a block of plaintext is treated as a whole and used
to produce a ciphertext block of equal length. Typically, a block size of 64 or 128 bits
is used. As with a stream cipher, the two users share a symmetric encryption key.
Ciphertext
Ciphertext
A block cipher can be used to achieve the same effect as a stream cipher. In general,
they seem applicable to a broader range of applications than stream ciphers. The vast
majority of network-based symmetric cryptographic applications make use of block
ciphers.
In the latter case, a ciphertext of 01 could have been produced by one of two
plain- text blocks. So if we limit ourselves to reversible mappings, the
number of different transformations is 2n!.2
Encryption should be reversible. Figure shows the logic of a general substitution cipher for n=4
(block size).
In general the logic of a general substitution cipher for n=4 with 4-bit input produces one of
16 possible input states, which is mapped by the substitution cipher into a unique one of 16
possible output states, each of which is represented by 4 cipher text bits. The encryption and
decryption mappings can be defined by tabulation, as shown below.
This is the most general form of block cipher and can be used to define any
reversible mapping between plaintext and ciphertext. Feistel refers to this as the ideal block
cipher, because it allows for the maximum number of possible encryption mappings from
the plaintext block.
with a key length of k bits and a block length of n bits, allowing a total of 2 k possible
transformations, rather than the 2n ! transformations available with the ideal block cipher. In
particular, Feistel proposed the use of a cipher that alternates substitutions and permutations,
where these terms are defined as follows:
Adding k successive letters to get a ciphertext letter yn. The letter frequencies in the ciphertext will
be more nearly equal than in the plaintext (structure dissipated).
Confusion seeks to make the relationship between the statistics of the ciphertext and and the value
of the encryption key as complex as possible. This is achieved by the use of a complex substitution
algorithm. These operations became the cornerstone of modern block cipher design.
We see that
Thus, we have LD1 = RE15 and RD1 = LE15. Therefore, the output of the first round of
the decryption process is RE15 LE15, which is the 32-bit swap of the input to the sixteenth
round of the encryption. This correspondence holds all the way through the 16 iterations,
as is easily shown. We can cast this process in general terms. For the ith iteration of the
encryption algorithm
LEi = REi-1
REi = LEi-1 ⊕ F(REi-1, Ki)
Rearranging terms:
REi-1 = LEi
The exact realization of a Feistel network depends on the choice of the following parameters
and design features:
Block size: Larger block sizes mean greater security (all other things being equal)
but reduced encryption/decryption speed for a given algorithm. The greater
security is achieved by greater diffusion. Traditionally, a block size of 64 bits has
been considered a reasonable trade off and was nearly universal in block cipher
design. However, the new AES uses a 128-bit block size
Key size: Larger key size means greater security but may decrease encryption/ decryption
speed. The greater security is achieved by greater resistance to brute-force attacks
and greater confusion. Key sizes of 64 bits or less are now widely considered to be
inadequate, and 128 bits has become a common size.
Number of rounds: The essence of the Feistel cipher is that a single round offers
inadequate security but that multiple rounds offer increasing security. A typical size
is 16 rounds.
Subkey generation algorithm: Greater complexity in this algorithm should lead to
greater difficulty of cryptanalysis.
Round function F: Again, greater complexity generally means greater resistance to
cryptanalysis.
There are two other considerations in the design of a Feistel cipher:
■ Fast software encryption/decryption: In many cases, encryption is embedded in applications
or utility functions in such a way as to preclude a hardware implementation. Accordingly,
the speed of execution of the algorithm becomes a concern.
■ Ease of analysis: Although we would like to make our algorithm as difficult as possible to
cryptanalyze, there is great benefit in making the algorithm easy to analyze. That is, if the
algorithm can be concisely and clearly explained, it is easier to analyze that algorithm for
cryptanalytic vulnerabilities and therefore develop a higher level of assurance as to its
strength. DES, for example, does not have an easily analyzed functionality.
Input Structure
1. Block size: 128-bit block
Key Structure
1. Key size: 128-bit key
7. Word formation: First four bytes of expanded key form a word, occupying the first
column of the w matrix
Figure shows the overall structure of the AES encryption process. The cipher takes a plaintext
block size of 128 bits, or 16 bytes. The key length can be 16, 24, or 32 bytes (128, 192, or 256
bits). The algorithm is referred to as AES-128, AES-192, or AES-256, depending on the key
length.
The input to the encryption and decryption algorithms is a single 128-bit block. this block is
depicted as a 4 × 4 square matrix of bytes. This block is copied into the State array, which is
modified at each stage of encryption or decryption. After the final stage, State is copied to an
output matrix. These operations are depicted in Figure b. Similarly, the key is depicted as a
square matrix of bytes. This key is then expanded into an array of key schedule words.
Fig b shows the expansion for the 128-bit key. Each word is four bytes, and the total key
schedule is 44 words for the 128-bit key. Note that the ordering of bytes within a ma- trix is by
column. So, for example, the first four bytes of a 128-bit plaintext input to the encryption cipher
occupy the first column of the in matrix, the second four bytes occupy the second column, and so
on. Similarly, the first four bytes of the expanded key, which form a word, occupy the first
column of the w matrix.
The cipher consists of N rounds, where the number of rounds depends on the key length:
10 rounds for a 16-byte key
12 rounds for a 24-byte key, and
14 rounds for a 32-byte key .
The first N - 1 rounds consist of four distinct transformation functions:
SubBytes, ShiftRows, MixColumns, and AddRoundKey, which are described subsequently.
The final round contains only three transformations, and there is a initial single transformation
(AddRoundKey) before the firstround, which can be considered Round 0 .
4 × 4 matrices as input and produces a 4 × 4 matrix as output. Figure a. shows that the output
of each round is a 4 × 4 matrix, with the output of the final round being the ciphertext. Also,
the key expansion function generates N + 1 round keys, each of which is a distinct 4 × 4 matrix.
Each round key serves as one of the inputs to the AddRoundKey transformation in each round.
Here are the key points explaining the structure and operation of the cipher:
Cipher Structure
- The cipher consists of N rounds.
- The number of rounds depends on the key length:
- 10 rounds for a 16-byte key.
- 12 rounds for a 24-byte key.
- 14 rounds for a 32-byte key.
Round Operations
- The first N - 1 rounds consist of four transformations:
- SubBytes.
- ShiftRows.
- MixColumns.
- AddRoundKey.
- The final round contains only three transformations.
Key Expansion
- The key expansion function generates N + 1 round keys.
- Each round key is a distinct 4 × 4 matrix.
- Each round key serves as input to the Add Round Key transformation in each round.
Figure C shows the AES cipher in more detail, indicating the sequence of transformations in each
round and showing the corresponding decryption function. AES instead processes the entire
data block as a single matrix during each round using substitutions and permutation.
1. The key that is provided as input is expanded into an array of forty-four 32-bit words,
w[i]. Four distinct words (128 bits) serve as a round key for each round.
2. Four different stages are used, one of permutation and three of substitution:
a. Substitute bytes: Uses an S-box to perform a byte-by-byte substitution of the
block.
b. ShiftRows: A simple permutation.
c. MixColumns: A substitution that makes use of arithmetic over GF(28).
d. AddRoundKey: A simple bitwise XOR of the current block with a portion of the
expanded key.
3. The structure is quite simple. For both encryption and decryption, the cipher begins
with an Add RoundKey stage, followed by nine rounds that each in- cludes all four
stages, followed by a tenth round of three stages. Figure c. depicts the structure of a full
encryption round.
4. Only the AddRoundKey stage makes use of the key. For this reason, the cipher begins and
ends with an AddRoundKey stage. Any other stage, applied at the beginning or end, is
reversible without knowledge of the key and so would add no security.
5. The AddRoundKey stage is, in effect, a form of Vernam cipher and by itself would not
be formidable. The other three stages together provide confusion, diffusion, and
nonlinearity, but by themselves would provide no security be- cause they do not use the
key. We can view the cipher as alternating operations of XOR encryption (AddRoundKey)
of a block, followed by scrambling of the block (the other three stages), followed by
XOR encryption, and so on. This scheme is both efficient and highly secure.
6. Each stage is easily reversible. For the Substitute Byte, ShiftRows, and MixColumns
stages, an inverse function is used in the decryption algorithm. For the AddRoundKey
stage, the inverse is achieved by XORing the same round key to the block, using the
result that A ⊕ B ⊕ B = A.(Refer fig D)
7. As with most block ciphers, the decryption algorithm makes use of the expanded key
in reverse order. However, the decryption algorithm is not
identical to the encryption algorithm. This is a consequence of the particular structure
of AES.
8. Once it is established that all four stages are reversible, it is easy to verify that
decryption does recover the plaintext. Figure lays out encryption and decryption going
in opposite vertical directions. At each horizontal point (e.g., the dashed line in the
figure), State is the same for both encryption and decryption.
9. The final round of both encryption and decryption consists of only three stages. Again, this is
a consequence of the particular structure of AES and is required to make the cipher
reversible.
10. The final round of both encryption and decryption consists of only three stages. Again, this is
a consequence of the particular structure of AES and is required to make the cipher
reversible
1. RotWord performs a one-byte circular left shift on a word. This means that an input word [B 0,
B1, B2, B3] is transformed into [B 1, B2, B3, B0].
2. SubWord performs a byte substitution on each byte of its input word, using the S-box (Table
6.2a).
3. The result of steps 1 and 2 is XORed with a round constant, Rcon[j].
The round constant is a word in which the three rightmost bytes are always 0. Thus, the
effect of an XOR of a word with Rcon is to only perform an XOR on the
leftmost byte of the word. The round constant is different for e ach round and is de-
fined as Rcon[j] = (RC[j], 0, 0, 0), with RC[1] = 1, RC[j] = 2 RC[j - .1] and with
multiplication defined over the field GF(28). The values of RC[j] in hexadecimal are
j 1 2 3 4 5 6 7 8 9 10
RC[j] 01 02 04 08 10 20 40 80 1B 36
Rationale
The Rijndael developers designed the expansion key algorithm to be resistant to known
cryptanalytic attacks. The inclusion of a round-dependent round constant eliminates the
symmetry, or similarity, between the ways in which round keys are generated in different
4. Output feedback:
The output feedback (OFB) mode is similar in structure to that of CFB. For OFB,
the output of the encryption function is fed back to become the input for encrypting
the next block of plaintext fig h. In CFB, the output of the XOR unit is fed back
to become input for encrypting the next block. The other difference is that the OFB
mode operates on full blocks of plaintext and ciphertext, whereas CFB operates
on an s-bit subset.
As with CBC and CFB, the OFB mode requires an initialization vector. In the
case of OFB, the IV must be a nonce; that is, the IV must be unique to each
execution of the encryption operation
The reason for this is that the sequence of encryption output blocks, Oi, depends
only on the key and the IV and does not de- pend on the plaintext. Therefore, for
a given key and IV, the stream of output bits used to XOR with the stream of
plaintext bits is fixed. If two different messages had an identical block of plaintext
in the identical position, then an attacker would be able to determine that portion
of the Oi stream.
One advantage of the OFB method is that bit errors in transmission do not
propagate. For example, if a bit error occurs in C1, only the recovered value of P1
is affected; subsequent plaintext units are not corrupted.
5. Counter mode:
Although interest in the counter (CTR) mode has increased recently with
appli- cations to ATM (asynchronous transfer mode) network security and
IPsec (IP security), this mode was proposed in 1979
Fig i depicts the CTR mode. A counter equal to the plaintext block size is used.
The only requirement stated in SP 800-38A is that the counter value must be different
for each plaintext block that is encrypted. Typically, the counter is initialized to
some value and then incremented by 1 for each subsequent block
For encryption, the counter is encrypted and then XORed with the plaintext block
to produce the ciphertext block; there is no chaining. For decryption, the same
sequence of counter values is used, with each encrypted counter XORed with a
ciphertext block to recover the corresponding plaintext block.
Thus, the initial counter value must be made available for decryption.
As with the OFB mode, the initial counter value must be a nonce; that is, T1
must be different for all of the messages encrypted using the same key. Further,
all Ti values across all messages must be unique.
Advantages:
1. Hardware efficiency
2. Software efficiency
3. Preprocessing
4. Random access
5. Provable security
6. Simplicity