Professional Documents
Culture Documents
Practical - 8 Q-1: From Import From Import From Import Import
Practical - 8 Q-1: From Import From Import From Import Import
D22CE156,
D22CE157, CE348 Information Security
Practical - 8
Q-1 Show a píactical scenaíio of Key Distíibution. Use the sepaíate key-shaíing seíveí that shaíes
the secíet key cíeated using the AES-256-bit algoíithm and shaíe the secíet key using the RSA
algoíithm with 2048 bits key size. ľhe key-shaíing seíveí píoduces a new secíet key foí each new
communication between two nodes.
class KeySharingServer:
def init (self):
self.private_key = RSA.generate(2048) self.public_key
= self.private_key.publickey()
def generate_session_key(self):
return get_random_bytes(32) # AES-256 bit key size
1
21ce140
D22CE156,
D22CE157, CE348 Information Security
class Node:
def init (self, name, key_sharing_server): self.name
= name
self.key_sharing_server = key_sharing_server
2
21ce140
D22CE156,
D22CE157, CE348 Information Security
self.session_key = None
alice.receive_session_key(encrypted_session_key_for_alice)
bob.receive_session_key(encrypted_session_key_for_bob)
3
21ce140
D22CE156,
D22CE157, CE348 Information Security
Output: