|
Lines 35-40
Link Here
|
| 35 |
#include "compat.h" |
35 |
#include "compat.h" |
| 36 |
#include "log.h" |
36 |
#include "log.h" |
| 37 |
#include "match.h" |
37 |
#include "match.h" |
|
|
38 |
#include "kex.h" |
| 38 |
|
39 |
|
| 39 |
int compat13 = 0; |
40 |
int compat13 = 0; |
| 40 |
int compat20 = 0; |
41 |
int compat20 = 0; |
|
Lines 248-289
proto_spec(const char *spec)
Link Here
|
| 248 |
return ret; |
249 |
return ret; |
| 249 |
} |
250 |
} |
| 250 |
|
251 |
|
| 251 |
/* |
|
|
| 252 |
* Filters a proposal string, excluding any algorithm matching the 'filter' |
| 253 |
* pattern list. |
| 254 |
*/ |
| 255 |
static char * |
| 256 |
filter_proposal(char *proposal, const char *filter) |
| 257 |
{ |
| 258 |
Buffer b; |
| 259 |
char *orig_prop, *fix_prop; |
| 260 |
char *cp, *tmp; |
| 261 |
|
| 262 |
buffer_init(&b); |
| 263 |
tmp = orig_prop = xstrdup(proposal); |
| 264 |
while ((cp = strsep(&tmp, ",")) != NULL) { |
| 265 |
if (match_pattern_list(cp, filter, 0) != 1) { |
| 266 |
if (buffer_len(&b) > 0) |
| 267 |
buffer_append(&b, ",", 1); |
| 268 |
buffer_append(&b, cp, strlen(cp)); |
| 269 |
} else |
| 270 |
debug2("Compat: skipping algorithm \"%s\"", cp); |
| 271 |
} |
| 272 |
buffer_append(&b, "\0", 1); |
| 273 |
fix_prop = xstrdup((char *)buffer_ptr(&b)); |
| 274 |
buffer_free(&b); |
| 275 |
free(orig_prop); |
| 276 |
|
| 277 |
return fix_prop; |
| 278 |
} |
| 279 |
|
| 280 |
char * |
252 |
char * |
| 281 |
compat_cipher_proposal(char *cipher_prop) |
253 |
compat_cipher_proposal(char *cipher_prop) |
| 282 |
{ |
254 |
{ |
| 283 |
if (!(datafellows & SSH_BUG_BIGENDIANAES)) |
255 |
if (!(datafellows & SSH_BUG_BIGENDIANAES)) |
| 284 |
return cipher_prop; |
256 |
return cipher_prop; |
| 285 |
debug2("%s: original cipher proposal: %s", __func__, cipher_prop); |
257 |
debug2("%s: original cipher proposal: %s", __func__, cipher_prop); |
| 286 |
cipher_prop = filter_proposal(cipher_prop, "aes*"); |
258 |
if ((cipher_prop = match_filter_list(cipher_prop, "aes*")) == NULL) |
|
|
259 |
fatal("match_filter_list failed"); |
| 287 |
debug2("%s: compat cipher proposal: %s", __func__, cipher_prop); |
260 |
debug2("%s: compat cipher proposal: %s", __func__, cipher_prop); |
| 288 |
if (*cipher_prop == '\0') |
261 |
if (*cipher_prop == '\0') |
| 289 |
fatal("No supported ciphers found"); |
262 |
fatal("No supported ciphers found"); |
|
Lines 296-302
compat_pkalg_proposal(char *pkalg_prop)
Link Here
|
| 296 |
if (!(datafellows & SSH_BUG_RSASIGMD5)) |
269 |
if (!(datafellows & SSH_BUG_RSASIGMD5)) |
| 297 |
return pkalg_prop; |
270 |
return pkalg_prop; |
| 298 |
debug2("%s: original public key proposal: %s", __func__, pkalg_prop); |
271 |
debug2("%s: original public key proposal: %s", __func__, pkalg_prop); |
| 299 |
pkalg_prop = filter_proposal(pkalg_prop, "ssh-rsa"); |
272 |
if ((pkalg_prop = match_filter_list(pkalg_prop, "ssh-rsa")) == NULL) |
|
|
273 |
fatal("match_filter_list failed"); |
| 300 |
debug2("%s: compat public key proposal: %s", __func__, pkalg_prop); |
274 |
debug2("%s: compat public key proposal: %s", __func__, pkalg_prop); |
| 301 |
if (*pkalg_prop == '\0') |
275 |
if (*pkalg_prop == '\0') |
| 302 |
fatal("No supported PK algorithms found"); |
276 |
fatal("No supported PK algorithms found"); |
|
Lines 310-319
compat_kex_proposal(char *p)
Link Here
|
| 310 |
return p; |
284 |
return p; |
| 311 |
debug2("%s: original KEX proposal: %s", __func__, p); |
285 |
debug2("%s: original KEX proposal: %s", __func__, p); |
| 312 |
if ((datafellows & SSH_BUG_CURVE25519PAD) != 0) |
286 |
if ((datafellows & SSH_BUG_CURVE25519PAD) != 0) |
| 313 |
p = filter_proposal(p, "curve25519-sha256@libssh.org"); |
287 |
if ((p = match_filter_list(p, |
|
|
288 |
"curve25519-sha256@libssh.org")) == NULL) |
| 289 |
fatal("match_filter_list failed"); |
| 314 |
if ((datafellows & SSH_OLD_DHGEX) != 0) { |
290 |
if ((datafellows & SSH_OLD_DHGEX) != 0) { |
| 315 |
p = filter_proposal(p, "diffie-hellman-group-exchange-sha256"); |
291 |
if ((p = match_filter_list(p, |
| 316 |
p = filter_proposal(p, "diffie-hellman-group-exchange-sha1"); |
292 |
"diffie-hellman-group-exchange-sha256," |
|
|
293 |
"diffie-hellman-group-exchange-sha1")) == NULL) |
| 294 |
fatal("match_filter_list failed"); |
| 317 |
} |
295 |
} |
| 318 |
debug2("%s: compat KEX proposal: %s", __func__, p); |
296 |
debug2("%s: compat KEX proposal: %s", __func__, p); |
| 319 |
if (*p == '\0') |
297 |
if (*p == '\0') |