Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz at gmail.com>
To: iwd at lists.01.org
Subject: Re: [PATCH 02/12] dpp-util: add dpp_point_from_asn1()
Date: Thu, 20 Jan 2022 14:10:32 -0600	[thread overview]
Message-ID: <bfbe6420-c777-a368-8bb2-1c7776bec48b@gmail.com> (raw)
In-Reply-To: 20220118212512.2017977-2-prestwoj@gmail.com

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

Hi James,

On 1/18/22 15:25, James Prestwood wrote:
> Given an ASN1 blob of the right form, parse and create
> an l_ecc_point object. The form used is specific to DPP
> hence why this isn't general purpose and put into dpp-util.
> ---
>   src/dpp-util.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   src/dpp-util.h |  1 +
>   2 files changed, 70 insertions(+)
> 

<snip>

> +	/* BITSTRING */
> +	key_data = asn1_der_find_elem(outer_seq, outer_len, 1, &tag, &elen);
> +	if (!key_data || tag != ASN1_ID_BIT_STRING || elen < 34)

Why 34? Aren't you only concerned that elen >= 2?

> +		return NULL;
> +
> +	curve = l_ecc_curve_from_ike_group(curve_num);
> +	if (!curve)
> +		return NULL;

Perhaps this check should be moved up?

> +
> +	return l_ecc_point_from_data(curve, key_data[1],
> +					key_data + 2, elen - 2);

Aren't you relying on ecc_point_from_data to validate the length?  Hence the 
unnecessary '34' magic number above?

Should ecc_point_from_data also validate that all of the data passed in was 
consumed?  Or maybe return the number of bytes consumed so that we can validate 
it here?

Regards,
-Denis

             reply	other threads:[~2022-01-20 20:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 20:10 Denis Kenzior [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-01-20 23:13 [PATCH 02/12] dpp-util: add dpp_point_from_asn1() James Prestwood
2022-01-18 21:25 James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bfbe6420-c777-a368-8bb2-1c7776bec48b@gmail.com \
    --to=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox