diff options
| author | tb <> | 2026-06-09 05:24:47 +0000 |
|---|---|---|
| committer | tb <> | 2026-06-09 05:24:47 +0000 |
| commit | 2e00d0bb059dae7f2a099952fda78cd682f5b3e4 (patch) | |
| tree | 803d820e0fd574ee80acbc9168e1c6f91d39cf8e /src/lib/libcrypto/ecdh | |
| parent | baf3d6d1012f4dbbc344143b7e0aec718fd4d552 (diff) | |
| download | openbsd-2e00d0bb059dae7f2a099952fda78cd682f5b3e4.tar.gz openbsd-2e00d0bb059dae7f2a099952fda78cd682f5b3e4.tar.bz2 openbsd-2e00d0bb059dae7f2a099952fda78cd682f5b3e4.zip | |
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
Diffstat (limited to 'src/lib/libcrypto/ecdh')
| -rw-r--r-- | src/lib/libcrypto/ecdh/ecdh.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/libcrypto/ecdh/ecdh.c b/src/lib/libcrypto/ecdh/ecdh.c index 51b409a5dd..218c584558 100644 --- a/src/lib/libcrypto/ecdh/ecdh.c +++ b/src/lib/libcrypto/ecdh/ecdh.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecdh.c,v 1.14 2026/06/08 12:08:08 tb Exp $ */ | 1 | /* $OpenBSD: ecdh.c,v 1.15 2026/06/09 05:24:47 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 | * | 4 | * |
| @@ -169,11 +169,15 @@ ec_key_ecdh_compute_key(unsigned char **out, size_t *out_len, | |||
| 169 | if ((group = EC_KEY_get0_group(ecdh)) == NULL) | 169 | if ((group = EC_KEY_get0_group(ecdh)) == NULL) |
| 170 | goto err; | 170 | goto err; |
| 171 | 171 | ||
| 172 | if (EC_POINT_is_at_infinity(group, pub_key)) | 172 | if (EC_POINT_is_at_infinity(group, pub_key)) { |
| 173 | ECerror(EC_R_POINT_AT_INFINITY); | ||
| 173 | goto err; | 174 | goto err; |
| 175 | } | ||
| 174 | 176 | ||
| 175 | if (EC_POINT_is_on_curve(group, pub_key, ctx) <= 0) | 177 | if (EC_POINT_is_on_curve(group, pub_key, ctx) <= 0) { |
| 178 | ECerror(EC_R_POINT_IS_NOT_ON_CURVE); | ||
| 176 | goto err; | 179 | goto err; |
| 180 | } | ||
| 177 | 181 | ||
| 178 | if ((point = EC_POINT_new(group)) == NULL) { | 182 | if ((point = EC_POINT_new(group)) == NULL) { |
| 179 | ECerror(ERR_R_MALLOC_FAILURE); | 183 | ECerror(ERR_R_MALLOC_FAILURE); |
