0% found this document useful (0 votes)
102 views6 pages

A Modified Hill Cipher Involving Permutation, Iteration and The Key in A Specified Position

The document proposes a modification to the classical Hill cipher that introduces permutation and iteration to strengthen security. The encryption process involves multiplying the plaintext matrix by the key matrix from the left in one iteration and from the right in the next iteration, repeating until all iterations are complete. Permutation is applied between iterations using a function to provide confusion and diffusion. Decryption follows the reverse process. Analysis shows the relationship between ciphertext and plaintext is nonlinear, resisting cryptanalysis. Permutation plays a key role in strengthening the cipher.

Uploaded by

IJCNSVol2NO10
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views6 pages

A Modified Hill Cipher Involving Permutation, Iteration and The Key in A Specified Position

The document proposes a modification to the classical Hill cipher that introduces permutation and iteration to strengthen security. The encryption process involves multiplying the plaintext matrix by the key matrix from the left in one iteration and from the right in the next iteration, repeating until all iterations are complete. Permutation is applied between iterations using a function to provide confusion and diffusion. Decryption follows the reverse process. Analysis shows the relationship between ciphertext and plaintext is nonlinear, resisting cryptanalysis. Permutation plays a key role in strengthening the cipher.

Uploaded by

IJCNSVol2NO10
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

(IJCNS) International Journal of Computer and Network Security, 157

Vol. 2, No. 10, 2010

A Modified Hill Cipher Involving Permutation,


Iteration and the Key in a Specified Position
V.U.K.Sastry1 and Aruna Varanasi2
1
Department of computer Science and Engineering,SNIST
Hyderabad, India,
[email protected]
2
Department of computer Science and Engineering,SNIST
Hyderabad, India,
[email protected]

In a recent investigation, sastry et al. [4], have applied a


Abstract: In this paper we have developed a block cipher by key matrix on both the sides of the plaintext matrix and
modifying the classical Hill cipher. In this we have introduced have avoided the direct possibility of breaking the cipher.
additional features such as Permutation and Iteration. For They have strengthened the cipher by using a function
simplicity and elegancy of this cipher, the plaintext is multiplied called mix() for mixing the plaintext bits at every stage of
by the key from the left side in the first iteration and from the the iteration process involved in the cipher. They have
right side in the second iteration and this process is continued in found that the relation between the Ciphertext and the
the subsequent iterations. The above mentioned operations
plaintext is highly nonlinear and hence the cipher cannot be
carried out in this analysis led to a thorough confusion and
broken by any cryptanalytic attack. Of late sastry et al.[5]
diffusion of the information. The avalanche effect and the
cryptanalysis, carried out in this paper, clearly indicate that the have developed a cipher, wherein they have taken a pair of
cipher is a strong one. In this analysis the permutation is keys. In this they have introduced an iterative procedure,
playing a very prominent role in strengthening the cipher. which includes a Permutation and have shown that the
cipher is significantly strong.
Key words: Encryption, Decryption, Cryptanalysis, avalanche In the present paper our objective is to develop a block
effect, permutation. cipher which involves a nonlinear relation between the
Ciphertext and the plaintext. In this analysis we have
1. Introduction introduced the key matrix, K as a left multiplicant in one
step of the iteration, and as a right multiplicant in the next
The classical Hill Cipher [1], which came in to existence step of the iteration, and we have continued this process till
much before the advent of Computers has brought in a all the iterations are completed. The procedure is
revolution in the area of Cryptography. It is governed by the strengthened by using a function named Permute() for
relations achieving confusion and diffusion.
C = KP mod26, and (1) In what follows we present the plan of the paper. In
P = K¯1C mod26. (2) Section 2, we introduce the development of the cipher, and
In these relations P is a plaintext vector, C the Ciphertext put forth the algorithms for encryption and decryption.
vector, K the key matrix and K¯1 is the modular arithmetic Section 3 is devoted to illustration of the cipher. In section
inverse of K. In the above relations mod 26 is used as 26 4 we discuss the cryptanalysis in detail. Finally in section 5
characters of English alphabet are used in the development we mention the computations related to the cipher and draw
of the cipher. conclusions.
In the literature of Cryptography, it is well established
that this cipher can be broken by the known plaintext attack.
This is due to the fact that the equation (1) can be brought to 2. Development of the cipher
the form
Y = KX mod 26, Consider a plaintext, P. Let this be written in the form of
in which X and Y are matrices containing appropriate a matrix given by
number of column vectors of the plaintext and the P = [Pij], i= 1 to n , j=1 to n. (3)
corresponding column vectors of the ciphertext, and the Here each element of P is a decimal number lying
modular arithmetic inverse of X can be obtained in several between
instances. 0 and 255.
Before proceeding to the development of Feistel cipher[2- Let us take a key matrix K, which can be represented in
3], Feistel has noticed that the Hill cipher involving only a the form
linear transformations is quite vulnerable and it can be K = [Kij], i=1 to n, j=1 to n, (4)
broken. Thus he has introduced a XOR Operation, linking where each Kij is a decimal number in the interval 0 to 255.
the portions of the plaintext and the key, and an iterative Let the Ciphertext, C be given by
procedure so that confusion and diffusion, which offer C = [Cij], i=1 to n, j=1 to n, (5)
strength to the cipher, can be achieved. In which all the elements of C also lie between [0-255].
158 (IJCNS) International Journal of Computer and Network Security,
Vol. 2, No. 10, 2010

In this we have used 0-255 as we have made use of EBCDIC and


code for the conversion of plaintext into the corresponding P= Permute(P).
decimal numbers.
The process of encryption and the process of decryption are The process of decryption is given by
described by the flowchart given in Figure-1.
The basic relations governing the process of encryption C=IPermute(C )
are given by and
if (r mod 2 = 1) then if(r mod 2 =1) then
P=KP mod 256 C=K-1 C mod 256
else else
P=PK mod 256 C=C K-1mod 256.
(IJCNS) International Journal of Computer and Network Security, 159
Vol. 2, No. 10, 2010
The process of permutation can be described as follows. 1 1 0 1 1 0 0 0
1 1 0 1 1 0 1 0
Let P be a matrix containing n rows and n columns. This 
0 0 0 1 0 0 1 0
can be written in the form of a matrix containing m(=n2) 
1 1 1 0 1 0 1 0

(9)
rows and eight columns as shown below: 1 0 1 0 0 1 0 1
 
0 1 1 1 0 1 0 0
1 0 0 1 1 0 1 1
 p111 L p118 
1 0 0 0 0 0 0 0

 p121 O p128

0 1 1 0 1 0 1 1

 M  0

1 1 1 1 0 0 1

O M (6) .
  1
0
0 0 1 1 0 1 0
0 0 0 1 1 0 0
 M O M  
0 0 1 1 0 0 0 0

 pnn1 K pnn8 1

1 0 0 0 0 1 0

0 0 1 1 1 0 0 0
 
0 0 0 0 0 0 1 1
This is obtained by converting each element of the P into
In order to have clear insight into the process of
its binary form. On assuming that the n is an even number,
permutation let us explain what we have done. Here we
the above matrix can be divided into two equal halves,
have started with the last element of the last row of the
where in each half contains m/2 rows. Then the upper half
upper half in (8), and have gone in the backward direction (
is mapped into a matrix containing m rows and four
placing the elements one after another in a column wise
columns. In the process of mapping we start with the last
manner in the first column, second column, etc., ) till we
element of the upper half and place it as the first row, first
have reached the first element of the matrix. This results in
column element of a new matrix. Then we place the last but
the first four columns of (9). Then we have commenced
one element of the upper half as the element in the second
with the first element of the lower half and filled up,
row and first column. We continue this process of placing
element after element, in the remaining four columns of (9)
the remaining elements of the upper half, one after another,
till we have reached the last element of (8). This has
till we get m rows and four columns of the new matrix.
enabled us to obtain (9). This process of permutation is
Then we place the elements of the lower half from the
expected to thoroughly permute the binary bits which are
beginning to the end in their order , such that they occupy
obtained as a consequence of the product of the plaintext
four more columns and m rows. Thus we again get a matrix
matrix and the key matrix.
of size mx8.
The matrix (9) can be brought into its corresponding
For example when n=4 (i.e., m=16), let us suppose
decimal form as shown below.
that the plaintext matrix, P is given by
 216 218 18 234
 86 103 83 56   
 35 43 36 219  165 116 155 128 
P=   (7)  107 121 154 12  (10)
210 242 12 16   
   48 194 56 
 3 
114 165 10 193 
Obviously as it is expected the elements of original
matrix, P (7) and the elements of the matrix (10) obtained
on permutation are totally different.
This can be brought to the binary form given by
It may be noted here that the IPermute() in the
0 1 0 1 0 1 1 0 decryption is a reverse process of the Permute() used in the
0 1 1 0 0 1 1 1  encryption.

0 1 0 1 0 0 1 1 The algorithms for encryption and decryption are
 
