def on_encryption_key_responce(self, c): """ STEP 3.1: decrypt client AES key with our RSA key """ aeskey = encryption.decrypt(c.shared_secret, self.factory.rsakey) self.cipher = encryption.make_aes(aeskey, aeskey) self.decipher = encryption.make_aes(aeskey, aeskey)
def on_encryption_key_request(self, c): """ STEP 2.1: decode encryption request from the server use it for the server side """ aes_key = encryption.get_random_bytes() self.cipher = encryption.make_aes(aes_key, aes_key) self.decipher = encryption.make_aes(aes_key, aes_key) public_key = encryption.load_pubkey(c.public_key) self.enc_shared_sercet = encryption.encrypt(aes_key, public_key) self.enc_4bytes = encryption.encrypt(c.verify_token, public_key)