summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2018-11-05 06:55:37 +0000
committerjsing <>2018-11-05 06:55:37 +0000
commit6947abc46581e19432245e0ce409d468fb702c7d (patch)
tree1b8aa8d5399aca7e65610168e61564f2acac553b /src
parent2ab1af323eb2251dedee9fcb3661f284ae62b640 (diff)
downloadopenbsd-6947abc46581e19432245e0ce409d468fb702c7d.tar.gz
openbsd-6947abc46581e19432245e0ce409d468fb702c7d.tar.bz2
openbsd-6947abc46581e19432245e0ce409d468fb702c7d.zip
Clean up the code that checks if we can choose an EC cipher suite.
The tls1_check_ec_tmp_key() function is now rather misnamed, so just inline the code. Also, rather than running tls1_get_shared_curve() once per EC cipher suite, we can run it once at the start of the ssl3_choose_cipher() function. ok bluhm@ tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/s3_lib.c7
-rw-r--r--src/lib/libssl/ssl_locl.h3
-rw-r--r--src/lib/libssl/t1_lib.c13
3 files changed, 7 insertions, 16 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c
index 6fcbbfc2c5..e1bad1ba1a 100644
--- a/src/lib/libssl/s3_lib.c
+++ b/src/lib/libssl/s3_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: s3_lib.c,v 1.171 2018/10/24 18:04:50 jsing Exp $ */ 1/* $OpenBSD: s3_lib.c,v 1.172 2018/11/05 06:55: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 *
@@ -2286,12 +2286,15 @@ ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
2286 unsigned long alg_k, alg_a, mask_k, mask_a; 2286 unsigned long alg_k, alg_a, mask_k, mask_a;
2287 STACK_OF(SSL_CIPHER) *prio, *allow; 2287 STACK_OF(SSL_CIPHER) *prio, *allow;
2288 SSL_CIPHER *c, *ret = NULL; 2288 SSL_CIPHER *c, *ret = NULL;
2289 int can_use_ecc;
2289 int i, ii, ok; 2290 int i, ii, ok;
2290 CERT *cert; 2291 CERT *cert;
2291 2292
2292 /* Let's see which ciphers we can support */ 2293 /* Let's see which ciphers we can support */
2293 cert = s->cert; 2294 cert = s->cert;
2294 2295
2296 can_use_ecc = (tls1_get_shared_curve(s) != NID_undef);
2297
2295 /* 2298 /*
2296 * Do not set the compare functions, because this may lead to a 2299 * Do not set the compare functions, because this may lead to a
2297 * reordering by "id". We want to keep the original ordering. 2300 * reordering by "id". We want to keep the original ordering.
@@ -2336,7 +2339,7 @@ ssl3_choose_cipher(SSL *s, STACK_OF(SSL_CIPHER) *clnt,
2336 * an ephemeral EC key check it. 2339 * an ephemeral EC key check it.
2337 */ 2340 */
2338 if (alg_k & SSL_kECDHE) 2341 if (alg_k & SSL_kECDHE)
2339 ok = ok && tls1_check_ec_tmp_key(s); 2342 ok = ok && can_use_ecc;
2340 2343
2341 if (!ok) 2344 if (!ok)
2342 continue; 2345 continue;
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h
index 8cedc29490..b11bb4ac61 100644
--- a/src/lib/libssl/ssl_locl.h
+++ b/src/lib/libssl/ssl_locl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl_locl.h,v 1.217 2018/11/05 03:49:44 jsing Exp $ */ 1/* $OpenBSD: ssl_locl.h,v 1.218 2018/11/05 06:55: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 *
@@ -1287,7 +1287,6 @@ void tls12_get_req_sig_algs(SSL *s, unsigned char **sigalgs,
1287 size_t *sigalgs_len); 1287 size_t *sigalgs_len);
1288 1288
1289int tls1_check_ec_server_key(SSL *s); 1289int tls1_check_ec_server_key(SSL *s);
1290int tls1_check_ec_tmp_key(SSL *s);
1291 1290
1292int ssl_add_clienthello_use_srtp_ext(SSL *s, unsigned char *p, 1291int ssl_add_clienthello_use_srtp_ext(SSL *s, unsigned char *p,
1293 int *len, int maxlen); 1292 int *len, int maxlen);
diff --git a/src/lib/libssl/t1_lib.c b/src/lib/libssl/t1_lib.c
index 30305e6b2f..b06004e88a 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.145 2018/11/05 03:49:44 jsing Exp $ */ 1/* $OpenBSD: t1_lib.c,v 1.146 2018/11/05 06:55: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 *
@@ -604,17 +604,6 @@ tls1_check_ec_server_key(SSL *s)
604 return tls1_check_ec_key(s, &curve_id, &comp_id); 604 return tls1_check_ec_key(s, &curve_id, &comp_id);
605} 605}
606 606
607/* Check EC temporary key is compatible with client extensions. */
608int
609tls1_check_ec_tmp_key(SSL *s)
610{
611 /* Need a shared curve. */
612 if (tls1_get_shared_curve(s) != NID_undef)
613 return (1);
614
615 return (0);
616}
617
618/* 607/*
619 * List of supported signature algorithms and hashes. Should make this 608 * List of supported signature algorithms and hashes. Should make this
620 * customisable at some point, for now include everything we support. 609 * customisable at some point, for now include everything we support.