summaryrefslogtreecommitdiff
path: root/src/lib/libssl/tls12_record_layer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libssl/tls12_record_layer.c')
-rw-r--r--src/lib/libssl/tls12_record_layer.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/lib/libssl/tls12_record_layer.c b/src/lib/libssl/tls12_record_layer.c
index 04699f9a83..7fa31707d3 100644
--- a/src/lib/libssl/tls12_record_layer.c
+++ b/src/lib/libssl/tls12_record_layer.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls12_record_layer.c,v 1.10 2021/01/19 18:34:02 jsing Exp $ */ 1/* $OpenBSD: tls12_record_layer.c,v 1.11 2021/01/19 18:51:08 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2020 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -168,6 +168,33 @@ tls12_record_layer_alert(struct tls12_record_layer *rl, uint8_t *alert_desc)
168 *alert_desc = rl->alert_desc; 168 *alert_desc = rl->alert_desc;
169} 169}
170 170
171int
172tls12_record_layer_write_overhead(struct tls12_record_layer *rl,
173 size_t *overhead)
174{
175 size_t block_size, eiv_len, mac_len;
176
177 *overhead = 0;
178
179 if (rl->write->aead_ctx != NULL) {
180 *overhead = rl->write->aead_ctx->tag_len;
181 } else if (rl->write->cipher_ctx != NULL) {
182 eiv_len = 0;
183 if (rl->version != TLS1_VERSION) {
184 if (!tls12_record_protection_eiv_len(rl->write, &eiv_len))
185 return 0;
186 }
187 if (!tls12_record_protection_block_size(rl->write, &block_size))
188 return 0;
189 if (!tls12_record_protection_mac_len(rl->write, &mac_len))
190 return 0;
191
192 *overhead = eiv_len + block_size + mac_len;
193 }
194
195 return 1;
196}
197
171void 198void
172tls12_record_layer_set_version(struct tls12_record_layer *rl, uint16_t version) 199tls12_record_layer_set_version(struct tls12_record_layer *rl, uint16_t version)
173{ 200{