diff options
Diffstat (limited to 'src/lib/libssl/tls13_record.h')
-rw-r--r-- | src/lib/libssl/tls13_record.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/lib/libssl/tls13_record.h b/src/lib/libssl/tls13_record.h new file mode 100644 index 0000000000..ca7a63f99c --- /dev/null +++ b/src/lib/libssl/tls13_record.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* $OpenBSD: tls13_record.h,v 1.1 2019/01/19 02:53:54 jsing Exp $ */ | ||
2 | /* | ||
3 | * Copyright (c) 2019 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_TLS13_RECORD_H | ||
19 | #define HEADER_TLS13_RECORD_H | ||
20 | |||
21 | #include "bytestring.h" | ||
22 | #include "tls13_internal.h" | ||
23 | |||
24 | __BEGIN_HIDDEN_DECLS | ||
25 | |||
26 | /* | ||
27 | * TLSv1.3 - RFC 8446 section 5. | ||
28 | * | ||
29 | * The maximum plaintext is 2^14, however for inner plaintext an additional | ||
30 | * byte is allowed for the content type. A maximum AEAD overhead of 255-bytes | ||
31 | * is permitted, along with a 5-byte header, giving a maximum size of | ||
32 | * 5 + 2^14 + 1 + 255 = 16,645-bytes. | ||
33 | */ | ||
34 | #define TLS13_RECORD_HEADER_LEN 5 | ||
35 | #define TLS13_RECORD_MAX_AEAD_OVERHEAD 255 | ||
36 | #define TLS13_RECORD_MAX_PLAINTEXT_LEN 16384 | ||
37 | #define TLS13_RECORD_MAX_INNER_PLAINTEXT_LEN \ | ||
38 | (TLS13_RECORD_MAX_PLAINTEXT_LEN + 1) | ||
39 | #define TLS13_RECORD_MAX_CIPHERTEXT \ | ||
40 | (TLS13_RECORD_MAX_INNER_PLAINTEXT_LEN + TLS13_RECORD_MAX_AEAD_OVERHEAD) | ||
41 | #define TLS13_RECORD_MAX_LEN \ | ||
42 | (TLS13_RECORD_HEADER_LEN + TLS13_RECORD_MAX_CIPHERTEXT) | ||
43 | |||
44 | struct tls13_record *tls13_record_new(void); | ||
45 | void tls13_record_free(struct tls13_record *_rec); | ||
46 | uint8_t tls13_record_content_type(struct tls13_record *_rec); | ||
47 | int tls13_record_content(struct tls13_record *_rec, CBS *_cbs); | ||
48 | void tls13_record_data(struct tls13_record *_rec, CBS *_cbs); | ||
49 | void tls13_record_set_data(struct tls13_record *_rec, uint8_t *_data, | ||
50 | size_t _data_len); | ||
51 | ssize_t tls13_record_recv(struct tls13_record *_rec, tls13_read_cb _wire_read, | ||
52 | void *_wire_arg); | ||
53 | ssize_t tls13_record_send(struct tls13_record *_rec, tls13_write_cb _wire_write, | ||
54 | void *_wire_arg); | ||
55 | |||
56 | __END_HIDDEN_DECLS | ||
57 | |||
58 | #endif | ||