Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5240988ybp; Mon, 14 Oct 2019 18:18:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyn3SChUO7/g7UwOkIbCy3vYSgpgm/rntgbWox0C+3AsqTFtSnSJ5LOxMVCUG6gZtUo2HcH X-Received: by 2002:a50:9a46:: with SMTP id o64mr31687862edb.191.1571102322358; Mon, 14 Oct 2019 18:18:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571102322; cv=none; d=google.com; s=arc-20160816; b=zdelMMQtyQcdoZu1/s6sy3lLOyVl0CoaaX9ZdPBPdRrRf8lM9o/NAvwKNW3n4pGMJ6 o3qdwjknO1FRkNtyAAGwg4o2wp9iSApe8LjVLLaiAdM9UTBgPkea3NSdgGUFuH1kwABd 5je5W3/6/fNPeDVhPAJayyVUTgufB28SKZiGN5tbxhs15rT7kA8344P49aGfguFm/+z8 H12OZpxydFTJQSVWHOxXMMzMZUt87agH6w7ihiMbgp16L0c77I65VJ5AF/ORW/msEzfr 8DMPtPA+uRNGk5Q9EBkj3N/0fcM96canZint3PLB056YuRqI6v1e+R1cQDmudMwz2MM7 SPuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nrJNXPIqTHHoCVaF0tpZvTb1MB7Cq5v/wf4zSTlV3Ig=; b=Xystj0lzxVQY/TEHw4AuEbtQcYoQJGOivcTWW8gPOe5VgW39q5nCAeksTn7gW1TAd3 Lz5vN1DY/3O33XS3qtBSb/s0QLO0qEmnqHTvOJuYehvqAlMaee3578aAMIESG0XCSUJn HLjf1rqh7WopDYo3JSpxw8Up8OF6GigKXfsFxB5FpNF4VRhMwY1U7oQzya9+vZTAyIPF W1WA1Hy2kl4USw/hCZqhCjoE1Otc6x9UTr/HXlw6wWIum3VIWD36vXM+txYC/PRTEQxP WX8wKv1Pi2AempXqMgciDojs/1Rky8+6r6AoALLN26A0wNW9E1w0Adq3Kn4dejYRdUeq 0Jhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si12437334ejc.34.2019.10.14.18.17.59; Mon, 14 Oct 2019 18:18:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730603AbfJNVsA (ORCPT + 99 others); Mon, 14 Oct 2019 17:48:00 -0400 Received: from mga12.intel.com ([192.55.52.136]:14950 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730586AbfJNVsA (ORCPT ); Mon, 14 Oct 2019 17:48:00 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Oct 2019 14:48:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,296,1566889200"; d="scan'208";a="225211295" Received: from ingas-nuc1.sea.intel.com ([10.251.131.249]) by fmsmga002.fm.intel.com with ESMTP; 14 Oct 2019 14:47:59 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Add provisioner confirmation Date: Mon, 14 Oct 2019 14:47:58 -0700 Message-Id: <20191014214758.13829-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds codes to send a confirmationfrom provisioner's side after receiving a callback from a provisioning agent. --- mesh/prov-initiator.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/mesh/prov-initiator.c b/mesh/prov-initiator.c index eb59f53f1..5e45d6813 100644 --- a/mesh/prov-initiator.c +++ b/mesh/prov-initiator.c @@ -265,6 +265,18 @@ static void calc_local_material(const uint8_t *random) print_packet("Nonce", prov->s_nonce, sizeof(prov->s_nonce)); } +static void send_confirm(struct mesh_prov_initiator *prov) +{ + struct prov_conf_msg msg; + + msg.opcode = PROV_CONFIRM; + mesh_crypto_aes_cmac(prov->calc_key, prov->rand_auth_workspace, + 32, msg.conf); + prov->trans_tx(prov->trans_data, &msg, sizeof(msg)); + prov->state = INT_PROV_CONF_SENT; + prov->expected = PROV_CONFIRM; +} + static void number_cb(void *user_data, int err, uint32_t number) { struct mesh_prov_initiator *rx_prov = user_data; @@ -284,6 +296,7 @@ static void number_cb(void *user_data, int err, uint32_t number) l_put_be32(number, prov->rand_auth_workspace + 28); l_put_be32(number, prov->rand_auth_workspace + 44); prov->material |= MAT_RAND_AUTH; + send_confirm(prov); } static void static_cb(void *user_data, int err, uint8_t *key, uint32_t len) @@ -304,6 +317,7 @@ static void static_cb(void *user_data, int err, uint8_t *key, uint32_t len) memcpy(prov->rand_auth_workspace + 16, key, 16); memcpy(prov->rand_auth_workspace + 32, key, 16); prov->material |= MAT_RAND_AUTH; + send_confirm(prov); } static void pub_key_cb(void *user_data, int err, uint8_t *key, uint32_t len) @@ -321,11 +335,13 @@ static void pub_key_cb(void *user_data, int err, uint8_t *key, uint32_t len) return; } - memcpy(prov->conf_inputs.dev_pub_key, key, 64); - prov->material |= MAT_REMOTE_PUBLIC; + memcpy(prov->conf_inputs.dev_pub_key, key, 64); + prov->material |= MAT_REMOTE_PUBLIC; - if ((prov->material & MAT_SECRET) == MAT_SECRET) - int_credentials(prov); + if ((prov->material & MAT_SECRET) == MAT_SECRET) + int_credentials(prov); + + send_confirm(prov); } static void send_pub_key(struct mesh_prov_initiator *prov) @@ -338,18 +354,6 @@ static void send_pub_key(struct mesh_prov_initiator *prov) prov->state = INT_PROV_KEY_SENT; } -static void send_confirm(struct mesh_prov_initiator *prov) -{ - struct prov_conf_msg msg; - - msg.opcode = PROV_CONFIRM; - mesh_crypto_aes_cmac(prov->calc_key, prov->rand_auth_workspace, - 32, msg.conf); - prov->trans_tx(prov->trans_data, &msg, sizeof(msg)); - prov->state = INT_PROV_CONF_SENT; - prov->expected = PROV_CONFIRM; -} - static void send_random(struct mesh_prov_initiator *prov) { struct prov_rand_msg msg; -- 2.21.0