summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-07-14 15:39:36 +0000
committertb <>2024-07-14 15:39:36 +0000
commitf3b35d1af02c3bc250276acd62a2434d3b80d349 (patch)
treeb0f8e29dbb39c011b65adc36293b16c4cd32aed7 /src
parent3006ff83f98c4783ee71689e5e63047b95dc7bca (diff)
downloadopenbsd-f3b35d1af02c3bc250276acd62a2434d3b80d349.tar.gz
openbsd-f3b35d1af02c3bc250276acd62a2434d3b80d349.tar.bz2
openbsd-f3b35d1af02c3bc250276acd62a2434d3b80d349.zip
Prepare to provide SSL_CIPHER_get_handshake_digest()
Needed by newer freeradius. This is a straightforward implementation that essentially duplicates tls13_cipher_hash(). ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/hidden/openssl/ssl.h3
-rw-r--r--src/lib/libssl/ssl.h5
-rw-r--r--src/lib/libssl/ssl_ciph.c18
3 files changed, 23 insertions, 3 deletions
diff --git a/src/lib/libssl/hidden/openssl/ssl.h b/src/lib/libssl/hidden/openssl/ssl.h
index aa946ad25d..cff250ee75 100644
--- a/src/lib/libssl/hidden/openssl/ssl.h
+++ b/src/lib/libssl/hidden/openssl/ssl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl.h,v 1.6 2024/03/02 11:48:55 tb Exp $ */ 1/* $OpenBSD: ssl.h,v 1.7 2024/07/14 15:39:36 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2023 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -377,5 +377,6 @@ LSSL_USED(SSL_get_peer_quic_transport_params);
377LSSL_USED(SSL_set_quic_use_legacy_codepoint); 377LSSL_USED(SSL_set_quic_use_legacy_codepoint);
378LSSL_USED(ERR_load_SSL_strings); 378LSSL_USED(ERR_load_SSL_strings);
379LSSL_USED(OPENSSL_init_ssl); 379LSSL_USED(OPENSSL_init_ssl);
380LSSL_USED(SSL_CIPHER_get_handshake_digest);
380 381
381#endif /* _LIBSSL_SSL_H */ 382#endif /* _LIBSSL_SSL_H */
diff --git a/src/lib/libssl/ssl.h b/src/lib/libssl/ssl.h
index e63312a123..d8846a4851 100644
--- a/src/lib/libssl/ssl.h
+++ b/src/lib/libssl/ssl.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssl.h,v 1.238 2024/07/13 18:33:18 tb Exp $ */ 1/* $OpenBSD: ssl.h,v 1.239 2024/07/14 15:39:36 tb 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 *
@@ -1125,6 +1125,9 @@ int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c);
1125int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c); 1125int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c);
1126int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c); 1126int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c);
1127int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c); 1127int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c);
1128#if defined(LIBRESSL_INTERNAL) || defined(LIBRESSL_NEXT_API)
1129const EVP_MD *SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c);
1130#endif
1128int SSL_CIPHER_is_aead(const SSL_CIPHER *c); 1131int SSL_CIPHER_is_aead(const SSL_CIPHER *c);
1129 1132
1130int SSL_get_fd(const SSL *s); 1133int SSL_get_fd(const SSL *s);
diff --git a/src/lib/libssl/ssl_ciph.c b/src/lib/libssl/ssl_ciph.c
index a01465d9e0..13790c56be 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.142 2024/05/09 07:55:48 tb Exp $ */ 1/* $OpenBSD: ssl_ciph.c,v 1.143 2024/07/14 15:39:36 tb 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 *
@@ -524,6 +524,7 @@ ssl_get_handshake_evp_md(SSL *s, const EVP_MD **md)
524 524
525 handshake_mac = s->s3->hs.cipher->algorithm2 & SSL_HANDSHAKE_MAC_MASK; 525 handshake_mac = s->s3->hs.cipher->algorithm2 & SSL_HANDSHAKE_MAC_MASK;
526 526
527 /* XXX - can we simplify this now that TLSv1.0 and TLSv1.1 are gone? */
527 /* For TLSv1.2 we upgrade the default MD5+SHA1 MAC to SHA256. */ 528 /* For TLSv1.2 we upgrade the default MD5+SHA1 MAC to SHA256. */
528 if (SSL_USE_SHA256_PRF(s) && handshake_mac == SSL_HANDSHAKE_MAC_DEFAULT) 529 if (SSL_USE_SHA256_PRF(s) && handshake_mac == SSL_HANDSHAKE_MAC_DEFAULT)
529 handshake_mac = SSL_HANDSHAKE_MAC_SHA256; 530 handshake_mac = SSL_HANDSHAKE_MAC_SHA256;
@@ -1624,6 +1625,21 @@ SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c)
1624} 1625}
1625LSSL_ALIAS(SSL_CIPHER_get_auth_nid); 1626LSSL_ALIAS(SSL_CIPHER_get_auth_nid);
1626 1627
1628const EVP_MD *
1629SSL_CIPHER_get_handshake_digest(const SSL_CIPHER *c)
1630{
1631 switch (c->algorithm2 & SSL_HANDSHAKE_MAC_MASK) {
1632 case SSL_HANDSHAKE_MAC_DEFAULT:
1633 case SSL_HANDSHAKE_MAC_SHA256:
1634 return EVP_sha256();
1635 case SSL_HANDSHAKE_MAC_SHA384:
1636 return EVP_sha384();
1637 default:
1638 return NULL;
1639 }
1640}
1641LSSL_ALIAS(SSL_CIPHER_get_handshake_digest);
1642
1627int 1643int
1628SSL_CIPHER_is_aead(const SSL_CIPHER *c) 1644SSL_CIPHER_is_aead(const SSL_CIPHER *c)
1629{ 1645{