diff mbox series

[2/4] dpp-util: fix incorrect ASN1 compressed public key encoding

Message ID 20231010135704.198723-2-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [1/4] unit: add to test-dpp to expose ASN1 point conversion bug | expand

Commit Message

James Prestwood Oct. 10, 2023, 1:57 p.m. UTC
The prefix to the X coordinate was incorrect when using compressed
points. This has been modified to match the ANSI X9.62 spec.
---
 src/dpp-util.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/dpp-util.c b/src/dpp-util.c
index a2640076..0406a4dc 100644
--- a/src/dpp-util.c
+++ b/src/dpp-util.c
@@ -767,11 +767,11 @@  uint8_t *dpp_point_to_asn1(const struct l_ecc_point *p, size_t *len_out)
 
 	/*
 	 * Set the type to whatever avoids doing p - y when reading in the
-	 * key. Working backwards from l_ecc_point_from_data if Y is odd and
-	 * the type is BIT0 there is no subtraction. Similarly if Y is even
+	 * key. Working backwards from l_ecc_point_from_data if Y is even and
+	 * the type is BIT0 there is no subtraction. Similarly if Y is odd
 	 * and the type is BIT1.
 	 */
-	if (l_ecc_point_y_isodd(p))
+	if (!l_ecc_point_y_isodd(p))
 		point_type = L_ECC_POINT_TYPE_COMPRESSED_BIT0;
 	else
 		point_type = L_ECC_POINT_TYPE_COMPRESSED_BIT1;