def assert_fingerprint(cert, fingerprint):
<EOL>hashfunc_map = {<EOL><NUM_LIT:16>: md5,<EOL><NUM_LIT:20>: sha1,<EOL><NUM_LIT:32>: sha256,<EOL>}<EOL>fingerprint = fingerprint.replace('<STR_LIT::>', '<STR_LIT>').lower()<EOL>digest_length, odd = divmod(len(fingerprint), <NUM_LIT:2>)<EOL>if odd or digest_length not in hashfunc_map:<EOL><INDENT>raise SSLError('<STR_LIT>')<EOL><DEDENT>fingerprint_bytes = unhexlify(fingerprint.encode())<EOL>hashfunc = hashfunc_map[digest_length]<EOL>cert_digest = hashfunc(cert).digest()<EOL>if not cert_digest == fingerprint_bytes:<EOL><INDENT>raise SSLError('<STR_LIT>'<EOL>.format(hexlify(fingerprint_bytes),<EOL>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.