summaryrefslogtreecommitdiff
path: root/lib/quic-api.c
blob: 31908ac507afea3f82aa295c5cb2950649e87684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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);
	}
}