Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

exercise, we wil implement the four mechanisms required to create an encrypted socket: . 1 Symmetric key - based encryption known only to both sides

exercise, we wil implement the four mechanisms required to create an encrypted socket:
.1 Symmetric key-based encryption known only to both sides
2. Common encryption key selection mechanism
3. Hash function
4. Create a MAC signature by using a public key
This lab examines building these mechanisms. Here is an illustration of the steps:
Plain Data
Encrypted Data
Encrypted Data Hash
Encrypted Data MAC
.1 Key-based symmetric encryption
For educational reasons, we use symmetric XOR encryption rather than advanced encryption such as AES. Our encryption key wil only be 16 bits. It is not complex to crack this key by brute force, but it illustrates the principle and si not difficult to implement.
On the transmitter side: Any two bytes about to be sent over the socket will first be XORed with the
encryption key. fI the number of bytes that need to be sent si odd, for simplicity, use only the lower 8 bits of the encryption key.
On the receiving side: Every two bytes received from the socket si XORed with the encryption key. fI the number of bytes received is odd, use only the lower 8 bits of the encryption key to decrypt.
2. Common encryption key selection
Determine the key, the shared secret value, using the Diffie-Hellman algorithm. The shared secret should be 16 bits per the encryption method chosen above.
Step A: Select two prime numbers P and G, smaller than 65535(maximum value of 16 bits) Step B: Each party selects a private key.
Step C: Each party calculates its own public key and sends it to the other side, using the TCP
socket opened between them. At this stage, the information passing through the socket si not yet encrypted and includes only the public keys of both parties.
Step D: Each party calculates the shared secret, a 16-bit number as we consider taking only the remainder of the modulo division by P.
3. Hash function
Write ahash function to your liking. The function takes the encrypted message, performs various mathematical operations, and returns a 16-bit hash number.
4. Public key signature (MAC)
Use the RSA algorithm to generate the Message Authentication Code (MAC).
Use the following values: P=137
Q=151
Party Auses the private key 11669. Public key 1229. Party Buses the private key 7171. Public Key 2731.
The signature is generated as follows:
Step A: The sending party calculates the hash of the encrypted message.
Step B: The sending party calculates the value of the signature- the hash to the power of the private key, modulo (P*Q)
You can use the Python pow function, for example:
signature = pow(hash,11669,137*151)
Step C: The sending party sends the encrypted message appended with the signature.
Step D: The receiving party uses the sending party's public key to extract the original hash, for example:
R e c e i v e d _hash = pow(signature,1229,137*151)
Step E: The receiving party independently calculates the hash from the rest of the information sent to it.
Step:F The receiving party checks fi the calculated hash is the same as Received_hash and fi not, throws away the received message, as ti si not genuine.
Socket Communications
Stage :1 Establishing the encrypted channel
Exchange Diffie-Hellman public keys.
Exchange RSA public keys.
Stage 2: Encrypted communications
Messages are encrypted and signed with the MAC.
Assignment
Write a chat between a server and a client (no need to work with multiple clients), messages wil be transmitted ni encrypted and signed format.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Describe a persuasive message.

Answered: 1 week ago

Question

Identify and use the five steps for conducting research.

Answered: 1 week ago

Question

List the goals of a persuasive message.

Answered: 1 week ago