diff options
author | 2021-01-06 20:15:35 +0000 | |
---|---|---|
committer | 2021-01-06 20:15:35 +0000 | |
commit | ab7db32ba879db6efa9f38cec2ec968acf957256 (patch) | |
tree | 480e0456b79d05008326aa549604113fc934bdd5 /lib/libssl/tls13_server.c | |
parent | Fix two issues related to thread private data in asr. (diff) | |
download | wireguard-openbsd-ab7db32ba879db6efa9f38cec2ec968acf957256.tar.xz wireguard-openbsd-ab7db32ba879db6efa9f38cec2ec968acf957256.zip |
Use tls13_secret_{init,cleanup}() for the finished_key
This trades an array on the stack for a dynamically allocated secret in
tls13_{client,server}_finished_send() but has the benefit of wiping out
an intermediate secret on function exit.
ok jsing
Diffstat (limited to 'lib/libssl/tls13_server.c')
-rw-r--r-- | lib/libssl/tls13_server.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libssl/tls13_server.c b/lib/libssl/tls13_server.c index 9e5664b79a1..f929e132a8c 100644 --- a/lib/libssl/tls13_server.c +++ b/lib/libssl/tls13_server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_server.c,v 1.66 2021/01/05 17:32:39 jsing Exp $ */ +/* $OpenBSD: tls13_server.c,v 1.67 2021/01/06 20:15:35 tb Exp $ */ /* * Copyright (c) 2019, 2020 Joel Sing <jsing@openbsd.org> * Copyright (c) 2020 Bob Beck <beck@openbsd.org> @@ -770,10 +770,9 @@ tls13_server_finished_send(struct tls13_ctx *ctx, CBB *cbb) { struct tls13_secrets *secrets = ctx->hs->secrets; struct tls13_secret context = { .data = "", .len = 0 }; - struct tls13_secret finished_key; + struct tls13_secret finished_key = { .data = NULL, .len = 0 } ; uint8_t transcript_hash[EVP_MAX_MD_SIZE]; size_t transcript_hash_len; - uint8_t key[EVP_MAX_MD_SIZE]; uint8_t *verify_data; size_t verify_data_len; unsigned int hlen; @@ -782,8 +781,8 @@ tls13_server_finished_send(struct tls13_ctx *ctx, CBB *cbb) SSL *s = ctx->ssl; int ret = 0; - finished_key.data = key; - finished_key.len = EVP_MD_size(ctx->hash); + if (!tls13_secret_init(&finished_key, EVP_MD_size(ctx->hash))) + goto err; if (!tls13_hkdf_expand_label(&finished_key, ctx->hash, &secrets->server_handshake_traffic, "finished", @@ -818,6 +817,7 @@ tls13_server_finished_send(struct tls13_ctx *ctx, CBB *cbb) ret = 1; err: + tls13_secret_cleanup(&finished_key); HMAC_CTX_free(hmac_ctx); return ret; |