CNS Unit-Ii
CNS Unit-Ii
Block Cipher: A block cipher is a method of encrypting text in which a cryptographic key and
algorithm are applied to a block of data at one rather than to one bit at a time. In general a block
size may be 64 or 128 bits.
Ex: DES, AES, IDEA, BlowFish,
Stream Cipher: A stream cipher is a method of encrypting text in which cryptographic key and
algorithm are applied to each binary digits in a data stream, one bit at a time. This method is not
much used in modern cryptography.
Ex: Onetime pad, autokeyed Vigenere, Vernam cipher.
The Data Encryption Standard (DES) is a block cipher that was selected by the National
Bureau of Standards as an official Federal Information Processing Standard (FIPS) for the
United States in 1976. It is based on a symmetric-key algorithm that uses a 56-bit key. It takes a
fixed length string of plain text bits and transforms it through a series of complicated operations
into another cipher text bit string of the same length. In case of DES the block size is 64 bits.
LEFT SIDE:
First the plain text passes through initial permutation (IP) which rearranges the bits and produces
the permuted output. Then it is followed by a phase consisting of 16 rounds of the same function,
which involves both permutation and substitution. The output of the last round consists of 64
bits. After 6 rounds the left and right halves of the output are swapped to produce the preoutput.
Finally the preoutput is passed through a permutation (IP -1) that is the inverse of the initial
permutation to produce the 64- bit cipher text.
RIGHT SIDE:
It shows the subkey generation process. Initially the key is passed through a permutation
function. The permutation function is same for all the 16 rounds, but it produces different
subkeys because of the repeated shifts of the key bits.
DETAILS OF SINGLE ROUND:
LEFT SIDE DIAGRAM:
The left and right halves of each 64-bit intermediate values are treated as separate 32-bit
quantities labeled as L (left) and R (right).
Li = Ri–1
Ri = Li–1 xor F(Ri–1, Ki) The round key Ki is 48 bits. The R input is 32 bits.
This R input is first expanded to 48 bits using a table that defines a permutation plus and
expansion that involves a duplication of 16 of the R bits.
KEY GENERATION:
56-bit key is used as input to the algorithm is first subjected to a permutation governed by
initial permuted choice one.
The resulting 56-bit key is then treated as two 28-bit quantities labeled as Co and Do.
At each round Ci-1 and Di-1 are subjected to a circular left shirt or rotation of 1 or 2 bits
as governed by the DES Key schedule calculation.
These shifted values serve as input to the next round.
Apply Permuted Choice 2 to produce 48-bit output that serves the input to the
function.
The Nature of The DES Algorithm: DES algorithm focuses on the eight substitution boxes that
are used in each iteration. The design criteria for these boxes are indeed for the entire algorithm
were not made public, there is a suspicion that the boxes were constructed in such a way that
cryptanalysis is possible for an opponent who knows the weaknesses in the S-boxes.
Timing Attacks: A timing attack is an example of an attack that exploits the implementation of
an algorithm rather than the algorithm itself.
AES is a symmetric block cipher intended to replace DES for commercial applications. It uses
128 bit block size and a key size of 128, 192 or 256 bits. AES was published by National
Institute of Standards and Technology (NIST) in 2001.
EVOLUTION CRITERIA:
Security: It refers the effort that is required to cryptanalyze the algorithm. Because of the key
size for AES is 128 bits, brute-force attacks with current and projected technology was
impractical.
Efficiency: The intension of NIST is to design AES is to be practical in a wide range of
applications and must have high computational efficiency.
Algorithm and Implementation Characteristics: It includes the flexibility, suitability for
various hardware and software implementations, simplicity and security. The following criteria
is used for final evaluation.
General Security: Compared to DES, the amount of time and the number of cryptographers
devoted to analysis are quite limited. So AES provides more security than the DES.
Software Implementations: The concern is execution speed, performance across a variety of
platforms and variation of speed with key size.
Restricted Space Environments: Representation of S-boxes will be stored in RAM or ROM
and subkey storage is in RAM is required.
Hardware Implementations: Like software, hardware implementations can be optimized for
size and speed. In the case of hardware size translates directly into cost that is usually in the case
for software implementations.
Attacks on Implementations: It deals with the various types of attacks the exploit the
mathematical properties of the algorithms.
Encryption versus Decryption: It deals with the issues related to the considerations of both
encryption and decryption.
Key agility: It refers to change of the keys quickly with a minimum of resources.
Other Versatility and Flexibility: It refers to the possibility of optimizing cipher elements.
Potential for Instruction Level Parallelism: It refers the ability of ILP feature implementations
in current and future processors.
AES Cipher:
AES is having following parameters.
Number of rounds 10 12 14
General structure
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 5.2a. Similarly, the key is depicted as a square matrix of bytes.
This key is then expanded into an array of key schedule words. Figure 5.2b 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
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 (Table5.1).
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 first round
Substitution Byte:
By using S-boxes byte-by-byte substitution is done. AES defines a 16 * 16 matrix of byte values,
called an S-box that contains a permutation of all possible 256 8-bit values.
The input to the encryption and decryption algorithm is 128 bit block. This block is copied into a
state array. The state array is modified at each stage of encryption or decryption. After the final
stage the output is copied into output matrix. 128 bit key is also depicted as a square matrix of
bytes. This key is then expanded into the array of key scheduled words. Each word is 4 bytes and
the total key schedule is 44 words for the 128 bit key. The ordering of bytes within a matrix is by
column. For example first 4 bytes of a 128 bit plaintext input to the encryption cipher occupies
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 forms a word, occupy the first column
of the w matrix.
With three distinct keys, TDES has an effective key length of 168 bits. FIPS (Federal
Information Processing Standards) also allows for the use of two keys with K1=K3. This
provides a length of 112 bits. FIPS includes the following guidelines for TDES.
TDES is the FIPs approved conventional encryption algorithm.
GOvt. organizations with DES systems are encourages to transit to TDES.
It is anticipated that TDES and AES will coexist as FIPS approved algorithms allowing for a
gradual transition to AES.
Design Issues:
IDEA does not use S-boxes.
IDEA relies on three different mathematical operations:
XOR
Binary Addition of 16-bit integers,
Binary Multiplication of 16-bit integers.
These functions are combines to produce a complex transformation and are very difficult
to cryptanalyze.
The 64-bit input plain text block-divided into 4 part (16 bits each) Declare p1 to p4.
Therefore, p1 to p4 will be the inputs for the initial round of the algorithm.
There are 8 such rounds.
The key is made up of 128 bits.
In each round, 6 sub-keys will be produced.
Each one of the sub-keys includes 16 bits.
All these sub-keys will be put on the 4 input blocks p1 to p4.
The last actions include Output Transformation, which usually benefits simply 4 sub-
Keys.
The last result is 4 blocks of ciphertext C1 to C4 (each of 16 bits).
They are mixed to create the last 64-bit ciphertext block.
Encryption:
64 bit plain text is divided into 4 16-bit blocks and they are taken as input in first round.
The first round output is taken as input for second round.
The same process is repeated for all the subsequent 8 encryption rounds.
The 9th round uses 4 keys and performs different operations.
Decryption:
The process of decryption is same as the process used for encryption.
The difference is the keys used for decryption is the inverse of the keys used during
encryption.
Applications:
Financial and commercial data
E-Mail
Smart Cards, etc.
Four 32 bit S-boxes consist of 256 entries each (S1, S2, S3, S4).
XOR P1 with first 32 bits of the key, XOR P2 with second 32 bits of the key, XOR P3 with third
32 bits of the key and so on until the entire P-array has been XORed with the key bits.
Encrypt all zero string with blowfish algorithm using the subkeys which are generated in step 1
and 2.
Replace P1 and P2 with the output obtained in step 3.
Encrypt the output of step 3 using Blowfish algorithm with the modified sub keys.
Continue the same process until all the entries in the P array are replaced and then all the S-
boxes with the output of the continuously changing Blowfish algorithm.
Encryption:
It has 16 rounds and each round consists of key-dependent permutation and a key and data-
dependent substitution. All operations are XORs and additions on 32-bit words.
Blowfish Encryption divides the plaintext into two 32-bit halves: xL, xR
For i = 1 to 16:
xL = XL XOR Pi
xR = F(XL) XOR xR
Swap XL and xR
xR = xR XOR P17
xL = xL XOR P18
Recombine xL and xR
Decryption:
Decryption is exactly same as encryption, except that P1, P2,…P18 are used in the reverse order.
CAST-128 is a symmetric key block cipher and also been approved for Government of Canada
use by Communications Security Establishment.
CAST-128 is a 12 or 16-round Feistel network with a 64-bit block size and a key size of between
40 to 128 bits (but only in 8-bit increments).
The full 16 rounds are used when the key size is longer than 80 bits. Components include large
8×32-bit S-boxes based on bent functions (special type of Boolean functions), key- dependent
rotations, modular addition, subtraction and XOR operations. There are three alternating types of
round function, but they are similar in structure and differ only in the choice of the exact
operation (addition, subtraction or XOR) at various points.
For a message longer than 64 bits, the procedure is simply break the message into 64-bit blocks,
padding the last block if necessary.
Decryption is performed one block at a time, always using the same key.
In the above Figure, the plaintext (padded as necessary) consists of a sequence of 64-bit blocks,
P1, P2, ..., PN; the corresponding sequence of ciphertext blocks is C1, C2, ….,CN.
The ECB method is ideal for a short amount of data, such as an encryption key, thus, if you want
to transmit a DES key securely, ECB is the appropriate mode to use.
The most significant characteristic of ECB is that the same 64-bit block of plaintext, if it appears
more than once in the message, always produces the same ciphertext.
For lengthy messages, the ECB mode may not be secure.
In the Figure, it is assumed that the unit of transmission is s bits; a common value of S is
8. In CBC the units of plaintext are chained together but in CFB rather than units of 64 bits of
the plaintext it is divided into segment of s bits.
Counter Mode:
In CTR mode a counter, equal to the plaintext block size is used. The only requirement 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.
Advantages:
Hardware efficiency
NUMBER THEORY
Prime and Relatively Prime Numbers:
An integer P>1 is a prime number only if it divisors 2 are ±1 and ±P.
Ex:
18 = 2 x 3 x 3
35 = 7 x 5
So 18 and 35 are relatively prime numbers. 18 = 2 x 3 x 3
21 = 3 x 7
3 is common factor for both 18 and 21, so 18 and 21 are not relatively prime numbers.
Two numbers are said to be relative prime numbers when they share no factors in common
other than one
If two integers a, b are relatively prime if gcd(a,b)=1.
Example-1:
15 and 28 are relatively prime numbers
15=the factors are (1,3,5)
28=the factors are (1,2,4,7)
7 and 20 are relatively prime numbers
12 and 13 are relatively prime numbers
Example-2:
18 = 2 x 3 x 3
35 = 7 x 5
So 18 and 35 are relatively prime numbers.
18 = 2 x 3 x 3
MODULAR ARITHMETIC:
If n and a are any two positive integers and if we divide a by n we get an integer quotient 1 and
an integer remainder r that obey the following condition.
A = qn + r 0<=r<n ;[q=[a/n]
Ex:
A= 11 n= 7
Q = 11/ 7 =1 r = 11/7 = 4
A = qn+r
= (1x7)+4
=7+4
= 11
If n is a positive integer and a is an integer, then we define a mod n. The integer n is called the
modulus.
A= [a/n] x n + (a mod n)
Property Expression
Commutative Laws (a+b) mod n = (b+a) mod n
(a*b) mod n = (b*a) mod n
Associative Laws [(a+b)+c] mod n = [a+(b+c)] mod n
[(a*b)*c] mod n = [a*(b*c)] mod n
Distributive Law [a*(b+c)] mod n = [(a+b)*(a+c)] mod n
Identites (0+a) mod n = a mod n
(1*a) mod n = a mod n
FERMAT’ S THEOREM
This theorem plays an important role in public key cryptography. This theorem states that If ‘p’
is a prime and ‘a’ is a positive integer not divisible by p then a p-1 Ξ 1 (mod p). This theorem is
also known as Fermat’s little theorem. This theorem is used in RSA and primality testing.
Proof:
Consider a set of positive integers less than p. P = {1,2,……,p-1}
Multiply each element by a and modulo p, to get the set X. X = { a mod p, 2a mod p,…., (p-1)a
mod p}.
Euler’s theorem states that every a and n that are relatively prime. aΦ (n) Ξ 1(mod n)
Example: A= 3, n=10, Φ (10)= 4
a Φ (n)= 34 = 81 = 1(mod 10) = 1( mod n)
X = b1M1x1 + b2M2x2 +…..+ bnMnxn Note that x is a solution of the desired system since, for i
=1 ,2,…, n
X = b1M1x1 + b2M2x2 +…..+ biMixi +….+ bnMnxn Ξ 0 + 0 + …..+ bi +….+ 0 mod mi
Ξ bi mod mi
Note that the proof of the CRT shows the existence and uniqueness of the claimed solution
modulo M by actually constructing this solution. Such a proof is said to be constructive; the
advantage of constructive proofs is that they yield a procedure or algorithm for obtaining the
desired quantity. We now use the procedure motivated in the proof of therorem to solve the
system of linear congruences in one variable.
Example:
X Ξ 2 mod 3
X Ξ 1 mod 4
X Ξ 3 mod 5
M=3. 4. 5 = 60
M1=60/3 =20
M2=60/4 =15
M3=60/5 =12
M1=20, m1 = 3
Solve 20x1 Ξ 1 mod 3
2x1 Ξ 1 mod 3
M2=15, m2 = 4
Solve 15x2 Ξ 1 mod 4
3x2 Ξ 1 mod 4
M3=12, m3 = 5
Solve 12x3 Ξ 1 mod 5
2x3 Ξ 1 mod 5
DISCRETE LOGARITHMS
Discrete logarithms are fundamental to number of public key algorithms.
The powers of Integer, modulo n:
According to Euler’s theorem; aΦ(n) Ξ 1 (mod n)
where Φ(n) is Euler’s totient function, represents the number of positive integers less than ‘n’ are
relatively prime to ‘n’.
amΞ 1(mod n) where m = Φ(n)
The highest possible exponent to which a number can belong (mod n) is Φ(n). if a number is of
this order, it is referred to as a primitive root of n. the importance of this solution is that if ‘a’ is a
prime root of n, then its powers;
a, a2, …., aΦ(n)
are distinct (mod n) and are all relatively prime to n. in particual for a primer number p, if a is a
primitive root of p, then
a, a2, …., ap-1
are distinct (mod p). for othe pirme number 19, the primitive roots are 2, 3, 10, 13, 14 and
15.