From: tb Date: Sat, 15 Jul 2023 20:11:37 +0000 (+0000) Subject: Fix return value check for ECDH_compute_key() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a1610dfc38dd717ee13028c2919dcd8462291d77;p=openbsd Fix return value check for ECDH_compute_key() ECDH_compute_key() usually returns -1 on error (but sometimes 0). This was also the case in OpenSSL when these tests were written. This will soon change. The check for <= 0 will still be correct. --- diff --git a/regress/lib/libcrypto/ecdh/ecdhtest.c b/regress/lib/libcrypto/ecdh/ecdhtest.c index 8770e4a8f07..6388343cfe8 100644 --- a/regress/lib/libcrypto/ecdh/ecdhtest.c +++ b/regress/lib/libcrypto/ecdh/ecdhtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdhtest.c,v 1.16 2023/05/20 16:00:22 tb Exp $ */ +/* $OpenBSD: ecdhtest.c,v 1.17 2023/07/15 20:11:37 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -348,14 +348,14 @@ ecdh_kat(BIO *out, const char *cname, int nid, goto err; if ((Ztmp = malloc(Ztmplen)) == NULL) goto err; - if (!ECDH_compute_key(Ztmp, Ztmplen, - EC_KEY_get0_public_key(key2), key1, 0)) + if (ECDH_compute_key(Ztmp, Ztmplen, + EC_KEY_get0_public_key(key2), key1, 0) <= 0) goto err; if (memcmp(Ztmp, Z, Zlen)) goto err; memset(Ztmp, 0, Zlen); - if (!ECDH_compute_key(Ztmp, Ztmplen, - EC_KEY_get0_public_key(key1), key2, 0)) + if (ECDH_compute_key(Ztmp, Ztmplen, + EC_KEY_get0_public_key(key1), key2, 0) <= 0) goto err; if (memcmp(Ztmp, Z, Zlen)) goto err;