summaryrefslogtreecommitdiffstats
path: root/lib/libssl/src
diff options
context:
space:
mode:
authorjsing <jsing@openbsd.org>2015-09-13 14:11:57 +0000
committerjsing <jsing@openbsd.org>2015-09-13 14:11:57 +0000
commit22725a542b2aa8628bb5342910b93e7848071330 (patch)
tree57b56ebdfa7fb7c783c07b70a2b38a704c1f2f98 /lib/libssl/src
parentremove e_os2.h includes (diff)
downloadwireguard-openbsd-22725a542b2aa8628bb5342910b93e7848071330.tar.xz
wireguard-openbsd-22725a542b2aa8628bb5342910b93e7848071330.zip
Only check for key truncation if no KDF function is being used.
ok beck@ miod@
Diffstat (limited to 'lib/libssl/src')
-rw-r--r--lib/libssl/src/crypto/ecdh/ech_key.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libssl/src/crypto/ecdh/ech_key.c b/lib/libssl/src/crypto/ecdh/ech_key.c
index 7202c497cf1..e695b0b9ade 100644
--- a/lib/libssl/src/crypto/ecdh/ech_key.c
+++ b/lib/libssl/src/crypto/ecdh/ech_key.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ech_key.c,v 1.4 2015/09/13 12:27:14 jsing Exp $ */
+/* $OpenBSD: ech_key.c,v 1.5 2015/09/13 14:11:57 jsing Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
@@ -162,7 +162,7 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ERR_R_INTERNAL_ERROR);
goto err;
}
- if (outlen < buflen) {
+ if (KDF == NULL && outlen < buflen) {
/* The resulting key would be truncated. */
ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ECDH_R_KEY_TRUNCATION);
goto err;
@@ -178,14 +178,14 @@ ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
goto err;
}
- if (KDF != 0) {
+ if (KDF != NULL) {
if (KDF(buf, buflen, out, &outlen) == NULL) {
ECDHerr(ECDH_F_ECDH_COMPUTE_KEY, ECDH_R_KDF_FAILED);
goto err;
}
ret = outlen;
} else {
- /* No KDF, just copy as much as we can and zero the rest. */
+ /* No KDF, just copy out the key and zero the rest. */
if (outlen > buflen) {
memset(out + buflen, 0, outlen - buflen);
outlen = buflen;