diff options
author | jsing <> | 2016-11-05 08:26:37 +0000 |
---|---|---|
committer | jsing <> | 2016-11-05 08:26:37 +0000 |
commit | 9fa2112db3b5977fa473ce68fa02199114a3b870 (patch) | |
tree | f18e5a0a899b59b54269ba0efb72acd8d5566f6f /src/lib/libssl/t1_lib.c | |
parent | 8e601af590fe4daecd1a7d96cddb851fc0118296 (diff) | |
download | openbsd-9fa2112db3b5977fa473ce68fa02199114a3b870.tar.gz openbsd-9fa2112db3b5977fa473ce68fa02199114a3b870.tar.bz2 openbsd-9fa2112db3b5977fa473ce68fa02199114a3b870.zip |
Convert ssl3_get_server_kex_ecdhe() to CBS, simplifying tls1_check_curve()
in the process. This also fixes a long standing bug where
tls1_ec_curve_id2nid() is called with only one byte of the curve ID.
ok beck@ miod@
Diffstat (limited to 'src/lib/libssl/t1_lib.c')
-rw-r--r-- | src/lib/libssl/t1_lib.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c index e7dbe9cd99..090259cf1f 100644 --- a/src/lib/libssl/t1_lib.c +++ b/src/lib/libssl/t1_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: t1_lib.c,v 1.93 2016/10/19 16:38:40 jsing Exp $ */ | 1 | /* $OpenBSD: t1_lib.c,v 1.94 2016/11/05 08:26:37 jsing Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -282,7 +282,7 @@ static const uint16_t eccurves_default[] = { | |||
282 | }; | 282 | }; |
283 | 283 | ||
284 | int | 284 | int |
285 | tls1_ec_curve_id2nid(uint16_t curve_id) | 285 | tls1_ec_curve_id2nid(const uint16_t curve_id) |
286 | { | 286 | { |
287 | /* ECC curves from draft-ietf-tls-ecc-12.txt (Oct. 17, 2005) */ | 287 | /* ECC curves from draft-ietf-tls-ecc-12.txt (Oct. 17, 2005) */ |
288 | if ((curve_id < 1) || | 288 | if ((curve_id < 1) || |
@@ -405,27 +405,15 @@ tls1_get_curvelist(SSL *s, int client_curves, const uint16_t **pcurves, | |||
405 | 405 | ||
406 | /* Check that a curve is one of our preferences. */ | 406 | /* Check that a curve is one of our preferences. */ |
407 | int | 407 | int |
408 | tls1_check_curve(SSL *s, const unsigned char *p, size_t len) | 408 | tls1_check_curve(SSL *s, const uint16_t curve_id) |
409 | { | 409 | { |
410 | CBS cbs; | ||
411 | const uint16_t *curves; | 410 | const uint16_t *curves; |
412 | size_t curveslen, i; | 411 | size_t curveslen, i; |
413 | uint8_t type; | ||
414 | uint16_t cid; | ||
415 | |||
416 | CBS_init(&cbs, p, len); | ||
417 | |||
418 | /* Only named curves are supported. */ | ||
419 | if (CBS_len(&cbs) != 3 || | ||
420 | !CBS_get_u8(&cbs, &type) || | ||
421 | type != NAMED_CURVE_TYPE || | ||
422 | !CBS_get_u16(&cbs, &cid)) | ||
423 | return (0); | ||
424 | 412 | ||
425 | tls1_get_curvelist(s, 0, &curves, &curveslen); | 413 | tls1_get_curvelist(s, 0, &curves, &curveslen); |
426 | 414 | ||
427 | for (i = 0; i < curveslen; i++) { | 415 | for (i = 0; i < curveslen; i++) { |
428 | if (curves[i] == cid) | 416 | if (curves[i] == curve_id) |
429 | return (1); | 417 | return (1); |
430 | } | 418 | } |
431 | return (0); | 419 | return (0); |