diff options
| author | jsing <> | 2021-02-07 15:26:32 +0000 |
|---|---|---|
| committer | jsing <> | 2021-02-07 15:26:32 +0000 |
| commit | 47c1b962cd395a4d7c4ae96396ddc86dc0cb4aa7 (patch) | |
| tree | ea023a4f428381ff72f5edc2aec4d7c062671aff /src | |
| parent | cd637ddd633829db55ee42ccf627164fcba056b6 (diff) | |
| download | openbsd-47c1b962cd395a4d7c4ae96396ddc86dc0cb4aa7.tar.gz openbsd-47c1b962cd395a4d7c4ae96396ddc86dc0cb4aa7.tar.bz2 openbsd-47c1b962cd395a4d7c4ae96396ddc86dc0cb4aa7.zip | |
Absorb ssl3_get_algorithm2() into ssl_get_handshake_evp_md().
The mess that is ssl_get_algorithm2() only exists to upgrade the handshake
MAC of a pre-TLSv1.2 cipher suite to SHA256 when used with TLSv1.2. We can
readily do this in ssl_get_handshake_evp_md(), which is far more readable.
ok tb@
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libssl/s3_lib.c | 16 | ||||
| -rw-r--r-- | src/lib/libssl/ssl_ciph.c | 16 | ||||
| -rw-r--r-- | src/lib/libssl/ssl_clnt.c | 5 | ||||
| -rw-r--r-- | src/lib/libssl/ssl_locl.h | 4 |
4 files changed, 19 insertions, 22 deletions
diff --git a/src/lib/libssl/s3_lib.c b/src/lib/libssl/s3_lib.c index 3df2ef76db..75f71c4c7d 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.203 2021/02/07 15:12:52 jsing Exp $ */ | 1 | /* $OpenBSD: s3_lib.c,v 1.204 2021/02/07 15:26:32 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 | * |
| @@ -2722,17 +2722,3 @@ ssl3_renegotiate_check(SSL *s) | |||
| 2722 | } | 2722 | } |
| 2723 | return (ret); | 2723 | return (ret); |
| 2724 | } | 2724 | } |
| 2725 | /* | ||
| 2726 | * If we are using default SHA1+MD5 algorithms switch to new SHA256 PRF | ||
| 2727 | * and handshake macs if required. | ||
| 2728 | */ | ||
| 2729 | long | ||
| 2730 | ssl_get_algorithm2(SSL *s) | ||
| 2731 | { | ||
| 2732 | long alg2 = S3I(s)->hs.new_cipher->algorithm2; | ||
| 2733 | |||
| 2734 | if (SSL_USE_SHA256_PRF(s) && | ||
| 2735 | alg2 == (SSL_HANDSHAKE_MAC_DEFAULT|TLS1_PRF)) | ||
| 2736 | return SSL_HANDSHAKE_MAC_SHA256 | TLS1_PRF_SHA256; | ||
| 2737 | return alg2; | ||
| 2738 | } | ||
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c index fd576cee7b..1ffd90dc16 100644 --- a/src/lib/libssl/ssl_ciph.c +++ b/src/lib/libssl/ssl_ciph.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_ciph.c,v 1.119 2020/09/13 16:49:05 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_ciph.c,v 1.120 2021/02/07 15:26:32 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 | * |
| @@ -559,9 +559,21 @@ ssl_cipher_get_evp_aead(const SSL_SESSION *ss, const EVP_AEAD **aead) | |||
| 559 | int | 559 | int |
| 560 | ssl_get_handshake_evp_md(SSL *s, const EVP_MD **md) | 560 | ssl_get_handshake_evp_md(SSL *s, const EVP_MD **md) |
| 561 | { | 561 | { |
| 562 | unsigned long handshake_mac; | ||
| 563 | |||
| 562 | *md = NULL; | 564 | *md = NULL; |
| 563 | 565 | ||
| 564 | switch (ssl_get_algorithm2(s) & SSL_HANDSHAKE_MAC_MASK) { | 566 | if (S3I(s)->hs.new_cipher == NULL) |
| 567 | return 0; | ||
| 568 | |||
| 569 | handshake_mac = S3I(s)->hs.new_cipher->algorithm2 & | ||
| 570 | SSL_HANDSHAKE_MAC_MASK; | ||
| 571 | |||
| 572 | /* For TLSv1.2 we upgrade the default MD5+SHA1 MAC to SHA256. */ | ||
| 573 | if (SSL_USE_SHA256_PRF(s) && handshake_mac == SSL_HANDSHAKE_MAC_DEFAULT) | ||
| 574 | handshake_mac = SSL_HANDSHAKE_MAC_SHA256; | ||
| 575 | |||
| 576 | switch (handshake_mac) { | ||
| 565 | case SSL_HANDSHAKE_MAC_DEFAULT: | 577 | case SSL_HANDSHAKE_MAC_DEFAULT: |
| 566 | *md = EVP_md5_sha1(); | 578 | *md = EVP_md5_sha1(); |
| 567 | return 1; | 579 | return 1; |
diff --git a/src/lib/libssl/ssl_clnt.c b/src/lib/libssl/ssl_clnt.c index 25164ea012..0c7bdbc776 100644 --- a/src/lib/libssl/ssl_clnt.c +++ b/src/lib/libssl/ssl_clnt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ssl_clnt.c,v 1.77 2021/02/07 15:04:10 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_clnt.c,v 1.78 2021/02/07 15:26:32 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 | * |
| @@ -2238,7 +2238,8 @@ ssl3_send_client_kex_gost(SSL *s, SESS_CERT *sess_cert, CBB *cbb) | |||
| 2238 | goto err; | 2238 | goto err; |
| 2239 | } | 2239 | } |
| 2240 | 2240 | ||
| 2241 | if (ssl_get_algorithm2(s) & SSL_HANDSHAKE_MAC_GOST94) | 2241 | /* XXX check handshake hash instead. */ |
| 2242 | if (S3I(s)->hs.new_cipher->algorithm2 & SSL_HANDSHAKE_MAC_GOST94) | ||
| 2242 | nid = NID_id_GostR3411_94; | 2243 | nid = NID_id_GostR3411_94; |
| 2243 | else | 2244 | else |
| 2244 | nid = NID_id_tc26_gost3411_2012_256; | 2245 | nid = NID_id_tc26_gost3411_2012_256; |
diff --git a/src/lib/libssl/ssl_locl.h b/src/lib/libssl/ssl_locl.h index b56a99bb79..edb8223fe2 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.319 2021/02/07 15:04:10 jsing Exp $ */ | 1 | /* $OpenBSD: ssl_locl.h,v 1.320 2021/02/07 15:26:32 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 | * |
| @@ -1383,8 +1383,6 @@ int ssl_check_serverhello_tlsext(SSL *s); | |||
| 1383 | 1383 | ||
| 1384 | int tls1_process_ticket(SSL *s, CBS *ext_block, int *alert, SSL_SESSION **ret); | 1384 | int tls1_process_ticket(SSL *s, CBS *ext_block, int *alert, SSL_SESSION **ret); |
| 1385 | 1385 | ||
| 1386 | long ssl_get_algorithm2(SSL *s); | ||
| 1387 | |||
| 1388 | int tls1_check_ec_server_key(SSL *s); | 1386 | int tls1_check_ec_server_key(SSL *s); |
| 1389 | 1387 | ||
| 1390 | /* s3_cbc.c */ | 1388 | /* s3_cbc.c */ |
