

def get_verifier(context, img_signature_certificate_uuid, img_signature_hash_method, img_signature, img_signature_key_type):
    'Instantiate signature properties and use them to create a verifier.\n\n    :param context: the user context for authentication\n    :param img_signature_certificate_uuid:\n           uuid of signing certificate stored in key manager\n    :param img_signature_hash_method:\n           string denoting hash method used to compute signature\n    :param img_signature: string of base64 encoding of signature\n    :param img_signature_key_type:\n           string denoting type of keypair used to compute signature\n    :returns: instance of\n       cryptography.hazmat.primitives.asymmetric.AsymmetricVerificationContext\n    :raises: SignatureVerificationError if we fail to build the verifier\n    '
    image_meta_props = {
        'img_signature_uuid': img_signature_certificate_uuid,
        'img_signature_hash_method': img_signature_hash_method,
        'img_signature': img_signature,
        'img_signature_key_type': img_signature_key_type,
    }
    for key in image_meta_props.keys():
        if (image_meta_props[key] is None):
            raise exception.SignatureVerificationError(reason=(_('Required image properties for signature verification do not exist. Cannot verify signature. Missing property: %s') % key))
    signature = get_signature(img_signature)
    hash_method = get_hash_method(img_signature_hash_method)
    signature_key_type = SignatureKeyType.lookup(img_signature_key_type)
    public_key = get_public_key(context, img_signature_certificate_uuid, signature_key_type)
    verifier = signature_key_type.create_verifier(signature, hash_method, public_key)
    if verifier:
        return verifier
    else:
        raise exception.SignatureVerificationError(reason=_('Error occurred while creating the verifier'))

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/signature_utils.py get_verifier/original