MATLAB-Simulink Implementation of AES Algorithm For Image Transfer

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Middle-East Journal of Scientific Research 18 (12): 1709-1712, 2013

ISSN 1990-9233
IDOSI Publications, 2013
DOI: 10.5829/idosi.mejsr.2013.18.12.1003

MATLAB-Simulink Implementation of
AES Algorithm for Image Transfer
1
T. Saravanan, 1V. Srinivasan and 2R.Udayakumar

1
Deparment of ETC, Bharath University, Chennai, India
2
Department of IT, Bharath University, Chennai, India

Abstract: The best-known problem in the aspect of providing end-to-end secure communication is providing
Confidentiality, i.e. preventing the unauthorized from extraction of information over an insecure channel to
ensure privacy. Thus the use of the internet has fostered new interest in Cryptography. This paper presents
a challenging task of transferring the image to the destination with high confidentiality. The algorithm used is
Rijndael -128 which was approved as an Advanced Encryption Standard (AES). The proposed paper involves
design and simulation of AES-128 algorithm in MATLAB, which is perfectly suited for the matrix based data
structure of Rijndael algorithm. An AES encryptor is designed and implemented in MATLAB. An AES
decryptor is also designed and integrated with the AES encryptor to yield a full functional AES en/decryptor.
This algorithm is more applicable for security of complex imaging problems in disciplines such as aerospace and
defense, remote sensing, medical and scientific imaging.

Key words: Cipher Plaindata Cipherdata, Inverse Cipher, Key Expansion, Round Key, State Matrix.

INTRODUCTION This matrix is known as the State matrix. The conversion


from plain text to State Matrix is shown in Fig 1.
Depending on type of organization, information is of The original 128-bit key is also divided in to 16 bytes as
different categories. Organizations involved in design like 128 bit data and are also arranged in the form of 4*4
have to protect their design documents as the intellectual matrix. This conversion to KeyMatrix is shown in Fig. 2.
property developed is very precious [1]. Organizations Both these matrices forms the necessary inputs to the
involved in services have to protect information of algorithm. The structure of AES encryption is shown in
clients. There are several ways to guarantee the operation Fig. 3.
of these systems with security services like AES encryption includes an initial round (0), nine
Confidentiality, Authentication and Integration these are general rounds (1 to 9) and a final round (10). In round
achieved by Cryptography. One such scheme which helps Zero the two matrices are simply X-Ored under
in secured data transaction is Advanced Encryption AddRoundKey transformation [3]. The output of Round
Standard (AES). 0 is given as the input to the Round 1. Any general round
is composed of four distinct uniform and invertible
Aes Description: The AES-128 is a block oriented transformations: SubBytes, ShiftRows, MixColumn and
symmetric key encryption algorithm, which operates on a AddRoundKey. The final round is same as general round
128-bit plain data at a time and uses a 128-bit length key except that MixColumn is omitted. Each of the cipher
[2]. A data block to be processed is partitioned into an operations is byte-oriented The sub keys needed for all
array of bytes (group of 8 bits). Such bytes are interpreted the rounds from Round1 to Round 10 are derived from the
as finite field elements using polynomial representation. original 128-bit key provided. After finishing all the ten
The 128-bit data block of the input is divided into 16 rounds the output is 128 bits, which is the encrypted
bytes and then arranged into a 4*4 matrix (column wise). output [4].

Corresponding Author: T. Saravanan, Department of ETC, Bharath University, Chennai, India.

1709
Middle-East J. Sci. Res., 18 (12): 1709-1712, 2013

Fig. 1: Input data converted to state matrix Fig. 2: Initial key converted to Key matrix

Fig. 3: Structure of AES Encryption

Fig. 4: SubBytes Transformation Fig. 5. ShiftRows Transformation

Each Round Description in Encryption Process: matrix shifting cyclically a certain number of bytes (Fig. 5).
SubBytes is a non-linear byte substitution operation The first row is left unchanged. The second row is left
designed to give the required amount of Confusion. It rotated by one byte, third row by two bytes and fourth
operates independently on each byte of the State matrix row by three bytes.
using a substitution table S-box (Fig. 4). To avoid attacks
based on simple algebraic properties, the S-box is Mix Column: Is a mixing operation designed to give the
constructed by combining the inverse function with an required amount of Intra-Word Diffusion. It operates on
invertible affine transformation [5-9]. each column of the State matrix individually, combining
the four bytes in each column using multiplications and
Shift Rows is a transposition step designed to give the additions in GF(28). Here matrix multiplication is done in
required amount of Inter-Word Diffusion. It operates which the new column is the product of the old column
individually on each of the last three rows of State and a constant matrix as shown below (Fig. 6).

1710
Middle-East J. Sci. Res., 18 (12): 1709-1712, 2013

Fig. 6: MixColumn Transformation Fig. 7: Key Expansion Process

Add Round Key: Is designed to provide Key Dependency Implementation of Aes Using Matlab: The image file taken
and Asymmetry. It operates independently on each byte for this paper is the gray level image file. MATLAB stores
of the State matrix by adding it with the corresponding gray images as two-dimensional arrays (i.e., matrices), in
byte of the Subkey using bitwise XOR. For each round, a which each element of the matrix corresponds to a single
Subkey is derived from the main key using the pixel in the displayed image. For example, an image
keyexpansion function. Each subkey has the same size as composed of 200 rows and 300 columns of different
the state matrix. intensity dots would be stored in MATLAB as a 200-by-
300 matrix. The Pixel values lies with in 0 to 255 and can be
Key Expansion: The key expansion function takes the represented by 8-bits i.e. one Byte. In this paper, three
user supplied 16 bytes long key and utilizes the round image files of sizes 120*160 pixels, 256*256 pixels and,
constant matrix rcon and the substitution table Sbox to 336*412 pixels are considered before encryption, after
generate a 176 byte long key schedule ek, which will be encryption and after decryption.
used during the encryption and decryption processes.
The 16 bytes of the key vector are rearranged (row-wise) Inialization Module: Here each round operation of AES is
into a 4 4 initial key matrix (k11 . . . k44). The basic done in modules. Before doing any actual en- or
principle of the KeyExpansion (Fig. 7) is an element-wise decryption, the initialization module initial (Fig.8) has to
XOR--sum of two rows, the direct predecessor row and be called once. This module generates the substitution
the row four rows up. The seventh row (k71 . . . k74) e. g. tables Sbox by a call to sbox_gen, defines the round
results from XORing the sixth row (k61 . . . k64) and the constant vector rcon and original key and computes the
third row (k31 . . . k34). Additionally every fourth row expanded key schedule ek . Additionally the two
(row 5, row 9 . . .) is created differently. The predecessor polynomial matrices that are used in MixColumn matrix are
row is rotated, substituted and XORed with also generated.
its corresponding round constant before applying the
XOR. Image Encryption Module: Main program module is
ImageEncryption (Fig. 8 ). This module takes the input as
Decryption Algorithm: Decryption is the process in image file, encrypts it and stores the encrypted image to
which the encrypted data is converted back to its original another file.The initialization step supplies the actual
form. The encryption structure in Fig. 3 can be inverted to encryption module(cipher) with the expanded key ek, the
get a straightforward structure for decryption. substitution tables sbox and inv_sbox and the polynomial
Corresponding to the transformations in the encryption, matrices mix_col_mat and inv_mix_col_mat. It then
InvSubBytes, InvShiftRows, InvMixColumns and receives the image file and the private key from the user,
AddRoundKey are the transformations used in the reads the image file and calculates its size( rows and
decryption. AddRoundKey is its own inverse, so the columns) so as to find the total number of pixels in an
same name is used. The round keys used are same as image. The image is then converted into a new matrix by
those in encryption generated by Key Expansion, but are rearranging each distinct 4-by-4 block of pixels in the
used in reverse order. image f into a column of b. Thus the number of 128 bit

