ISAA Final Report

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

Encryption of text and images using the

Advanced Encryption Standard


Rithvik Shankar Moksheswara Reddy Sai Anirudh Guduru
19BCE0755 19BCT0156 19BCE0562

A report submitted for the J component of

CSE3501 – INFORMATION SECURITY ANALYSIS AND AUDIT

Supervisor: Dr. Amutha Prabakar M

School of Computer Science and Engineering


Vellore institute of Technology, Vellore

Fall Semester 2021 - 2022


Table of Contents
Abstract ............................................................................................................................................ 3

Objective .......................................................................................................................................... 3

Chapter 1: Literature Survey...................................................................................................... 3

Chapter 2: System Architecture ................................................................................................. 7

Chapter 3: Methodology ............................................................................................................ 7

3.1 Bit Permutation .......................................................................................................................... 8

3.2 Inverse Bit permutation .............................................................................................................. 9

3.3 Explanation of modules............................................................................................................ 10

Chapter 4: Results and Discussions……………………………………………….…………. 15

4.1 Output and Implementation ...................................................................................................... 15

4.2 Source Code ............................................................................................................................. 21

Chapter 5: Conclusion ............................................................................................................. 21

References ..................................................................................................................................... 21

Bibliography ................................................................................................................................. 22

Page 2
Abstract
Advanced Encryption Standard (AES) algorithm is one on the most common and widely used
symmetric block cipher algorithms. This algorithm is used to encrypt and decrypt sensitive data and is
applied at the hardware and software level all over the world. It is extremely difficult for hackers to
retrieve the original data when encrypted using the AES algorithm. AES can handle three different key
sizes - 128, 192 and 256 bit, and each of these ciphers have a 128 bit block size. The project implements
the AES algorithm and our objective is to design a tool to encrypt text and images.

Objective
In our project, we aim to create an encryption and decryption tool that takes images or text files and
performs AES encryption/decryption on them. Our implementation of AES is slightly different from
existing methods. The tool also sends the encrypted file to the user’s email.

1. Literature survey

Author Date Title Abstract Methodology Link


Priya 2016 An image In this paper they The implementation of [1]
Deshmukh encryption and give an image as the AES-128
decryption using input to the AES encryption and
AES algorithm encryption decryption algorithm is
algorithm which performed, in which the
gives the encrypted input is an image and
output. It is given the key is in
as input to the AES hexadecimal format.
decryption The output is the same
algorithm and the as that of the input
original image is image. For encryption
regained as the process, first divide the
output. This is image and make it into
implemented using a 4*4 matrix. The
MATLAB. number of rounds is
calculated based on the
key size and expand the
key using the key
schedule. (n-1) rounds
are performed which
are substitute bytes,
shift rows, mix columns
and add round key. The
final round does not
have the mix columns
operation.
Heidilyn May Modified AES for In this paper, the The paper used bit [2]
V. Gamido 2018 Text and Image AES algorithm is permutation to replace
, Ariel M. Encryption modified to remove the MixColumns
Sison, Ruji the MixColumns Transformation of AES
P. Medina operation and to improve the
replace it with bit efficiency of AES. The
permutation due to paper compared the
its high performance of the
computational standard and modified
requirement. AES algorithm by
Results of this encrypting text files and

Page 3
study show that the images. The two
modified AES algorithms were
increases evaluated based on their
efficiency and has encryption time, CPU
higher avalanche usage and avalanche
effect. effect. Based on the
results, the modified
AES has increased the
efficiency of the
standard AES as it has
faster encryption time
in text files and images.
M. 2012 Implementation of In this paper, AES The AES encryption [3]
Pitchaiah, Advanced encryption and algorithm is used in
Philemon Encryption Decryption (128 wireless security which
Daniel, Standard bit) by using is required in military
Praveen Algorithm Rijndael algorithm communication and
has been designed mobile telephony where
as synthesizable there is an emphasis on
Verilog code which the speed and integrity
can be used with of communication.
FPGA readily. The
cipher converts the
data to an
unreadable form.
The Key
Expansion
algorithm
generates a key
schedule which is
used in making the
cipher and inverse
cipher. The cipher
and inverse cipher
consist of a specific
number of rounds.
In the AES
algorithm, no. of
rounds that are
performed during
the running of the
algorithm uses a
round function that
is composed of four
different types of
transformations.
Dr. N. Suba July, An Image In this paper, an The proposed work uses [4]
Rani, Dr. 2019 Encryption & image encryption the AES algorithm to
A. Noble Decryption And and decryption encrypt and decrypt
Mary Comparison With algorithm using images and text. A 128
Juliet, K. Text - AES AES was proposed. bit key is used for
Renuka Algorithm The encryption has encryption which in
Devi a random image turn makes it more
and decryption secure and faster than
returns the original DES. Since the key size

