Coverage Report

Created: 2023-03-26 08:33

/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 =
36
0
      _gnutls_recv_handshake(session,
37
0
           GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS, 0,
38
0
           &buf);
39
0
  if (ret < 0)
40
0
    return gnutls_assert_val(ret);
41
42
0
  _gnutls_handshake_log("HSK[%p]: parsing encrypted extensions\n",
43
0
            session);
44
0
  ret =
45
0
      _gnutls_parse_hello_extensions(session, GNUTLS_EXT_FLAG_EE,
46
0
             GNUTLS_EXT_ANY, buf.data,
47
0
             buf.length);
48
0
  _gnutls_buffer_clear(&buf);
49
50
0
  if (ret < 0)
51
0
    return gnutls_assert_val(ret);
52
53
0
  return 0;
54
0
}
55
56
int _gnutls13_send_encrypted_extensions(gnutls_session_t session,
57
          unsigned again)
58
0
{
59
0
  int ret;
60
0
  mbuffer_st *bufel = NULL;
61
0
  gnutls_buffer_st buf;
62
63
0
  if (again == 0) {
64
0
    ret = _gnutls_buffer_init_handshake_mbuffer(&buf);
65
0
    if (ret < 0)
66
0
      return gnutls_assert_val(ret);
67
68
0
    ret =
69
0
        _gnutls_gen_hello_extensions(session, &buf,
70
0
             GNUTLS_EXT_FLAG_EE,
71
0
             GNUTLS_EXT_ANY);
72
0
    if (ret < 0) {
73
0
      gnutls_assert();
74
0
      goto cleanup;
75
0
    }
76
77
0
    bufel = _gnutls_buffer_to_mbuffer(&buf);
78
0
  }
79
80
0
  return _gnutls_send_handshake(session, bufel,
81
0
              GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS);
82
83
0
 cleanup:
84
0
  _gnutls_buffer_clear(&buf);
85
0
  return ret;
86
0
}