mirror of
https://github.com/openbsd/src.git
synced 2026-06-18 07:13:36 +02:00
ecdh: add error codes for point at infinity/not on curve
The point at infinity would previously raise EC_R_POINT_AT_INFINITY via EC_POINT_get_affine_coordinates(). For consistency, also raise an error for off-curve points. pointed out by/ok kenjiro
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ecdh.c,v 1.14 2026/06/08 12:08:08 tb Exp $ */
|
||||
/* $OpenBSD: ecdh.c,v 1.15 2026/06/09 05:24:47 tb Exp $ */
|
||||
/* ====================================================================
|
||||
* Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
|
||||
*
|
||||
@@ -169,11 +169,15 @@ ec_key_ecdh_compute_key(unsigned char **out, size_t *out_len,
|
||||
if ((group = EC_KEY_get0_group(ecdh)) == NULL)
|
||||
goto err;
|
||||
|
||||
if (EC_POINT_is_at_infinity(group, pub_key))
|
||||
if (EC_POINT_is_at_infinity(group, pub_key)) {
|
||||
ECerror(EC_R_POINT_AT_INFINITY);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (EC_POINT_is_on_curve(group, pub_key, ctx) <= 0)
|
||||
if (EC_POINT_is_on_curve(group, pub_key, ctx) <= 0) {
|
||||
ECerror(EC_R_POINT_IS_NOT_ON_CURVE);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if ((point = EC_POINT_new(group)) == NULL) {
|
||||
ECerror(ERR_R_MALLOC_FAILURE);
|
||||
|
||||
Reference in New Issue
Block a user