Page 4
image. The is larger, it aids in
algorithm is written overcoming many types
in Java. Its of attacks like brute
efficiency is force and man in the
compared using middle attacks. The
image and text. The proposed system makes
result shows that it such that the
sharing encryption image
information doesn’t remain the same
through images is and is chosen at
much more secure random. Thus, AES
when compared to algorithm is suited for
sharing it as text. image encryption.
Rahul Nov RK-AES: An In this paper, the The proposed RK-AES [5]
Saha, G. 2018 Improved Version reasons of the is more efficient in
Geetha, of AES Using a loopholes in AES terms of cryptographic
Gulshan New Key have been shown. algorithms. Also, AES
Kumar, Generation Also, a solution by uses a single key for
Tai-hoon Process with using a Symmetric both encryption and
Kim Random Keys Random Function decryption. The round
Generator has been keys are stored
provided. separately as each
Randomness has round key is generated
been used in the at random and is used
key generation for decryption
process in the block respectively.
cipher. The results
have been
compared with the
original AES by
comparing
parameters such as
nonlinearity,
resiliency,
balancedness,
propagation
characteristics, and
immunity.
Ako June Advanced This paper This paper explains a [6]
Muhamad 2017 Encryption provides an number of important
Abdullah Standard (AES) overview of the features of the AES
Algorithm to AES algorithm and algorithm and presents
Encrypt and explains several previous research that
Decrypt Data important features has been done on it. The
of the algorithm in AES algorithm’s ability
detail. It to encrypt data under
demonstrates different parameters has
research that has been evaluated.
been done by
comparing it to
algorithms like
Blowfish, DES,
3DES, etc.

Page 5
Nishtha 2016 AES Based Text This paper An improved AES [7]
Mathur, Encryption Using proposed a algorithm is utilised to
Rajesh 12 Rounds with combination of encrypt the plain text.
Bansode Dynamic Key AES and ECC. The The ECC algorithm is
Selection results have been used to encrypt the AES
calculated based on key thus increasing the
AES key’s length security of the system.
as 128 bit and the This is done by using
number of software-based
iterations equal to countermeasures to
10. To increase remove vulnerabilities
effectiveness and which are presented by
to decrease the timing side channel
drawbacks, this attacks.
paper proposed a
hybrid encryption
scheme. The
parameters that are
studied mainly
focus on key
length, number of
iterations and the
type of side
channel attacks to
be utilised. The key
length used has
been increased to
192 bits and the
number of
iterations is taken
as 12.
*More papers had been surveyed and their links have been added below

Page 6
2. System Architecture

Figure 2.1: Architecture Diagram

3. Methodology
The tool first asks the user whether they would like to encrypt or decrypt a file. They can then choose
to operate on either an image or a text file. Now the user can enter the file to be encrypted/decrypted.
The tool then performs encryption or decryption to the file. In the case of encryption, the tool sends the
encrypted file to the user’s desired email address. The receiver can then download the encrypted file
and run it through the tool. It decrypts the file which can be accessed by the user.

Figure 3.1: Modified AES

Page 7
3.1.Bit permutation
We start with a 4x4 matrix with values between 0 and 255

A B C D
E F G H
I J K L
M N O P

We take one column and convert the values to 8-bit binary and form a 4x8 matrix
8-BIT BINARY
A 00 01 02 03 04 05 06 07
E 10 11 12 13 14 15 16 17
I 20 21 22 23 24 25 26 27
M 30 31 32 33 34 35 36 37

We break up the columns into four 4x2 blocks


BLOCK BLOCK BLOCK BLOCK
0 1 2 3
00 01 02 03 04 05 06 07
10 11 12 13 14 15 16 17
20 21 22 23 24 25 26 27
30 31 32 33 34 35 36 37

We transpose the blocks

We concatenate the 1st and 2nd rows of each block to get the 8-bit binary values of the first column. This
process is repeated for the remaining columns.

A’ 00 10 20 30 01 11 21 31
E’ 02 12 22 32 03 13 23 33
I’ 04 14 24 34 05 15 25 35
M’ 06 16 26 36 07 17 27 37

Page 8
Code for the bit permutation function

Figure 3.1.1: Bit Permutation

3.2.Inverse bit permutation


We start with a 4x4 matrix with values between 0 and 255

A B C D
E F G H
I J K L
M N O P

We calculate the 8-bit binary values of one row and convert it to a 1x32 matrix
8-BIT BINARY 8-BIT BINARY
A 0 1 2 3 4 5 6 7 B 8 9 10 11 12 13 14 15
C 16 17 18 19 20 21 22 23 D 24 25 26 27 28 29 30 31

We break it up into eight blocks of 1x4 matrices and transpose them to eight 4x1 matrices. We
concatenate the respective elements of each block to get the required 8 bit values of the first row. This
process is repeated for the remaining rows.
BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK BLOCK
0 1 2 3 4 5 6 7
A’ 0 4 8 12 16 20 24 28
B’ 1 5 9 13 17 21 25 29
C’ 2 6 10 14 18 22 26 30
D’ 3 7 11 15 19 23 27 31

Page 9
Code for the inverse bit permutation function

Figure 3.2.1: Inverse Bit Permutation

3.3. Explanation of modules and variables

The sub box and the inverse sub box is predefined in the code

Figure 3.3.1: Sub Box and Inverse Sub Box

