summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2021-10-23 13:12:14 +0000
committerjsing <>2021-10-23 13:12:14 +0000
commitd2039e7348559d4183f5d055e691e70e1dadf349 (patch)
treebfbb08766325a11dd03fa658249cdacb09f2c3c0
parentc4a5b1f8676a44f32abf55d9aff5ae7d2c36a4be (diff)
downloadopenbsd-d2039e7348559d4183f5d055e691e70e1dadf349.tar.gz
openbsd-d2039e7348559d4183f5d055e691e70e1dadf349.tar.bz2
openbsd-d2039e7348559d4183f5d055e691e70e1dadf349.zip
Rename tls13_buffer to tls_buffer.
This code will soon be used in the DTLSv1.2 and TLSv1.2 stack. Also introduce tls_internal.h and move/rename the read/write/flush callbacks. ok beck@ tb@
-rw-r--r--src/lib/libssl/Makefile4
-rw-r--r--src/lib/libssl/tls13_handshake_msg.c18
-rw-r--r--src/lib/libssl/tls13_internal.h27
-rw-r--r--src/lib/libssl/tls13_record.c20
-rw-r--r--src/lib/libssl/tls13_record.h6
-rw-r--r--src/lib/libssl/tls_buffer.c (renamed from src/lib/libssl/tls13_buffer.c)49
-rw-r--r--src/lib/libssl/tls_internal.h56
7 files changed, 111 insertions, 69 deletions
diff --git a/src/lib/libssl/Makefile b/src/lib/libssl/Makefile
index d468308c7e..82e139911e 100644
--- a/src/lib/libssl/Makefile
+++ b/src/lib/libssl/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.71 2021/09/04 16:26:12 jsing Exp $ 1# $OpenBSD: Makefile,v 1.72 2021/10/23 13:12:14 jsing Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4.ifndef NOMAN 4.ifndef NOMAN
@@ -70,7 +70,6 @@ SRCS= \
70 tls12_key_schedule.c \ 70 tls12_key_schedule.c \
71 tls12_lib.c \ 71 tls12_lib.c \
72 tls12_record_layer.c \ 72 tls12_record_layer.c \
73 tls13_buffer.c \
74 tls13_client.c \ 73 tls13_client.c \
75 tls13_error.c \ 74 tls13_error.c \
76 tls13_handshake.c \ 75 tls13_handshake.c \
@@ -82,6 +81,7 @@ SRCS= \
82 tls13_record.c \ 81 tls13_record.c \
83 tls13_record_layer.c \ 82 tls13_record_layer.c \
84 tls13_server.c \ 83 tls13_server.c \
84 tls_buffer.c \
85 tls_content.c 85 tls_content.c
86 86
87HDRS= dtls1.h srtp.h ssl.h ssl2.h ssl23.h ssl3.h tls1.h 87HDRS= dtls1.h srtp.h ssl.h ssl2.h ssl23.h ssl3.h tls1.h
diff --git a/src/lib/libssl/tls13_handshake_msg.c b/src/lib/libssl/tls13_handshake_msg.c
index ff6d6d7e19..67eab3152f 100644
--- a/src/lib/libssl/tls13_handshake_msg.c
+++ b/src/lib/libssl/tls13_handshake_msg.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_handshake_msg.c,v 1.3 2021/05/16 14:19:04 jsing Exp $ */ 1/* $OpenBSD: tls13_handshake_msg.c,v 1.4 2021/10/23 13:12:14 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -28,7 +28,7 @@ struct tls13_handshake_msg {
28 uint8_t *data; 28 uint8_t *data;
29 size_t data_len; 29 size_t data_len;
30 30
31 struct tls13_buffer *buf; 31 struct tls_buffer *buf;
32 CBS cbs; 32 CBS cbs;
33 CBB cbb; 33 CBB cbb;
34}; 34};
@@ -40,7 +40,7 @@ tls13_handshake_msg_new()
40 40
41 if ((msg = calloc(1, sizeof(struct tls13_handshake_msg))) == NULL) 41 if ((msg = calloc(1, sizeof(struct tls13_handshake_msg))) == NULL)
42 goto err; 42 goto err;
43 if ((msg->buf = tls13_buffer_new(0)) == NULL) 43 if ((msg->buf = tls_buffer_new(0)) == NULL)
44 goto err; 44 goto err;
45 45
46 return msg; 46 return msg;
@@ -57,7 +57,7 @@ tls13_handshake_msg_free(struct tls13_handshake_msg *msg)
57 if (msg == NULL) 57 if (msg == NULL)
58 return; 58 return;
59 59
60 tls13_buffer_free(msg->buf); 60 tls_buffer_free(msg->buf);
61 61
62 CBB_cleanup(&msg->cbb); 62 CBB_cleanup(&msg->cbb);
63 63
@@ -74,7 +74,7 @@ tls13_handshake_msg_data(struct tls13_handshake_msg *msg, CBS *cbs)
74int 74int
75tls13_handshake_msg_set_buffer(struct tls13_handshake_msg *msg, CBS *cbs) 75tls13_handshake_msg_set_buffer(struct tls13_handshake_msg *msg, CBS *cbs)
76{ 76{
77 return tls13_buffer_set_data(msg->buf, cbs); 77 return tls_buffer_set_data(msg->buf, cbs);
78} 78}
79 79
80uint8_t 80uint8_t
@@ -137,12 +137,12 @@ tls13_handshake_msg_recv(struct tls13_handshake_msg *msg,
137 return TLS13_IO_FAILURE; 137 return TLS13_IO_FAILURE;
138 138
139 if (msg->msg_type == 0) { 139 if (msg->msg_type == 0) {
140 if ((ret = tls13_buffer_extend(msg->buf, 140 if ((ret = tls_buffer_extend(msg->buf,
141 TLS13_HANDSHAKE_MSG_HEADER_LEN, 141 TLS13_HANDSHAKE_MSG_HEADER_LEN,
142 tls13_handshake_msg_read_cb, rl)) <= 0) 142 tls13_handshake_msg_read_cb, rl)) <= 0)
143 return ret; 143 return ret;
144 144
145 tls13_buffer_cbs(msg->buf, &cbs); 145 tls_buffer_cbs(msg->buf, &cbs);
146 146
147 if (!CBS_get_u8(&cbs, &msg_type)) 147 if (!CBS_get_u8(&cbs, &msg_type))
148 return TLS13_IO_FAILURE; 148 return TLS13_IO_FAILURE;
@@ -157,12 +157,12 @@ tls13_handshake_msg_recv(struct tls13_handshake_msg *msg,
157 msg->msg_len = msg_len; 157 msg->msg_len = msg_len;
158 } 158 }
159 159
160 if ((ret = tls13_buffer_extend(msg->buf, 160 if ((ret = tls_buffer_extend(msg->buf,
161 TLS13_HANDSHAKE_MSG_HEADER_LEN + msg->msg_len, 161 TLS13_HANDSHAKE_MSG_HEADER_LEN + msg->msg_len,
162 tls13_handshake_msg_read_cb, rl)) <= 0) 162 tls13_handshake_msg_read_cb, rl)) <= 0)
163 return ret; 163 return ret;
164 164
165 if (!tls13_buffer_finish(msg->buf, &msg->data, &msg->data_len)) 165 if (!tls_buffer_finish(msg->buf, &msg->data, &msg->data_len))
166 return TLS13_IO_FAILURE; 166 return TLS13_IO_FAILURE;
167 167
168 return TLS13_IO_SUCCESS; 168 return TLS13_IO_SUCCESS;
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h
index 20cb52ebdd..7e3b081966 100644
--- a/src/lib/libssl/tls13_internal.h
+++ b/src/lib/libssl/tls13_internal.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_internal.h,v 1.94 2021/09/16 19:25:30 jsing Exp $ */ 1/* $OpenBSD: tls13_internal.h,v 1.95 2021/10/23 13:12:14 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2018 Bob Beck <beck@openbsd.org>
4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018 Theo Buehler <tb@openbsd.org>
@@ -24,6 +24,7 @@
24#include <openssl/ssl.h> 24#include <openssl/ssl.h>
25 25
26#include "bytestring.h" 26#include "bytestring.h"
27#include "tls_internal.h"
27 28
28__BEGIN_HIDDEN_DECLS 29__BEGIN_HIDDEN_DECLS
29 30
@@ -89,29 +90,11 @@ __BEGIN_HIDDEN_DECLS
89typedef void (*tls13_alert_cb)(uint8_t _alert_desc, void *_cb_arg); 90typedef void (*tls13_alert_cb)(uint8_t _alert_desc, void *_cb_arg);
90typedef ssize_t (*tls13_phh_recv_cb)(void *_cb_arg, CBS *_cbs); 91typedef ssize_t (*tls13_phh_recv_cb)(void *_cb_arg, CBS *_cbs);
91typedef void (*tls13_phh_sent_cb)(void *_cb_arg); 92typedef void (*tls13_phh_sent_cb)(void *_cb_arg);
92typedef ssize_t (*tls13_read_cb)(void *_buf, size_t _buflen, void *_cb_arg);
93typedef ssize_t (*tls13_write_cb)(const void *_buf, size_t _buflen,
94 void *_cb_arg);
95typedef ssize_t (*tls13_flush_cb)(void *_cb_arg);
96typedef void (*tls13_handshake_message_cb)(void *_cb_arg); 93typedef void (*tls13_handshake_message_cb)(void *_cb_arg);
97typedef void (*tls13_info_cb)(void *_cb_arg, int _state, int _ret); 94typedef void (*tls13_info_cb)(void *_cb_arg, int _state, int _ret);
98typedef int (*tls13_ocsp_status_cb)(void *_cb_arg); 95typedef int (*tls13_ocsp_status_cb)(void *_cb_arg);
99 96
100/* 97/*
101 * Buffers.
102 */
103struct tls13_buffer;
104
105struct tls13_buffer *tls13_buffer_new(size_t init_size);
106int tls13_buffer_set_data(struct tls13_buffer *buf, CBS *data);
107void tls13_buffer_free(struct tls13_buffer *buf);
108ssize_t tls13_buffer_extend(struct tls13_buffer *buf, size_t len,
109 tls13_read_cb read_cb, void *cb_arg);
110void tls13_buffer_cbs(struct tls13_buffer *buf, CBS *cbs);
111int tls13_buffer_finish(struct tls13_buffer *buf, uint8_t **out,
112 size_t *out_len);
113
114/*
115 * Secrets. 98 * Secrets.
116 */ 99 */
117struct tls13_secret { 100struct tls13_secret {
@@ -199,9 +182,9 @@ int tls13_key_share_derive(struct tls13_key_share *ks, uint8_t **shared_key,
199struct tls13_record_layer; 182struct tls13_record_layer;
200 183
201struct tls13_record_layer_callbacks { 184struct tls13_record_layer_callbacks {
202 tls13_read_cb wire_read; 185 tls_read_cb wire_read;
203 tls13_write_cb wire_write; 186 tls_write_cb wire_write;
204 tls13_flush_cb wire_flush; 187 tls_flush_cb wire_flush;
205 tls13_alert_cb alert_recv; 188 tls13_alert_cb alert_recv;
206 tls13_alert_cb alert_sent; 189 tls13_alert_cb alert_sent;
207 tls13_phh_recv_cb phh_recv; 190 tls13_phh_recv_cb phh_recv;
diff --git a/src/lib/libssl/tls13_record.c b/src/lib/libssl/tls13_record.c
index 3bdaead5a7..2c744668e5 100644
--- a/src/lib/libssl/tls13_record.c
+++ b/src/lib/libssl/tls13_record.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_record.c,v 1.8 2021/05/16 14:19:04 jsing Exp $ */ 1/* $OpenBSD: tls13_record.c,v 1.9 2021/10/23 13:12:14 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -26,7 +26,7 @@ struct tls13_record {
26 size_t data_len; 26 size_t data_len;
27 CBS cbs; 27 CBS cbs;
28 28
29 struct tls13_buffer *buf; 29 struct tls_buffer *buf;
30}; 30};
31 31
32struct tls13_record * 32struct tls13_record *
@@ -36,7 +36,7 @@ tls13_record_new(void)
36 36
37 if ((rec = calloc(1, sizeof(struct tls13_record))) == NULL) 37 if ((rec = calloc(1, sizeof(struct tls13_record))) == NULL)
38 goto err; 38 goto err;
39 if ((rec->buf = tls13_buffer_new(TLS13_RECORD_MAX_LEN)) == NULL) 39 if ((rec->buf = tls_buffer_new(TLS13_RECORD_MAX_LEN)) == NULL)
40 goto err; 40 goto err;
41 41
42 return rec; 42 return rec;
@@ -53,7 +53,7 @@ tls13_record_free(struct tls13_record *rec)
53 if (rec == NULL) 53 if (rec == NULL)
54 return; 54 return;
55 55
56 tls13_buffer_free(rec->buf); 56 tls_buffer_free(rec->buf);
57 57
58 freezero(rec->data, rec->data_len); 58 freezero(rec->data, rec->data_len);
59 freezero(rec, sizeof(struct tls13_record)); 59 freezero(rec, sizeof(struct tls13_record));
@@ -118,7 +118,7 @@ tls13_record_set_data(struct tls13_record *rec, uint8_t *data, size_t data_len)
118} 118}
119 119
120ssize_t 120ssize_t
121tls13_record_recv(struct tls13_record *rec, tls13_read_cb wire_read, 121tls13_record_recv(struct tls13_record *rec, tls_read_cb wire_read,
122 void *wire_arg) 122 void *wire_arg)
123{ 123{
124 uint16_t rec_len, rec_version; 124 uint16_t rec_len, rec_version;
@@ -130,11 +130,11 @@ tls13_record_recv(struct tls13_record *rec, tls13_read_cb wire_read,
130 return TLS13_IO_FAILURE; 130 return TLS13_IO_FAILURE;
131 131
132 if (rec->content_type == 0) { 132 if (rec->content_type == 0) {
133 if ((ret = tls13_buffer_extend(rec->buf, 133 if ((ret = tls_buffer_extend(rec->buf,
134 TLS13_RECORD_HEADER_LEN, wire_read, wire_arg)) <= 0) 134 TLS13_RECORD_HEADER_LEN, wire_read, wire_arg)) <= 0)
135 return ret; 135 return ret;
136 136
137 tls13_buffer_cbs(rec->buf, &cbs); 137 tls_buffer_cbs(rec->buf, &cbs);
138 138
139 if (!CBS_get_u8(&cbs, &content_type)) 139 if (!CBS_get_u8(&cbs, &content_type))
140 return TLS13_IO_FAILURE; 140 return TLS13_IO_FAILURE;
@@ -153,18 +153,18 @@ tls13_record_recv(struct tls13_record *rec, tls13_read_cb wire_read,
153 rec->rec_len = rec_len; 153 rec->rec_len = rec_len;
154 } 154 }
155 155
156 if ((ret = tls13_buffer_extend(rec->buf, 156 if ((ret = tls_buffer_extend(rec->buf,
157 TLS13_RECORD_HEADER_LEN + rec->rec_len, wire_read, wire_arg)) <= 0) 157 TLS13_RECORD_HEADER_LEN + rec->rec_len, wire_read, wire_arg)) <= 0)
158 return ret; 158 return ret;
159 159
160 if (!tls13_buffer_finish(rec->buf, &rec->data, &rec->data_len)) 160 if (!tls_buffer_finish(rec->buf, &rec->data, &rec->data_len))
161 return TLS13_IO_FAILURE; 161 return TLS13_IO_FAILURE;
162 162
163 return rec->data_len; 163 return rec->data_len;
164} 164}
165 165
166ssize_t 166ssize_t
167tls13_record_send(struct tls13_record *rec, tls13_write_cb wire_write, 167tls13_record_send(struct tls13_record *rec, tls_write_cb wire_write,
168 void *wire_arg) 168 void *wire_arg)
169{ 169{
170 ssize_t ret; 170 ssize_t ret;
diff --git a/src/lib/libssl/tls13_record.h b/src/lib/libssl/tls13_record.h
index 4b7ac4f8dc..18e4fa1aba 100644
--- a/src/lib/libssl/tls13_record.h
+++ b/src/lib/libssl/tls13_record.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_record.h,v 1.4 2021/05/16 14:20:29 jsing Exp $ */ 1/* $OpenBSD: tls13_record.h,v 1.5 2021/10/23 13:12:14 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -56,9 +56,9 @@ int tls13_record_content(struct tls13_record *_rec, CBS *_cbs);
56void tls13_record_data(struct tls13_record *_rec, CBS *_cbs); 56void tls13_record_data(struct tls13_record *_rec, CBS *_cbs);
57int tls13_record_set_data(struct tls13_record *_rec, uint8_t *_data, 57int tls13_record_set_data(struct tls13_record *_rec, uint8_t *_data,
58 size_t _data_len); 58 size_t _data_len);
59ssize_t tls13_record_recv(struct tls13_record *_rec, tls13_read_cb _wire_read, 59ssize_t tls13_record_recv(struct tls13_record *_rec, tls_read_cb _wire_read,
60 void *_wire_arg); 60 void *_wire_arg);
61ssize_t tls13_record_send(struct tls13_record *_rec, tls13_write_cb _wire_write, 61ssize_t tls13_record_send(struct tls13_record *_rec, tls_write_cb _wire_write,
62 void *_wire_arg); 62 void *_wire_arg);
63 63
64__END_HIDDEN_DECLS 64__END_HIDDEN_DECLS
diff --git a/src/lib/libssl/tls13_buffer.c b/src/lib/libssl/tls_buffer.c
index b46ac65ecf..5c0ca7e40e 100644
--- a/src/lib/libssl/tls13_buffer.c
+++ b/src/lib/libssl/tls_buffer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls13_buffer.c,v 1.5 2021/05/16 14:19:04 jsing Exp $ */ 1/* $OpenBSD: tls_buffer.c,v 1.1 2021/10/23 13:12:14 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018, 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -15,49 +15,52 @@
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */ 16 */
17 17
18#include <stdlib.h>
19#include <string.h>
20
18#include "bytestring.h" 21#include "bytestring.h"
19#include "tls13_internal.h" 22#include "tls_internal.h"
20 23
21struct tls13_buffer { 24struct tls_buffer {
22 size_t capacity; 25 size_t capacity;
23 uint8_t *data; 26 uint8_t *data;
24 size_t len; 27 size_t len;
25 size_t offset; 28 size_t offset;
26}; 29};
27 30
28static int tls13_buffer_resize(struct tls13_buffer *buf, size_t capacity); 31static int tls_buffer_resize(struct tls_buffer *buf, size_t capacity);
29 32
30struct tls13_buffer * 33struct tls_buffer *
31tls13_buffer_new(size_t init_size) 34tls_buffer_new(size_t init_size)
32{ 35{
33 struct tls13_buffer *buf = NULL; 36 struct tls_buffer *buf = NULL;
34 37
35 if ((buf = calloc(1, sizeof(struct tls13_buffer))) == NULL) 38 if ((buf = calloc(1, sizeof(struct tls_buffer))) == NULL)
36 goto err; 39 goto err;
37 40
38 if (!tls13_buffer_resize(buf, init_size)) 41 if (!tls_buffer_resize(buf, init_size))
39 goto err; 42 goto err;
40 43
41 return buf; 44 return buf;
42 45
43 err: 46 err:
44 tls13_buffer_free(buf); 47 tls_buffer_free(buf);
45 48
46 return NULL; 49 return NULL;
47} 50}
48 51
49void 52void
50tls13_buffer_free(struct tls13_buffer *buf) 53tls_buffer_free(struct tls_buffer *buf)
51{ 54{
52 if (buf == NULL) 55 if (buf == NULL)
53 return; 56 return;
54 57
55 freezero(buf->data, buf->capacity); 58 freezero(buf->data, buf->capacity);
56 freezero(buf, sizeof(struct tls13_buffer)); 59 freezero(buf, sizeof(struct tls_buffer));
57} 60}
58 61
59static int 62static int
60tls13_buffer_resize(struct tls13_buffer *buf, size_t capacity) 63tls_buffer_resize(struct tls_buffer *buf, size_t capacity)
61{ 64{
62 uint8_t *data; 65 uint8_t *data;
63 66
@@ -74,17 +77,17 @@ tls13_buffer_resize(struct tls13_buffer *buf, size_t capacity)
74} 77}
75 78
76int 79int
77tls13_buffer_set_data(struct tls13_buffer *buf, CBS *data) 80tls_buffer_set_data(struct tls_buffer *buf, CBS *data)
78{ 81{
79 if (!tls13_buffer_resize(buf, CBS_len(data))) 82 if (!tls_buffer_resize(buf, CBS_len(data)))
80 return 0; 83 return 0;
81 memcpy(buf->data, CBS_data(data), CBS_len(data)); 84 memcpy(buf->data, CBS_data(data), CBS_len(data));
82 return 1; 85 return 1;
83} 86}
84 87
85ssize_t 88ssize_t
86tls13_buffer_extend(struct tls13_buffer *buf, size_t len, 89tls_buffer_extend(struct tls_buffer *buf, size_t len,
87 tls13_read_cb read_cb, void *cb_arg) 90 tls_read_cb read_cb, void *cb_arg)
88{ 91{
89 ssize_t ret; 92 ssize_t ret;
90 93
@@ -92,10 +95,10 @@ tls13_buffer_extend(struct tls13_buffer *buf, size_t len,
92 return buf->len; 95 return buf->len;
93 96
94 if (len < buf->len) 97 if (len < buf->len)
95 return TLS13_IO_FAILURE; 98 return TLS_IO_FAILURE;
96 99
97 if (!tls13_buffer_resize(buf, len)) 100 if (!tls_buffer_resize(buf, len))
98 return TLS13_IO_FAILURE; 101 return TLS_IO_FAILURE;
99 102
100 for (;;) { 103 for (;;) {
101 if ((ret = read_cb(&buf->data[buf->len], 104 if ((ret = read_cb(&buf->data[buf->len],
@@ -103,7 +106,7 @@ tls13_buffer_extend(struct tls13_buffer *buf, size_t len,
103 return ret; 106 return ret;
104 107
105 if (ret > buf->capacity - buf->len) 108 if (ret > buf->capacity - buf->len)
106 return TLS13_IO_FAILURE; 109 return TLS_IO_FAILURE;
107 110
108 buf->len += ret; 111 buf->len += ret;
109 112
@@ -113,13 +116,13 @@ tls13_buffer_extend(struct tls13_buffer *buf, size_t len,
113} 116}
114 117
115void 118void
116tls13_buffer_cbs(struct tls13_buffer *buf, CBS *cbs) 119tls_buffer_cbs(struct tls_buffer *buf, CBS *cbs)
117{ 120{
118 CBS_init(cbs, buf->data, buf->len); 121 CBS_init(cbs, buf->data, buf->len);
119} 122}
120 123
121int 124int
122tls13_buffer_finish(struct tls13_buffer *buf, uint8_t **out, size_t *out_len) 125tls_buffer_finish(struct tls_buffer *buf, uint8_t **out, size_t *out_len)
123{ 126{
124 if (out == NULL || out_len == NULL) 127 if (out == NULL || out_len == NULL)
125 return 0; 128 return 0;
diff --git a/src/lib/libssl/tls_internal.h b/src/lib/libssl/tls_internal.h
new file mode 100644
index 0000000000..10af32efdd
--- /dev/null
+++ b/src/lib/libssl/tls_internal.h
@@ -0,0 +1,56 @@
1/* $OpenBSD: tls_internal.h,v 1.1 2021/10/23 13:12:14 jsing Exp $ */
2/*
3 * Copyright (c) 2018, 2019, 2021 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#ifndef HEADER_TLS_INTERNAL_H
19#define HEADER_TLS_INTERNAL_H
20
21#include "bytestring.h"
22
23__BEGIN_HIDDEN_DECLS
24
25#define TLS_IO_SUCCESS 1
26#define TLS_IO_EOF 0
27#define TLS_IO_FAILURE -1
28#define TLS_IO_ALERT -2
29#define TLS_IO_WANT_POLLIN -3
30#define TLS_IO_WANT_POLLOUT -4
31#define TLS_IO_WANT_RETRY -5 /* Retry the previous call immediately. */
32
33/*
34 * Callbacks.
35 */
36typedef ssize_t (*tls_read_cb)(void *_buf, size_t _buflen, void *_cb_arg);
37typedef ssize_t (*tls_write_cb)(const void *_buf, size_t _buflen,
38 void *_cb_arg);
39typedef ssize_t (*tls_flush_cb)(void *_cb_arg);
40
41/*
42 * Buffers.
43 */
44struct tls_buffer;
45
46struct tls_buffer *tls_buffer_new(size_t init_size);
47int tls_buffer_set_data(struct tls_buffer *buf, CBS *data);
48void tls_buffer_free(struct tls_buffer *buf);
49ssize_t tls_buffer_extend(struct tls_buffer *buf, size_t len,
50 tls_read_cb read_cb, void *cb_arg);
51void tls_buffer_cbs(struct tls_buffer *buf, CBS *cbs);
52int tls_buffer_finish(struct tls_buffer *buf, uint8_t **out, size_t *out_len);
53
54__END_HIDDEN_DECLS
55
56#endif