From 533a2cdb71a16eafbc7aced4709154605f68cd6d Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 13 Sep 2015 14:11:57 +0000 Subject: Only check for key truncation if no KDF function is being used. ok beck@ miod@ --- src/lib/libcrypto/ecdh/ech_key.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/libcrypto/ecdh/ech_key.c') diff --git a/src/lib/libcrypto/ecdh/ech_key.c b/src/lib/libcrypto/ecdh/ech_key.c index 7202c497cf..e695b0b9ad 100644 --- a/src/lib/libcrypto/ecdh/ech_key.c +++ b/src/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; -- cgit v1.2.3-55-g6feb