Sei sulla pagina 1di 4

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

Vol. 2, No. 9, September 2010

A Modified Hill Cipher Involving a Pair of Keys


and a Permutation
V.U.K.Sastry1, Aruna Varanasi2 and S.Udaya Kumar3
1
Department of Computer Science and Engineering, SNIST
Hyderabad, A.P.India,
vuksastry@rediffmail.com
2
Department of Computer Science and Engineering, SNIST
Hyderabad, A.P. India,
varanasi.aruna2002@gmail.com
3
Department of Computer Science and Engineering, SNIST
Hyderabad, A.P. India,
uksusarla@rediffmail.com

Abstract: In this paper, we have developed a block cipher by analysis. Finally in section 6 we have presented the
introducing a pair of keys-one as a left multiplicant of the numerical computations carried out in this analysis and
plaintext and the second one as a right multiplicant of the drawn conclusions.
plaintext. Here as we utilize EBCDIC code for converting
characters into decimal numbers, we use mod 256. We have
developed an iterative procedure, which includes a permutation, 2. Development of the cipher
for the cipher. The avalanche effect and the cryptanalysis
clearly show that the cipher is a potential one. Consider a plaintext, P. Let this be written in the form of a
matrix given by
Keywords: Encryption, Decryption, Cryptanalysis, avalanche P = [Pij], i= 1 to n , j=1 to n. (1)
effect, permutation, pair of keys. Here each Pij is a decimal number lying between 0 and 255.
Let us choose a pair of keys denoted by K and L, where K
1. Introduction and L can be represented in the form
K = [Kij], i=1 to n, j=1 to n, (2)
In the recent years, several modifications of Hill Cipher [1- and L = [Lij], i=1 to n, j=1 to n. (3)
5] have appeared in the literature of Cryptography. In all Here the elements of K and L are decimal numbers lying in
these investigations, modular arithmetic inverse of a key [0-255].
matrix plays a vital role in the processes of encryption Let the ciphertext, C be given by
and decryption. C = [Cij], i=1 to n, j=1 to n, (4)
It is well known that the Hill Cipher containing the key in which all the elements of C also lie in the interval 0 to
matrix on the left side of the plaintext as multiplicant can be 255.
broken by the known plaintext attack. In a recent paper, to The process of encryption and the process of decryption
overcome this drawback, Sastry et al.[6] have developed a are described by the flow charts given in Figure1.
block cipher which includes a key matrix on both the sides
of the plaintext matrix. In this analysis they have discussed
the avalanche effect and cryptanalysis, and have shown that
the cipher is a strong one.
In the present paper, our objective is to modify the Hill
Cipher by including a pair of key matrices, one on the left
side of the plaintext matrix and another one on the right
side of the plaintext matrix as multiplicants, so that the
strength of the cipher becomes highly significant. In this we
represent each character of the plaintext under consideration
in terms of EBCDIC code and use mod 256 as a
fundamental operation. Here the security of the cipher is
expected to be more as we have two keys. This is on account
of the fact that, in some untoward circumstances, though
one key is known to the hackers, other remains as a secret
one and it protects the secrecy of the cipher.
In what follows we present the plan of the paper. In
section 2, we have mentioned the development of cipher. In
section 3, we have illustrated the cipher by giving an
example and discussed the avalanche effect. Section 4 is
devoted to the cryptanalysis of the cipher. In section 5 we Figure 1. Flow Charts of the Cipher
have presented the summary of the results obtained in this
106 (IJCNS) International Journal of Computer and Network Security,
Vol. 2, No. 9, September 2010

The process of encryption, which is in the form of 4. P=C


iteration, is governed by the relations
5. Write (P)
P = (K P L) mod 256,
and P = Permute(P).
Algorithm for Inverse(K)
The process of decryption is governed by the relations,
1. Read A, n, N
C= IPermute(C ) and
// A is an n x n matrix. N is a positive integer with which
C= (K¯1 C L¯1) mod 256,
modular arithmetic
The process of permutation adopted in Permute()
is carried out. Here N= 256.
function can be described as follows.
2. Find the determinant of A. Let it be denoted by Δ,
Let us convert each element of P into its binary form.
where Δ ≠ 0.
Then we get a matrix, which can be brought to the form
3. Find the inverse of A. The inverse is given by [Aji]/ Δ,
given below:
i= 1 to n , j = 1 to n
 p111 L p118  // [Aij] are the cofactors of aij, where aij are the
 p121 O p128  elements of A
 M O M  for i = 1 to N
  {
 M O M  // Δ is relatively prime to N
 pnn1 K pnn8 if((iΔ) mod N == 1) break;
This contains m (=n2) rows and eight columns. }
Assuming that n is an even number, the above matrix is d= i;
divided into two halves. The upper half contains m/2 rows B = [dAji] mod N. // B is the modular arithmetic
and eight columns, and similarly the lower half. Then the inverse of A.
upper half is mapped into a matrix containing m rows and
four columns. In the process of mapping we start with the
last element of the upper half and place it as the first row, 3. Illustration of the cipher
first column element of a new matrix. Then we place the last Let us consider the plaintext given below.
but one element of the upper half as the element in the The Government is trying to break our unity. What wrong
second row and first column. We continue this process of we have done! we are working according to our conscience.
placing the remaining elements of the upper half, one after Unity is our Divinity. Spread this motto. (5)
another, till we get m rows and four columns of the new Let us focus of our attention on the first sixteen characters of
matrix. Then we place the elements of the lower half from the plaintext. Thus we have
the beginning to the end, such that they occupy four more The Government i (6)
columns and m rows. Thus we again get a matrix of size On using EBCDIC Code we get the plaintext matrix, P
mx8. This process of permutation is expected to thoroughly in the form
permute the binary bits of the elements. The clear picture of
this permutation can be seen later in illustration.
 227 136 133 64 
