|
Lines 130-140
order_hostkeyalgs(char *host, struct sockaddr *hostaddr, u_short port)
Link Here
|
| 130 |
while ((alg = strsep(&avail, ",")) && *alg != '\0') { |
130 |
while ((alg = strsep(&avail, ",")) && *alg != '\0') { |
| 131 |
if ((ktype = sshkey_type_from_name(alg)) == KEY_UNSPEC) |
131 |
if ((ktype = sshkey_type_from_name(alg)) == KEY_UNSPEC) |
| 132 |
fatal("%s: unknown alg %s", __func__, alg); |
132 |
fatal("%s: unknown alg %s", __func__, alg); |
|
|
133 |
/* |
| 134 |
* If we have a @cert-authority marker in known_hosts then |
| 135 |
* prefer all certificate algorithms. |
| 136 |
*/ |
| 137 |
if (sshkey_type_is_cert(ktype) && |
| 138 |
lookup_marker_in_hostkeys(hostkeys, MRK_CA)) { |
| 139 |
ALG_APPEND(first, alg); |
| 140 |
continue; |
| 141 |
} |
| 142 |
/* If the key appears in known_hosts then prefer it */ |
| 133 |
if (lookup_key_in_hostkeys_by_type(hostkeys, |
143 |
if (lookup_key_in_hostkeys_by_type(hostkeys, |
| 134 |
sshkey_type_plain(ktype), NULL)) |
144 |
sshkey_type_plain(ktype), NULL)) { |
| 135 |
ALG_APPEND(first, alg); |
145 |
ALG_APPEND(first, alg); |
| 136 |
else |
146 |
continue; |
| 137 |
ALG_APPEND(last, alg); |
147 |
} |
|
|
148 |
/* Otherwise, put it last */ |
| 149 |
ALG_APPEND(last, alg); |
| 138 |
} |
150 |
} |
| 139 |
#undef ALG_APPEND |
151 |
#undef ALG_APPEND |
| 140 |
xasprintf(&ret, "%s%s%s", first, |
152 |
xasprintf(&ret, "%s%s%s", first, |