From 4cb07c9e3fc91e5dc28172f5d72c551e563f49dd Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Sun, 15 Mar 2020 11:18:30 +0100 Subject: prf: define gnutls_prf_get as an ephemeral API Signed-off-by: Daiki Ueno --- lib/ephemeral_functions.gperf | 1 + lib/gnutls_int.h | 2 ++ lib/includes/gnutls/ephemeral.h | 2 ++ lib/prf.c | 20 ++++++++++++++++++++ 4 files changed, 25 insertions(+) diff --git a/lib/ephemeral_functions.gperf b/lib/ephemeral_functions.gperf index caf1f20e3f..1d96f18c2e 100644 --- a/lib/ephemeral_functions.gperf +++ b/lib/ephemeral_functions.gperf @@ -3,3 +3,4 @@ %readonly-tables struct ephemeral_function_st { const char *name; void *func; }; %% +gnutls_prf_get, _gnutls_prf_get diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index d9d851be62..e23e1b17f2 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -1639,4 +1639,6 @@ get_certificate_type(gnutls_session_t session, extern unsigned int _gnutls_global_version; +int _gnutls_prf_get(gnutls_session_t session); + #endif /* GNUTLS_LIB_GNUTLS_INT_H */ diff --git a/lib/includes/gnutls/ephemeral.h b/lib/includes/gnutls/ephemeral.h index 9a9a6c8ccd..f7dfdb049d 100644 --- a/lib/includes/gnutls/ephemeral.h +++ b/lib/includes/gnutls/ephemeral.h @@ -53,6 +53,8 @@ static inline ret name arglist \ return ((ret (*)arglist)func)args; \ } +GNUTLS_EPHEMERAL_INT(gnutls_prf_get, int, (gnutls_session_t session), (session)) + /* *INDENT-OFF* */ #ifdef __cplusplus } diff --git a/lib/prf.c b/lib/prf.c index 40c52d156f..ee09ed4966 100644 --- a/lib/prf.c +++ b/lib/prf.c @@ -348,3 +348,23 @@ gnutls_prf(gnutls_session_t session, return ret; } + +/** + * _gnutls_prf_get: + * @session: is a #gnutls_session_t type. + * + * Returns the current PRF algorithm enabled on the session. + * + * Returns: a #gnutls_mac_algorithm_t on success, or a negative error code. + * + * Since: 3.6.13 + * Stability: Unstable + **/ +int +_gnutls_prf_get(gnutls_session_t session) +{ + if (session->security_parameters.prf == NULL) + return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST); + + return session->security_parameters.prf->id; +} -- cgit v1.2.1