You are on page 1of 24

An 8086 implementation of AES 128

Algorithm
PROJECT REPORT
For
Microprocessor and Interfacing (CSE2006)

Submitted By

Name Registration Number


M S Samyukhtha 19BCE0949
Saransh Dabas 19BCE0966
Nevin Hardy Koshy 18BCI0242
Rohan Pon Surya M 19BCE0254

Under the guidance of

Dr .Manish Kumar

SCHOOL OF COMPUTER SCIENCE AND ENGINEERING

November,2021
Table of Contents
Content Page Number
Abstract 3
Introduction 3
Objective 4
Literature Survey 4
Flowchart 7
Algorithm 9
Software Components 9
Output Screenshots 11
Code 14
Conclusion 25
References 25
• Abstract
Cryptography is a term used in computer science to describe the secure
information and communication systems used in mathematical concepts and a set
of legal statistics known as algorithms to transform communication in ways that
are difficult to explain. The Emu8086, Intel 8086 (compatible with AMD)
microprocessor emulator with integrated 8086 assembler and introductory scholars,
was used as a device. The emulator runs programs step by step, like a real CPU.
We are using emu8086 for this project to create a cryptography tool that can
encrypt and decrypt your favorite message.

• Introduction
Cryptography can be found almost anywhere. It has evolved into an integrated
defense platform for all digital transformation activities, now known as the digital
business. Cryptography is used to protect transactions and communications, to
protect personal information (PII) and other confidential information, to prove your
identity, to prevent document fraud, and to build trust between servers as a basis
for modern security systems. Cryptography is one of the most important strategies
used by businesses to protect systems that contain their valuable assets - data -
whether on the go or at rest.

As a result, it is important to understand how cryptography can be done using the


various resources we receive. Emu8086 is the utility used in this project. The
Emu8086 is a debugger software (PC PC) with a powerful source, compiler, and
disassembler, as well as step-by-step tutorials. This program is most beneficial for
people who have just learned the language of assembly. Compiles the source code
and applies it to the template step by step.The visual interface is easy to use. While
your system is running, you can view registers, flags, and memory. The Arithmetic
and Logical Unit (ALU) shows the internal functions of the central processing unit
(CPU). Emulator uses programs on a Virtual PC, preventing them from accessing
real hardware such as hard drives and RAM. This project explores the
cryptography sector using an 8086 microprocessor.
• Objective
Our aim in this project is to learn and use the AES-128 algorithm method, the
equivalent encryption method and to decrypt messages in microprocessor 8086.
We look forward to successfully building this system so that no input restrictions
are applied, and we have made the system more efficient by reducing the time
involved in creating and validating results.

• Literature Survey

Title Author, Year Journal Findings

FPGA Guzmán et al., Dyna, vol. 83, no. Comparisons of


implementation 2016 198, pp. 37-43, how the methods
of AES-128 2016 Universidad are performed
algorithm in non- Nacional de have shown that
response systems Colombia the CTR mode has
more important
advantages than
the ECB mode,
such as safety
level. This is
because the
encrypted blocks
in CTR mode are
always different.
Highly Effective Bilgin et al., 2014 Springer It is shown that
AES Threshold International the
Implementation implementation
resists the first
state-of-the-art
attack with 10
million tracks in
strictly pro-enemy
situations (No
algorithmic noise
from PRNG,
startup
information, slow
and reliable clock,
and large
measurements
take place. ).

Design and use Paul et al., 2012 ResearchGate The goal of this
real-time AES- proposed structure
128 in real-time is to provide real-
FPGA multi- time data
network communications
operating system while maintaining
a high level of
security and, if
appropriate,
providing faster
processing time.
The key used in
our test has a
minimum length
of 128 bits, and
the result is good.
Design of Mondal et al., ACM Journal The proposed
Functional 2020 design and
Structures for implementation
AES-128 requires minimal
Algorithm in calculation
Embedded resources, making
Systems them suitable for
embedded systems
with limited
resources and
power. The
proposed parallel
and pipeline
structure achieves
the maximum
performance and
minimum delay
desired in real-
time systems.

