def assert_fingerprint(cert, fingerprint):
fingerprint = fingerprint.replace('<STR_LIT::>', '<STR_LIT>').lower()<EOL>digest_length = len(fingerprint)<EOL>hashfunc = HASHFUNC_MAP.get(digest_length)<EOL>if not hashfunc:<EOL><INDENT>raise SSLError(<EOL>'<STR_LIT>'.format(fingerprint))<EOL><DEDENT>fingerprint_bytes = unhexlify(fingerprint.encode())<EOL>cert_digest = hashfunc(cert).digest()<EOL>if not _const_compare_digest(cert_digest, fingerprint_bytes):<EOL><INDENT>raise SSLError('<STR_LIT>'<EOL>.format(fingerprint, hexlify(cert_digest)))<EOL><DEDENT>
Checks if given fingerprint matches the supplied certificate.

:param cert:
    Certificate as bytes object.
:param fingerprint:
    Fingerprint as string of hexdigits, can be interspersed by colons.