Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ISSN:2319-7900
Abstract
1. Introduction
The efficiency of a cryptographic algorithm is based on
the time taken for encryption, decryption and the way it produces different cipher-text from a clear-text. Ganapathy and
Mani (2009) suggested an alternative approach to handling
ASCII characters in the cryptosystem, a magic square implementation (computer oriented) to enhance the efficiency
by providing add-on security to the cryptosystem. The encryption/decryption is based on numerals generated by magic square rather than ASCII values and expected to provide
another layer of security to any public key algorithms such
as RSA, EL Gamal etc. Hill ciphers experienced disadvantages in decryption because of the involvement of 2 and 13
(factors of 26). Normal magic squares/weak magic squares
of any order, n (odd, doubly-even and singly-even) involves
SUCCESSFUL IMPLEMENTATION OF THE HILL AND MAGIC SQUARE CIPHERS: A NEW DIRECTION
Step-2:
Step-3:
Step-4:
Case-1: For any odd n
Step-1: Represent the consecutive numbers 1 to n2 in n
rows and n columns.
(1 n 2 )
n ( n 2 1)
Find P =
and magic sum, S =
2
2
Step-2: Arrange the n*n matrix in basic Latin square format
to give the column sums equal.
Step-3: Select the row associated with P, assign this row as
main diagonal elements (keeping the pivot element
in the middle cell) in ascending or descending order
and arrange other (column) elements in an orderly
manner to give the desired magic square.
Case-I1: For any doubly-even n
bers,
( ) and
n2
2
Step-6:
1 and find T= n 1
Step-2: Select the column associated with these two numbers, assign this column as main diagonal elements
and arrange other (row) elements in an orderly
manner to give diagonals sums equal
Step-3: Make symmetric transformations of other elements
(retaining the diagonal elements unchanged) to
construct the extreme corner blocks and central
blocks of (2 x 2) each.
Step-4: Reverting 12 n 4 rows and columns in a systematic manner, a magic parametric constant (T) and
a set of sub-magic parametric constants are generated.
Step-5: Main adjustments should be made on the pairnumbers satisfying T, whereas minor adjustments
should be made on other elements of sub-magic parametric constants (if necessary) to get the desired
magic square for any doubly-even n.
Case-III:
Step-5:
find T = n 1
Select the column associated with these two numbers, assign it as main diagonal elements and arrange other (row) elements in an orderly manner to
make diagonal sums equal
Make symmetric transformations of other elements
(retaining the diagonal elements unchanged) to
generate extreme corner blocks and central block of
(2 x 2) each.
Reverting 12 n 4 rows and columns in a systematic manner, a magic parametric constant, T and a
set of sub-magic parametric constants are generated.
Revert one of the main diagonal elements (retaining
central block un-changed). Select a suitable central
block and assign the pair-numbers satisfying T in
selective positions. (Assigning the pair-numbers in
alternate positions with rotation 900 can provide
better results).
Main adjustments should be made on the pairnumbers satisfying T, whereas minor adjustments
should be made on other elements to get the magic
square for any singly-even n.
2.
Methodology
Magic squares (normal) of order n comprise of consecutive numbers 1 to n 2 involving the numbers 2 and 13 (factors
of 26) and therefore not suitable for encryption and decryption using modulo 26 as experienced by Hill (1929).
English alphabets consist of 26 letters (5 vowels and 21 consonants). The frequency count of the letters are as follows It
is observed that the frequency of the vowel letter E is the
highest, followed by A, O I. and U.
84
INTERNATIONAL JOURNAL OF ADVANCE COMPUTER TECHNOLOGY | VOLUME 2, NUMBER 3,
: Commonly used : AU
: Commonly used : EA, EE, EI
: Commonly used : IE
: Commonly used : OO, OU
: Commonly used : -UA
CT
10
PT
CT
11
12
13
14
15
16
17
18
19
20
21
PT
Au
Ea
Ee
Oo
Ou
CT
22
23
24
25
26
27
28
29
30
(ii) Application of a matrix or weak magic square as addon security in public key cryptosystem
To show the relevance of this work to the security of
public-key encryption scheme, a public-key cryptosystem,
RSA is taken. The private key of a user consists of two
prime p and q and an exponent (decryption key) d.
The public-key consists of the modulus n = p*q, and an exponent e such that d = e-1 mod (p-1) (q-1). To encrypt a
plaintext, M the user computes C = Me mod n and decryption
is done by calculating M = Cd mod n.
Encryption Process:
The encrypted ciphertext using the m*m matrix or weak
magic square (i) is done by using
Ciphertext(i) = {(m*m) matrix/ weak magic square}* M mod
31: denoted as CT(i).
The encrypted ciphertext, CT(i) is then applied to RSA
algorithm given above C(1) = {CT(i)}e mod n. In fact, C(i)
represents the doubly encrypted ciphertext (first using a
weak magic square and secondly using RSA algorithm) of a
message.
Decryption Process:
The applicability of Hill & magic square ciphers can be discussed in two ways
(i) Encryption/decryption with a matrix or/weak magic
square
Encryption Process:
(i)
(ii)
(iii)
(iv)
Decryption Process:
[
(v)
85
SUCCESSFUL IMPLEMENTATION OF THE HILL AND MAGIC SQUARE CIPHERS: A NEW DIRECTION
3. Examples
Construction of magic squares
Examples for constructing magic squares using basic Latin
Squares are shown separately for odd order, even order
(doubly even and singly even cases) magic squares.
( n 2 1)
2
= 5,
n ( n 2 1)
S-2:
S-3:
S=
= 15 for n=3
2
Arranging in basic Latin Square format [fig-2] gives
column totals equal
Selecting the pivot row, assigning as main diagonal
elements and rearranging column elements in an orderly manner gives the magic square (fig-3);
1
4
2
5
3
6
1
5
9
Fig-1
Example-2:
S-1:
2
6
7
8
3
4
3
4
8
1
5
9
Fig-2
6
7
2
Fig-3
(5 * 5) Magic Square
( n 2 1)
2
= 13
S-3:
Selecting the pivot row, assigning as diagonal elements and rearranging column elements in an orderly
manner gives (fig-3),
1
10
13
19
14
20
15
16
25
21
22
17
23
24
5
1
7
8
14
15
16
11
17
12
18
4
10
6
12
13
19
20
21
22
3
23
24
11
18
25
Fig-2
Fig-3
39
47
6
14
15
23
31
48 1
7
9
8
17
16 25
24 33
Fig-2
32 41
40 49
10
18
26
34
42
43
2
19
27
35
36
44
3
11
28
29
37
45
4
12
20
1
6
11
16
2
7
12
13
3
8
9
14
15
16
13
14
4
5
10
15
11
12
9
10
10 3
1 12 8 13
15
1
4
14
6
12
9
7
10
8
5
11
7
8
5
6
3
4
1
2
4 9 5 16
14 7 11 2
3
13
16
2
S=
S-2:
= 65 for n = 5
Step-3:
Step-2:
Step-3
Step-4 & 5
61
62
63
64
57
58
59
60
61
3
2
1
8
7
6
60
61
3
58
1
64
7
6
60
53
54
55
56
49
50
51
52
45
46
47
48
41
42
43
44
37
38
39
40
33
34
35
36
29
30
31
32
25
26
27
28
21
22
23
24
17
18
19
20
12
54
10
9
16
15
51
13
20
19
47
17
24
42
22
21
28
27
26
33
40
31
30
29
36
35
34
25
32
39
38
37
44
43
23
41
48
18
46
45
52
14
50
49
56
55
11
53
5
59
58
57
64
63
62
4
37
38
39
32
25
34
30
36
44
43
23
24
17
18
46
45
52
14
10
49
16
55
11
53
5
59
2
57
8
63
62
4
12
54
50
9
56
15
51
13
21
22
47
48
41
42
19
20
28
27
26
40
33
31
35
29
13
14
15
16
9
10
11
12
Step-2:
1
8
15
22
29
36
2
3
9
10
Step-1
16
17
23
24
30
25
31
32
4
11
18
19
26
33
5
12
13
20
27
34
6
7
14
21
28
35
5
6
7
8
1
2
3
4
Step-4
Step-5:
Step-6:
31
5
4
3
2
36
12
26
10
9
29
7
18
17
16
22
14
13
24
23
15
21
20
19
30
8
28
27
11
25
1
35
34
33
32
6
31
5
34
3
2
36
12
26
28
9
29
7
13
14
16
22
17
18
24
23
15
21
20
19
30
8
10
27
11
25
1
35
4
33
32
6
6
5
34
3
2
36
12
11
28
9
29
7
13
14
16
22
17
18
24
23
15
21
20
19
30
8
10
27
26
25
1
35
4
33
32
31
6
7
19
18
25
36
111
32
11
14
20
29
5
111
3
27
16
22
10
33
111
34
28
15
21
9
4
111
35
8
23
17
26
2
111
1
30
24
13
12
31
111
111
111
111
111
111
111
111
SUCCESSFUL IMPLEMENTATION OF THE HILL AND MAGIC SQUARE CIPHERS: A NEW DIRECTION
WMS-6
WMS-1
WMS-2
WMS-3
WMS-4
WMS-5
34
2
31
6
5
33
111
9
29
30
12
26
10
116
16
17
24
19
20
15
111
34
2
31
6
5
33
111
9
29
30
12
26
10
116
34
2
36
1
5
33
111
9
29
25
7
26
10
106
22
17
13
18
20
21
111
15
14
19
24
23
16
111
34
2
36
1
5
33
111
9
29
25
7
26
10
106
22
23
13
18
20
21
117
15
14
19
24
17
16
105
34
2
31
6
5
33
111
9
29
30
7
26
10
111
16
17
18
24
14
22
111
21
20
13
19
23
15
111
16
23
24
19
20
15
117
21
14
18
13
23
22
111
21
14
18
13
17
22
105
27
11
7
25
8
28
106
4
32
1
36
35
3
111
111
105
111
111
117
111
111
27
11
7
25
8
28
106
4
32
1
36
35
3
111
111
111
111
111
105
111
111
27
11
12
30
8
28
116
4
32
6
31
35
3
111
111
105
111
111
117
111
111
27
11
12
30
8
28
116
4
32
6
31
35
3
111
111
111
111
111
111
111
111
4
32
1
36
35
3
111
111
111
105
117
111
111
111
27
11
12
25
8
28
111
4. Illustrations
Illustration 1: Using 5 selected dummy letters, the message
SEA SEa corresponds to plaintext of [ 18 27]
3 7
5 12
243
Encryption: 3 7 * 18 mod31
mod31
5 12 27
414
26
represents the ciphertext, [Ao L]
11
12 7
Decryption A-1 =
5 3
12 7 26
235
Now, A-1 C =
*
mod 31
mod 31
5 3 11
97
18
1
2
2
5
4
3
7
5
1 2 3 7
* mod 31
2 5 7 30
2 4 5 17
Encryption:
118
283 mod 31
219
29
4
2
3
4
2 1
1 1
0
1
34
9
16
21
27
4
111
2
29
17
20
11
32
111
31
30
18
13
12
7
111
6 JOURNAL
1 OF
24ADVANCE
19
25COMPUTER
36
111
INTERNATIONAL
TECHNOLOGY | VOLUME 2, NUMBER 3,
5
26
14
23
8
35
111
33
10
22
15
28
3
111
2
1
0
1
1
1
* 25 mod 31
4
29
88
38
125 mod31
79
7
30
17
8
Encryption:
3
4
11
22
6 7
*
mod 31
7 30
2
17
1
5
9
188
290 mod 31
332
2
14
4
Now,A-1C =
24 25 11 2
* mod 31
7 20 2 11
29 15 16
22
565
278 mod31
575
34
22
15
27
34
16
21
27
29
23
14
11
32
29
17
14
11
32
36
25
13
19
12
31
30
24
18
18
24
30
31
12
19
13
25
36
26 WMS-Fig-A
20 17 8
35
26WMS-Fig-B
20 23 8
35
33
10
33
10
21
16
28
WMS-Fig-A
Encryption:
6
1
0 13 14
19 6
4
12 1 25
4
25
mod 31
238
138 mod 31
148
Encryption Process:
For encryption, a block of 6 (six) letters is considered as a
vector of 6 dimensions and multiplied by a 6*6 weak magic
25
29
24
A 0,
25
15
6
Decryption Process:
Decryption is done by calculating
M(1) = (WMS-Fig-A)-1 * CT(1) mod 31
M(2) = (WMS-Fig-B)-1 * CT(2) mod 31
Here,
WMS-Fig-B
32
146 311
1
407 238 266
6453
83 221 247
24
28
decryption is ensured. Now, ciphertext = [{(6*6) weak magic square}* plaintext] mod 31.
Let CT be the encrypted ciphertext of the message by
using 6*6 weak magic squares shown above.
CT(1) = [WMS-Fig-A] * [05 11 14 22 04 17] mod 31
[15 06 22 0 19 16] corresponds to the
ciphertext PGWATQ
CT(2) = [WMS-Fig-B] * [05 11 14 22 04 17] mod 31
[29 28 27 21 11 30] corresponds to
the ciphertext OO EE EAV L OU
21
A-1 =
7
22
* 2
14
15
29
A-1C = 8 25 25 * 21 mod 31
7 29 15 14
29 24 6
24
1118
913 mod
1089
31
SUCCESSFUL IMPLEMENTATION OF THE HILL AND MAGIC SQUARE CIPHERS: A NEW DIRECTION
192410 577230
90790 539190
1211 806597
Using the multiplicative inverse of 2308920 mod 31 9
mod 31 as 7 mod 31, it gives:
1227647
29730
-1
A = 1 993870
2308920 577230
548790
919393
247301
198850
431450
192410
530
190059
128412
11280
275280
0
22440
135708
214524
89400
364080
0
104160
134796
23 18
21 10
27 17
Here,
23
28
0
0
3
8
3
28
19
0
0
6
29
6
5
13
1
17
25
1
mod 31
26
8
18
14208
9768 27115
70179 16537
38322 18646
11544
7104 25450
= 15 26 4
0
4
0
30 0
14 0 26 28
2 23
18 18
6
13
30
25
28
9
82977
49566
188862
222162
136146
136035
6
8
6 mod31
22
16
[11]
6. Conclusions
The technique developed by Tomba (2012) can be used
for finding magic squares using basic Latin Squares of any
order (n 1). However, for singly-even n, the technique can
generate different weak magic squares depending upon the
choice of the central block and assignment of pair-numbers
satisfying T in different positions. Weak magic squares or
matrices of any order (non-singular) can also be used as addon device to any cryptosystem. The instruction of dummy
letters is to reduce the repetitions of vowel letters and to
make the total number of letters as 31 (prime number)
against the existing 26 letters. The process will affect ASCII
characteristics. If considered for implementation of a similar
process, a new direction for encryption and decryption will
be provided making the decryption more complicated giving
difficulties particularly to the crypt analyzers.
Acknowledgments
The authors are thankful to IJACT Journal for the support to
develop this document.
References
[1].
[2]
[3]
[4]
[5]
[6]
[7]
[8].
[9]
[10]
[12]
[13]
Biographies
Tomba received the degrees of B.Sc.Hons (Statistics)
from the University of Gauhati, Guwahati, in 1974, M.Sc
(Statistics) from the Banaras Hindu University, Varanasi in
1976 and the Ph.D.(Mathematics) from the Manipur University, Imphal 1992, respectively. Currently, he is working as
Associate Professor in the Department of Mathematics, Manipur University. His research interest includes mathematical
modeling, operations research, probability theory, population studies and cryptography.
Shibiraj received the degrees of M.Sc..(Mathematics)
from the University of Banglore, Banglore in 2007 and currently a research scholar in Mathematics in CMJ university,
Meghalaya.
.
91
SUCCESSFUL IMPLEMENTATION OF THE HILL AND MAGIC SQUARE CIPHERS: A NEW DIRECTION