All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gix, Brian" <brian.gix@intel.com>
To: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Cc: "testtgsh@gmail.com" <testtgsh@gmail.com>,
	"Stotland, Inga" <inga.stotland@intel.com>
Subject: Re: [PATCH BlueZ v2] tools/mesh-cfgclient: Add support for Static OOB key
Date: Thu, 12 Mar 2020 18:19:59 +0000	[thread overview]
Message-ID: <662ab7993d46a10c04f4736c27b5168ac5ae5b02.camel@intel.com> (raw)
In-Reply-To: <20200311225940.6628-1-brian.gix@intel.com>

Applied
On Wed, 2020-03-11 at 15:59 -0700, Brian Gix wrote:
> This fixes a bug that didn't allow 16 octet Static OOB strings during
> provisioning.
> ---
>  tools/mesh-cfgclient.c | 29 +++++++++++++++++++----------
>  tools/mesh/agent.c     | 10 ++++++----
>  2 files changed, 25 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c
> index b4d76de93..4b7bd2200 100644
> --- a/tools/mesh-cfgclient.c
> +++ b/tools/mesh-cfgclient.c
> @@ -372,12 +372,11 @@ static void agent_input_done(oob_type_t type, void *buf, uint16_t len,
>  	struct l_dbus_message *reply = NULL;
>  	struct l_dbus_message_builder *builder;
>  	uint32_t val_u32;
> -	uint8_t ascii[16];
> +	uint8_t oob_data[16];
>  
>  	switch (type) {
>  	case NONE:
>  	case OUTPUT:
> -	case HEXADECIMAL:
>  	default:
>  		break;
>  
> @@ -386,12 +385,18 @@ static void agent_input_done(oob_type_t type, void *buf, uint16_t len,
>  			bt_shell_printf("Bad input length\n");
>  			break;
>  		}
> +		/* Fall Through */
>  
> -		memset(ascii, 0, 16);
> -		memcpy(ascii, buf, len);
> +	case HEXADECIMAL:
> +		if (len > 16) {
> +			bt_shell_printf("Bad input length\n");
> +			break;
> +		}
> +		memset(oob_data, 0, 16);
> +		memcpy(oob_data, buf, len);
>  		reply = l_dbus_message_new_method_return(msg);
>  		builder = l_dbus_message_builder_new(reply);
> -		append_byte_array(builder, ascii, 16);
> +		append_byte_array(builder, oob_data, 16);
>  		l_dbus_message_builder_finalize(builder);
>  		l_dbus_message_builder_destroy(builder);
>  		break;
> @@ -539,12 +544,16 @@ static struct l_dbus_message *prompt_static_call(struct l_dbus *dbus,
>  		return l_dbus_message_new_error(msg, dbus_err_fail, NULL);
>  	}
>  
> -	if (!strcmp(str, "in-alpha") && !strcmp(str, "out-alpha"))
> -		return l_dbus_message_new_error(msg, dbus_err_support, NULL);
> -
> -	l_dbus_message_ref(msg);
> -	agent_input_request(ASCII, 8, "Enter displayed Ascii code",
> +	if (!strcmp(str, "in-alpha") || !strcmp(str, "out-alpha")) {
> +		l_dbus_message_ref(msg);
> +		agent_input_request(ASCII, 8, "Enter displayed Ascii code",
>  							agent_input_done, msg);
> +	} else if (!strcmp(str, "static-oob")) {
> +		l_dbus_message_ref(msg);
> +		agent_input_request(HEXADECIMAL, 16, "Enter Static Key",
> +							agent_input_done, msg);
> +	} else
> +		return l_dbus_message_new_error(msg, dbus_err_support, NULL);
>  
>  	return NULL;
>  }
> diff --git a/tools/mesh/agent.c b/tools/mesh/agent.c
> index 1f83347bf..0258a3803 100644
> --- a/tools/mesh/agent.c
> +++ b/tools/mesh/agent.c
> @@ -81,15 +81,16 @@ static bool str2hex(const char *str, uint16_t in_len, uint8_t *out,
>  static void response_hexadecimal(const char *input, void *user_data)
>  {
>  	uint8_t buf[MAX_HEXADECIMAL_OOB_LEN];
> +	uint16_t len = pending_request.len;
>  
>  	if (!str2hex(input, strlen(input), buf, pending_request.len) ) {
>  		bt_shell_printf("Incorrect input: expecting %d hex octets\n",
>  			  pending_request.len);
> -		return;
> +		len = 0;
>  	}
>  
>  	if (pending_request.cb)
> -		pending_request.cb(HEXADECIMAL, buf, pending_request.len,
> +		pending_request.cb(HEXADECIMAL, buf, len,
>  					pending_request.user_data);
>  
>  	reset_input_request();
> @@ -98,14 +99,15 @@ static void response_hexadecimal(const char *input, void *user_data)
>  static void response_decimal(const char *input, void *user_data)
>  {
>  	uint8_t buf[DECIMAL_OOB_LEN];
> +	uint16_t len = DECIMAL_OOB_LEN;
>  
>  	if (strlen(input) > pending_request.len)
> -		return;
> +		len = 0;
>  
>  	bt_put_be32(atoi(input), buf);
>  
>  	if (pending_request.cb)
> -		pending_request.cb(DECIMAL, buf, DECIMAL_OOB_LEN,
> +		pending_request.cb(DECIMAL, buf, len,
>  					pending_request.user_data);
>  
>  	reset_input_request();

      reply	other threads:[~2020-03-12 18:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 22:59 [PATCH BlueZ v2] tools/mesh-cfgclient: Add support for Static OOB key Brian Gix
2020-03-12 18:19 ` Gix, Brian [this message]

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=662ab7993d46a10c04f4736c27b5168ac5ae5b02.camel@intel.com \
    --to=brian.gix@intel.com \
    --cc=inga.stotland@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=testtgsh@gmail.com \
    /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 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.