Hill Cipher With Parallel Processing
Hill Cipher With Parallel Processing
2 1170
Now let us choose another key, Kp comprising of sixteen matrix given by KS1 ' . Thus
ASCII characters in a random manner from 0 to 15. K p is
chosen as
Kp = [16 15 11 1 2 9 4 10 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1
3 5 12 6 8 13 14 7] (2.4) 0 0 1 1 0 0 1 1 0 1 0 1 1 1 1 1
1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0
Key matrix K is permuted using K p1 . K p1 is deduced
K S ' 1 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 (2.8)
from Kp by using the following equation 1
0 1 1 1 0 0 1 0 1 1 0 1 0 1 0 1
K p1 = Kp (2.5)
1 1 0 1 1 1 0 1 0 0 0 1 0 0 1 0
Thus 0 1
1 1 0 1 0 0 0 0 0 1 0 1 1 1
K p1 = [16 15 11 1 2 9 4 10
3 5 12 6 8 13 14 7] (2.6)
The process of mixing the bits of the Key matrix KS1 ' ,
Now let us describe the permutation of each row of the
row wise, used in RowShuff () function can be described
above key matrix K given in (2.3) based on the position of
as follows:
characters of K p1 given in (2.6)
Now let us leave the first row as it is and replace the
The sixteenth bit in the first row of the matrix K is placed second row with the fifth row, third row with the second
as the first bit of the same row in the resultant matrix row, fourth row with the sixth row, fifth row with the third
denoted by KOAP. The fifteenth bit of the first row is row, sixth row with the seventh row and seventh row with
placed as the second bit of the same row. We keep on the fourth row. This will result in the first subkey, K S1
arranging the remaining bits of the first row of K
given by
depending upon the position of numbers given in K p1 .
1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1
The same procedure is adopted for all the remaining rows 0 1 1 1 0 0 1 0 1 1 0 1 0 1 0 1
of K using K p1 . Thus
0 0 1 1 0 0 1 1 0 1 0 1 1 1 1 1
1 1 0 1 1 1 0 1 1 0 0 0 1 1 0 1
K S1 1 1 0 1 1 1 0 1 0 0 0 1 0 0 1 0 (2.9)
0 1
1 0 1 0 0 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 0
1 1 1 1 0 1 1 0 1 1 1 1 1 1 0 0 0 1 1 0 1 0 0 0 0 0 1 0 1 1 1 1
1
K OAP 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0(2.7) 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0
0 1 0 1 1 0 0 0 1 1 0 0 1 1 1 1 Now, let us describe the process of generating the second
subkey K S 2 from K S1 wherein we use permuted key,
1 0 1 0 0 0 0 1 1 1 1 1 0 1 0 0
0 1
K p 2 . The permuted key K p 2 is derived from K p1 by
1 1 0 0 1 1 1 1 0 0 0 0 0 1
making the circular left shift operation by one element on
Now we describe the process of generating the subkeys.
K p1 shown in (2.6). Thus
The procedure for generating the first subkey KS1 is
K p 2 = [15 11 1 2 9 4 10
described hereunder:
3 5 12 6 8 13 14 7 16] (2.10)
The process of mixing the bits of the Key matrix KOAP,
The procedure adopted in the generation of KOAP from K is
column wise, adopted in ColShuff () function can be
described as follows: used to generate KOAP1 from K S1 . Let us generate the
The first column of KOAP is placed as it is. The second subkey KS2 ' from K OAP1 similar to the manner used in
column is replaced by the ninth column, and the third the generation of K S1 ' from KOAP. KS2 ' is then used to
column is replaced by the second column, the fourth
column is replaced by the tenth column the fifth column is generate K S 2 in the same way as K S1 was generated
replaced by the third column, sixth column is replaced by
the eleventh column, seventh column by the fourth from K S1 ' .
column, eighth column by the twelfth column, ninth
The above described procedures adopted in the generation
column by the fifth column, tenth column by the thirteenth
column, eleventh column by the sixth column, twelfth of K S 2 are used in the generation of the remaining
column by the fourteenth column, thirteenth column by the subkeys namely, K S3 to K S16 .
seventh column, fourteenth column by the fifteenth
column, fifteenth column by the eighth column. The Now these subkeys are used along with the plaintext in the
sixteenth column is placed as it is. This will result in the generation of the cipher, which is described below.
1 1 0 1 1 1 0 1 1 0 0 1 0 1 1 1
1 0 1 0 0 1 1 1 0 1 1 1 1 1 0 1
1 1 1 1 1 1 0 0 1 0 1 1 0 1 0 1
P 1 0 1 0 0 0 0 0 1 1 1 0 0 1 1 1
1 0 0 1 0 1 1 1 0 0 0 1 1 1 1 1
0 1 0 1 1 1 1 0 0 1 0 1 1 0 1 0
0 1
1 1 1 1 0 1 0 0 1 1 1 1 0 0
(2.13)
We now describe the procedure adopted for the
permutation of the plaintext P based on the permutation
key K P1 shown in (2.6). We shall place the sixteenth bit
in the first row of the plaintext matrix P as the first bit of
the same row in the resultant matrix, denoted as P OAP. The
fifteenth bit of the first row of P is placed in the second bit
of the same row of POAP. In this way we arrange the
remaining bits of the first row of matrix P depending upon
the position of the numbers given in K P1 resulting in the
first row of the matrix POAP. We adopt the same procedure
for all the remaining rows of P using K P1 . Hence, we
have
Let us now convert the first row of K S1 into its decimal
POAP=
equivalent. We shall also convert the first row of P1 into
1 1 0 1 1 1 1 0 0 1 1 1 1 0 1 0
1 its decimal equivalent. We shall now perform the modulo
0 1 1 0 0 0 1 1 0 1 1 1 1 1 1 arithmetic addition(216) on the resultant decimal
1 0 1 1 1 1 1 0 1 1 1 1 0 0 1 0
equivalents of the first rows of K S1 and P1 respectively,
POAP 1 1 1 1 0 1 0 1 1 0 0 0 0 0 1 0(2.14)
1 1 0 1 0 0 1 0 0 0 1 1 1 1 1 1 thereby resulting in the first row of the matrix,C1deci whose
size is 7x1. The subscript deci is written to indicate the
0 1 0 0 1 0 1 1 0 1 1 1 0 1 0 1
decimal equivalent. The process is repeated for the
1 1
0 1 0 1 0 1 1 1 1 1 0 0 1 0
remaining 6 rows of P1 and K S1 which would give rise to
The matrix P1 given below, is derived from the matrix
POAP as per the procedure enunciated earlier in the the rest of the six rows of C1deci.
generation of the first subkey K S1 from KOAP.
39647 0 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0
0 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0
6706
694 0 0 0 0 1 0 1 1 1 0 0 0 0 1 0 0
C1deci = 4781 (2.16) C 1 1 0 0 1 0 0 1 0 1 1 0 1 0 0 0 (2.18)
1 1 0 1 1 0 0 1 1 0 0 0 0 1 1 1
57124
17610 1 1 1 1 1 1 0 0 1 1 1 1 0 1 0 0
1 0
59600 0 0 1 1 0 1 0 1 0 0 1 0 0 0
Convert each row of C1deci (which is a decimal number) We concatenate each row of C and get the 112 ciphertext
into its corresponding binary equivalent. This gives rise to bits. Let us now convert the binary bits of C into decimal
sixteen bit binary number for each row. This would result numbers by taking 7 bits at a time, starting from first bit.
in a matrix, C1'of size 7x16. Thus
1 0 0 1 1 0 1 0 1 1 0 1 1 1 1 1
C 5 31 68 72 32 46 9 73 52 54 48 127 103 82 53 16 (2.19 )
0 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0
Decryption of the cipher is done using the same algorithm
0 0 0 0 0 0 1 0 1 0 1 1 0 1 1 0 as encryption with the input being the ciphertext. The
C1 0
'
0 0 1 0 0 1 0 1 0 1 0 1 1 0 1 (2.17) decryption subkeys used are the modular additive inverses
1 of the Encryption subkeys with the key roles being
1 0 1 1 1 1 1 0 0 1 0 0 1 0 0
reversed from that of encryption. It may be noted here that
0 1 0 0 0 1 0 0 1 1 0 0 1 0 1 0 IPermute (), IRowShuff () and IColShuff () in decryption
1 0 are reverse processes of Permute (), RowShuff () and
1 1 0 1 0 0 0 1 1 0 1 0 0 0
ColShuff () respectively used in encryption process.
Now we shall describe the Permute () operation. Let us
now rearrange the bits of C1'as per the procedure explained 3. ENCRYPTION AND DECRYPTION
below to generate the matrix, C1 of size 7x16.
ALGORITHMS
Here the first seven columns of C1 are obtained by the
In what follows, we briefly present the algorithms for
following process: Writing the element of the eighth
subkey generation, encryption, decryption and additive
column of fourth row of C1' as the element of first column
inverse of the subkeys respectively.
of first row. Now we place the element of the seventh
column of fourth row of C1' as the element of first column 3.1 Algorithm for Subkeys Generation
of second row. In a similar manner, the remaining
elements of fourth row of C1' are placed in their reverse Step 1: Initialize key, K0 and permutation
order explained previously. The same procedure is Key, Kp
adopted for all the elements of the third, second and first Step 2: Generate K0A from K0
rows of C1'. Thus the eight columns of C1 are formed. Step 3: Generate K from K0A
Then the remaining eight columns of C1 are formed as Step 4: K p1 = Kp
follows: the last eight elements of fourth row, all the fifth, Step 5: for i=1 to 16
sixth and seventh row of C1' are placed directly in their {
order as the elements of ninth column to sixteenth column. Permute K to generate K0AP by using Kpi
Thus Ksi' = ColShuff (K0AP)
0 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 Ksi = RowShuff (Ksi')
1 0 1 0 1 1 1 0 0 1 1 0 1 1 0 0
K = Ksi
Kp(i+1)= Lcirshift(Kpi) // left circular shift
0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 }
// Ks1 to Ks16 are the subkeys
C1 0 1 1 0 0 0 0 1 0 0 0 0 0 1 0 0 (2.17)
Step 6: end
1 0 0 1 0 0 1 0 1 1 1 1 1 0 0 0
3.2 Algorithm for Encryption
0 1 0 0 1 1 1 0 1 1 0 0 1 1 0 0
0 0 Step 1: Read plaintext P0, permutation key, Kp and
1 0 0 0 1 0 1 0 1 0 0 0 1 1
subkeys Ks1 to Ks16.
This completes the first iteration (round1) giving rise to Step 2: Generate P0A from P0
the first round cipher denoted as C1. Now, this C1 becomes Step 3: Generate P from P0A
the plaintext P for the second round.
Step 4: K p1 = Kp
We shall adopt the same procedure for the remaining
Step 6: for i=1 to 16
fifteen rounds to generate the ciphertext C of size 7x16.
{
Thus
Generate P0AP using P and Kpi Ks16, the ciphertext is generated for the plaintext is as
Pi' = ColShuff (P0AP) shown below. The ciphertext is shown below
Pi = RowShuff(Pi')
Ci '= (Pi + Ksi ) % 216 0 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0
Ci = Permute(Ci ') 0 0 1 0 0 1 0 0 1 0 0 0 0 1 0 0
P = Ci 0 0 0 0 1 0 1 1 1 0 0 0 0 1 0 0
}
Step 7: C = C16 C 1 1 0 0 1 0 0 1 0 1 1 0 1 0 0 0(4.4)
Step 8: end 1 1 0 1 1 0 0 1 1 0 0 0 0 1 1 1
3.3 Algorithm for Decryption 1 1 1 1 1 1 0 0 1 1 1 1 0 1 0 0
1 0
Step 1: Read ciphertext C, permutation key, Kp and 0 0 1 1 0 1 0 1 0 0 1 0 0 0
subkeys Ks1 to Ks16.
The key given in (4.3) should be made available to the
Step 2: C1 = C
Receiver. The original plaintext is recovered from the
Step 3: Kp16 = Lcirshift15 (Kp) // left circular shift by 15
cipher by using the decryption algorithm (explained in
bits.
section 3.3) and the inverse subkeys, Ks1-1 to Ks16-1
Step 4: for i=16 to 1
(modulo additive inverse 216 of Ks1 to Ks16) outlined in
{
section 3.4.
Ci = IPermute(C)
Pi = (Ci + Ksi-1) % 216 As the encryption involves Permutation, modular
Pi' = IRowShuff(Pi) arithmetic addition and mixing the complexity of the
P0AP = I ColShuff(Pi') algorithm increases, which results in confusion and
Do Inverse permutation to generate Pi from P0AP diffusion, which are the two basic building blocks to show
using Kpi. that cipher is a strong one against cryptanalysis.
C = Pi
Kp(i-1) = rcirshift(Kpi) // right circular shift 5. CRYPTANALYSIS
} In the literature of Cryptography the general methods of
Step 5: P = P1 cryptanalytic attack are
3.4 Algorithm for Finding Modular Additive 1. Ciphertext only attack (Brute force
Inverse of the Subkeys attack)
2. Known plaintext attack
Step 1: Read subkeys Ks1 to Ks16\ 3. Chosen plaintext attack and
Step 2: for i = 1 to 16 4. Chosen ciphertext attack
{
Find Ksi-1 such that In this analysis we have taken the key, K consisting of 16
(Ksi + Ksi-1) % 216 ==0 numbers, where each number can be represented in terms
} of 7 binary bits (ASCII). Thus the length of the key is 112
// Ks1-1 to Ks16-1 are the additive inverse of the bits, in view of this fact the size of the key space is
subkeys Ks1 to Ks16 11. 2 11. 2
Step 3: end 2112 = (210) ≈ (103) = 1033.6.
4. ILLUSTRATION OF THE CIPHER If the determination of the plaintext for each value of the
key takes 10-7 seconds, then the time required for
Let us consider the plaintext given below in quotes (quotes computation with all the possible keys in the key space is
are not part of the plaintext): given by
“network security measures are needed to protect data
during their transmission” (4.1)
10 x10 7
33.6
years
365 x 24 x 60 x 60
Let us focus our attention on the first sixteen characters of
the plaintext. Thus we have
= 3.17 x (1033.6 1015 ) years
network security (4.2)
= 3.17 x (10)18.6 years
Now consider a key comprising 16 characters which is
given by Thus the cipher is computationally secure. In the case of
the known plaintext attack, we know as many pairs of
qrstuvwxyzabcdef (4.3)
plaintext and ciphertext as we require. For example, we
As discussed in section 2, we generate sixteen subkeys, confine our attention only to two rounds of the iteration
Ks1 to Ks16 which is outlined in section 3.1. By using the process in the encryption. For the sake of convenience in
encryption algorithm as described in section 3.2, and the presentation, let us denote the function Permute () as F().
plaintext given by equation (4.2) and the subkeys Ks1 to
Then we have 0 1 1 0 0 0 0 1 1 0 0 1 1 1 1 0
P = (P+K) mod 2 , 16
(4.1) 1 0 0 0 1 0 1 0 0 1 1 1 1 0 0 0
P = F(P), (4.2) 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 1
P = (P+K) mod 216 and (4.3)
P = F(P) mod 216. (4.4) Cnew 0 0 1 1 1 1 1 1 0 0 0 0 1 0 0 0(6.1)
C=P (4.5) 1 1 1 0 0 0 0 0 0 1 0 0 1 1 1 0
1 1 1 0 0 0 0 1 1 0 1 0 0 1 1 0
From (4.1) - (4.5), we get 1 1
0 0 0 0 1 0 1 0 1 0 1 1 1 1
C = F(( F((K+P) mod 256)+ K ) mod 256). (4.6)
On comparing (4.4) and (6.1), it is observed that the two
In (4.6) the innermost K and P are added and the result is ciphers differ by 63 bits out of 112 bits. This clearly shows
operated with mod 216. On converting the resulting that the cipher exhibits a strong avalanche effect.
numbers into their binary form, permutation is performed,
as mentioned earlier, and the resulting matrix containing Let us change the fourteenth character in the Key (4.3)
decimal numbers is obtained. Then this matrix is added by from d to e, which amounts to changing single bit. The
K and mod 216 is taken. Thus we have got a new matrix new key is
whose permutation yielded C. In this process the K and P qrstuvwxyzabceef (6.2)
are getting thoroughly interacted, and their binary bits are
undergoing diffusion and confusion in a very strong Keeping the plaintext as original plaintext given by(4.2)
chaotic manner. This is all on account of the permutation and applying the new key given by (6.2) and using the
and mod operation. Moreover the plaintext bits are Encryption Algorithm mentioned in section 3.2 we get the
shuffled row wise and column wise. Hence, the Plaintext ciphertext,Cknew given by
bits are scattered. The K and P are losing their shapes and
getting thoroughly mixed, so that no trace of them can be 0 0 1 1 1 1 1 1 0 1 0 1 1 0 1 1
found separately. In the above analysis we have taken only 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1
two rounds.
1 0 0 0 0 0 1 0 0 0 1 1 0 1 1 0
In general in our analysis of this problem, as we have
Cknew 1 0 1 1 1 1 0 1 0 1 0 1 0 1 0 0(6.3)
sixteen rounds, we get
0 0 0 0 0 0 0 1 0 0 1 1 1 1 0 1
C =F((….. F((F((P+K) mod 256)+K)mod 2 16)…..) mod
216). 0 1 1 0 1 1 1 1 0 1 1 0 1 0 0 1
0 1
In this relation, as we have addition, mod 2 16 and 0 0 1 1 1 0 1 1 1 0 0 0 1 1
Permutation playing a vital role, the binary bits of K and P On comparing the two ciphers given in (4.4) and (6.3), it
are undergoing several changes several times. Thus we are can be seen that the two ciphers differ in 60 bits out of 112
not able to get the key or a function of the key so, that the bits. This once again proves that the algorithm has
cipher can be broken. Hence the cipher is a very strong pronounced avalanche effect.
one. It is only after 13 rounds the algorithm becomes complex
The third and fourth attacks namely chosen plaintext and enough to make a one bit change in key or in the plaintext
chosen ciphertext attacks merely depend upon the vision resulting in a significant change in the cipher (binary bits).
and the intuition of the attacker. Though the cipher is an One bit change in the key or the plaintext results into
elegant one, its suggesting a plaintext or a ciphertext to be change of 70 bits or 65 bit in the ciphertext (binary bits).
chosen is found to be impossible. Hence the cipher is This clearly indicates that the cryptographic algorithm
secure in the last two cases too. itself manifests avalanche effect significantly after ten
rounds.
6. AVALANCHE EFFECT 7. EXPERIMENTAL RESULTS AND
Avalanche effect is one of the parameters that depict the CONCLUSIONS
strength of a Cryptographic algorithm. Here we test our
algorithm by considering the avalanche effect. We obtain In this analysis we have written java programs
the ciphertext, C mentioned in (4.4) corresponding to the corresponding to the algorithms for encryption and
plaintext, P given in (4.2) and Key given in (4.3). decryption presented in section 3.
Here we change the third character in the plaintext (4.2) On dividing the complete plaintext (3.1) into blocks,
from„t‟ to „u‟, which is equivalent to changing the wherein each block contains 16 characters, we have
plaintext in a single bit position, i.e. Network security. By adopted the process of the encryption. However, in the last
using the same key mentioned in (4.3) and applying the block whose length is less than 16 characters, we have
encryption algorithm discussed in section 3, we obtain the appended blank spaces at the end to make the block size to
ciphertext, Cnew given by 16 characters. Thus we get the ciphertext for the entire
plaintext in the form shown below.
REFERENCES
[1] William Stallings, “Cryptography and Network
Security”, Principles and Practice, Third Edition,
Pearson, 2003.
[2] V. U. K. Sastry, S. Udaya Kumar, and A Vinaya
Babu, “A Large Block Cipher Using Modular
Arithmetic Inverse of a Key Matrix and Mixing of
the Key Matrix and the Plaintext”, Journal of
Computer Science, Vol. 2(9), pp. 698 – 703, 2006.
[3] Behrouz A. Forouzan, “Introduction to Cryptography
and Network Security”, McGraw-Hill Higher
Education, 2008.
[4] Davies D W, “Some Regular Properties of the DES”,
Advances in Cryptology, Springer-Verlag, 1992.
[5] V. U. K. Sastry, V. Janaki, “On the Modular
Arithmetic Inverse in the Cryptology of Hill Cipher”,
Proceedings of North American Technology and
Business Conference, Sep. 2005.
[6] V.U.K.Sastry, Aruna Varanasi, “A Modified Hill
Cipher Involving Permutation, Iteration and the Key
in a Specified Position” (IJCNS) International
Journal of Computer and Network Security, Vol. (10),
pp.157-162, October 2010.