Week 2
Week 2
1 Hill Cipher
This cipher is used to do encryption-decryption process using a nXn matrix as a secret key. We will
ensure that the matrix is invertible so that the decryption can also be done easily. For encryption
process, we will multiply the matrix used as a secret key with the plain text(message) and for
decryption process, we will multiply its inverse with the cipher text in order to get the original
message(plaintext).
Here, A represents nxn invertible matrix, M represents original message/plaintext and C rep-
resents the cipher text.
3 Block Cipher
In the Block Cipher, we will divide the message into fixed size blocks where the size of the blocks
is predefined.
M = m0 ||m1 ||...||mn
C = Enc(m0 , K)||...||Enc(mn , K)
C = c0 ||c1 ||...||cn
If the length of the message is not divisible by the size of the blocks, then we will add some
predefined constants at the end of the message such that the new length becomes divisible by the
block size.In general practice, we usually pad the message with 0s in order to make it divisible by
block size.
Suppose the message is M = m0 ||m1 ||m2 and the length of m0 , m1 is n but the length of m2 is
l which is less than n. So, a padding of r 0s is done such that:
1
l+r =n
C0 = Enc(m0 , K)
C1 = Enc(m1 , K)
C2 = Enc(m2 ||0n−l , K)
C = c0 ||c1 ||c2
D = Dec(c0 , K)||...||Dec(cn , K)
In general, this cipher is used for small/limited size message but using ECB mode of opera-
tion, it can also be used for larger messages.
If same characters exists in 2 different blocks, then it becomes easier to decode that same type
of text exists as its encryption would be identical, so it is one of the problems with this cipher.
4 Product Cipher
We create a product cipher by combining two or more transformation process such that the
resulting cipher is more secure than the individual components. Now, we can use this product
cipher for the encryption-decryption process.
Permutation Box: It is defined as a method of bit-shuffling used to permute bits across sub-
stitution boxes.
n n n
s s .... r .... s
m m m
p mr
2
6 Fiestel Network
Here, we will use this cipher for encryption-decryption process of a plaintext of size 2n. If the size
of the plaintext is not even, then we will make it even by padding with 0. Here, we will divide the
plaintext into 2 blocks of size n. Left Block is represented as L0 and right block is represented as
R0 .
P = L0 ||R0
Also, we will use a function f which is necessary for this process and k is a secret key which will
also be used for this process.
n-bits n-bits
L0 R0
L
f
L1 R1
n-bits n-bits
L1 = R0
M
R1 = L0 f (R0 , k)
Decryption:
Now, we will look at the decryption process. Here, it is not necessary for f to be invertible.
Decryption process will work properly even if f is not invertible.
3
n-bits n-bits
L1 R1
L
f
L0 R0
n-bits n-bits
M
L0 = R1 f (L1 , k)
R0 = L1
Encryption : C1 = F (k1, P )
C = F (k2, C1 )
The above represents an example of iterated block cipher where P is the plain text, Total no.
of rounds(r) is 2, k1 and k2 are round keys, C1 is an intermediary cipher text, C is the final cipher
text and F represents the round function.
The scheduling of keys is very necessary as we have r round keys for r rounds so it becomes
extremely crucial to decide which key should be used for which round.So, a function G(k) acts
as the key scheduling algorithm.So, the order of keys is known so we can easily do decryption
corresponding to the encryption in that order.
In the above example, the keys were scheduled as first k1 and then k2.
4
8 Data Encryption Standard
Data Encryption Standard(DES) was developed by IBM. It is a iterated block cipher and is
based on Fiestel Network.
In DES, the block size is fixed as 64 bit and the size of the secret key is also fixed as 64
bit. There are a total of 16 rounds.
In the 64 bit secret key, there are 8 parity check bits and So, we can say that 8 bits
depend on the rest of the 56 bits.Here, every 8th bit is a parity check bit. So, in a text
011101111100101010101010... every 8th bit which is highlighted is a parity bit.As we have seen
above that there are 16 rounds in total. So, in total 16 round keys are created ( k1 , k2 , ....., k16
) and size of each round key is of 48 bits.
IP
L0 R0
K
+ F
Round 1
L1 R1
K
+ F Round 2
L2 R2
L16 R16
IP −1