diff options
Diffstat (limited to 'lib/quic-api.c')
-rw-r--r-- | lib/quic-api.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/quic-api.c b/lib/quic-api.c new file mode 100644 index 0000000000..31908ac507 --- /dev/null +++ b/lib/quic-api.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 Free Software Foundation, Inc. + * + * Author: Aniketh Girish + * + * This file is part of GnuTLS. + * + * The GnuTLS is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/> + * + */ + +/* This file contains TLS API for QUIC protocol related types, prototypes and includes. + */ + +#include "gnutls_int.h" +#include "quic.h" +#include <gnutls/gnutls.h> + + +/** + * gnutls_session_set_secret_hook_function: + * @session: is #gnutls_session_t type + * @func: is the function to be called + * + * This function will set a callback to be called when a new traffic + * secret is installed. The callback will only be called when TLS 1.3 + * or later is negotiated. + * + * Since: 3.6.11 + */ +void +gnutls_session_set_secret_hook_function(gnutls_session_t session, + gnutls_secret_hook_func func) +{ + session->internals.secret_hook = func; +} + +void +_gnutls_call_secret_hook_func(gnutls_session_t session, + gnutls_encryption_level_t level, + unsigned int sender, + const uint8_t *secret, + size_t secret_size) +{ + if (session->internals.secret_hook != NULL) { + unsigned int incoming = + sender != session->security_parameters.entity; + gnutls_datum_t data = {(void*)secret, secret_size}; + + session->internals.secret_hook(session, level, incoming, &data); + } +} |