From a80e02e19ec4481da9c394e20c725672e6a41eba Mon Sep 17 00:00:00 2001 From: jsing Date: Thu, 17 Jan 2019 06:32:12 +0000 Subject: Provide an extensible buffer implementation that uses a read callback. The read callback returns a TLS13_IO_* value on EOF, failure, want pollin or want pollout, or a positive value indicating the number of bytes read. This will be used by upcoming TLSv1.3 handshake message and record processing code, both of which need the ability to read a fixed size header, before extending the buffer to the number of bytes specified in the header. ok beck@ tb@ --- lib/libssl/tls13_internal.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'lib/libssl/tls13_internal.h') diff --git a/lib/libssl/tls13_internal.h b/lib/libssl/tls13_internal.h index 83f99881406..872aced77cc 100644 --- a/lib/libssl/tls13_internal.h +++ b/lib/libssl/tls13_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_internal.h,v 1.5 2018/11/09 23:56:20 jsing Exp $ */ +/* $OpenBSD: tls13_internal.h,v 1.6 2019/01/17 06:32:12 jsing Exp $ */ /* * Copyright (c) 2018 Bob Beck * Copyright (c) 2018 Theo Buehler @@ -21,8 +21,27 @@ #include +#include "bytestring.h" + __BEGIN_HIDDEN_DECLS +#define TLS13_IO_EOF 0 +#define TLS13_IO_FAILURE -1 +#define TLS13_IO_WANT_POLLIN -2 +#define TLS13_IO_WANT_POLLOUT -3 + +typedef ssize_t (*tls13_read_cb)(void *_buf, size_t _buflen, void *_cb_arg); +typedef ssize_t (*tls13_write_cb)(const void *_buf, size_t _buflen, void *_cb_arg); + +struct tls13_buffer; + +struct tls13_buffer *tls13_buffer_new(size_t init_size); +void tls13_buffer_free(struct tls13_buffer *buf); +ssize_t tls13_buffer_extend(struct tls13_buffer *buf, size_t len, + tls13_read_cb read_cb, void *cb_arg); +void tls13_buffer_cbs(struct tls13_buffer *buf, CBS *cbs); +int tls13_buffer_finish(struct tls13_buffer *buf, uint8_t **out, size_t *out_len); + struct tls13_secret { uint8_t *data; size_t len; -- cgit v1.2.3-59-g8ed1b