It may be noted here that IPermute() in decryption is a
199 150 165 133
P=   (7)
reverse process of Permute() used in encryption.
153 149 148 133

The algorithms for encryption and decryption can be
149 163 64 137
written as follows.
Let us now select the Key matrices K and L. Here we
take
Algorithm for Encryption
1. Read n,P,K,L,r
12 120 9 67 
2. for i = 1 to r 4 17 20 11 
{ K=   (8) and
P = (K P L) mod 256  48 99 109 75

P= Permute(P) 39 55 85 92 
}
C=P
102 20 33 45
3. Write( C ) 117 120 89 97
L=   (9)
Algorithm for Decryption  79 49 53 23

1. Read n,C,K,L,r  10 33 54 37
2. K¯1 = Inverse(K)
L¯1 = Inverse(L)
The process of permutation, included in the function
3. for i= 1 to r
Permute(), involved in the process of encryption can be
{
explained as follows. Let us express each element of P,
C = IPermute(C)
obtained in the current iteration, in its binary form. For
C = (K¯1 C L¯1) mod 256
example, in the first iteration after carrying out the
}
computation of the relation P = (KPL) mod 256, we get
(IJCNS) International Journal of Computer and Network Security, 107
Vol. 2, No. 9, September 2010

Here the first column is obtained by writing the elements


142 40 90 202 of the eighth row and then the seventh row of (11) in reverse
 250 165 54 44  order, similarly the other three columns are obtained by
P=  (10) using the sixth and fifth rows, and so on, one after the other,
 245 90 230 149  taking two rows of (11) at a time and placing the elements
187 166 40 144  in reverse order. Then the fifth column is formed by placing
the ninth and tenth rows of (11) directly in their order.
On converting each element of P, given by (10), into its Further the remaining three columns are achieved by using
binary form, and placing the binary bits of the first element the remaining six rows of (11), by taking two rows at a time,
142 in the fir st row, the binary bits of 40 in the second row and placing the elements in their order.
and so on, we rewrite P in the form of a 16x8 matrix as On converting each row of (12) into decimal form, and
shown below. Thus we have arranging the decimal numbers in a matrix of size 4x4, we
get

 78 44 207 186
 3 220 38 106
1 0 0 0 1 1 1 0 P=   (13)
0 0 1 0 1 0 0 0  7 248 146 125

0 1 0 1 1 0 1 0
  232 198 106 84 
 
1 1 0 0 1 0 1 0
1 1 1 1 1 0 1 0 This is the final result of permutation.
1 0 1 0 0 1 0 1
 On using (7 – 9), and applying the encryption
 
algorithm, given in section 2, with r=16, we get
0 0 1 1 0 1 1 0
0 0 1 0 1 1 0 0
P= 
1
(11)
1 1 1 1 0 1 0
  197 13 153 234
0 1 0 1 1 0 1 0 108 170 106 175 
1 1 1 0 0 1 1 0 C=   (14)
1 0 0 1 0 1 0 1 110 217 254 8

  195 15 104 58 
1 0 1 1 1 0 1 1
1 0 1 0 0 1 1 0 On adopting the decryption algorithm, we get back the
0 0 1 0 1 0 0 0 original plaintext given by (7).
1 
 0 0 1 0 0 0 0
Now, in order to examine the strength of the algorithm,
let us study the avalanche effect. To this end, let us modify
On adopting the permutation process described in
the plaintext (6) by changing the character G to F. The
section 2, (11) can be brought into the form of a matrix,
EBCDIC code of G and F are 199 and 198 respectively, and
containing 16 rows and eight columns, given by
they differ in one binary bit. Thus, on using the modified
0 1 0 0 1 1 1 0 plaintext and the encryption algorithm, let us compute the
0 0 1 0 1 1 0 0 corresponding ciphertext. This is given by
1 1 0 0 1 1 1 1
 
1 0 1 1 1 0 1 0  238 206 114 23 
0 0 0 0 0 0 1 1 127 135 247 32 
1 1 0 1 1 1 0 0 C =  233  (15)
216 221 177
   
0 0 1 0 0 1 1 0  17 223 251 14 
0 1 1 0 1 0 1 0
P= 
0 0 0 0 0 1 1 1
(12) On converting (14) and (15) into their binary form, we
  notice that the two ciphertexts differ by 65 bits (out of 128
1 1 1 1 1 0 0 0 bits). This shows that the cipher is a strong one.
1 0 0 1 0 0 1 0
0 1 1 1 1 1 0 1 Let us now change a number in one of the keys, say
  key, K. Here we change the third row first column element
