Encrypted TCP Chat Using RSA and AES Algorithm
Encrypted TCP Chat Using RSA and AES Algorithm
OCTOBER 2018
1|Page
2|Page
CONTENTS
CONTENT…………………………………………………………3
ACRONYMS………………………………………………………5
FIGURES………………………………………………………….6
2. OBJECTIVE OF THE REPORT……..…………………….9
3. DEVELOPMENT ENVIRONMENT………………………..10
3.1 C/C++………………………………………………………………………..10
4. THEORY………………………………………………………11
4.1 CIPHERING ALGORITHMS…………………………………………….121
3|Page
5.3 CIPHERING LAYER……………………………………………29
7. FURTHER DEVELOPMENT………………………………34
7.1 WHAT HAS BEEN DONE…………………………………..34
8. CONCLUSION……………………………………………….36
REFERENCES………………………………………………….37
4|Page
ACRONYMS
ACK – Acknowledgement
IP – Internet Protocol
UI – User Interface
FIGURES
5|Page
6|Page
“We live in a society that is awash with information, but very few
of us understand what information is.”
(Floridi L. 2010)
7|Page
FIGURE 1 Amount of data on the Internet (Silicon Angle)
One of the fields that requires focus in the Security aspect is the
Internet Communication. It is the most common mode of
communication 95% of the globe uses and lack of proper security
may lead to attackers to encroach into people’s chats and
information.
8|Page
As mentioned in the previous chapter the application should be:
Fast
Working over TCP protocol
Reliable
Allowing communication between two users
RSA Algorithm
XOR Encryption
Morse Code
3.1 C/C++
The core of the application responsible for implementation of the
cipher systems was written using C programming language in
Sublime 3, it can also be implemented using C++. This language
was chosen because it’s “fast”, efficient and compatible with
library, which was used to implement ciphers algorithms, using
C language (Sublime was installed using basic commands in
terminal with cloning from GitHub).
3.2 Sublime 3
The entire program was typed in the IDE Sublime, this
application was chosen because of its interface and auto –
indentation which enhances the readability of the code making it
easier for debugging. The IDE also has a dark theme which
reduces the strain and amount of blue light entering the eye.
Also, it is the most compatible and recommended IDE for
Ubuntu.
10 | P a g e
To create ciphering application, it is very important and
necessary to first understand the algorithms that are used in the
program. If the theory placed below isn’t sufficient it is
recommended to read PKCS #1 about RSA.
11 | P a g e
An important part of that application is also the communication
protocol which allows hosts to send information via public
Internet
12 | P a g e
To generate RSA key pair this algorithm is to be used:
Public key is defined as the number pair (n, e) while private key
is defined as the pair (n, d)
ci = miemodn
To decrypt with RSA algorithm every ci block had to be
transformed like this:
mi = cid modn
13 | P a g e
the highest possible bit value for real time and on a smaller scale
for testing and debugging purposes.
a b a^b
14 | P a g e
0 0 0
0 1 1
1 0 1
1 1 0
Ex:- Suppose,
Hence,
15 | P a g e
We have just seen how the data transforms from ‘ a ‘ to ‘ l ‘. This is
The next page contains the ASCII table for all characters used by
Our computers: (NOTE: Key must be chosen above the ASCII value
33, because using characters below the ASCII values 33 can
lead to giving an XOR result of irretrievable data)
16 | P a g e
17 | P a g e
4.4.2 MORSE CODE
The Morse code has it’s own set of replacement for the alphabets,
numbers, and symbols. The Morse code table is given below:
18 | P a g e
This encryption technique is pretty much self-explanatory, all we
have to do is replace the characters in the message with the
corresponding Morse code.
……-…-..---
19 | P a g e
TCP protocol was chosen to be the internet layer on which
communication will be built and established. This protocol is
reliable, ordered and error – checked delivery of messages between
hosts via LAN, intranet or public Internet. It belongs to transport
layer of TCP/IP suite and communication services between
application program and IP.
20 | P a g e
5.1 CONCEPT
Communication Layer
Ciphering Layer
22 | P a g e
Socket Socket
Bind
Listen
Accept Connect
COMMUNICATION ESTABLISHMENT
23 | P a g e
Client Server
Message Message
Encryption Decryption
Transmission Receive
CIPHERING ARCHITECTURE
24 | P a g e
5.2 COMMUNICATION LAYER
5.2.1 NETINET AND SOCKET
Communication between two hosts is done using “Netinet.h” and
“Socket.h” Header files which come in-built with a standard C
compiler.
25 | P a g e