summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2019-01-21 00:24:19 +0000
committerjsing <>2019-01-21 00:24:19 +0000
commitec0a42c8a74417f7ba05753597cf210a41fb6fc8 (patch)
tree19d1d694cd987d664b59664078018347ca4cc5e4
parent5aeed39af0ab7b8b55b8ea5588529ff784c1c6be (diff)
downloadopenbsd-ec0a42c8a74417f7ba05753597cf210a41fb6fc8.tar.gz
openbsd-ec0a42c8a74417f7ba05753597cf210a41fb6fc8.tar.bz2
openbsd-ec0a42c8a74417f7ba05753597cf210a41fb6fc8.zip
Store the record version and make it available for use.
While here correct an int vs size_t mismatch. ok tb@
-rw-r--r--src/lib/libssl/tls13_record.c24
-rw-r--r--src/lib/libssl/tls13_record.h7
2 files changed, 21 insertions, 10 deletions
diff --git a/src/lib/libssl/tls13_record.c b/src/lib/libssl/tls13_record.c
index 1a4e22ee47..e0631dff76 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.2 2019/01/20 09:12:05 jsing Exp $ */ 1/* $OpenBSD: tls13_record.c,v 1.3 2019/01/21 00:24:19 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 *
@@ -23,6 +23,7 @@
23#include "tls13_record.h" 23#include "tls13_record.h"
24 24
25struct tls13_record { 25struct tls13_record {
26 uint16_t version;
26 uint8_t content_type; 27 uint8_t content_type;
27 size_t rec_len; 28 size_t rec_len;
28 uint8_t *data; 29 uint8_t *data;
@@ -62,6 +63,18 @@ tls13_record_free(struct tls13_record *rec)
62 freezero(rec, sizeof(struct tls13_record)); 63 freezero(rec, sizeof(struct tls13_record));
63} 64}
64 65
66uint16_t
67tls13_record_version(struct tls13_record *rec)
68{
69 return rec->version;
70}
71
72uint8_t
73tls13_record_content_type(struct tls13_record *rec)
74{
75 return rec->content_type;
76}
77
65int 78int
66tls13_record_header(struct tls13_record *rec, CBS *cbs) 79tls13_record_header(struct tls13_record *rec, CBS *cbs)
67{ 80{
@@ -73,12 +86,6 @@ tls13_record_header(struct tls13_record *rec, CBS *cbs)
73 return 1; 86 return 1;
74} 87}
75 88
76uint8_t
77tls13_record_content_type(struct tls13_record *rec)
78{
79 return rec->content_type;
80}
81
82int 89int
83tls13_record_content(struct tls13_record *rec, CBS *cbs) 90tls13_record_content(struct tls13_record *rec, CBS *cbs)
84{ 91{
@@ -120,8 +127,8 @@ tls13_record_recv(struct tls13_record *rec, tls13_read_cb wire_read,
120{ 127{
121 uint16_t rec_len, rec_version; 128 uint16_t rec_len, rec_version;
122 uint8_t content_type; 129 uint8_t content_type;
130 ssize_t ret;
123 CBS cbs; 131 CBS cbs;
124 int ret;
125 132
126 if (rec->data != NULL) 133 if (rec->data != NULL)
127 return TLS13_IO_FAILURE; 134 return TLS13_IO_FAILURE;
@@ -145,6 +152,7 @@ tls13_record_recv(struct tls13_record *rec, tls13_read_cb wire_read,
145 return TLS13_IO_FAILURE; 152 return TLS13_IO_FAILURE;
146 153
147 rec->content_type = content_type; 154 rec->content_type = content_type;
155 rec->version = rec_version;
148 rec->rec_len = rec_len; 156 rec->rec_len = rec_len;
149 } 157 }
150 158
diff --git a/src/lib/libssl/tls13_record.h b/src/lib/libssl/tls13_record.h
index 72350d5d49..400153ba77 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.2 2019/01/20 09:12:05 jsing Exp $ */ 1/* $OpenBSD: tls13_record.h,v 1.3 2019/01/21 00:24:19 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2019 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -46,10 +46,13 @@ __BEGIN_HIDDEN_DECLS
46 */ 46 */
47#define TLS13_RECORD_SEQ_NUM_LEN 8 47#define TLS13_RECORD_SEQ_NUM_LEN 8
48 48
49struct tls13_record;
50
49struct tls13_record *tls13_record_new(void); 51struct tls13_record *tls13_record_new(void);
50void tls13_record_free(struct tls13_record *_rec); 52void tls13_record_free(struct tls13_record *_rec);
51int tls13_record_header(struct tls13_record *_rec, CBS *_cbs); 53uint16_t tls13_record_version(struct tls13_record *_rec);
52uint8_t tls13_record_content_type(struct tls13_record *_rec); 54uint8_t tls13_record_content_type(struct tls13_record *_rec);
55int tls13_record_header(struct tls13_record *_rec, CBS *_cbs);
53int tls13_record_content(struct tls13_record *_rec, CBS *_cbs); 56int tls13_record_content(struct tls13_record *_rec, CBS *_cbs);
54void tls13_record_data(struct tls13_record *_rec, CBS *_cbs); 57void tls13_record_data(struct tls13_record *_rec, CBS *_cbs);
55int tls13_record_set_data(struct tls13_record *_rec, uint8_t *_data, 58int tls13_record_set_data(struct tls13_record *_rec, uint8_t *_data,