diff options
author | jsing <> | 2021-01-19 18:57:09 +0000 |
---|---|---|
committer | jsing <> | 2021-01-19 18:57:09 +0000 |
commit | eb720c630d40660f4bf00d58faa6f6d59ba82ea2 (patch) | |
tree | 1cc6adc2f532c5f987be2b9a01b957de5960ebfa /src/lib/libssl/tls12_record_layer.c | |
parent | ac4995fa26f1a8ba3ff386c0caf843a423a4abc7 (diff) | |
download | openbsd-eb720c630d40660f4bf00d58faa6f6d59ba82ea2.tar.gz openbsd-eb720c630d40660f4bf00d58faa6f6d59ba82ea2.tar.bz2 openbsd-eb720c630d40660f4bf00d58faa6f6d59ba82ea2.zip |
Provide functions to determine if TLSv1.2 record protection is engaged.
Call these functions from code that needs to know if we've changed cipher
state and enabled record protection, rather than inconsistently checking
various pointers from other places in the code base. This also fixes a
minor bug where the wrong pointers are checked if we're operating with
AEAD.
ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/tls12_record_layer.c')
-rw-r--r-- | src/lib/libssl/tls12_record_layer.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/libssl/tls12_record_layer.c b/src/lib/libssl/tls12_record_layer.c index 7fa31707d3..affc5375a2 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.11 2021/01/19 18:51:08 jsing Exp $ */ | 1 | /* $OpenBSD: tls12_record_layer.c,v 1.12 2021/01/19 18:57:09 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -59,6 +59,12 @@ tls12_record_protection_free(struct tls12_record_protection *rp) | |||
59 | } | 59 | } |
60 | 60 | ||
61 | static int | 61 | static int |
62 | tls12_record_protection_engaged(struct tls12_record_protection *rp) | ||
63 | { | ||
64 | return rp->aead_ctx != NULL || rp->cipher_ctx != NULL; | ||
65 | } | ||
66 | |||
67 | static int | ||
62 | tls12_record_protection_eiv_len(struct tls12_record_protection *rp, | 68 | tls12_record_protection_eiv_len(struct tls12_record_protection *rp, |
63 | size_t *out_eiv_len) | 69 | size_t *out_eiv_len) |
64 | { | 70 | { |
@@ -195,6 +201,18 @@ tls12_record_layer_write_overhead(struct tls12_record_layer *rl, | |||
195 | return 1; | 201 | return 1; |
196 | } | 202 | } |
197 | 203 | ||
204 | int | ||
205 | tls12_record_layer_read_protected(struct tls12_record_layer *rl) | ||
206 | { | ||
207 | return tls12_record_protection_engaged(rl->read); | ||
208 | } | ||
209 | |||
210 | int | ||
211 | tls12_record_layer_write_protected(struct tls12_record_layer *rl) | ||
212 | { | ||
213 | return tls12_record_protection_engaged(rl->write); | ||
214 | } | ||
215 | |||
198 | void | 216 | void |
199 | tls12_record_layer_set_version(struct tls12_record_layer *rl, uint16_t version) | 217 | tls12_record_layer_set_version(struct tls12_record_layer *rl, uint16_t version) |
200 | { | 218 | { |