Advanced Abdullah et al., ResearchGate In this paper, it


Encryption 2017 outlines many key
Standard (AES) features of the
Algorithm for AES algorithm
encrypting and and presents
decryption of previous research
data conducted on it to
evaluate the
effectiveness of
AES encryption
data under
different
parameters.
According to the
results of the
study it shows that
AES has the
ability to provide
more security
compared to other
algorithms such as
DES, 3DES etc.

• Flowchart

Fig i-AES Encryption


Fig ii- AES Decryption

Fig iii-Work Flowchart


• Algorithm
When the encryption key is 128 bits long, the number of rounds is the input state
array is XORed with the first four words of the key schedule before any round-
based encryption processing can occur. During decryption, the same thing happens,
but we now XOR the ciphertext state array with the last four words of the key
schedule. Each round, also known as encryption, consists of the four processes
below: 1) Substitute bytes, 2) Shift rows, 3) Mix columns, and 4) Add a round key.
The output of the preceding three phases is XORed with four words from the key
schedule in the last step. Each cycle of decryption consists of the following four
steps: 1) Inverse shift rows, 2) Inverse Substitute bytes, 3) Add a round key, and 4)
Inverse mix columns. The output of the previous two phases is XORed with four
words from the key schedule in the third step. The order in which substitution and
shifting operations are performed in a decryption round differs from the order in
which equivalent operations are performed in an encryption round. The last round
of encryption doesn’t make use of the “Mix Column” step. The "Inverse mix
columns" step is skipped in the last phase of decryption.

• Software Components

➢ Windows 10
➢ Emu8086-8086 Microprocessor Emulator, often known as EMU8086, is a
microprocessor emulator for the 8086 software. It has a built-in 8086
assembler for development. On both PC desktops and laptops, this
application may run apps. This program's main purpose is to replicate or
simulate hardware.
• Output Screenshots
• Code
.model small

org 100h
.data
; name type initializer
sum DW 0
delta DW 02ACh
v0 DW ?
v1 DW ?
k0 DW ?
k1 DW ?
k2 DW ?
k3 DW ?
msgV DB 'Please enter the input string of 4 characters: $'
msgK DB 0Dh,0Ah,'Please enter thekey of 4 characters : $'
encrypting DB 0Dh,0Ah,'Encrypting... $'
decrypting DB 0Dh,0Ah,'Decrypting... $'
encryptedMsg DB 0Dh,0Ah,'Encrypted text: $'
decryptedMsg DB 0Dh,0Ah,'Decrypted text again: $'

; DB 8-bit integer
; DW 16-bit integer
; DD 32-bit integer or real
; DQ 64-bit integer or real
; DT 80-bit integer (10 byte)

.code

main proc

mov ah, 09h ; from dx the string is written


lea dx, msgV ; load effective address is given by lea
int 21h ; the do it interrupt

; reading v0
mov ah, 01h
int 21h
mov bh, al
int 21h
mov bl, al
mov v0, bx

; reading v1
mov ah, 01h
int 21h
mov bh, al
int 21h
mov bl, al
mov v1, bx

; "Enter password of 4 character keys: "


mov ah, 09h
lea dx, msgK
int 21h

; k[0] read
mov ah, 01h
int 21h
xor bx, bx
mov bl, al
mov k0, bx

mov ah, 01h


int 21h
xor bx, bx
mov bl, al
mov k1, bx

mov ah, 01h


int 21h
xor bx, bx
mov bl, al
mov k2, bx

mov ah, 01h


int 21h
xor bx, bx
mov bl, al
mov k3, bx

mov ah, 09h


mov dx, offset encrypting
int 21h

call encrypt

mov ah, 09h


mov dx, offset encryptedMsg
int 21h

