Sei sulla pagina 1di 25

Semester Report

OCTOBER 2018

Master of Science in Software Systems

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

4.2 RSA OVERVIEW…………………………………………………………12

4.3 RSA DETAILS…………………………………………………………….12

4.4 OTHER CIPHERS…………………………………………………………

4.4.1 XOR Encryption………………………………………………………

4.4.2 Morse Code……………………………………………………………

4.6 TCP PROTOCOL………………………………………………………….14

5. DESIGN AND IMPLEMENTATION……………………….17


5.1 CONCEPT……………………………………………………………………18

5.2 COMMUNICATION LAYER……………………………………………….24

5.2.1 Netinet and Socket……………………….……………………..24

5.2.2 Parameters and Requirement…………….…………………..27

3|Page
5.3 CIPHERING LAYER……………………………………………29

5.3.1 Creating/Reading RSA key from a file……………………..29

5.3.2 Custom Creation of Ciphers…………………………………30

5.3.2.1 XOR Encryption…………………………………….………………30

5.3.2.2 Pan Wheel Encryption………………….…………………………..31

6. SYSTEM REQUIREMENTS AND ENVIRONMENT…..32


6.1 REQUIRED SOFTWARES………………………………….32

6.2 SETTING UP THE ENVIRONMENT………………………33

7. FURTHER DEVELOPMENT………………………………34
7.1 WHAT HAS BEEN DONE…………………………………..34

7.2 WHAT CAN BE DONE………………………………………35

8. CONCLUSION……………………………………………….36
REFERENCES………………………………………………….37

4|Page
ACRONYMS
ACK – Acknowledgement

IP – Internet Protocol

LAN – Local Area Network

UI – User Interface

TCP - Transmission Control Protocol

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)

Nowadays people need to communicate with each other all the


time. Communication often takes place between people who are
far from each other, so they use the Internet to that. They are
exchanging information with significant value. This fact leads to
the statement that the message that they are exchanging should

remain secret for other parties who are not authorized.

7|Page
FIGURE 1 Amount of data on the Internet (Silicon Angle)

Security is nowadays one of the most important issues in a


network. Every BIT of data that flows transmitted flows through
the data channels which are common to all, which can make it
prone to attack by malicious attackers leading to stealth of
valuable information. Hence to overcome this problem the World
must not only focus on improve search for data and transmission
but also it’s protection.

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.

According to everything that was mentioned above, it was


decided to create application with implemented cryptographic
algorithms that meets the previously mentioned goals. The name
of the application is Secure Chat (further referred as S – Chat).

8|Page
As mentioned in the previous chapter the application should be:

 Fast
 Working over TCP protocol
 Reliable
 Allowing communication between two users

Working on computer with Ubuntu x64 Operating System (The


Application can’t be made to work on Windows because entirely
focuses on the backend development and doesn’t demonstrate
the GUI)

To provide the above requirements it was decided to use the


following Cryptographic functions:

 RSA Algorithm
 XOR Encryption
 Morse Code

The project assumed providing communication only between


two users at a time. Communication can take place via one
channel only, hence one has to wait until the other sends the
message to be able to send another message. It was also
assumed that before establishment of communication , users
exchange their public keys.
9|Page
Ensuring communication with multiple users using different
channels must be implemented in the future.

The application was developed under Ubuntu 18 operating


system.

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.

4.1 Ciphering Algorithms

Before starting to develop that project, there were very important


decisions to be made. The algorithm was chosen carefully
according to information about security and reliable.

The RSA Algorithm which is used in this application is an


Asymmetric Algorithm. Meaning that the keys generated are in a
pair. For example, if ‘A’ encrypts the message then ‘B’ can
decrypt it using his set of key and vice-versa.

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

RSA is an asymmetric encrypting algorithm normally used to


send a session key between users and which will be used in the
future by users in ciphering with the use of asymmetric
algorithms. The normal RSA ciphering doesn’t cipher the
communication, it just generates two keys, a public key and a
private key and that just encrypts the chat but not the
communication (This can be easily implemented using the
OpenSSL library, which has in-built function for generating the
keys and encryption). But in this application, we will be focusing
on the encryption of data sent through this communication
channel, which does require a great deal of resources and
challenging but highly secure.

The strength of this algorithm lies in two mathematical problems:

 The problem of factorizing large numbers


 RSA problem

