summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Sing <jsing@cvs.openbsd.org>2015-09-13 14:11:58 +0000
committerJoel Sing <jsing@cvs.openbsd.org>2015-09-13 14:11:58 +0000
commit147263b5f706bcea6159c19b4d962d9a2935f9f7 (patch)
tree048cb3b3f012283d2ecfa0f0a9d5e71873a6e9aa
parentbd53a3891c54700c47ec74797357eee8fc5f7204 (diff)
Only check for key truncation if no KDF function is being used.
ok beck@ miod@
-rw-r--r--lib/libcrypto/ecdh/ech_key.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libcrypto/ecdh/ech_key.c b/lib/libcrypto/ecdh/ech_key.c
index 7202c497cf1..e695b0b9ade 100644
--- a/lib/libcrypto/ecdh/ech_key.c
+++ b/lib/libcrypto/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;