def key_matches_x509_crt(key, crt):
    """
    Verify that the public key derived from the given private key matches the
    private key in the given X.509 certificate.

    :param object key: A private key object created using load_privkey()
    :param object crt: An X.509 certificate object created using load_x509()
    :rtype bool: True, iff the key matches the certificate
    """
    return crt.public_key().public_numbers() == key.public_key().public_numbers()