diff options
author | tb <> | 2023-07-02 11:29:36 +0000 |
---|---|---|
committer | tb <> | 2023-07-02 11:29:36 +0000 |
commit | ab0c921abc95eecbe93ec6d3ae73409cbecb4f0d (patch) | |
tree | 7662bd86085bd5a051661c1d68ee71eda899b847 /src/lib | |
parent | c6b15736ca3e92b4dda32d69c6f51ee388d687d9 (diff) | |
download | openbsd-ab0c921abc95eecbe93ec6d3ae73409cbecb4f0d.tar.gz openbsd-ab0c921abc95eecbe93ec6d3ae73409cbecb4f0d.tar.bz2 openbsd-ab0c921abc95eecbe93ec6d3ae73409cbecb4f0d.zip |
Unconditionally zero the ECDH key
While memset() is quite expensive, we can afford zeroing a few extra bytes
to make this code more readable.
ok beck jsing
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/ecdh/ech_key.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/lib/libcrypto/ecdh/ech_key.c b/src/lib/libcrypto/ecdh/ech_key.c index d93e95b239..bac5b6e28d 100644 --- a/src/lib/libcrypto/ecdh/ech_key.c +++ b/src/lib/libcrypto/ecdh/ech_key.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ech_key.c,v 1.31 2023/07/02 03:11:51 tb Exp $ */ | 1 | /* $OpenBSD: ech_key.c,v 1.32 2023/07/02 11:29:36 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
4 | * | 4 | * |
@@ -68,7 +68,6 @@ | |||
68 | */ | 68 | */ |
69 | 69 | ||
70 | #include <limits.h> | 70 | #include <limits.h> |
71 | #include <stdint.h> | ||
72 | #include <stdlib.h> | 71 | #include <stdlib.h> |
73 | #include <string.h> | 72 | #include <string.h> |
74 | 73 | ||
@@ -163,11 +162,9 @@ ossl_ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, | |||
163 | goto err; | 162 | goto err; |
164 | } | 163 | } |
165 | } else { | 164 | } else { |
166 | /* No KDF, just copy out the key and zero the rest. */ | 165 | memset(out, 0, outlen); |
167 | if (outlen > buflen) { | 166 | if (outlen > buflen) |
168 | memset((void *)((uintptr_t)out + buflen), 0, outlen - buflen); | ||
169 | outlen = buflen; | 167 | outlen = buflen; |
170 | } | ||
171 | memcpy(out, buf, outlen); | 168 | memcpy(out, buf, outlen); |
172 | } | 169 | } |
173 | 170 | ||