1711
Middle-East J. Sci. Res., 18 (12): 1709-1712, 2013

Table 1: Performance of AES - Rijndael in Software REFERENCES


File Size (pixels) Encryption Time(seconds) Decryption Time(seconds)
120*160 50.125 57.266 1. Daemen, J. and V. Rijmen, AES Proposal: Rijndael, in
256*256 115.703 154.032
http://csrc.nist.gov/encryption/aes/
336*412 214.047 293.125
2. NIST - FIPS Standard, n.197, 2001, November 26,
Announcing the ADVANCED ENCRYPTION
blocks to be encrypted becomes the number of columns STANDARD (AES), in Federal Information
in matrix b. Now each column is independently received
Processing Standards Publication.
and encrypted by another module called cipher. 3. Jif org J. Buchholz, 2001. December 19, Matlab
Implementation of the Advanced Encryption
Performance Analysis: In this paper, three image files of Standard, in http://buchholz.hs-bremen.de
sizes 120*160 pixels, 256*256 pixels and, 336*412 pixels
4. Rafel C. Gonzalez, Richard E. Woods and Steven L.
are considered before encryption, after encryption and Eddins, 2004. Digital image processing using Matlab,
after decryption. The corresponding encryption and
Pearson Education, Delhi, India Neal Koblitz, A
decryption times are shown in Table 1. It shows that the Course in Number Theory and Cryptography, Second
encryption/decryption times increases with increase in file
Edition, Springer.
size. 5. Sibghatullah Nasir, 2013. Microfinance in India
Contemporary Issues and Challenges. Middle-East
Performance Analysis: In this paper, three image files of Journal of Scientific Research, 15(2): 191-199.
sizes 120*160 pixels, 256*256 pixels and, 336*412 pixels
6. Mueen Uddin, Asadullah Shah, Raed Alsaqour and
are considered before encryption, after encryption and Jamshed Memon, 2013. Measuring Efficiency of Tier
after decryption. The corresponding encryption and
Level Data Centers to Implement Green Energy
decryption times are shown in Table.1. It shows that the Efficient Data Centers, Middle-East Journal of
encryption/decryption times increases with increase in file
Scientific Research, 15(2): 200-207.
size. 7. Hossein Berenjeian Tabrizi, Ali Abbasi and Hajar
Jahadian Sarvestani, 2013. Comparing the Static and
RESULTS Dynamic Balances and Their Relationship with the
Anthropometrical Characteristics in the Athletes of
In this paper AES-128 algorithm is designed and Selected Sports, Middle-East Journal of Scientific
implemented in MATLAB for image encryption. An
Research, 15(2): 216-221.
exactly reverse procedure is followed to retrieve the 8. Anatoliy Viktorovich Molodchik, 2013.
original image at receiver. Fig. 10. shows a 256*256 pixel
Leadership Development. A Case of a Russian
X-Ray image before encryption, after encryption and after Business School, Middle-East Journal of Scientific
decryption. The image files i.e. before encryption and after
Research, 15(2): 222-228.
decryption are tested for one to one correspondence. 9. Meruert Kylyshbaevna Bissenova and Ermek
This algorithm is tested under Windows-XP operating
Talantuly Nurmaganbet, 2013. The Notion of Guilt
system with the system configuration as 1.8 GHz and Problems of Legislative Regulations of its
processor speed, 512 MB RAM. The speed of the
Forms. The Notion of Guilt in the Criminal Law of
operation of the code can be effectively increased by Kazakstan, Middle-East Journal of Scientific
loading the software on a highly configured system It
Research, 15(2): 229-236.
should be noted that performance cannot be classified by
word size alone.

CONCLUSION

The performance of AES or any other encryption


algorithm depends on a particular high-level language
used (like assembler, compiler or interpreter). C and
Hand-coded assembly code will generally produce better
performance results. The main advantage of implementing
with Matlab is the understandability, more than speed of
execution.

1712

You might also like