-/* $OpenBSD: ech_key.c,v 1.21 2023/07/01 14:48:01 tb Exp $ */
+/* $OpenBSD: ech_key.c,v 1.22 2023/07/01 14:50:39 tb Exp $ */
/* ====================================================================
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
*
BIGNUM *x;
const BIGNUM *priv_key;
const EC_GROUP* group;
- int ret = -1;
unsigned char *buf = NULL;
int buflen, len;
+ int ret = -1;
if (outlen > INT_MAX) {
/* Sort of, anyway. */
ECDHerror(ECDH_R_KDF_FAILED);
goto err;
}
- ret = outlen;
} else {
/* No KDF, just copy out the key and zero the rest. */
if (outlen > buflen) {
outlen = buflen;
}
memcpy(out, buf, outlen);
- ret = outlen;
}
+ ret = outlen;
err:
EC_POINT_free(tmp);
BN_CTX_end(ctx);
BN_CTX_free(ctx);
free(buf);
- return (ret);
+
+ return ret;
}
int
int
ECDH_size(const EC_KEY *d)
{
- return ((EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8);
+ return (EC_GROUP_get_degree(EC_KEY_get0_group(d)) + 7) / 8;
}