0 0 1 1 1 0 0 0
(8) written below.
0 0 1 0 0 0 1 1
 
0 0 1 0 1 0 1 1
0 0 1 0 0 1 0 0 Algorithm for Encryption
 
1 1 0 1 1 0 1 1
 
1 1 0 1 0 0 1 0 1. Read n,P,K,r
1 1 1 1 0 0 1 0
  2. for i = 1 to r
0 0 0 0 1 1 0 0
0 0 0 1 0 0 0 0
{
 
0 1 1 1 0 0 1 0 if ( (i mod 2)=1)
1 0 1 0 0 1 0 1
  P=(KP) mod 256
0 0 0 0 1 0 1 0
  else
1 1 0 0 0 0 0 1
P =( PK) mod 256
On permuting the above matrix in accordance with P= Permute(P)
the process explained earlier, we get }
C=P
3. Write( C )
160 (IJCNS) International Journal of Computer and Network Security,
Vol. 2, No. 10, 2010

Algorithm for Decryption Let us take the key, K in the form


1. Read n,C,K,r 123 25 9 67

2. K¯1 = Inverse(K) 134 17 20 11
3. for i= r to 1 K=  (14)
 48 199 209 75
{  
 39 55 85 92
C = IPermute(C) On applying the encryption algorithm, described in
If ((i mod 2)=1) section 2, with r=16, we get the Ciphertext given by
C = (K¯1 C ) mod 256 115 168 140 127
else  
146 72 8 57 
C= (C K¯1 ) mod 256 C=  (15)
 63 133 218 101
 
}  0 193 141 195
4. P=C
5. Write (P) On adopting the decryption algorithm, we get back the
original plaintext given by (13).
Algorithm for Inverse(K) In order to estimate the strength of the algorithm, let us
1. Read A, n, N study the avalanche effect.
// A is an n x n matrix. N is a positive integer with which Here we replace the fifth character “e” of the plaintext
modular arithmetic (12) by “d”. The EBCDIC codes of “e” and “d” are 133 and
is carried out. Here N= 256. 132, which differ by one bit in their binary form. Thus, on
2. Find the determinant of A. Let it be denoted by Δ, using the modified plaintext, the key (14) and the
where Δ ≠ 0. encryption algorithm, let us compute the corresponding
3. Find the inverse of A. The inverse is given by [Aji]/ Δ, i= ciphertext. This is given by
1 to n , j = 1 to n
// [Aij] are the cofactors of aij, where aij are the  80 6 60 130 
elements of A  7 181 53 106 
for i = 1 to N C=   (16)
{  75 36 232 91 
 
// Δ is relatively prime to N 224 22 148 255
if((iΔ) mod N == 1) break;
} On converting (15) and (16) into their binary form, we
d= i; notice that the two ciphertexts differ by 69 bits (out of 128
B = [dAji] mod N. // B is the modular arithmetic bits). This shows that the cipher is a strong one.
inverse of A. Let us now change a number in key, K. We replace
199,the third row second column element of (14), by 198.
3. Illustration of the cipher These two numbers also differ by only one binary bit. On
performing the encryption with the modified key and the
Let us consider the plaintext given below. original plaintext intact, we get the ciphertext given by
Father! it is really a pleasure to see India as a visitor. Each
village has a temple, each town has an engineering college  22 63 75 65 
and of course, each place has a liquor shop. (11)  
239 228 137 58 
We focus our attention on the first sixteen characters of C=  (17)
 82 253 221 232
the plaintext (11). This is given by  
Father! it is re (12)  79 255 248 95 
On using EBCDIC code the plaintext (12) can be
written in the form of a matrix, P given by Now on comparing the binary forms of (15) and (17), we
find that they differ by 68 bits (out of 128 bits). This also
198 129 163 136 shows that the cipher is a potential one.
133 153 79 64 
P=   (13) 4. Cryptanalysis
137 163 64 137
  In the literature of Cryptography the general methods of
162 64 153 133 cryptanalytic attack are
• Ciphertext only attack (Brute force attack)
• Known plaintext attack
• Chosen plaintext attack and
(IJCNS) International Journal of Computer and Network Security, 161
Vol. 2, No. 10, 2010
• Chosen ciphertext attack an elegant one, its suggesting a plaintext or a Ciphertext to
In this analysis we have taken the key, K consisting of 16 be chosen is found to be impossible. Hence the cipher
numbers, where each number can be represented in terms of cannot be broken in the last two cases too.
8 binary bits. Thus the length of the key is 128 bits, in view The above analysis clearly shows that the cipher cannot
of this fact the size
12. 8 of the
12.key
8 space is be broken by any attack.
2128 = 210 ≈ 103 =1038.4.
If the determination of the plaintext for each value of the 5. Computations and Conclusions
key takes 10-7 seconds, then the time required for
computation with all the possible keys in the key space is In this paper we have modified the Hill Cipher by
given by introducing a Permutation, Iteration and the key in a

(10 )
specified position. In the first round the key is on the left
x10 −7
( )
38.4 side of the plaintext and it is on the right side in the second
= 3.17 x 10 38.4 x10 −15 round. The same pattern is continued in the subsequent
365 x 24 x 60 x 60
rounds.

( )
The algorithms for encryption and decryption, mentioned
= 3.17 x 10 23.4 years. in section 2, are implemented in java.
Thus the cipher cannot be broken by the Ciphertext only On using the program for encryption the Ciphertext
attack. corresponding to the entire plaintext given in 3.2 is
In the case of the known plaintext attack, we know as obtained as
many pairs of plaintext and ciphertext as we require. For
example, we confine our attention only to two rounds of the
iteration process in the encryption. For the sake of
convenience in presentation, let us denote the function
Permute() as F(). Then we have

P = (KP) mod 256, (18)


P = F(P), (19)
P = (PK) mod 256 and (20)
P = F(P) mod 256. (21) In carrying out the computation, we have taken a block
C=P (22) of 16 characters of the plaintext in each round. In the last
From (18) - (22), we get round when the plaintext has fallen short to sixteen
C = F(( F((KP) mod 256) K) mod 256). (23) characters by a few characters, we have appended additional
characters at random to make up the block complete.
In (23) the innermost K and P are multiplied and the In this analysis we have seen that the multiplication of K
result is operated with mod 256. On converting the and P, the mod operation which is modifying the product
resulting numbers into their binary form, permutation is and the permutation causing a thorough diffusion and
performed, as mentioned earlier, and the resulting matrix confusion are playing a prominent role in strengthening the
containing decimal numbers is obtained. Then this matrix is cipher. The potentiality of the cipher is seen markedly in
multiplied by K on the right side and mod 256 is taken. the discussion of the avalanche effect. The cryptanalysis
Thus we have got a new matrix whose permutation yielded clearly indicates that the cipher cannot be broken by any
C. In this process the K and P are getting thoroughly cryptanalytic attack.
interacted, and their binary bits are undergoing diffusion The key K as a left multiplicant in all the odd rounds and
and confusion in a very strong chaotic manner. This is all as a right multiplicant in all the even rounds is expected to
on account of the permutation and mod operation. The K play a significant role in diffusing the information in all
and P are losing their shapes and getting thoroughly mixed, directions, so that the strength of the cipher is enhanced.
so that no trace of them can be found separately. In the From the development and the analysis of the above
above analysis we have taken only two rounds. cipher, we notice that the modified Hill Cipher is a strong
one and it can be applied very confidently for the security of
In general in our analysis of this problem, as we have information.
sixteen rounds, we get
C =F((….. F((F((KP) mod 256)K)mod 256)…..) mod 256). References:
In this relation, as we have multiplication, mod 256 and [1] William Stallings, Cryptography and Network Security,
Permutation playing a vital role, the binary bits of K and P Principles and Practice, Third edition, Pearson, 2003.
are undergoing several changes several times. Thus we are [2] Feistel, H. “Cryptography and Computer Privacy”
not able to get the key or a function of the key so, that the Scientific American, May 1973.
cipher can be broken. Hence the cipher is a very strong one. [3] Feistel, H., Notz., W., and Smith,J. “Some
The third and fourth attacks namely chosen plaintext Cryptographic Techniques for Machine-to-Machine
and chosen Ciphertext attacks merely depend upon the Data Communications.” Proceedings of the IEEE,
vision and the intuition of the attacker. Though the cipher is November 1975.
162 (IJCNS) International Journal of Computer and Network Security,
Vol. 2, No. 10, 2010
[4] V.U.K.Sastry, D.S.R.Murthy, S. Durga Bhavani, “A
Large Block Cipher Involving a Key Applied on both
the Sides of the Plaintext”, Vol.2, No.2, pp.10-
13,February.2010.
[5] V.U.K.Sastry, V.Aruna, Dr.S.Udaya Kumar, “ A
Modified Hill Cipher Involving a Pair of Keys and a
Permutation”, Vol.2,No.9, pp.105-108, September
2010.

You might also like