def verify_pss_padding(hash_algorithm, salt_length, key_length, message, signature):
if _backend != '<STR_LIT>' and sys.platform != '<STR_LIT>':<EOL><INDENT>raise SystemError(pretty_message(<EOL>'''<STR_LIT>'''<EOL>))<EOL><DEDENT>if not isinstance(message, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(message)<EOL>))<EOL><DEDENT>if not isinstance(signature, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(signature)<EOL>))<EOL><DEDENT>if not isinstance(salt_length, int_types):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(salt_length)<EOL>))<EOL><DEDENT>if salt_length < <NUM_LIT:0>:<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>repr(salt_length)<EOL>))<EOL><DEDENT>if hash_algorithm not in set(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']):<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>repr(hash_algorithm)<EOL>))<EOL><DEDENT>hash_func = getattr(hashlib, hash_algorithm)<EOL>em_bits = key_length - <NUM_LIT:1><EOL>em_len = int(math.ceil(em_bits / <NUM_LIT:8>))<EOL>message_digest = hash_func(message).digest()<EOL>hash_length = len(message_digest)<EOL>if em_len < hash_length + salt_length + <NUM_LIT:2>:<EOL><INDENT>return False<EOL><DEDENT>if signature[-<NUM_LIT:1>:] != b'<STR_LIT>':<EOL><INDENT>return False<EOL><DEDENT>zero_bits = (<NUM_LIT:8> * em_len) - em_bits<EOL>masked_db_length = em_len - hash_length - <NUM_LIT:1><EOL>masked_db = signature[<NUM_LIT:0>:masked_db_length]<EOL>first_byte = ord(masked_db[<NUM_LIT:0>:<NUM_LIT:1>])<EOL>bits_that_should_be_zero = first_byte >> (<NUM_LIT:8> - zero_bits)<EOL>if bits_that_should_be_zero != <NUM_LIT:0>:<EOL><INDENT>return False<EOL><DEDENT>m_prime_digest = signature[masked_db_length:masked_db_length + hash_length]<EOL>db_mask = _mgf1(hash_algorithm, m_prime_digest, em_len - hash_length - <NUM_LIT:1>)<EOL>left_bit_mask = ('<STR_LIT:0>' * zero_bits) + ('<STR_LIT:1>' * (<NUM_LIT:8> - zero_bits))<EOL>left_int_mask = int(left_bit_mask, <NUM_LIT:2>)<EOL>if left_int_mask != <NUM_LIT:255>:<EOL><INDENT>db_mask = chr_cls(left_int_mask & ord(db_mask[<NUM_LIT:0>:<NUM_LIT:1>])) + db_mask[<NUM_LIT:1>:]<EOL><DEDENT>db = int_to_bytes(int_from_bytes(masked_db) ^ int_from_bytes(db_mask))<EOL>if len(db) < len(masked_db):<EOL><INDENT>db = (b'<STR_LIT:\x00>' * (len(masked_db) - len(db))) + db<EOL><DEDENT>zero_length = em_len - hash_length - salt_length - <NUM_LIT:2><EOL>zero_string = b'<STR_LIT:\x00>' * zero_length<EOL>if not constant_compare(db[<NUM_LIT:0>:zero_length], zero_string):<EOL><INDENT>return False<EOL><DEDENT>if db[zero_length:zero_length + <NUM_LIT:1>] != b'<STR_LIT>':<EOL><INDENT>return False<EOL><DEDENT>salt = db[<NUM_LIT:0> - salt_length:]<EOL>m_prime = (b'<STR_LIT:\x00>' * <NUM_LIT:8>) + message_digest + salt<EOL>h_prime = hash_func(m_prime).digest()<EOL>return constant_compare(m_prime_digest, h_prime)<EOL>
Verifies the PSS padding on an encoded message

:param hash_algorithm:
    The string name of the hash algorithm to use: "sha1", "sha224",
    "sha256", "sha384", "sha512"

:param salt_length:
    The length of the salt as an integer - typically the same as the length
    of the output from the hash_algorithm

:param key_length:
    The length of the RSA key, in bits

:param message:
    A byte string of the message to pad

:param signature:
    The signature to verify

:return:
    A boolean indicating if the signature is invalid