diff options
author | jsing <> | 2021-01-07 15:32:59 +0000 |
---|---|---|
committer | jsing <> | 2021-01-07 15:32:59 +0000 |
commit | a44b8f51b28515300b7d351485e371c07311a9f4 (patch) | |
tree | d58094850feafb23ea66396721d16b400c034196 /src/lib/libssl/tls12_record_layer.c | |
parent | 35e7c2f41633d153898933e5ba6cf0580ce70f26 (diff) | |
download | openbsd-a44b8f51b28515300b7d351485e371c07311a9f4.tar.gz openbsd-a44b8f51b28515300b7d351485e371c07311a9f4.tar.bz2 openbsd-a44b8f51b28515300b7d351485e371c07311a9f4.zip |
Move the read MAC key into the TLSv1.2 record layer.
ok inoguchi@ tb@
Diffstat (limited to 'src/lib/libssl/tls12_record_layer.c')
-rw-r--r-- | src/lib/libssl/tls12_record_layer.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/lib/libssl/tls12_record_layer.c b/src/lib/libssl/tls12_record_layer.c index 56ff94d95c..32e3fcc813 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.5 2020/10/03 17:35:17 jsing Exp $ */ | 1 | /* $OpenBSD: tls12_record_layer.c,v 1.6 2021/01/07 15:32:59 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2020 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -33,6 +33,9 @@ struct tls12_record_layer { | |||
33 | int read_stream_mac; | 33 | int read_stream_mac; |
34 | int write_stream_mac; | 34 | int write_stream_mac; |
35 | 35 | ||
36 | uint8_t *read_mac_key; | ||
37 | size_t read_mac_key_len; | ||
38 | |||
36 | /* | 39 | /* |
37 | * XXX - for now these are just pointers to externally managed | 40 | * XXX - for now these are just pointers to externally managed |
38 | * structs/memory. These should eventually be owned by the record layer. | 41 | * structs/memory. These should eventually be owned by the record layer. |
@@ -45,9 +48,6 @@ struct tls12_record_layer { | |||
45 | EVP_CIPHER_CTX *write_cipher_ctx; | 48 | EVP_CIPHER_CTX *write_cipher_ctx; |
46 | EVP_MD_CTX *write_hash_ctx; | 49 | EVP_MD_CTX *write_hash_ctx; |
47 | 50 | ||
48 | const uint8_t *read_mac_key; | ||
49 | size_t read_mac_key_len; | ||
50 | |||
51 | uint8_t *read_seq_num; | 51 | uint8_t *read_seq_num; |
52 | uint8_t *write_seq_num; | 52 | uint8_t *write_seq_num; |
53 | }; | 53 | }; |
@@ -66,6 +66,7 @@ tls12_record_layer_new(void) | |||
66 | void | 66 | void |
67 | tls12_record_layer_free(struct tls12_record_layer *rl) | 67 | tls12_record_layer_free(struct tls12_record_layer *rl) |
68 | { | 68 | { |
69 | freezero(rl->read_mac_key, rl->read_mac_key_len); | ||
69 | freezero(rl, sizeof(struct tls12_record_layer)); | 70 | freezero(rl, sizeof(struct tls12_record_layer)); |
70 | } | 71 | } |
71 | 72 | ||
@@ -189,7 +190,17 @@ int | |||
189 | tls12_record_layer_set_read_mac_key(struct tls12_record_layer *rl, | 190 | tls12_record_layer_set_read_mac_key(struct tls12_record_layer *rl, |
190 | const uint8_t *mac_key, size_t mac_key_len) | 191 | const uint8_t *mac_key, size_t mac_key_len) |
191 | { | 192 | { |
192 | rl->read_mac_key = mac_key; | 193 | freezero(rl->read_mac_key, rl->read_mac_key_len); |
194 | rl->read_mac_key = NULL; | ||
195 | rl->read_mac_key_len = 0; | ||
196 | |||
197 | if (mac_key == NULL || mac_key_len == 0) | ||
198 | return 1; | ||
199 | |||
200 | if ((rl->read_mac_key = calloc(1, mac_key_len)) == NULL) | ||
201 | return 0; | ||
202 | |||
203 | memcpy(rl->read_mac_key, mac_key, mac_key_len); | ||
193 | rl->read_mac_key_len = mac_key_len; | 204 | rl->read_mac_key_len = mac_key_len; |
194 | 205 | ||
195 | return 1; | 206 | return 1; |