Chapter - 3 Cryptography and Encryption Techniques
Chapter - 3 Cryptography and Encryption Techniques
Block cipher: splits the plaintext into fixed sized blocks and generates fixed
2
sized blocks of ciphertext.
Stream Ciphers
A stream cipher takes a key K of n bits in length and stretches it into a long keystream.
This keystream is then XORed with the plaintext P to produce ciphertext C.
The use of the keystream is identical to the use of the key in a one-time pad cipher.
To decrypt with a stream cipher, the same keystream is generated and XORed with the
ciphertext.
3
Stream Ciphers ---
The encryption formula is:
where P = p0p1p2 . . . is the plaintext, S = s0s1s2 . . . is the keystream and
C =c0c1c2 . . . is the ciphertext.
To decrypt ciphertext C, the keystream S is again used
4
Stream Ciphers ---
For example, if keystream is 01101100 the plaintext byte is 11001100, then the resulting ciphertext byte
is :
5
A5/1
Used by GSM cell phones for confidentiality.
A GSM transmission is organized as sequences of bursts.
o In a typical channel and in one direction, one burst is sent every 4.615 milliseconds and
contains 114 bits available for information.
o A5/1 is used to produce for each burst a 114 bit sequence of keystream which is
XORed with the 114 bits prior to modulation.
A5/1 employs three linear feedback shift registers called LFSRs: Lets label as
X, Y, and Z.
• Register X holds 19 bits, which we label (x0, x1, . . . , x18).
• Register Y holds 22 bits (y0, y1, . . . , y21), and
• Z holds 23 bits (z0, z1, . . . , z22). It’s no chance that the three LFSRs hold a total of 64 bits.
Not unpredictably, the key K is 64 bits.
The key is used as the initial fill of the three registers.
After these three registers are filled with the key, we are ready to generate
the keystream.
6
RC4
RC4 is a stream cipher, widely used in wireless networks (WEP and WPA), as well as in SSL and various
products.
Table always contains a permutation of all 8-bit numbers from 0 through 255
A variable-length key of from 1 to 256 bytes (8 to 2048 bits) is used to initialize a 256- byte state vector S,
with elements
For encryption and decryption, a byte is generated from S by selecting one of the 255 entries in a
systematic fashion.
BLOCK CIPHERS
8
BLOCK CIPHER
Block cipher splits the plaintext into fixed sized blocks and generates fixed sized blocks
of ciphertext.
The ciphertext is obtained from the plaintext by iterating a function F over some
number of rounds.
The function F, which depends on the output of the previous round and the key
K, is known as a round function, not because of its shape, but because it is applied at each round.
The design goals for block ciphers are security and efficiency.
It’s not too difficult to develop either a secure block cipher or an efficient algorithm, but it’s
surprisingly tricky to design a secure block cipher that is highly efficient.
A block cipher operates on a plaintext block of n bits to produce a ciphertext block of
n bits.
There are possible different plaintext blocks and, for the encryption to be reversible
(i.e., for decryption to be possible), each must produce a unique ciphertext block.
9
BLOCK CIPHER ---
Reading Assignment:
Modes of Block cipher operation (ECB, CBC, CFB , OFB and CTR )
10
BLOCK CIPHER ---
Feistel Structure for Block Ciphers
In cryptography, a Feistel cipher is a symmetric structure used in the construction of block
ciphers, named after the German IBM cryptographer Horst Feistel ;
It is also commonly known as a Feistel network.
Feistel cipher alternates: substitutions, transpositions (permutations)
Applies concepts of diffusion and confusion
Applied in many ciphers today
Approach:
Plaintext split into halves
Subkeys (or round keys) generated from key
Round function, F , applied to right half
Apply substitution on left half using XOR
Apply permutation: interchange to halves
11
Diffusion and Confusion
Diffusion
Statistical nature of plaintext is reduced in ciphertext
E.g. A plaintext letter affects the value of many ciphertext letters
How: repeatedly apply permutation (transposition) to data, and then apply
function
Confusion
Make relationship between ciphertext and key as complex as possible
Even if attacker can find some statistical characteristics of ciphertext, still hard to
find key
How: apply complex (non-linear) substitution algorithm
12
Feistel Encryption and Decryption
13
BLOCK CIPHER ---
Popular and common types of Block ciphers:
1. DES
2. Triple DES
3. AES
4. IDEA
5. Blowfish
14
Data Encryption Standards (DES)
In 1973, the NBS (National Bureau of Standards, now called NIST- National Institute of Standards and
Technology) published a request for an encryption algorithm that would meet the following criteria:
• Have a high security level
• Be easily understood
• Not depend on the algorithm's confidentiality
• Be adaptable and economical
• Be efficient
In late 1974, IBM proposed "Lucifer", which was then modified by NSA (National Security Agency) in
1976 to become the DES (Data Encryption Standard)
• A stream cipher processes the input elements continuously, producing output one element at
a time, as it goes along
The key in DES is 56 bits; 8-bit out of the total 64-bit block key is used for parity
check (for example, if odd parity is used, each byte has an odd number of bits)
17
DES ---
DES Encryption
Phase 2
• The 64 bits are then divided into two 32-bit halves called L and R.
• The encryption then proceeds through 16 rounds of the same function, each using
the L and R parts, and a subkey
• In each round, the new L part is simply a copy of the incoming R part
• The R and Subkeys are processed in the so called
f-function, and exclusive-or of the output of the f-function with the existing L
part to create the new R part
Phase 3
• The pre output is passed through a permutation that is the inverse of the initial
permutation (IP-1), to produce the 64-bit ciphertext
18
DES ---
19
Fig : Structure of DES Algorithm
DES ---
20
Fig : Structure of DES Algorithm
DES ---
DES – Permutation: The initial permutation and its inverse are defined by tables; in all
tables, the numbers are the bit positions
Initial Permutation (IP) Inverse Permutation (IP-1)
21
CHAPTER - 4
AES
22
Advanced Encryption Standard (AES)
The AES Encryption algorithm (also known as the Rijndael algorithm) is a symmetric block cipher algorithm
with a block/chunk size of 128 bits.
It converts these individual blocks using keys of 128, 192, and 256 bits. Once it encrypts these blocks, it joins
them together to form the ciphertext.
It consists of a series of linked operations, including replacing inputs with specific outputs (substitutions) and
others involving bit shuffling (permutations).
In AES the number of rounds to be carried out depends on the length of the key being used to encrypt data.
The 128-bit key size has ten rounds, the 192-bit key size has 12 rounds, and the 256-bit key size has 14 rounds.
10 round of repetition for 128-bit keys.
12 round of repetition for 192-bit keys.
23
14 round of repetition for 256-bit keys.
How Does AES Work?
To understand the way AES works, you first need to learn how it transmits information
between multiple steps.
Since a single block is 16 bytes, a 4x4 matrix holds the data in a single block, with each cell
holding a single byte of information.
0 4 8 12
1 5 9 13
2 6 10 14
3 7 11 15
25
The mentioned steps are to be followed for every block sequentially..
Advanced Encryption Standard (AES)---
The steps are as follows:
1. Add Round Key: You pass the block data stored in the state array through an XOR function with the
first key generated (K0).
It passes the resultant state array on as input to the next step.
2. Sub-Bytes: In this step, it converts each byte of the state array into hexadecimal, divided into two
equal parts.
These parts are the rows and columns, mapped with a substitution box (S-Box) to generate
new values for the final state array.
3. Shift Rows: It swaps the row elements among each other.
First row is not shifted, Second row is shifted one (byte) position to the left.
Third row is shifted two positions to the left, and Fourth row is shifted three positions to the
left.
The result is a new matrix consisting of the same 16 bytes but shifted with respect to each
other.
4. Mix Columns: Each column of four bytes is now transformed using a special mathematical function.
This function takes as input the four bytes of one column and outputs four completely new
26 bytes, which replace the original column.
The result is another new matrix consisting of 16 new bytes. It should be noted that this step is
Advanced Encryption Standard (AES) ---
Steps:
Key Expansions round keys are derived from the cipher key using Rijndael's key schedule.
AES requires a separate 128-bit round key block for each round plus one more.
1) Initial round
Add Round-Key each byte of the state is combined with a block of the round key using
bitwise XOR.
2) Next rounds
i. Sub-Bytes: a non-linear substitution step where each byte is replaced with another
according to a lookup table.
ii. Shift-Rows: a transposition step where the last three rows of the state are shifted
cyclically a certain number of steps.
iii. Mix-Columns: a mixing operation which operates on the columns of the state,
combining the four bytes in each column.
iv. Add Round-Key
3) Final round
v. Sub-Bytes
vi. Shift-Rows
27 vii. Add Round-Key
Advanced Encryption Standard (AES) ---
For 16 byte key AES encryption and decryption
28
Comparison of DES and AES
29
Table: Comparison of DES and AES