summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2021-01-05 17:40:11 +0000
committertb <>2021-01-05 17:40:11 +0000
commiteb9d67981acc2795da64ed1850dcf071a7082a28 (patch)
treea9f4cee71c658205bf8b2ea29ab9142b68224421 /src/lib
parent3ccf974958be8f023733b00628808a665a256f24 (diff)
downloadopenbsd-eb9d67981acc2795da64ed1850dcf071a7082a28.tar.gz
openbsd-eb9d67981acc2795da64ed1850dcf071a7082a28.tar.bz2
openbsd-eb9d67981acc2795da64ed1850dcf071a7082a28.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/lib')
-rw-r--r--src/lib/libssl/tls13_internal.h4
-rw-r--r--src/lib/libssl/tls13_key_schedule.c27
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
144int tls13_secret_init(struct tls13_secret *secret, size_t len);
145void tls13_secret_cleanup(struct tls13_secret *secret);
144struct tls13_secrets *tls13_secrets_create(const EVP_MD *digest, 146struct tls13_secrets *tls13_secrets_create(const EVP_MD *digest,
145 int resumption); 147 int resumption);
146void tls13_secrets_destroy(struct tls13_secrets *secrets); 148void 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
25int
26tls13_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
42void
43tls13_secret_cleanup(struct tls13_secret *secret)
44{
45 freezero(secret->data, secret->len);
46 secret->data = NULL;
47 secret->len = 0;
48}
49
25void 50void
26tls13_secrets_destroy(struct tls13_secrets *secrets) 51tls13_secrets_destroy(struct tls13_secrets *secrets)
27{ 52{