Page 10
Function to calculate sub bytes and inverse sub bytes

Figure 3.3.2: subBytes and invSubBytes Functions

Function for shift rows and inverse shift rows

Figure 3.3.3: shiftRows and invShiftRows Functions

Function to add round keys

Figure 3.3.4: addRoundKey Function

Function to calculate 8 bit binary string of decimal number

Figure 3.3.5: to8bitBinary Function

Page 11
The functions permutate(arrs) and inpermutate(arrs) for bit permutation and inverse
bit permutation respectively

Figure 3.3.6: permutate Function

Figure 3.3.7: inpermutate Function

Bytes to matrix and matrix to bytes function

Figure 3.3.8: bytesToMatrix and matrixToBytes Functions

Page 12
Some additional functions that operate on the bytes

Figure 3.3.9: Functions that operate on bytes

Menu of the program

Figure 3.3.10: Main Function

Page 13
Figure 3.3.11: Main Function Continued

Code to send the encrypted file via email

Figure 3.3.12: Code to Mail Encrypted File

Page 14
Decryption part

Figure 3.3.13: Decryption of Encrypted File

4. Results
4.1. Output
Text file
Sample text

Figure 4.1.1: sample.txt

Page 15
Encrypting the text file

Figure 4.1.2: Encrypting Process of sample.txt

Email received by user

Figure 4.1.3: Email Received

Contents of the email

Figure 4.1.4: Contents of the Email Received

Page 16
The encrypted file sent as an attachment

Figure 4.1.5: Encrypted File received

Decrypting the encrypted file

Figure 4.1.6: Decryption Process

Page 17
Decrypted file

Figure 4.1.7: output.txt

Image

Sample image

Figure 4.1.8: sample.jpg

Page 18
Encrypting the file

Figure 4.1.9: Process to Encrypt Image

Email received by the user

Figure 4.1.10: Email Received

Contents of the mail

Figure 4.1.11: Contents of Email

Page 19
Encrypted file sent as an attachment

Figure 4.1.12: Encrypted File Received

Decrypting the encrypted file

Figure 4.1.13: Decryption Process

Page 20
Decrypted file

Figure 4.1.14: output.jpeg

Image source: https://www.readersdigest.ca/home-garden/pets/6-things-know-owning-puppy/

4.2. Source code and required files:


https://drive.google.com/drive/folders/17KIPNGkiCtXd2zxLMWgI0KKtPdRMpKsD?usp=sharing

5. Conclusion
We have successfully designed an AES encryption/decryption tool using bit permutation. The program
is able to send the encrypted file (text or image) to the user’s desired email address. It is also able to
autodetect the file type and decrypt it accordingly.

References

[1] Priya Deshmukh, “An image encryption and decryption using AES algorithm”
[2] Heidilyn V. Gamido , Ariel M. Sison, Ruji P. Medina, “Modified AES for Text and Image
Encryption”
[3] M. Pitchaiah, Philemon, Daniel, Praveen “Implementation of Advanced Encryption Standard
Algorithm”
[4] Dr. N. Suba Rani, Dr. A. Noble Mary Juliet, K. Renuka Devi, “An Image Encryption &
Decryption And Comparison With Text - AES Algorithm”
[5] Rahul Saha, G. Geetha, Gulshan Kumar, Tai-hoon Kim, “RK-AES: An Improved Version of
AES Using a New Key Generation Process with Random Keys”
[6] Ako Muhamad Abdullah, “Advanced Encryption Standard (AES) Algorithm to Encrypt and
Decrypt Data”

Page 21
[7] Nishtha Mathur, Rajesh Bansode, “AES Based Text Encryption Using 12 Rounds with
Dynamic Key Selection”
[8] William Stallings, “Advance Encryption Standard,” in Cryptography and Network Security,
4th Ed., India:PEARSON

Bibliography

[1] http://www.ijlret.com/Papers/Vol-2-issue-5/11-B2016268.pdf
[2] https://core.ac.uk/download/pdf/235221236.pdf
[3] https://publications.waset.org/7580/pdf
[4] https://ieeexplore.ieee.org/document/1030726
[5] https://www.ijrte.org/wp-content/uploads/papers/v8i5/E6475018520.pdf
[6] https://www.ijert.org/research/performance-analysis-of-aes-cryptographic-algorithm-
IJERTCONV3IS27014.pdf
[7] https://link.springer.com/chapter/10.1007/978-3-642-35326-0_51
[8] https://link.springer.com/chapter/10.1007/978-3-540-74735-2_15
[9] http://ijcsit.com/docs/Volume%205/vol5issue05/ijcsit20140505184.pdf
[10] https://ieeexplore.ieee.org/document/8729488
[11] https://www.irjet.net/archives/V7/i4/IRJET-V7I4272.pdf
[12] https://globaljournals.org/GJCST_Volume13/4-A-Study-of-Encryption-Algorithms.pdf
[13] https://www.researchgate.net/publication/320631771_Digital_Image_Encryption_Impleme
ntations_Based_on_AES_Algorithm

Page 22

You might also like