This was ours (Bruno Moura, Rafael Remígio and João Teles) submission for our cybersecurity course's (SIO) second practical project.
At our first submission we received a 16.8 mark, and after further improvements we received a 19.2. Both out of 20.
All changes since the first delivery are listed and explained in the report/changes.pdf file or at the end of the report.pdf file along with the previous report.
Project Documentation
-
File Description Caller.py Script for initializing the Caller process (requires nickname) Player.py Script for initializing the Player process (requires nickname) PlayingArea.py Script for initializing the Playing Area process (requires card and deck size) src/user.py Generic logic for both the caller and player src/caller.py Extends user.py and implements Caller specific logic src/player.py Extends user.py and implements Player specific logic src/playing_area.py Playing Area logic src/protocol.py Contains the messages classes and functions for sending and receiveing messages through websockets src/crypto.py Helper functions for cryptography operations src/common.py Data types that are common to multiple classes. Namely player and log data. To test the project, run PlayingArea.py, Caller.py and at least two Player.py instances.
-
Message
Description Generic message Methods to_json(), should_log() returns True -
Authenticate
Description Message for Users to authenticate themselves to the playing area. Uses challenge-response authentication Extends Message Methods parse() Parameters - public_key
- challenge
- response
- success
-
Register
Description Message for players to register themselves to the playing area Extends Message Methods parse() Parameters - nickname
- playing_key
- auth_key
- signature
- success
- sequence
-
GetUsers
Description Message for getting a list of registered users Extends Message Methods parse(), should_log() returns false Parameters - public_key
- signature
- response
-
CardSize
Description Simple message for letting users know the card size Extends Message Methods parse(), should_log() returns false Parameters - card_size
-
GetLog
Description Message for getting a list of logged messages Extends Message Methods parse(), should_log() returns false Parameters - public_key
- signature
- response
should_log -> returns false
-
PartyUpdate
Description Message for updating registered users on how big the party is Extends Message Methods parse(), should_log() returns false Parameters - public_key
- signature
- response
should_log -> returns false
-
GenerateDeck
Description Message telling the caller to generate the deck and initiate the card generation proccess Extends Message Methods parse() Parameters - deck_size
-
GenerateCard
Description Message Players will pass around until everyone has commited their card Extends Message Methods parse()
sign(private_key : str)- Description: Signs the deck with private_Key and append the public key to the signatures array
Call our Cryptography function sign
verify(publicKey : str, signature)- Description: Verifies the signature of the deck with the public key
Call our Cryptography function verifyParameters - sequence (int)
- deck (list)
- signatures (list)
- done (bool)
-
DeckKeyRequest
Description Message requesting that players and caller reveal their symmetric key after the deck is commited Extends Message Methods parse() Parameters - sequence
-
DeckKeyResponse
Description Response to the deck key request Extends Message Methods parse()
sign(private_key : str)- Description: Signs the response with private_Key and assigns it to signature
Call our Cryptography function signParameters - sequence
- response
- signature
-
GameOver
Description Message for when the game is over / aborted Extends Message Methods parse()
should_log() returns false
__ str __()Parameters - status
-
Methods
-
send_msg
Description Sends through a connection a Message object. Parameters - connection: socket
- msg: Message
Return None -
recv_msg
Description Receives through a connection a Message object. Parameters - connection: socket
Return Message -
parse_msg
Description Returns from message string a Message Instance Parameters - msg_str: str
Return Message
-
-
ProtoBadFormat (Class)
Description Exception when source message is not Proto.
Cryptographic utilities
Uses cryptography.hazmat.primitives
-
sym_gen
Description Generates a new AESGCM (key, nonce) tuple Parameters Return tuple -
sym_encrypt
Description Encrypts data given with given AESGCM key Parameters - key: bytes
- data
- nonce: bytes
Return bytes -
sym_decrypt
Description Decrypts encrypted data given with given AESGCM key Parameters - key: bytes
- crypted_data
- nonce: bytes
Return bytes -
do_hash
Description Returns an hash of a given data; Uses SHA256 Parameters data: bytes Return bytes -
asym_gen
Description Encrypts data using given public key Parameters Return bytes -
sign
Description Returns Signature of given data signed with given private key; Uses SHA256 Parameters - private_key
- data
Return bytes -
verify
Description Verifies if given message matches with given signature; Uses SHA256 Parameters - public_key
- message
- signature: bytes
Return bool