summaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorAlex Bozarth <ajbozart@us.ibm.com>2023-05-19 14:08:41 -0500
committerTomas Mraz <tomas@openssl.org>2023-06-06 17:03:41 +0200
commit68668243b176cd2bc53a83c6768d4f39930ba8ed (patch)
tree61cddf3545b28d1f276a92eb8e8736fcc5cb932b /ssl
parent8229874476cc2955e6947cf6d3fee09e13b8c160 (diff)
Add SSL_get0_group_name() to get name of the group used for KEX
Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/20866)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/s3_lib.c16
-rw-r--r--ssl/ssl_local.h1
-rw-r--r--ssl/t1_lib.c10
3 files changed, 27 insertions, 0 deletions
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index 835af33fea..10cff08eae 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -5022,6 +5022,22 @@ int ssl_encapsulate(SSL_CONNECTION *s, EVP_PKEY *pubkey,
return rv;
}
+const char *SSL_get0_group_name(SSL *s)
+{
+ SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL(s);
+ unsigned int id;
+
+ if (sc == NULL)
+ return NULL;
+
+ if (SSL_CONNECTION_IS_TLS13(sc) && sc->s3.did_kex)
+ id = sc->s3.group_id;
+ else
+ id = sc->session->kex_group;
+
+ return tls1_group_id2name(s->ctx, id);
+}
+
const char *SSL_group_to_name(SSL *s, int nid) {
int group_id = 0;
const TLS_GROUP_INFO *cinf = NULL;
diff --git a/ssl/ssl_local.h b/ssl/ssl_local.h
index 7ab84acc80..decb02a207 100644
--- a/ssl/ssl_local.h
+++ b/ssl/ssl_local.h
@@ -2767,6 +2767,7 @@ __owur int ssl_check_srvr_ecc_cert_and_alg(X509 *x, SSL_CONNECTION *s);
SSL_COMP *ssl3_comp_find(STACK_OF(SSL_COMP) *sk, int n);
__owur const TLS_GROUP_INFO *tls1_group_id_lookup(SSL_CTX *ctx, uint16_t curve_id);
+__owur const char *tls1_group_id2name(SSL_CTX *ctx, uint16_t group_id);
__owur int tls1_group_id2nid(uint16_t group_id, int include_unknown);
__owur uint16_t tls1_nid2group_id(int nid);
__owur int tls1_check_group_id(SSL_CONNECTION *s, uint16_t group_id,
diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c
index 189f241f7a..576c7a3271 100644
--- a/ssl/t1_lib.c
+++ b/ssl/t1_lib.c
@@ -755,6 +755,16 @@ const TLS_GROUP_INFO *tls1_group_id_lookup(SSL_CTX *ctx, uint16_t group_id)
return NULL;
}
+const char *tls1_group_id2name(SSL_CTX *ctx, uint16_t group_id)
+{
+ const TLS_GROUP_INFO *tls_group_info = tls1_group_id_lookup(ctx, group_id);
+
+ if (tls_group_info == NULL)
+ return NULL;
+
+ return tls_group_info->tlsname;
+}
+
int tls1_group_id2nid(uint16_t group_id, int include_unknown)
{
size_t i;