diff options
| author | tb <> | 2021-01-05 17:40:11 +0000 |
|---|---|---|
| committer | tb <> | 2021-01-05 17:40:11 +0000 |
| commit | 98ed5a11185e1e013dd02ad00f377be86a157f5d (patch) | |
| tree | a9f4cee71c658205bf8b2ea29ab9142b68224421 /src | |
| parent | 34fac48299b0cc05da218aa9d764f8b28cfb190b (diff) | |
| download | openbsd-98ed5a11185e1e013dd02ad00f377be86a157f5d.tar.gz openbsd-98ed5a11185e1e013dd02ad00f377be86a157f5d.tar.bz2 openbsd-98ed5a11185e1e013dd02ad00f377be86a157f5d.zip | |
Add tls13_secret_{init,cleanup}()
These are two functions that will help streamlining various functions
in the TLSv1.3 code that do not need to know about the interna of this
struct.
input/ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libssl/tls13_internal.h | 4 | ||||
| -rw-r--r-- | src/lib/libssl/tls13_key_schedule.c | 27 |
2 files changed, 29 insertions, 2 deletions
diff --git a/src/lib/libssl/tls13_internal.h b/src/lib/libssl/tls13_internal.h index ea5f9a1473..c339a8ef10 100644 --- a/src/lib/libssl/tls13_internal.h +++ b/src/lib/libssl/tls13_internal.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_internal.h,v 1.87 2020/11/16 18:55:15 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_internal.h,v 1.88 2021/01/05 17:40:11 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2018 Bob Beck <beck@openbsd.org> |
| 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> | 4 | * Copyright (c) 2018 Theo Buehler <tb@openbsd.org> |
| @@ -141,6 +141,8 @@ struct tls13_secrets { | |||
| 141 | struct tls13_secret resumption_master; | 141 | struct tls13_secret resumption_master; |
| 142 | }; | 142 | }; |
| 143 | 143 | ||
| 144 | int tls13_secret_init(struct tls13_secret *secret, size_t len); | ||
| 145 | void tls13_secret_cleanup(struct tls13_secret *secret); | ||
| 144 | struct tls13_secrets *tls13_secrets_create(const EVP_MD *digest, | 146 | struct tls13_secrets *tls13_secrets_create(const EVP_MD *digest, |
| 145 | int resumption); | 147 | int resumption); |
| 146 | void tls13_secrets_destroy(struct tls13_secrets *secrets); | 148 | void tls13_secrets_destroy(struct tls13_secrets *secrets); |
diff --git a/src/lib/libssl/tls13_key_schedule.c b/src/lib/libssl/tls13_key_schedule.c index 35180cfe5c..bf8699dc31 100644 --- a/src/lib/libssl/tls13_key_schedule.c +++ b/src/lib/libssl/tls13_key_schedule.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls13_key_schedule.c,v 1.9 2020/11/16 18:55:15 jsing Exp $ */ | 1 | /* $OpenBSD: tls13_key_schedule.c,v 1.10 2021/01/05 17:40:11 tb Exp $ */ |
| 2 | /* Copyright (c) 2018, Bob Beck <beck@openbsd.org> | 2 | /* Copyright (c) 2018, Bob Beck <beck@openbsd.org> |
| 3 | * | 3 | * |
| 4 | * Permission to use, copy, modify, and/or distribute this software for any | 4 | * Permission to use, copy, modify, and/or distribute this software for any |
| @@ -22,6 +22,31 @@ | |||
| 22 | #include "bytestring.h" | 22 | #include "bytestring.h" |
| 23 | #include "tls13_internal.h" | 23 | #include "tls13_internal.h" |
| 24 | 24 | ||
| 25 | int | ||
| 26 | tls13_secret_init(struct tls13_secret *secret, size_t len) | ||
| 27 | { | ||
| 28 | uint8_t *data; | ||
| 29 | |||
| 30 | if (secret->data != NULL) | ||
| 31 | return 0; | ||
| 32 | |||
| 33 | if ((data = calloc(1, len)) == NULL) | ||
| 34 | return 0; | ||
| 35 | |||
| 36 | secret->data = data; | ||
| 37 | secret->len = len; | ||
| 38 | |||
| 39 | return 1; | ||
| 40 | } | ||
| 41 | |||
| 42 | void | ||
| 43 | tls13_secret_cleanup(struct tls13_secret *secret) | ||
| 44 | { | ||
| 45 | freezero(secret->data, secret->len); | ||
| 46 | secret->data = NULL; | ||
| 47 | secret->len = 0; | ||
| 48 | } | ||
| 49 | |||
| 25 | void | 50 | void |
| 26 | tls13_secrets_destroy(struct tls13_secrets *secrets) | 51 | tls13_secrets_destroy(struct tls13_secrets *secrets) |
| 27 | { | 52 | { |
