def ssh_key_info_from_key_data(key_id, priv_key=None):
    """Get/load SSH key info necessary for signing.

    @param key_id {str} Either a private ssh key fingerprint, e.g.
        'b3:f0:a1:6c:18:3b:42:63:fd:6e:57:42:74:17:d4:bc', or the path to
        an ssh private key file (like ssh's IdentityFile config option).
    @param priv_key {str} Optional. SSH private key file data (PEM format).
    @return {dict} with these keys:
        - type: "agent"
        - signer: Crypto signer class (a PKCS#1 v1.5 signer for RSA keys)
        - fingerprint: key md5 fingerprint
        - algorithm: See ALGO_FROM_SSH_KEY_TYPE for supported list.
        - ... some others added by `load_ssh_key()`
    """
    if FINGERPRINT_RE.match(key_id) and priv_key:
        key_info = {"fingerprint": key_id, "priv_key": priv_key}
    else:
        # Otherwise, we attempt to load necessary details from ~/.ssh.
        key_info = load_ssh_key(key_id)

    # Load a key signer.
    key = None
    try:
        key = serialization.load_pem_private_key(
            key_info["priv_key"],
            password=None,
            backend=default_backend())
    except TypeError as ex:
        log.debug("could not import key without passphrase (will "
            "try with passphrase): %s", ex)
        if "priv_key_path" in key_info:
            prompt = "Passphrase [%s]: " % key_info["priv_key_path"]
        else:
            prompt = "Passphrase: "
        for i in range(3):
            passphrase = getpass(prompt)
            if not passphrase:
                break
            try:
                key = serialization.load_pem_private_key(
                    key_info["priv_key"],
                    password=passphrase,
                    backend=default_backend())
            except ValueError:
                continue
            else:
                break
        if not key:
            details = ""
            if "priv_key_path" in key_info:
                details = " (%s)" % key_info["priv_key_path"]
            raise MantaError("could not import key" + details)

    # If load_ssh_key() wasn't run, set the algorithm here.
    if 'algorithm' not in key_info:
        if isinstance(key, ec.EllipticCurvePrivateKey):
            key_info['algorithm'] = ECDSA_ALGO_FROM_KEY_SIZE[str(key.key_size)]
        elif isinstance(key, rsa.RSAPrivateKey):
            key_info['algorithm'] = RSA_STR
        else:
            raise MantaError("Unsupported key type for: {}".format(key_id))

    key_info["signer"] = key
    key_info["type"] = "ssh_key"
    return key_info