def __init__(self, verifying_key, encryption_key): """ Initialize the object :param verifying_key: PEM encoded ECDSA verifying key :param encryption_key: PEM encoded RSA encryption key """ self._verifying_key = crypto.SIG_PublicKey(verifying_key) self._encryption_key = crypto.PKENC_PublicKey(encryption_key)
def generate_encrypted_key(self, key, encryption_key): """ Function to generate session key for the client Parameters: - encryption_key is a one-time encryption used to encrypt the passed key - key that needs to be encrypted """ pub_enc_key = crypto.PKENC_PublicKey(encryption_key) return pub_enc_key.EncryptMessage(key)