1 1 1 0 1 0 0 0 of 8 from 48 to 49, which differ only by one binary bit. On
1 1 0 0 0 1 1 0 carrying out the process of encryption with the modified
0 1 1 0 1 0 1 0 key, keeping the other key and the original plaintext intact,
0 1 0 1 0 1 0 0
  we get the ciphertext given by
108 (IJCNS) International Journal of Computer and Network Security,
Vol. 2, No. 9, September 2010

 211 115 111 110 6. Summary of the Results


 237 18 141 17 
C=  75  (16) The avalanche effect presented in section 3 clearly indicates
133 230 180
  that the cipher is a strong one. The cryptanalysis discussed
190 121 219 150 in section 4 shows that the cipher cannot be broken by any
cryptanalytic attack.
On comparing (14) and (16), after converting them into
their binary form, we find that they differ by 69 bits (out of 6. Computations and Conclusions
128 bits). This also shows that the cipher is a potential one.
In this analysis we have written java programs
4. Cryptanalysis corresponding to the algorithms for encryption and
decryption presented in section 2.
On dividing the complete plaintext (5) into blocks,
In the literature of Cryptography, the general types of wherein each block contains 16 characters, we have adopted
attacks on a cipher are the process of the encryption. However, in the last block
1. Ciphertext only attack (brute force attack) whose length is less than 16 characters, we have appended
2. Known plaintext attack blank spaces at the end. Thus we get the ciphertext for the
3. Chosen plaintext attack entire plaintext in the form as shown below:
4. Chosen ciphertext attack
In the cipher under consideration, the keys K and L,
both put together, are containing 2n2 numbers, wherein each
number can be represented in terms of 8 binary bits. Thus 197 13 153 234 108 170 106 175 110 217 254 8 195 15 104 58 
the key space is of size 150 58 141 125 167 197 174 69 51 238 35 35 185 81 118 96 
214 142 15 230 27 88 190 113 20 245 221 19 105 124 14 224

216n2 = (210)1.6n2 ≈ 104.8n2  86 253 226 231 104 48 231 89 190 140 240 40 24 158 137 72

215
16 202 219 146 193 0 67 37 172 144 15 126 240 137 185 148

 84 
191 221 17 187 138 41 153 14 1 140 202 62 68 85 248

 64 186 
52 62 247 108 192 65 153 113 2 103 95 161 254 228 2
On assuming that the computation of the cipher with a 174 187 58 138 54 197 192 199 131 192 107 174 29 72
specified pair of values of the keys takes 10-7 seconds, the 222 106 203 119 15 138 35 213 167 38 187 132 67 228 115 129 

time required for the brute force attack is obtained as  19 47 99 229 114 138 22 168 129 152 78 38 66 117 152 108 

 104.8n 2 x10−7  The avalanche effect, discussed in section 3, and the


  cryptanalysis, performed in section 4, clearly indicate that
  = 57 x  10 4.8n 2 x10 −15 
  the cipher is a strong one. The pair of key matrices, one on
365 x 24 x 60 x 60   the left side of the plaintext and the other on the right side
of the plaintext and the process of permutation are totally
= 57 x  10
4.8n 2 −15 
 responsible for the strength of the cipher.
  This analysis can be extended to a large block of
plaintext by enhancing the size of K and L appropriately.
This shows that the time required for computation is
several years when n>=2. References:
Thus the cipher cannot be broken by the cipher text only
attack. [1] William Stallings, Cryptography and Network Security,
In the case of known plaintext attack, we have as many Principles and Practice, Third edition, Pearson, 2003.
plaintext and ciphertext pairs as we require for our attack. [2] V.U.K.Sastry, S.Udaya Kumar, A.Vinaya Babu, “ A
Here in this analysis, as the plaintext undergoes several Large Block Cipher using Modular Arithmetic Inverse
transformations on account of multiplication by the key of a Key Matrix and Mixing of the Key Matrix and the
matrices and permutation, in each round of the iteration, Plaintext”, Journal of Computer Science 2(9),pp.698-
before the plaintext becomes the ciphertext, the nonlinearity 703,2006.
involved in the process does not allow any one to break the [3] V.U.K.Sastry, V.Janaki, “A Block Cipher Using Linear
cipher. Congruences”, Journal of Computer Science 3(7),
Intuitively choosing a plaintext or a ciphertext is an pp.556-561,2007.
impossible one as the process involved in the cipher is a [4] V.U.K.Sastry, V.Janaki, “A Modified Hill Cipher with
complex one. Thus the cipher cannot be broken by chosen Multiple Keys”, International Journal of Computational
plaintext/ciphertext attack. Science, Vol.2, No.6,pp.815-826, Dec.2008.
In the light of the above discussion, we conclude that the [5] V.U.K.Sastry, D.S.R.Murthy, S. Durga Bhavani, “A
cipher is a strong one. Large Block Cipher Involving a Key Applied on Both
the Sides of the Plaintext”, Vol.2, No.2, pp.10-
13,February.

Potrebbero piacerti anche