summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-10-23 13:42:50 +0000
committertb <>2024-10-23 13:42:50 +0000
commitef42116f2f12a51e930b5b9fecc997735d3639fa (patch)
tree97e6a8029362524a75723c4ad0090c38fe190686 /src
parent14d65af2c2a60922560e8b6b99c54957aeffdf2c (diff)
downloadopenbsd-ef42116f2f12a51e930b5b9fecc997735d3639fa.tar.gz
openbsd-ef42116f2f12a51e930b5b9fecc997735d3639fa.tar.bz2
openbsd-ef42116f2f12a51e930b5b9fecc997735d3639fa.zip
EC_POINT_point2oct() need to special case the point at infinity
This is annoying since it undoes some polishing done before commit and reintroduces an unpleasant asymmetry. found by anton via openssl-ruby tests ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/ec/ecp_oct.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/libcrypto/ec/ecp_oct.c b/src/lib/libcrypto/ec/ecp_oct.c
index d4ef0406f5..5444b5ec34 100644
--- a/src/lib/libcrypto/ec/ecp_oct.c
+++ b/src/lib/libcrypto/ec/ecp_oct.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ecp_oct.c,v 1.26 2024/10/22 21:28:53 tb Exp $ */ 1/* $OpenBSD: ecp_oct.c,v 1.27 2024/10/23 13:42:50 tb Exp $ */
2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> 2/* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de>
3 * for the OpenSSL project. 3 * for the OpenSSL project.
4 * Includes code written by Bodo Moeller for the OpenSSL project. 4 * Includes code written by Bodo Moeller for the OpenSSL project.
@@ -377,6 +377,13 @@ ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
377 CBB_init_fixed(&cbb, buf, len); 377 CBB_init_fixed(&cbb, buf, len);
378 BN_CTX_start(ctx); 378 BN_CTX_start(ctx);
379 379
380 if (form == EC_OCT_POINT_AT_INFINITY) {
381 if (!ec_oct_add_leading_octet_cbb(&cbb, form, 0))
382 goto err;
383
384 goto done;
385 }
386
380 if ((x = BN_CTX_get(ctx)) == NULL) 387 if ((x = BN_CTX_get(ctx)) == NULL)
381 goto err; 388 goto err;
382 if ((y = BN_CTX_get(ctx)) == NULL) 389 if ((y = BN_CTX_get(ctx)) == NULL)
@@ -387,9 +394,7 @@ ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
387 if (!ec_oct_add_leading_octet_cbb(&cbb, form, BN_is_odd(y))) 394 if (!ec_oct_add_leading_octet_cbb(&cbb, form, BN_is_odd(y)))
388 goto err; 395 goto err;
389 396
390 if (form == EC_OCT_POINT_AT_INFINITY) { 397 if (form == EC_OCT_POINT_COMPRESSED) {
391 /* Encoded in leading octet. */;
392 } else if (form == EC_OCT_POINT_COMPRESSED) {
393 if (!ec_oct_add_field_element_cbb(&cbb, group, x)) 398 if (!ec_oct_add_field_element_cbb(&cbb, group, x))
394 goto err; 399 goto err;
395 } else { 400 } else {
@@ -399,6 +404,7 @@ ec_GFp_simple_point2oct(const EC_GROUP *group, const EC_POINT *point,
399 goto err; 404 goto err;
400 } 405 }
401 406
407 done:
402 if (!CBB_finish(&cbb, NULL, &ret)) 408 if (!CBB_finish(&cbb, NULL, &ret))
403 goto err; 409 goto err;
404 410