This project focuses on implementing a secure communication protocol for Teams chat. The protocol utilizes RSA encryption with a key size of 2048 bits, SHA1 for MGF hash function in RSA-OAEP, and SHA256 for HMAC hash function. RSA digital signatures employ SHA512. The protocol involves key generation, random byte generation, signature verification, master secret generation, and encryption/decryption using MiniAES and HMAC. The goal is to ensure secure and authenticated communication between client and server.
To communicate securely on Teams chat, we'll use hexadecimal string encoding for our messages. To generate true random bytes, you can use the secrets.token_bytes()
function. We'll be using RSA encryption with a key size of 2048 bits. The MGF hash function for RSA-OAEP will be SHA1, and the HMAC hash function will be SHA256. For RSA digital signatures, we'll use the SHA512 hash function. The digital signature will fit into the RSA-OAEP-2048 payload along with the random bytes.
Here are the steps to follow:
-
Form groups of two students and decide who will be the client and who will be the server.
-
Generate RSA key pairs for both sides:
client_rsa_enc_key
andserver_rsa_enc_key
for encryption, andclient_rsa_sign_key
andserver_rsa_sign_key
for signature. -
Generate 32 random bytes for each side:
client_public_random
andserver_public_random
. -
The client should send the following to the server:
client_rsa_enc_key.public
,client_rsa_sign_key.public
, andclient_public_random
. -
The server should send the following to the client:
server_rsa_enc_key.public
,server_rsa_sign_key.public
, andserver_public_random
. -
Generate 48 private random bytes for each side:
client_private_random
andserver_private_random
. -
The client signs
client_private_random
with RSA and sends it to the server using RSA-OAEP. The server decrypts the received message and verifies the signature. -
The server signs
server_private_random
with RSA and sends it to the client using RSA-OAEP. The client decrypts the received message and verifies the signature. -
Concatenate the private random bytes to form the
premaster_secret = client_private_random + server_private_random
. -
Generate the master secret using
PRF(premaster_secret, "master secret", client_public_random + server_public_random)
. The master secret should be 48 bytes long. -
Both the client and the server generate the following keys using
PRF(master_secret, "key expansion", client_public_random + server_public_random)
:client_write_mac_key
: 32 bytesserver_write_mac_key
: 32 bytesclient_write_key
: 2 bytesserver_write_key
: 2 bytes
-
The client sends a message to the server using MiniAES encryption with
client_write_key
and HMAC withclient_write_mac_key
. The server decrypts the message and verifies the authentication code. -
The server sends a message to the client using MiniAES encryption with
server_write_key
and HMAC withserver_write_mac_key
. The client decrypts the message and verifies the authentication code.
Authors: Alfredo Martins
& Chen Siyu
Professor: Ádám Zlehovszky Dr.
Place and date: Budapest, June 2023