summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls13_quic.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/tls13_quic.c')
-rw-r--r--src/lib/libssl/tls13_quic.c64
1 files changed, 48 insertions, 16 deletions
diff --git a/src/lib/libssl/tls13_quic.c b/src/lib/libssl/tls13_quic.c
index f58a0b8b28..ceb666ac4c 100644
--- a/src/lib/libssl/tls13_quic.c
+++ b/src/lib/libssl/tls13_quic.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_quic.c,v 1.3 2022/08/21 19:18:57 jsing Exp $ */ 1/* $OpenBSD: tls13_quic.c,v 1.4 2022/08/21 19:39:44 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2022 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -45,16 +45,20 @@ tls13_quic_wire_flush_cb(void *arg)
45 struct tls13_ctx *ctx = arg; 45 struct tls13_ctx *ctx = arg;
46 SSL *ssl = ctx->ssl; 46 SSL *ssl = ctx->ssl;
47 47
48 /* XXX - call flush_flight. */ 48 if (!ssl->quic_method->flush_flight(ssl)) {
49 SSLerror(ssl, ERR_R_INTERNAL_ERROR); 49 SSLerror(ssl, SSL_R_QUIC_INTERNAL_ERROR);
50 return TLS13_IO_FAILURE; 50 return TLS13_IO_FAILURE;
51 }
52
53 return TLS13_IO_SUCCESS;
51} 54}
52 55
53static ssize_t 56static ssize_t
54tls13_quic_handshake_read_cb(void *buf, size_t n, void *arg) 57tls13_quic_handshake_read_cb(void *buf, size_t n, void *arg)
55{ 58{
56 /* XXX - read handshake data. */ 59 struct tls13_ctx *ctx = arg;
57 return TLS13_IO_FAILURE; 60
61 return tls_buffer_read(ctx->hs->tls13.quic_read_buffer, buf, n);
58} 62}
59 63
60static ssize_t 64static ssize_t
@@ -63,9 +67,13 @@ tls13_quic_handshake_write_cb(const void *buf, size_t n, void *arg)
63 struct tls13_ctx *ctx = arg; 67 struct tls13_ctx *ctx = arg;
64 SSL *ssl = ctx->ssl; 68 SSL *ssl = ctx->ssl;
65 69
66 /* XXX - call add_handshake_data. */ 70 if (!ssl->quic_method->add_handshake_data(ssl,
67 SSLerror(ssl, ERR_R_INTERNAL_ERROR); 71 ctx->hs->tls13.quic_write_level, buf, n)) {
68 return TLS13_IO_FAILURE; 72 SSLerror(ssl, SSL_R_QUIC_INTERNAL_ERROR);
73 return TLS13_IO_FAILURE;
74 }
75
76 return n;
69} 77}
70 78
71static int 79static int
@@ -77,8 +85,18 @@ tls13_quic_set_read_traffic_key(struct tls13_secret *read_key,
77 85
78 ctx->hs->tls13.quic_read_level = read_level; 86 ctx->hs->tls13.quic_read_level = read_level;
79 87
80 /* XXX - call set_read_secret. */ 88 /* Handle both the new (BoringSSL) and old (quictls) APIs. */
81 SSLerror(ssl, ERR_R_INTERNAL_ERROR); 89
90 if (ssl->quic_method->set_read_secret != NULL)
91 return ssl->quic_method->set_read_secret(ssl,
92 ctx->hs->tls13.quic_read_level, ctx->hs->cipher,
93 read_key->data, read_key->len);
94
95 if (ssl->quic_method->set_encryption_secrets != NULL)
96 return ssl->quic_method->set_encryption_secrets(ssl,
97 ctx->hs->tls13.quic_read_level, read_key->data, NULL,
98 read_key->len);
99
82 return 0; 100 return 0;
83} 101}
84 102
@@ -91,8 +109,18 @@ tls13_quic_set_write_traffic_key(struct tls13_secret *write_key,
91 109
92 ctx->hs->tls13.quic_write_level = write_level; 110 ctx->hs->tls13.quic_write_level = write_level;
93 111
94 /* XXX - call set_write_secret. */ 112 /* Handle both the new (BoringSSL) and old (quictls) APIs. */
95 SSLerror(ssl, ERR_R_INTERNAL_ERROR); 113
114 if (ssl->quic_method->set_write_secret != NULL)
115 return ssl->quic_method->set_write_secret(ssl,
116 ctx->hs->tls13.quic_write_level, ctx->hs->cipher,
117 write_key->data, write_key->len);
118
119 if (ssl->quic_method->set_encryption_secrets != NULL)
120 return ssl->quic_method->set_encryption_secrets(ssl,
121 ctx->hs->tls13.quic_write_level, NULL, write_key->data,
122 write_key->len);
123
96 return 0; 124 return 0;
97} 125}
98 126
@@ -102,9 +130,13 @@ tls13_quic_alert_send_cb(int alert_desc, void *arg)
102 struct tls13_ctx *ctx = arg; 130 struct tls13_ctx *ctx = arg;
103 SSL *ssl = ctx->ssl; 131 SSL *ssl = ctx->ssl;
104 132
105 /* XXX - call send_alert. */ 133 if (!ssl->quic_method->send_alert(ssl, ctx->hs->tls13.quic_write_level,
106 SSLerror(ssl, ERR_R_INTERNAL_ERROR); 134 alert_desc)) {
107 return TLS13_IO_FAILURE; 135 SSLerror(ssl, SSL_R_QUIC_INTERNAL_ERROR);
136 return TLS13_IO_FAILURE;
137 }
138
139 return TLS13_IO_SUCCESS;
108} 140}
109 141
110static const struct tls13_record_layer_callbacks quic_rl_callbacks = { 142static const struct tls13_record_layer_callbacks quic_rl_callbacks = {