12 | P a g e
To generate RSA key pair this algorithm is to be used:

1. Choose randomly two large prime numbers p and q.


2. Solve n = p . q
3. Solve for Euler Function value for n: Φ(n) = (p-1) . (q-1)
4. Choose number e such that 1 < e < Φ(n) relatively prime
with Φ(n)
5. Solve d = e-1modΦ(n)

Public key is defined as the number pair (n, e) while private key
is defined as the pair (n, d)

To encrypt with RSA algorithm message has to be divided into mi


blocks of values not greater than n and then cipher it with the
pattern:

ci = miemodn
To decrypt with RSA algorithm every ci block had to be
transformed like this:

mi = cid modn

Clearly from the algorithm, the concept of this encryption


revolves around prime factorization which turns out to be
extremely difficult for higher numbers. In our application we use

13 | P a g e
the highest possible bit value for real time and on a smaller scale
for testing and debugging purposes.

4.4.1 XOR ENCRYPTION

XOR encryption was one of the earliest encryption techniques


made for the encryption of data in the field of Computer Science.
It’s based on the Bitwise operation XOR which is represented as

‘ ^ ‘. The XOR operation works according to the following truth


table:

a b a^b

14 | P a g e
0 0 0
0 1 1
1 0 1
1 1 0

So in this Algorithm a key is taken randomly or from the user


and all the characters in the given message or data are XORed
with that key made. Hence the character wouldn’t stay the same
coz it’s ASCII value changes.

Ex:- Suppose,

Key = ‘ 0 ‘ (anything enclosed between ‘ ‘ in C language


refers to character not an integer, here the ASCII value of
0 is 48)

Data = ‘ a ‘, ASCII code = 97.

Hence,

Encrypting would take place like:

Encrypted data = Data ^ Key

Which in Binary would be:

Data: ‘a’ = 0000 0000 0101 1100

Key: ‘0’ = 0000 0000 0011 0000

Data ^ Key = 0000 0000 0110 1100 Which is ‘ l ‘

15 | P a g e
We have just seen how the data transforms from ‘ a ‘ to ‘ l ‘. This is

Underlying principle of this Algorithm.

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

Morse code was one of the primitive encryption techniques used to


encrypt characters and was used for communication by the ARMY
and larger organizations like NASA to communicate coordinates.

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.

Ex:- HELLO in Morse code would be:

……-…-..---

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.

TCP works in Client – Server mode

1. The Server creates a socket, binds it and waits/listens for a


connection.
2. The client too creates a socket and asks for connection.
3. The Server accepts the connection and BINGO!!! The
connection is established.

This protocol guarantees that messages will be delivered in correct


order without any duplications. This ensures a reliable connection
at the expense of greater overhead in the form of a header and
larger number of packets sent.

20 | P a g e
5.1 CONCEPT

The idea of the project was to create an application that


provides secure communication over TCP protocol.

To provide the aforementioned functionality, the project was


divided into two layers:

 Communication Layer
 Ciphering Layer

User does not have to interact with the communication or the


ciphering layer, all he / she has to do is enter the IP Address
of the Server and the port number with which the
communication would be established.

C language was the chosen language that was used to write


the code for communication and ciphering layer. The sockets
are operated on port numbers 3000 and above because the
first 2000 ports are reserved for other purposes and the rest
1000 are left just for safety. In order to communicate within
the same computer using two terminals the IP Address that is
to be used is 127.1.0.0 or the command loopback.

Below is the scenario of the application’s working model:


21 | P a g e
 The connection was made between the Server and
the Client successfully and communication can be
done further.
 The Server choses the type of encryption and the
key ( if it has to be chosen) and that data is
transmitted to the client.
 The Client after receiving the type of cipher, being
the first sender types in his message. The message
is then encrypted according to the type of
encryption mode chosen by the Sever and the
message is transmitted. And this continues.
 Once the message is received successfully by the
Server the message is decrypted using the revers
logic of encryption and the message is displayed.
 The message seems normal at the sender’s and
receiver’s end, but is not in human readable format
in the transmission process.

This process is depicted in a flowchart in the following page.

22 | P a g e
Socket Socket

Bind

Listen

Accept Connect

CLIENT – SERVER ARCHITECTURE

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

Potrebbero piacerti anche