From 6e2e00257ac495d46ebe67e59fc48b67f8701fb3 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 21 Apr 2020 16:29:41 +0200 Subject: gnutls_ext_get_name2: new function This adds a generalized version of gnutls_ext_get_name, which can retrieve the name of the extension, even if it is registered per session. Signed-off-by: Daiki Ueno --- devel/libgnutls-latest-x86_64.abi | 1 + devel/symbols.last | 2 ++ doc/Makefile.am | 2 ++ doc/manpages/Makefile.am | 1 + lib/hello_ext.c | 24 ++++++++++++++++++++++++ lib/includes/gnutls/gnutls.h.in | 2 ++ lib/libgnutls.map | 6 ++++++ 7 files changed, 38 insertions(+) diff --git a/devel/libgnutls-latest-x86_64.abi b/devel/libgnutls-latest-x86_64.abi index 12d5f5b7af..8aa81a55dd 100644 --- a/devel/libgnutls-latest-x86_64.abi +++ b/devel/libgnutls-latest-x86_64.abi @@ -271,6 +271,7 @@ + diff --git a/devel/symbols.last b/devel/symbols.last index 5a8343a0f0..080f7f2954 100644 --- a/devel/symbols.last +++ b/devel/symbols.last @@ -3,6 +3,7 @@ GNUTLS_3_6_0@GNUTLS_3_6_0 GNUTLS_3_6_10@GNUTLS_3_6_10 GNUTLS_3_6_12@GNUTLS_3_6_12 GNUTLS_3_6_13@GNUTLS_3_6_13 +GNUTLS_3_6_14@GNUTLS_3_6_14 GNUTLS_3_6_2@GNUTLS_3_6_2 GNUTLS_3_6_3@GNUTLS_3_6_3 GNUTLS_3_6_4@GNUTLS_3_6_4 @@ -215,6 +216,7 @@ gnutls_error_to_alert@GNUTLS_3_4 gnutls_est_record_overhead_size@GNUTLS_3_4 gnutls_ext_get_current_msg@GNUTLS_3_6_3 gnutls_ext_get_data@GNUTLS_3_4 +gnutls_ext_get_name2@GNUTLS_3_6_14 gnutls_ext_get_name@GNUTLS_3_4 gnutls_ext_raw_parse@GNUTLS_3_6_3 gnutls_ext_register@GNUTLS_3_4 diff --git a/doc/Makefile.am b/doc/Makefile.am index 0f16eeccc8..83d851220c 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1023,6 +1023,8 @@ FUNCS += functions/gnutls_ext_get_data FUNCS += functions/gnutls_ext_get_data.short FUNCS += functions/gnutls_ext_get_name FUNCS += functions/gnutls_ext_get_name.short +FUNCS += functions/gnutls_ext_get_name2 +FUNCS += functions/gnutls_ext_get_name2.short FUNCS += functions/gnutls_ext_raw_parse FUNCS += functions/gnutls_ext_raw_parse.short FUNCS += functions/gnutls_ext_register diff --git a/doc/manpages/Makefile.am b/doc/manpages/Makefile.am index 97cc80ed6e..18f382ee45 100644 --- a/doc/manpages/Makefile.am +++ b/doc/manpages/Makefile.am @@ -313,6 +313,7 @@ APIMANS += gnutls_est_record_overhead_size.3 APIMANS += gnutls_ext_get_current_msg.3 APIMANS += gnutls_ext_get_data.3 APIMANS += gnutls_ext_get_name.3 +APIMANS += gnutls_ext_get_name2.3 APIMANS += gnutls_ext_raw_parse.3 APIMANS += gnutls_ext_register.3 APIMANS += gnutls_ext_set_data.3 diff --git a/lib/hello_ext.c b/lib/hello_ext.c index 1df1506e0b..8052488366 100644 --- a/lib/hello_ext.c +++ b/lib/hello_ext.c @@ -1000,3 +1000,27 @@ unsigned gnutls_ext_get_current_msg(gnutls_session_t session) { return _gnutls_ext_get_msg(session); } + +/** + * gnutls_ext_get_name2: + * @session: a #gnutls_session_t opaque pointer + * @tls_id: is a TLS extension numeric ID + * @parse_point: the parse type of the extension + * + * Convert a TLS extension numeric ID to a printable string. + * + * Returns: a pointer to a string that contains the name of the + * specified cipher, or %NULL. + **/ +const char *gnutls_ext_get_name2(gnutls_session_t session, unsigned int tls_id, + gnutls_ext_parse_type_t parse_point) +{ + const struct hello_ext_entry_st *ext; + + ext = tls_id_to_ext_entry(session, tls_id, parse_point); + if (ext) + return ext->name; + + return NULL; +} + diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index 517153634a..fdcf914f42 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -3130,6 +3130,8 @@ int gnutls_session_ext_register(gnutls_session_t, const char *name, int type, gn gnutls_ext_unpack_func unpack_func, unsigned flags); const char *gnutls_ext_get_name(unsigned int ext); +const char *gnutls_ext_get_name2(gnutls_session_t session, unsigned int tls_id, + gnutls_ext_parse_type_t parse_point); /* Public supplemental data related functions */ diff --git a/lib/libgnutls.map b/lib/libgnutls.map index 5541e9caba..512e403bb6 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -1324,6 +1324,12 @@ GNUTLS_3_6_13 gnutls_psk_set_client_credentials_function2; } GNUTLS_3_6_12; +GNUTLS_3_6_14 +{ + global: + gnutls_ext_get_name2; +} GNUTLS_3_6_13; + GNUTLS_FIPS140_3_4 { global: gnutls_cipher_self_test; -- cgit v1.2.1