/src/gnutls/lib/tls13/encrypted_extensions.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (C) 2017 Red Hat, Inc. |
3 | | * |
4 | | * Author: Nikos Mavrogiannopoulos |
5 | | * |
6 | | * This file is part of GnuTLS. |
7 | | * |
8 | | * The GnuTLS is free software; you can redistribute it and/or |
9 | | * modify it under the terms of the GNU Lesser General Public License |
10 | | * as published by the Free Software Foundation; either version 2.1 of |
11 | | * the License, or (at your option) any later version. |
12 | | * |
13 | | * This library is distributed in the hope that it will be useful, but |
14 | | * WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | | * Lesser General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public License |
19 | | * along with this program. If not, see <https://www.gnu.org/licenses/> |
20 | | * |
21 | | */ |
22 | | |
23 | | #include "gnutls_int.h" |
24 | | #include "errors.h" |
25 | | #include "hello_ext.h" |
26 | | #include "handshake.h" |
27 | | #include "mbuffers.h" |
28 | | #include "tls13/encrypted_extensions.h" |
29 | | |
30 | | int _gnutls13_recv_encrypted_extensions(gnutls_session_t session) |
31 | 0 | { |
32 | 0 | int ret; |
33 | 0 | gnutls_buffer_st buf; |
34 | |
|
35 | 0 | ret = _gnutls_recv_handshake( |
36 | 0 | session, GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS, 0, &buf); |
37 | 0 | if (ret < 0) |
38 | 0 | return gnutls_assert_val(ret); |
39 | | |
40 | 0 | _gnutls_handshake_log("HSK[%p]: parsing encrypted extensions\n", |
41 | 0 | session); |
42 | 0 | ret = _gnutls_parse_hello_extensions(session, GNUTLS_EXT_FLAG_EE, |
43 | 0 | GNUTLS_EXT_ANY, buf.data, |
44 | 0 | buf.length); |
45 | 0 | _gnutls_buffer_clear(&buf); |
46 | |
|
47 | 0 | if (ret < 0) |
48 | 0 | return gnutls_assert_val(ret); |
49 | | |
50 | 0 | return 0; |
51 | 0 | } |
52 | | |
53 | | int _gnutls13_send_encrypted_extensions(gnutls_session_t session, |
54 | | unsigned again) |
55 | 0 | { |
56 | 0 | int ret; |
57 | 0 | mbuffer_st *bufel = NULL; |
58 | 0 | gnutls_buffer_st buf; |
59 | |
|
60 | 0 | if (again == 0) { |
61 | 0 | ret = _gnutls_buffer_init_handshake_mbuffer(&buf); |
62 | 0 | if (ret < 0) |
63 | 0 | return gnutls_assert_val(ret); |
64 | | |
65 | 0 | ret = _gnutls_gen_hello_extensions( |
66 | 0 | session, &buf, GNUTLS_EXT_FLAG_EE, GNUTLS_EXT_ANY); |
67 | 0 | if (ret < 0) { |
68 | 0 | gnutls_assert(); |
69 | 0 | goto cleanup; |
70 | 0 | } |
71 | | |
72 | 0 | bufel = _gnutls_buffer_to_mbuffer(&buf); |
73 | 0 | } |
74 | | |
75 | 0 | return _gnutls_send_handshake(session, bufel, |
76 | 0 | GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS); |
77 | | |
78 | 0 | cleanup: |
79 | 0 | _gnutls_buffer_clear(&buf); |
80 | 0 | return ret; |
81 | 0 | } |