diff options
| author | beck <> | 2019-11-20 16:21:20 +0000 |
|---|---|---|
| committer | beck <> | 2019-11-20 16:21:20 +0000 |
| commit | f3053a044b26a9a6c7c7edb6783003483d758112 (patch) | |
| tree | 62957791149c439c8314612525488b6e16952e26 | |
| parent | 8909ea7f4f944f44def6cd61712e2334067501cb (diff) | |
| download | openbsd-f3053a044b26a9a6c7c7edb6783003483d758112.tar.gz openbsd-f3053a044b26a9a6c7c7edb6783003483d758112.tar.bz2 openbsd-f3053a044b26a9a6c7c7edb6783003483d758112.zip | |
Add accessors to change the buffer in a handshake message.
Needed for doing TLS 1.3 Post Handshake Handshake messages.
ok jsing@
| -rw-r--r-- | src/lib/libssl/tls13_buffer.c | 11 | ||||
| -rw-r--r-- | src/lib/libssl/tls13_handshake_msg.c | 8 | ||||
| -rw-r--r-- | src/lib/libssl/tls13_internal.h | 4 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/libssl/tls13_buffer.c b/src/lib/libssl/tls13_buffer.c index 1b490c8b46..8990327bb6 100644 --- a/src/lib/libssl/tls13_buffer.c +++ b/src/lib/libssl/tls13_buffer.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_buffer.c,v 1.1 2019/01/17 06:32:12 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_buffer.c,v 1.2 2019/11/20 16:21:20 beck 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 | * |
| @@ -75,6 +75,15 @@ tls13_buffer_resize(struct tls13_buffer *buf, size_t capacity) | |||
| 75 | return 1; | 75 | return 1; |
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | int | ||
| 79 | tls13_buffer_set_data(struct tls13_buffer *buf, CBS *data) | ||
| 80 | { | ||
| 81 | if (!tls13_buffer_resize(buf, CBS_len(data))) | ||
| 82 | return 0; | ||
| 83 | memcpy(buf->data, CBS_data(data), CBS_len(data)); | ||
| 84 | return 1; | ||
| 85 | } | ||
| 86 | |||
| 78 | ssize_t | 87 | ssize_t |
| 79 | tls13_buffer_extend(struct tls13_buffer *buf, size_t len, | 88 | tls13_buffer_extend(struct tls13_buffer *buf, size_t len, |
| 80 | tls13_read_cb read_cb, void *cb_arg) | 89 | tls13_read_cb read_cb, void *cb_arg) |
diff --git a/src/lib/libssl/tls13_handshake_msg.c b/src/lib/libssl/tls13_handshake_msg.c index f85271a537..21932fc4ee 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.1 2019/01/20 12:27:34 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_handshake_msg.c,v 1.2 2019/11/20 16:21:20 beck 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 | * |
| @@ -72,6 +72,12 @@ tls13_handshake_msg_data(struct tls13_handshake_msg *msg, CBS *cbs) | |||
| 72 | CBS_init(cbs, msg->data, msg->data_len); | 72 | CBS_init(cbs, msg->data, msg->data_len); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | int | ||
| 76 | tls13_handshake_msg_set_buffer(struct tls13_handshake_msg *msg, CBS *cbs) | ||
| 77 | { | ||
| 78 | return tls13_buffer_set_data(msg->buf, cbs); | ||
| 79 | } | ||
| 80 | |||
| 75 | uint8_t | 81 | uint8_t |
| 76 | tls13_handshake_msg_type(struct tls13_handshake_msg *msg) | 82 | tls13_handshake_msg_type(struct tls13_handshake_msg *msg) |
| 77 | { | 83 | { |
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index 03e75933a1..859030747f 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.34 2019/11/18 15:25:59 beck Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.35 2019/11/20 16:21:20 beck 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> |
| @@ -47,6 +47,7 @@ typedef ssize_t (*tls13_write_cb)(const void *_buf, size_t _buflen, | |||
| 47 | struct tls13_buffer; | 47 | struct tls13_buffer; |
| 48 | 48 | ||
| 49 | struct tls13_buffer *tls13_buffer_new(size_t init_size); | 49 | struct tls13_buffer *tls13_buffer_new(size_t init_size); |
| 50 | int tls13_buffer_set_data(struct tls13_buffer *buf, CBS *data); | ||
| 50 | void tls13_buffer_free(struct tls13_buffer *buf); | 51 | void tls13_buffer_free(struct tls13_buffer *buf); |
| 51 | ssize_t tls13_buffer_extend(struct tls13_buffer *buf, size_t len, | 52 | ssize_t tls13_buffer_extend(struct tls13_buffer *buf, size_t len, |
| 52 | tls13_read_cb read_cb, void *cb_arg); | 53 | tls13_read_cb read_cb, void *cb_arg); |
| @@ -141,6 +142,7 @@ struct tls13_handshake_msg; | |||
| 141 | struct tls13_handshake_msg *tls13_handshake_msg_new(void); | 142 | struct tls13_handshake_msg *tls13_handshake_msg_new(void); |
| 142 | void tls13_handshake_msg_free(struct tls13_handshake_msg *msg); | 143 | void tls13_handshake_msg_free(struct tls13_handshake_msg *msg); |
| 143 | void tls13_handshake_msg_data(struct tls13_handshake_msg *msg, CBS *cbs); | 144 | void tls13_handshake_msg_data(struct tls13_handshake_msg *msg, CBS *cbs); |
| 145 | int tls13_handshake_msg_set_buffer(struct tls13_handshake_msg *msg, CBS *cbs); | ||
| 144 | uint8_t tls13_handshake_msg_type(struct tls13_handshake_msg *msg); | 146 | uint8_t tls13_handshake_msg_type(struct tls13_handshake_msg *msg); |
| 145 | int tls13_handshake_msg_content(struct tls13_handshake_msg *msg, CBS *cbs); | 147 | int tls13_handshake_msg_content(struct tls13_handshake_msg *msg, CBS *cbs); |
| 146 | int tls13_handshake_msg_start(struct tls13_handshake_msg *msg, CBB *body, | 148 | int tls13_handshake_msg_start(struct tls13_handshake_msg *msg, CBB *body, |
