Private host key is sent instead of public in DH KEX?

Oleg NewYorker oleg.newyorker at gmail.com
Fri Mar 31 09:31:44 AEDT 2017


Hello,

Can someone please tell me if I am right or wrong that in the code below
private key can be sent (in DH KEX) instead of public one (need_private is
0). Both keys are available (sensitive_data.host_keys[i] and
sensitive_data.host_pubkeys[i] are not NULL).
I hope I am just missing something here.

Thanks.

static Key *
get_hostkey_by_type(int type, int nid, int need_private, struct ssh *ssh)
{
    int i;
    Key *key;

    for (i = 0; i < options.num_host_key_files; i++) {
        switch (type) {
        case KEY_RSA_CERT:
        case KEY_DSA_CERT:
        case KEY_ECDSA_CERT:
        case KEY_ED25519_CERT:
            key = sensitive_data.host_certificates[i];
            break;
        default:
            key = sensitive_data.host_keys[i];
            if (key == NULL && !need_private)
                key = sensitive_data.host_pubkeys[i];
            break;
        }
        if (key != NULL && key->type == type &&
            (key->type != KEY_ECDSA || key->ecdsa_nid == nid))
            return need_private ?
                sensitive_data.host_keys[i] : key;
    }
    return NULL;
}


More information about the openssh-unix-dev mailing list