Coverage Report

Created: 2022-08-24 06:31

/src/libressl/ssl/tls13_quic.c
Line
Count
Source (jump to first uncovered line)
1
/*  $OpenBSD: tls13_quic.c,v 1.2 2022/07/24 14:31:37 jsing Exp $ */
2
/*
3
 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
4
 *
5
 * Permission to use, copy, modify, and distribute this software for any
6
 * purpose with or without fee is hereby granted, provided that the above
7
 * copyright notice and this permission notice appear in all copies.
8
 *
9
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
 */
17
18
#include <ssl_locl.h>
19
20
#include "tls13_internal.h"
21
22
static ssize_t
23
tls13_quic_wire_read_cb(void *buf, size_t n, void *arg)
24
0
{
25
0
  struct tls13_ctx *ctx = arg;
26
0
  SSL *ssl = ctx->ssl;
27
28
0
  SSLerror(ssl, ERR_R_INTERNAL_ERROR);
29
0
  return TLS13_IO_FAILURE;
30
0
}
31
32
static ssize_t
33
tls13_quic_wire_write_cb(const void *buf, size_t n, void *arg)
34
0
{
35
0
  struct tls13_ctx *ctx = arg;
36
0
  SSL *ssl = ctx->ssl;
37
38
0
  SSLerror(ssl, ERR_R_INTERNAL_ERROR);
39
0
  return TLS13_IO_FAILURE;
40
0
}
41
42
static ssize_t
43
tls13_quic_wire_flush_cb(void *arg)
44
0
{
45
0
  struct tls13_ctx *ctx = arg;
46
0
  SSL *ssl = ctx->ssl;
47
48
  /* XXX - call flush_flight. */
49
0
  SSLerror(ssl, ERR_R_INTERNAL_ERROR);
50
0
  return TLS13_IO_FAILURE;
51
0
}
52
53
static ssize_t
54
tls13_quic_handshake_read_cb(void *buf, size_t n, void *arg)
55
0
{
56
  /* XXX - read handshake data. */
57
0
  return TLS13_IO_FAILURE;
58
0
}
59
60
static ssize_t
61
tls13_quic_handshake_write_cb(const void *buf, size_t n, void *arg)
62
0
{
63
0
  struct tls13_ctx *ctx = arg;
64
0
  SSL *ssl = ctx->ssl;
65
66
  /* XXX - call add_handshake_data. */
67
0
  SSLerror(ssl, ERR_R_INTERNAL_ERROR);
68
0
  return TLS13_IO_FAILURE;
69
0
}
70
71
static int
72
tls13_quic_set_read_traffic_key(struct tls13_secret *read_key,
73
    enum ssl_encryption_level_t read_level, void *arg)
74
0
{
75
0
  struct tls13_ctx *ctx = arg;
76
0
  SSL *ssl = ctx->ssl;
77
78
0
  ctx->hs->tls13.quic_read_level = read_level;
79
80
  /* XXX - call set_read_secret. */
81
0
  SSLerror(ssl, ERR_R_INTERNAL_ERROR);
82
0
  return 0;
83
0
}
84
85
static int
86
tls13_quic_set_write_traffic_key(struct tls13_secret *write_key,
87
    enum ssl_encryption_level_t write_level, void *arg)
88
0
{
89
0
  struct tls13_ctx *ctx = arg;
90
0
  SSL *ssl = ctx->ssl;
91
92
0
  ctx->hs->tls13.quic_write_level = write_level;
93
94
  /* XXX - call set_write_secret. */
95
0
  SSLerror(ssl, ERR_R_INTERNAL_ERROR);
96
0
  return 0;
97
0
}
98
99
static int
100
tls13_quic_alert_send_cb(int alert_desc, void *arg)
101
0
{
102
0
  struct tls13_ctx *ctx = arg;
103
0
  SSL *ssl = ctx->ssl;
104
105
  /* XXX - call send_alert. */
106
0
  SSLerror(ssl, ERR_R_INTERNAL_ERROR);
107
0
  return TLS13_IO_FAILURE;
108
0
}
109
110
static const struct tls13_record_layer_callbacks quic_rl_callbacks = {
111
  .wire_read = tls13_quic_wire_read_cb,
112
  .wire_write = tls13_quic_wire_write_cb,
113
  .wire_flush = tls13_quic_wire_flush_cb,
114
115
  .handshake_read = tls13_quic_handshake_read_cb,
116
  .handshake_write = tls13_quic_handshake_write_cb,
117
  .set_read_traffic_key = tls13_quic_set_read_traffic_key,
118
  .set_write_traffic_key = tls13_quic_set_write_traffic_key,
119
  .alert_send = tls13_quic_alert_send_cb,
120
121
  .alert_recv = tls13_alert_received_cb,
122
  .alert_sent = tls13_alert_sent_cb,
123
  .phh_recv = tls13_phh_received_cb,
124
  .phh_sent = tls13_phh_done_cb,
125
};
126
127
int
128
tls13_quic_init(struct tls13_ctx *ctx)
129
0
{
130
0
  BIO *bio;
131
132
0
  tls13_record_layer_set_callbacks(ctx->rl, &quic_rl_callbacks, ctx);
133
134
0
  ctx->middlebox_compat = 0;
135
136
  /*
137
   * QUIC does not use BIOs, however we currently expect a BIO to exist
138
   * for status handling.
139
   */
140
0
  if ((bio = BIO_new(BIO_s_null())) == NULL)
141
0
    return 0;
142
143
0
  BIO_up_ref(bio);
144
0
  SSL_set_bio(ctx->ssl, bio, bio);
145
0
  bio = NULL;
146
147
0
  return 1;
148
0
}