All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2 1/2] ecc: enforce strict length with l_ecc_point_from_data
@ 2022-01-21 19:44 Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-01-21 19:44 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

Hi James,

On 1/21/22 13:36, James Prestwood wrote:
> This add some extra convenience to users of l_ecc_point_from_data
> allowing the exact length to be verified in addition to creating
> the point.
> ---
>   ell/ecc.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 

Both applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v2 1/2] ecc: enforce strict length with l_ecc_point_from_data
@ 2022-01-21 19:36 James Prestwood
  0 siblings, 0 replies; 2+ messages in thread
From: James Prestwood @ 2022-01-21 19:36 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]

This add some extra convenience to users of l_ecc_point_from_data
allowing the exact length to be verified in addition to creating
the point.
---
 ell/ecc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ell/ecc.c b/ell/ecc.c
index a16b1c0..f1adcc4 100644
--- a/ell/ecc.c
+++ b/ell/ecc.c
@@ -538,8 +538,11 @@ LIB_EXPORT struct l_ecc_point *l_ecc_point_from_data(
 	if (!data)
 		return NULL;
 
-	/* In all cases there should be an X coordinate in data */
-	if (len < bytes)
+	/* Verify the data length matches a full point or X coordinate */
+	if (type == L_ECC_POINT_TYPE_FULL) {
+		if (len != bytes * 2)
+			return NULL;
+	} else if (len != bytes)
 		return NULL;
 
 	p = l_ecc_point_new(curve);
@@ -570,9 +573,6 @@ LIB_EXPORT struct l_ecc_point *l_ecc_point_from_data(
 
 		break;
 	case L_ECC_POINT_TYPE_FULL:
-		if (len < bytes * 2)
-			goto failed;
-
 		_ecc_be2native(p->y, (void *) data + bytes, curve->ndigits);
 
 		if (!ecc_valid_point(p))
-- 
2.31.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-21 19:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-21 19:44 [PATCH v2 1/2] ecc: enforce strict length with l_ecc_point_from_data Denis Kenzior
  -- strict thread matches above, loose matches on Subject: below --
2022-01-21 19:36 James Prestwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.