mov ah, 02h


mov bx, v0
mov dl, bh
int 21h
mov dl, bl
int 21h

mov bx, v1
mov dl, bh
int 21h
mov dl, bl
int 21h

mov ah, 09h


mov dx, offset decrypting
int 21h

call decrypt

mov ah, 09h


mov dx, offset decryptedMsg
int 21h
mov ah, 02h

mov bx, v0
mov dl, bh
int 21h
mov dl, bl
int 21h

mov bx, v1
mov dl, bh
int 21h
mov dl, bl
int 21h

mov ah, 4ch


int 21h

endp

; ============================================== encryption
procedure of the code
============================================== ;
encrypt proc
mov cx, 8 ; loop instruction counter

encLoop:

mov bx, delta


mov ax, sum
add ax, bx
mov sum, ax

mov ax, v1
shl ax, 4
mov bx, k0
add ax, bx
mov dx, ax

mov ax, v1
mov bx, sum
add ax, bx
xor dx, ax

mov ax, v1
shr ax, 5
mov bx, k1
add ax, bx
xor dx, ax

mov ax, v0
add ax, dx
mov v0, ax

mov ax, v0
shl ax, 4
mov bx, k2
add ax, bx
mov dx, ax

mov ax, v0
mov bx, sum
add ax, bx
xor dx, ax

mov ax, v0
shr ax, 5
mov bx, k3
add ax, bx
xor dx, ax
mov ax, v1
add ax, dx
mov v1, ax

loop encLoop ; cx used by loop as counter

ret
encrypt endp
; ============================================= END of code's
encryption proedure
============================================= ;
; ============================================== decryption
procedure of code ==============================================
;
decrypt proc

mov cx, 8

decLoop:

mov ax, v0
shl ax, 4
mov bx, k2
add ax, bx
mov dx, ax
mov ax, v0
mov bx, sum
add ax, bx
xor dx, ax

mov ax, v0
shr ax, 5
mov bx, k3
add ax, bx
xor dx, ax

mov ax, v1
sub ax, dx
mov v1, ax

mov ax, v1
shl ax, 4
mov bx, k0
add ax, bx
mov dx, ax

mov ax, v1
mov bx, sum
add ax, bx
xor dx, ax

mov ax, v1
shr ax, 5
mov bx, k1
add ax, bx
xor dx, ax

mov ax, v0
sub ax, dx
mov v0, ax

mov bx, delta


mov ax, sum
sub ax, bx
mov sum, ax

loop decLoop
ret
decrypt endp
; ============================================= END of code's
decryption procedure
============================================= ;

end
• Conclusion
In this project, we were introduced to the concept of Cryptography and its
important uses i.e., to ensure the security of information and communication
methods. We implemented the AES128 algorithm, an asymmetric mode to encrypt
and decrypt messages using 8086 microprocessor. We used 8086 emu to emulate
this project. The results were positive, showing how a string is encrypted first and
the decrypted string is displayed successfully.

• References
[1] Guzmán et al., 2016, FPGA implementation of the AES-128 algorithm in non-
feedback modes of operation, Dyna, vol. 83, no. 198, pp. 37-43, 2016 Universidad
Nacional de Colombia.
[2] Bilgin et al., 2014, A More Efficient AES Threshold Implementation, Springer
International
[3] Paul et al., 2012, Design and implementation of real time AES-128 on real time
operating system for multiple FPGA communication, ResearchGate
[4] Mondal et al., 2020, Efficient Architecture Design for the AES-128 Algorithm
on Embedded Systems, ACM Journal
[5] Abdullah et al., 2017, Advanced Encryption Standard (AES) Algorithm to
Encrypt and Decrypt Data, ResearchGate
[6] https://www.researchgate.net/figure/AES-Encryption-Decryption-
Flowchart_fig2_221958203
[7] https://engineering.purdue.edu/kak/compsec/NewLectures/Lecture8.pdf

You might also like