Encrypted Chat Room 1_System description and requirements

来源:互联网 发布:我知女人心免费阅读 编辑:程序博客网 时间:2024/05/29 14:28

 ENCRYPTED CHAT PROGRAM

This system allows pairs of users or clients “connected” to a network to establish a communication session and interchange encrypted text messages between them.

Every message sent to or received by a client is encrypted so anyone else who succeeds in intercepting the communication would not be able to understand the content of such message. To do so, the system implements a cryptography protocol called Key Exchange with Symmetry Cryptography.

The Key Distribution Server (KDS) maintains a list of currently connected clients. It is responsible for the creation and distribution of the session keys the clients are going to use when they want to exchange messages.

When client C1 wants to talk to client C2, the protocol’s steps are as follows:

1. C1 calls KDS and requests a session key to communicate with C2.
2. KDS generates a random session key. It encrypts two copies of it: one in C1’s key and the other in C2’s private key. KDS sends the respective private keys to C1 and C2.
3. C1 decrypts its copy of the session key.
4. C2 decrypts its copy of the session key.
5. Both C1 and C2 use this session key to communicate securely.
6. One of the clients ends the session.

Each user communicates with the KDS and other users through a graphical user interface (GUI) control panel.
Every user can see what other users are currently connected. Each user can select another user to talk to. The user can accept or reject a request of communication. Once a communication session has been established, they can send and receive messages to each other. Each user can have multiple chat sessions. The user’s GUI permits the management of the current sessions. Only one session can be used at a time for active communication between users.

There are 3 states a session can be in: WAIT_REPLY, ACCEPT_REJECT and CHAT.

The WAIT_REPLY state is when a user has initiated a session request and is waiting
for a reply from the requested user.

The ACCEPT_REJECT state is when a user is the recipient of a request to establish a communication session. The user is only able to accept or reject the request.

The CHAT state is when users write and exchanges messages with each other. In this state, the user is able to type in a text message, clear the text message and send the message. They are also able to end the session.
Whenever a message is sent or received, the encrypted and decrypted versions of the message are displayed on the text display area of the GUI.

The system has a control centre that is responsible for start-up of the client-server network and provides an interface for adding new clients to the network.
When the system first starts up, the KDS is created.

Each client is added by a user through the user interface of the control centre. Each client has their own private key, selected by the user.

Encryption and Decryption Algorithms
The encryption and decryption algorithms used are based on the Single Columnar Transposition Cipher encryption technique.

Encryption
The cipher uses a key with one or more upper case letters of the English alphabet (e.g. VAMPIRES, AVIATOR, SECRET). The message to be encrypted can contain any character of the ASCII code except the asterisk (*) which is used as part of the encryption algorithm.

The characters of the message are arranged from left to right and top to bottom in a dimensional table with a number of columns equal to the number of characters of the key. Let’s suppose the message to be encrypted is:
The mission has been successful, we can move on now.

and the key is ICECREAM, then the table should look like:

 T

 h

 e

 

 m

 i

 s

 s

 i

 o

 n

 

 h

 a

 s

 

 b

 e

 e

 n

 

 s

 u

 c

 c

 e

 s

 s

 f

 u

 l

 ,

 

 w

 e

 

 c

 a

 n

 

 m

 o

 v

 e

 

 o

 n

 

 n

 o

 w

 .

 *

 *

 *

 *

As the characters of the message do not completely fill the table, the empty positions are filled with an asterisk (*).
The encrypted message is created by reading the characters of each column top to bottom (the asterisks are not included in the encrypted message). The order in which the columns are read is defined by the order the characters in the key appear in the alphabet. In the example:
Key: I C E C R E A M
Order of characters: 6 2 4 3 8 5 1 7

‘A’ is the first in the alphabet, the second is C (the first C read from left to right), third the other C, fourth the E, and so on.
  6      2       4     3      8      5     1    7

 T

 h

 e

 

 m

 i

 s

 s

 i

 o

 n

 

 h

 a

 s

 

 b

 e

 e

 n

 

 s

 u

 c

 c

 e

 s

 s

 f

 u

 l

 ,

 

 w

 e

 

 c

 a

 n

 

 m

 o

 v

 e

 

 o

 n

 

 n

 o

 w

 .

 *

 *

 *

 *


Now the encrypted message can be read:

“ssulnnhoeewoo ns e.enesevwiasuaoTibc mns c, mh fc ”

Decryption
To obtain the original message the totally opposite process is carried out. The first thing to be done is calculating the order in which columns are filled in the table and the number of rows the table has. Remember that there might be some empty spaces at the end that need to be filled with asterisks, this is done first. Then the table is populated with the characters of the encrypted message and then the original message is obtained by reading the message from left to right, top to bottom. The asterisks are not read of course.

Limitations of the system
The client-server communication uses “mock” networking for this assignment. The client(s) and server will be running on the same machine, hence no real networking is required between machines. In a true client-server situation, the client and server normally reside on different machines in a network, and would require a specialised networking layer.

GUI Design
You are expected to apply the design principles of clarity and consistency to the GUI. You are at liberty to design the aesthetic “look and feel” of the interface, as long as you satisfy the class design specifications and the scenario requirements.

原创粉丝点击