From patchwork Wed May 19 00:10:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 12265857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BA86C43461 for ; Wed, 19 May 2021 00:10:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F26B761364 for ; Wed, 19 May 2021 00:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234461AbhESAL7 (ORCPT ); Tue, 18 May 2021 20:11:59 -0400 Received: from mga09.intel.com ([134.134.136.24]:41857 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234061AbhESAL7 (ORCPT ); Tue, 18 May 2021 20:11:59 -0400 IronPort-SDR: 1NVBmOGLNw9/ZW4yFjA3ZDneuHZ/Z+2cWoU2EQ0/MmaFwnT7Yq3JMhcF2ohXZ8GP7bXpLOcI5Q AmpE3VKxrNXg== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="200900089" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="200900089" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:36 -0700 IronPort-SDR: KUWrUWX0Zmo8BW/DvGrbL7KADaA8hFGPs2alphIb+NRo9F+eecty/UekdT4WnTUy9hfigmMK3F fLynP0zmTT8A== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="439707707" Received: from bgi1-mobl2.amr.corp.intel.com ([10.209.0.202]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:34 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ 1/4] mesh: Fix delivery of PB-ACK to acceptors Date: Tue, 18 May 2021 17:10:24 -0700 Message-Id: <20210519001027.1540720-2-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210519001027.1540720-1-brian.gix@intel.com> References: <20210519001027.1540720-1-brian.gix@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Rwmove unneeded initialization that prevented the Acceptor roll of ever recognizing a valid PB-ACK. --- mesh/pb-adv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mesh/pb-adv.c b/mesh/pb-adv.c index c74dae79f..83f922aa8 100644 --- a/mesh/pb-adv.c +++ b/mesh/pb-adv.c @@ -358,7 +358,6 @@ static void pb_adv_packet(void *user_data, const uint8_t *pkt, uint16_t len) first = !session->link_id; session->link_id = link_id; session->last_peer_trans_num = 0xFF; - session->local_acked = 0xFF; session->peer_trans_num = 0x00; session->local_trans_num = 0x7F; session->opened = true; From patchwork Wed May 19 00:10:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 12265855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B146C43460 for ; Wed, 19 May 2021 00:10:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61B4361364 for ; Wed, 19 May 2021 00:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234288AbhESAL7 (ORCPT ); Tue, 18 May 2021 20:11:59 -0400 Received: from mga09.intel.com ([134.134.136.24]:41857 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233582AbhESAL7 (ORCPT ); Tue, 18 May 2021 20:11:59 -0400 IronPort-SDR: N/iz48kWDa8+O1LC7ARLftXZc7ZOf0eAFZHenQnJKj+s5nvXtwTc5GJ3LmlT4U1mkQfPvhehe7 x+7rnDGpFwYw== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="200900090" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="200900090" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:36 -0700 IronPort-SDR: v1XDgDXXgjrmfhBxQjqao+1kDJMwHQhTJjfLEgMbRa3vKpG2LJBOjdAUMj5mbJmyMlJXj+A/Rq a7lmcZLZsVHw== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="439707711" Received: from bgi1-mobl2.amr.corp.intel.com ([10.209.0.202]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:34 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ 2/4] nesh: Normalize endian of public/private ECC keys Date: Tue, 18 May 2021 17:10:25 -0700 Message-Id: <20210519001027.1540720-3-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210519001027.1540720-1-brian.gix@intel.com> References: <20210519001027.1540720-1-brian.gix@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The Mesh profile specification defines a Mesh byte order of Big Endian for Public keys used to calculate shared secrets. Further the specification sample data also show this same byte order for Private keys. However, our internal ECDH shared secret calculation requires Little Endian byte ordering. This fixes our DBus interface, and debugging output to use Mesh Byte Ordering (Big Endian) for all human readable input/output. --- mesh/prov-acceptor.c | 8 +++++++- mesh/prov-initiator.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c index e806b12ef..8df9eee9f 100644 --- a/mesh/prov-acceptor.c +++ b/mesh/prov-acceptor.c @@ -223,7 +223,11 @@ static bool acp_credentials(struct mesh_prov_acceptor *prov) print_packet("PublicKeyProv", prov->conf_inputs.prv_pub_key, 64); print_packet("PublicKeyDev", prov->conf_inputs.dev_pub_key, 64); + + /* Normaize for debug out -- No longer needed for calculations */ + swap_u256_bytes(prov->private_key); print_packet("PrivateKeyLocal", prov->private_key, 32); + print_packet("ConfirmationInputs", &prov->conf_inputs, sizeof(prov->conf_inputs)); print_packet("ECDHSecret", prov->secret, 32); @@ -307,11 +311,13 @@ static void priv_key_cb(void *user_data, int err, uint8_t *key, uint32_t len) return; } + /* API delivers Mesh byte order, switch to little endian */ + swap_u256_bytes(key); memcpy(prov->private_key, key, 32); ecc_make_public_key(prov->private_key, prov->conf_inputs.dev_pub_key); - /* Convert to Mesh byte order */ + /* Convert Public key to Mesh byte order */ swap_u256_bytes(prov->conf_inputs.dev_pub_key); swap_u256_bytes(prov->conf_inputs.dev_pub_key + 32); diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index ae9c646de..c62577523 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -222,6 +222,9 @@ static bool int_credentials(struct mesh_prov_initiator *prov) print_packet("PublicKeyProv", prov->conf_inputs.prv_pub_key, 64); print_packet("PublicKeyDev", prov->conf_inputs.dev_pub_key, 64); + + /* Print DBG out in Mesh order */ + swap_u256_bytes(prov->private_key); print_packet("PrivateKeyLocal", prov->private_key, 32); print_packet("ConfirmationInputs", &prov->conf_inputs, sizeof(prov->conf_inputs)); From patchwork Wed May 19 00:10:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 12265851 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F2CFC433B4 for ; Wed, 19 May 2021 00:10:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFA4761364 for ; Wed, 19 May 2021 00:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233695AbhESALz (ORCPT ); Tue, 18 May 2021 20:11:55 -0400 Received: from mga18.intel.com ([134.134.136.126]:12937 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbhESALz (ORCPT ); Tue, 18 May 2021 20:11:55 -0400 IronPort-SDR: WAd+CI4Y159IvF5OLDpZ0+imCFtYqZBIjEH2YdrvcV6qHxd3Kv1irxoLSE8qg86OO15ZZvTcDQ HUPRQrH8tRiA== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="188263489" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="188263489" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:36 -0700 IronPort-SDR: eWtAkOFJROeYMkHvA0TMkJ4MnSSlKF3Y5F/qWcJwYE8KVaz2X8CfTyzKOkei3C0CjKnZFJ4s8D ZxV/CYb23dUw== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="439707715" Received: from bgi1-mobl2.amr.corp.intel.com ([10.209.0.202]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:34 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ 3/4] tools/mesh: Add all supported OOB methods to cfgclient Date: Tue, 18 May 2021 17:10:26 -0700 Message-Id: <20210519001027.1540720-4-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210519001027.1540720-1-brian.gix@intel.com> References: <20210519001027.1540720-1-brian.gix@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org To support the widest range of mesh devices, we need to support any possible capability combinations that a remote device may request. --- tools/mesh-cfgclient.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 49069674f..fd859a606 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -104,7 +104,17 @@ static struct model_info *cfgcli; static struct l_queue *devices; static bool prov_in_progress; -static const char *caps[] = {"static-oob", "out-numeric", "in-numeric"}; +static const char *caps[] = {"static-oob", + "push", + "twist", + "blink", + "beep", + "vibrate", + "public-oob", + "out-alpha", + "in-alpha", + "out-numeric", + "in-numeric"}; static bool have_config; @@ -419,7 +429,7 @@ 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 oob_data[16]; + uint8_t oob_data[64]; switch (type) { case NONE: @@ -435,15 +445,15 @@ static void agent_input_done(oob_type_t type, void *buf, uint16_t len, /* Fall Through */ case HEXADECIMAL: - if (len > 16) { + if (len > sizeof(oob_data)) { bt_shell_printf("Bad input length\n"); break; } - memset(oob_data, 0, 16); + memset(oob_data, 0, sizeof(oob_data)); memcpy(oob_data, buf, len); reply = l_dbus_message_new_method_return(msg); builder = l_dbus_message_builder_new(reply); - append_byte_array(builder, oob_data, 16); + append_byte_array(builder, oob_data, len); l_dbus_message_builder_finalize(builder); l_dbus_message_builder_destroy(builder); break; @@ -580,6 +590,16 @@ static struct l_dbus_message *prompt_numeric_call(struct l_dbus *dbus, return NULL; } +static struct l_dbus_message *prompt_public_call(struct l_dbus *dbus, + struct l_dbus_message *msg, + void *user_data) +{ + l_dbus_message_ref(msg); + agent_input_request(HEXADECIMAL, 64, "Enter 512 bit Public Key", + agent_input_done, msg); + return NULL; +} + static struct l_dbus_message *prompt_static_call(struct l_dbus *dbus, struct l_dbus_message *msg, void *user_data) @@ -618,6 +638,8 @@ static void setup_agent_iface(struct l_dbus_interface *iface) "u", "s", "number", "type"); l_dbus_interface_method(iface, "PromptStatic", 0, prompt_static_call, "ay", "s", "data", "type"); + l_dbus_interface_method(iface, "PublicKey", 0, prompt_public_call, + "ay", "", "data"); } static bool register_agent(void) From patchwork Wed May 19 00:10:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 12265853 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B0C6C433B4 for ; Wed, 19 May 2021 00:10:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 532C261360 for ; Wed, 19 May 2021 00:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233801AbhESAL4 (ORCPT ); Tue, 18 May 2021 20:11:56 -0400 Received: from mga18.intel.com ([134.134.136.126]:12937 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233582AbhESALz (ORCPT ); Tue, 18 May 2021 20:11:55 -0400 IronPort-SDR: XFW3yW9k6gf0q+GPTzfp1BqV8Uv+IYM3OXv93oNmgu7bM/rs4Cqx6KASFvo/vXr6itUtT5z4SR 5lAcO7YEaswQ== X-IronPort-AV: E=McAfee;i="6200,9189,9988"; a="188263490" X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="188263490" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:36 -0700 IronPort-SDR: Ik5765xWNzt/dY05Ge7ABt/wxwP3B+erVEYBZW1pIxX0MZ9ux9wuuBS4pIAKPnzUSn61P4FzPz KdSTvDSCRM8Q== X-IronPort-AV: E=Sophos;i="5.82,310,1613462400"; d="scan'208";a="439707717" Received: from bgi1-mobl2.amr.corp.intel.com ([10.209.0.202]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2021 17:10:34 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: inga.stotland@intel.com, brian.gix@intel.com Subject: [PATCH BlueZ 4/4] test/mesh: Add support for testing more OOB auth Date: Tue, 18 May 2021 17:10:27 -0700 Message-Id: <20210519001027.1540720-5-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210519001027.1540720-1-brian.gix@intel.com> References: <20210519001027.1540720-1-brian.gix@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org To pass IOP testing, we need to be able to support Input OOB and Out of band Public Key exchange, This patch adds agent methods to support those capabilities, but are turned off because the test code uses insecure fixed values instead of randomized values. --- test/agent.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/agent.py b/test/agent.py index b46cd95f4..57a74183d 100755 --- a/test/agent.py +++ b/test/agent.py @@ -35,7 +35,9 @@ class Agent(dbus.service.Object): caps = [] oob = [] caps.append('out-numeric') + #caps.append('in-numeric') -- Do not use well known in-oob caps.append('static-oob') + #caps.append('public-oob') -- Do not use well known key pairs oob.append('other') return { AGENT_IFACE: { @@ -56,6 +58,27 @@ class Agent(dbus.service.Object): print(set_cyan('DisplayNumeric ('), type, set_cyan(') number ='), set_green(value)) + @dbus.service.method(AGENT_IFACE, in_signature="s", out_signature="u") + def PromptNumeric(self, type): + # Sample in-oob -- DO-NOT-USE + value = 12345 + print(set_cyan('PromptNumeric ('), type, + set_cyan(') number ='), set_green(value)) + return dbus.UInt32(value) + + @dbus.service.method(AGENT_IFACE, in_signature="", out_signature="ay") + def PrivateKey(self): + # Sample Public/Private pair from Mesh Profile Spec DO-NOT-USE + private_key_str = '6872b109ea0574adcf88bf6da64996a4624fe018191d9322a4958837341284bc' + public_key_str = 'ce9027b5375fe5d3ed3ac89cef6a8370f699a2d3130db02b87e7a632f15b0002e5b72c775127dc0ce686002ecbe057e3d6a8000d4fbf2cdfffe0d38a1c55a043' + print(set_cyan('PrivateKey ()')) + print(set_cyan('Enter Public key on remote device: '), + set_green(public_key_str)); + private_key = bytearray.fromhex(private_key_str) + + return dbus.Array(private_key, signature='y') + + @dbus.service.method(AGENT_IFACE, in_signature="s", out_signature="ay") def PromptStatic(self, type): static_key = numpy.random.randint(0, 255, 16)