From 2ba88f05e955f207c342ebca924e3ebddde18c78 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Tue, 10 Oct 2023 06:57:02 -0700 Subject: [PATCH] dpp-util: fix incorrect ASN1 compressed public key encoding 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 --git a/src/dpp-util.c b/src/dpp-util.c index d4787b31..df7d0fc5 100644 --- a/src/dpp-util.c +++ b/src/dpp-util.c @@ -751,11 +751,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;