Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 89D47200B34 for ; Sat, 18 Jun 2016 02:08:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 886D8160A63; Sat, 18 Jun 2016 00:08:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0A318160A61 for ; Sat, 18 Jun 2016 02:08:02 +0200 (CEST) Received: (qmail 35054 invoked by uid 500); 18 Jun 2016 00:08:02 -0000 Mailing-List: contact commits-help@mynewt.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mynewt.incubator.apache.org Delivered-To: mailing list commits@mynewt.incubator.apache.org Received: (qmail 35040 invoked by uid 99); 18 Jun 2016 00:08:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Jun 2016 00:08:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id B1E0AC0DF1 for ; Sat, 18 Jun 2016 00:08:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id NlNz50yEjrzL for ; Sat, 18 Jun 2016 00:07:55 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with SMTP id 92A4A5F4E6 for ; Sat, 18 Jun 2016 00:07:53 +0000 (UTC) Received: (qmail 34697 invoked by uid 99); 18 Jun 2016 00:07:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Jun 2016 00:07:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8F2B8E049D; Sat, 18 Jun 2016 00:07:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ccollins@apache.org To: commits@mynewt.incubator.apache.org Date: Sat, 18 Jun 2016 00:07:52 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] incubator-mynewt-core git commit: BLE Host - Clean up host privacy. archived-at: Sat, 18 Jun 2016 00:08:04 -0000 Repository: incubator-mynewt-core Updated Branches: refs/heads/develop dd71f0014 -> 6970f587f BLE Host - Clean up host privacy. Adjust code to meet coding standards document and more closely resemble the rest of the host code. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/6970f587 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/6970f587 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/6970f587 Branch: refs/heads/develop Commit: 6970f587fab919d61b5a142c72c5002bfe3126f9 Parents: bd458b5 Author: Christopher Collins Authored: Fri Jun 17 17:03:57 2016 -0700 Committer: Christopher Collins Committed: Fri Jun 17 17:07:37 2016 -0700 ---------------------------------------------------------------------- apps/bletest/src/bletest_hci.c | 4 +- apps/bletiny/src/cmd.c | 4 +- net/nimble/host/include/host/ble_hs.h | 2 +- net/nimble/host/include/host/host_hci.h | 18 +- net/nimble/host/src/ble_gap.c | 10 +- net/nimble/host/src/ble_hci_util.c | 2 +- net/nimble/host/src/ble_hs_cfg.c | 2 +- net/nimble/host/src/ble_hs_conn.c | 2 +- net/nimble/host/src/ble_hs_priv.c | 256 ----------------------- net/nimble/host/src/ble_hs_priv.h | 17 +- net/nimble/host/src/ble_hs_pvcy.c | 245 ++++++++++++++++++++++ net/nimble/host/src/ble_hs_startup.c | 4 +- net/nimble/host/src/ble_sm.c | 7 +- net/nimble/host/src/ble_store.c | 4 +- net/nimble/host/src/host_hci_cmd.c | 90 ++++---- net/nimble/host/src/test/ble_hs_test_util.c | 2 +- net/nimble/host/src/test/ble_sm_test_util.c | 4 +- 17 files changed, 325 insertions(+), 348 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/apps/bletest/src/bletest_hci.c ---------------------------------------------------------------------- diff --git a/apps/bletest/src/bletest_hci.c b/apps/bletest/src/bletest_hci.c index c227cc0..9a692bd 100755 --- a/apps/bletest/src/bletest_hci.c +++ b/apps/bletest/src/bletest_hci.c @@ -592,7 +592,7 @@ bletest_hci_le_add_resolv_list(uint8_t *local_irk, uint8_t *peer_irk, memcpy(padd.addr, peer_ident_addr, BLE_DEV_ADDR_LEN); swap_buf(padd.local_irk, local_irk, 16); swap_buf(padd.peer_irk, peer_irk, 16); - rc = host_hci_cmd_add_device_to_resolving_list(&padd, buf, sizeof buf); + rc = host_hci_cmd_build_add_to_resolv_list(&padd, buf, sizeof buf); if (!rc) { rc = ble_hci_cmd_tx_empty_ack(buf); } @@ -606,7 +606,7 @@ bletest_hci_le_enable_resolv_list(uint8_t enable) uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADDR_RESOL_ENA_LEN]; - rc = host_hci_cmd_set_addr_resolution_enable(enable, buf, sizeof buf); + rc = host_hci_cmd_build_set_addr_res_en(enable, buf, sizeof buf); if (!rc) { rc = ble_hci_cmd_tx_empty_ack(buf); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/apps/bletiny/src/cmd.c ---------------------------------------------------------------------- diff --git a/apps/bletiny/src/cmd.c b/apps/bletiny/src/cmd.c index fc05aa2..476d402 100644 --- a/apps/bletiny/src/cmd.c +++ b/apps/bletiny/src/cmd.c @@ -953,7 +953,7 @@ cmd_show_addr(int argc, char **argv) uint8_t *id_addr; uint8_t id_addr_type; - id_addr = bls_hs_priv_get_local_identity_addr(&id_addr_type); + id_addr = ble_hs_pvcy_our_id_addr(&id_addr_type); console_printf("id_addr_type=%d id_addr=", id_addr_type); print_addr(id_addr); @@ -1532,7 +1532,7 @@ cmd_set(int argc, char **argv) rc = parse_arg_byte_stream_exact_length("irk", irk, 16); if (rc == 0) { good = 1; - ble_hs_priv_update_irk(irk); + ble_hs_pvcy_set_our_irk(irk); } else if (rc != ENOENT) { return rc; } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/include/host/ble_hs.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h index a23332f..1f46f6d 100644 --- a/net/nimble/host/include/host/ble_hs.h +++ b/net/nimble/host/include/host/ble_hs.h @@ -119,7 +119,7 @@ struct ble_hs_cfg { #define BLE_HS_PRIVACY_MODE_NONE (0) #define BLE_HS_PRIVACY_MODE_RANDOM_STATIC (1) #define BLE_HS_PRIVACY_MODE_RESOLV_RAND (2) - uint16_t privacy_resolvable_addr_timeout; + uint16_t rpa_timeout; }; extern const struct ble_hs_cfg ble_hs_cfg_dflt; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/include/host/host_hci.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/include/host/host_hci.h b/net/nimble/host/include/host/host_hci.h index af7c2c2..00cb7f5 100644 --- a/net/nimble/host/include/host/host_hci.h +++ b/net/nimble/host/include/host/host_hci.h @@ -101,29 +101,29 @@ int host_hci_data_tx(struct ble_hs_conn *connection, struct os_mbuf *om); int host_hci_cmd_build_set_data_len(uint16_t connection_handle, uint16_t tx_octets, uint16_t tx_time, uint8_t *dst, int dst_len); -int host_hci_cmd_add_device_to_resolving_list( +int host_hci_cmd_build_add_to_resolv_list( struct hci_add_dev_to_resolving_list *padd, uint8_t *dst, int dst_len); -int host_hci_cmd_remove_device_from_resolving_list(uint8_t addr_type, +int host_hci_cmd_build_remove_from_resolv_list(uint8_t addr_type, uint8_t *addr, uint8_t *dst, int dst_len); -int host_hci_cmd_read_resolving_list_size(uint8_t *dst, int dst_len); +int host_hci_cmd_build_read_resolv_list_size(uint8_t *dst, int dst_len); int -host_hci_cmd_clear_resolving_list(uint8_t *dst, int dst_len); -int host_hci_cmd_read_peer_resolvable_address(uint8_t peer_identity_addr_type, +host_hci_cmd_build_clear_resolv_list(uint8_t *dst, int dst_len); +int host_hci_cmd_build_read_peer_resolv_addr(uint8_t peer_identity_addr_type, uint8_t *peer_identity_addr, uint8_t *dst, int dst_len); -int host_hci_cmd_read_local_resolvable_address(uint8_t local_identity_addr_type, +int host_hci_cmd_build_read_lcl_resolv_addr(uint8_t local_identity_addr_type, uint8_t *local_identity_addr, uint8_t *dst, int dst_len); -int host_hci_cmd_set_addr_resolution_enable(uint8_t enable, +int host_hci_cmd_build_set_addr_res_en(uint8_t enable, uint8_t *dst, int dst_len); -int host_hci_cmd_set_resolvable_private_address_timeout(uint16_t timeout, +int host_hci_cmd_build_set_resolv_priv_addr_timeout(uint16_t timeout, uint8_t *dst, int dst_len); void host_hci_timer_set(void); -int host_hci_cmd_set_random_addr(uint8_t *addr, uint8_t *dst, int dst_len); +int host_hci_cmd_build_set_random_addr(uint8_t *addr, uint8_t *dst, int dst_len); #endif /* H_HOST_HCI_ */ http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_gap.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_gap.c b/net/nimble/host/src/ble_gap.c index 7c7ba7f..1fbf660 100644 --- a/net/nimble/host/src/ble_gap.c +++ b/net/nimble/host/src/ble_gap.c @@ -1438,9 +1438,8 @@ ble_gap_adv_start(uint8_t discoverable_mode, uint8_t connectable_mode, &gap_adv_params.adv_itvl_min, &gap_adv_params.adv_itvl_max); - /* set a new private address for random advertisements */ if (gap_adv_params.own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) { - ble_hs_priv_set_nrpa(); + ble_hs_pvcy_set_our_nrpa(); } switch (connectable_mode) { @@ -1689,9 +1688,8 @@ ble_gap_disc(uint32_t duration_ms, uint8_t discovery_mode, ble_gap_log_disc(scan_type, filter_policy, addr_mode); BLE_HS_LOG(INFO, "\n"); - /* set a new random address for this mode */ - if(addr_mode == BLE_HCI_ADV_OWN_ADDR_RANDOM) { - ble_hs_priv_set_nrpa(); + if (addr_mode == BLE_HCI_ADV_OWN_ADDR_RANDOM) { + ble_hs_pvcy_set_our_nrpa(); } rc = ble_gap_disc_tx_params(scan_type, filter_policy, addr_mode); @@ -2290,7 +2288,7 @@ ble_gap_notify_event(uint16_t conn_handle, uint16_t attr_handle, void ble_gap_init_identity_addr(uint8_t *addr) { - ble_hs_priv_update_identity(addr); + ble_hs_pvcy_set_our_id_addr(addr); } /***************************************************************************** http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_hci_util.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hci_util.c b/net/nimble/host/src/ble_hci_util.c index 8310e27..c792b6e 100644 --- a/net/nimble/host/src/ble_hci_util.c +++ b/net/nimble/host/src/ble_hci_util.c @@ -114,7 +114,7 @@ ble_hs_util_set_random_addr(uint8_t *addr) /* set the address in the controller */ - rc = host_hci_cmd_set_random_addr(addr, buf, sizeof(buf)); + rc = host_hci_cmd_build_set_random_addr(addr, buf, sizeof(buf)); if (rc != 0) { return rc; } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_hs_cfg.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs_cfg.c b/net/nimble/host/src/ble_hs_cfg.c index f08b4aa..05f9cfb 100644 --- a/net/nimble/host/src/ble_hs_cfg.c +++ b/net/nimble/host/src/ble_hs_cfg.c @@ -60,7 +60,7 @@ const struct ble_hs_cfg ble_hs_cfg_dflt = { .sm_our_key_dist = 0, .sm_their_key_dist = 0, /** privacy info */ - .privacy_resolvable_addr_timeout = 300, + .rpa_timeout = 300, }; struct ble_hs_cfg ble_hs_cfg; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_hs_conn.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs_conn.c b/net/nimble/host/src/ble_hs_conn.c index 3e0dd19..ff68bc2 100644 --- a/net/nimble/host/src/ble_hs_conn.c +++ b/net/nimble/host/src/ble_hs_conn.c @@ -321,7 +321,7 @@ ble_hs_conn_addrs(struct ble_hs_conn *conn, { /* Determine our address information. */ addrs->our_id_addr = - bls_hs_priv_get_local_identity_addr(&addrs->our_id_addr_type); + ble_hs_pvcy_our_id_addr(&addrs->our_id_addr_type); if (memcmp(conn->our_rpa_addr, ble_hs_conn_null_addr, 6) == 0) { addrs->our_ota_addr_type = addrs->our_id_addr_type; addrs->our_ota_addr = addrs->our_id_addr; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_hs_priv.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs_priv.c b/net/nimble/host/src/ble_hs_priv.c deleted file mode 100644 index b5720d1..0000000 --- a/net/nimble/host/src/ble_hs_priv.c +++ /dev/null @@ -1,256 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -#include -#include -#include -#include "ble_hs_priv.h" - -int identity_initalized; -static uint8_t identity_addr[6]; -static uint8_t identity_addr_type; - -static uint8_t nrpa[6]; - -uint8_t g_irk[16]; - - -/* use this as a default IRK if there is none stored in the ble_store */ -const uint8_t default_irk[16] = { - 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d, - 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8, -}; - -static int -ble_hs_generate_static_random_addr(uint8_t *addr) { - int rc; - rc = ble_hci_util_rand(addr, 6); - /* TODO -- set bits properly */ - addr[5] |= 0xc0; - return rc; -} - -int -ble_hs_priv_set_nrpa(void) { - int rc; - uint8_t addr[6]; - rc = ble_hci_util_rand(addr, 6); - assert(rc == 0); - addr[5] &= ~(0xc0); - memcpy(nrpa, addr, 6); - return ble_hs_util_set_random_addr(addr); -} - -void ble_hs_priv_get_nrpa(uint8_t *addr) { - memcpy(addr,nrpa, 6); -} - - -int -ble_hs_priv_get_identity_addr_type(uint8_t *addr_type) { - if(identity_initalized) { - return -1; - } - *addr_type = identity_addr_type; - return 0; -} - -static int -ble_hs_priv_set_addr_to(uint16_t timeout) { - int rc; - uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_RESOLV_PRIV_ADDR_TO_LEN]; - rc = host_hci_cmd_set_resolvable_private_address_timeout( - timeout, buf, sizeof(buf)); - return rc; -} - -static int -ble_keycache_set_status(int enable) -{ - uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADDR_RESOL_ENA_LEN]; - int rc; - rc = host_hci_cmd_set_addr_resolution_enable(enable, buf, sizeof(buf)); - - if (0 == rc) { - rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); - } - - return rc; -} - -int -ble_keycache_remove_irk_entry(uint8_t addr_type, uint8_t *addr) -{ - uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_RMV_FROM_RESOLV_LIST_LEN]; - int rc; - - /* build the message data */ - rc = host_hci_cmd_remove_device_from_resolving_list(addr_type, addr, - buf, sizeof(buf)); - - if (0 == rc) { - rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); - } - - return rc; -} - - -static int -ble_keycache_clear_irk_enties(void) -{ - uint8_t buf[BLE_HCI_CMD_HDR_LEN ]; - int rc; - - /* build the message data */ - rc = host_hci_cmd_clear_resolving_list(buf, sizeof(buf)); - - if (0 == rc) { - rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); - } - - return rc; -} - - -int -ble_keycache_write_irk_entry(uint8_t *addr, uint8_t addr_type, uint8_t *irk) -{ - struct hci_add_dev_to_resolving_list add; - uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_ADD_TO_RESOLV_LIST_LEN]; - int rc; - - /* build the message data */ - add.addr_type = addr_type; - memcpy(add.addr, addr, 6); - memcpy(add.local_irk, ble_hs_priv_get_local_irk(), 16); - memcpy(add.peer_irk, irk, 16); - - rc = host_hci_cmd_add_device_to_resolving_list(&add, buf, sizeof(buf)); - - if (0 == rc) { - rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); - } - - return rc; -} - - -void -ble_hs_priv_update_identity(uint8_t *addr) { - - int rc; - uint8_t random_addr[6]; - int first_init = (identity_initalized == 0); - - /* only do this stuff once */ - if(first_init) { - /* set up the periodic change of our NRA */ - rc = ble_hs_priv_set_addr_to(ble_hs_cfg.privacy_resolvable_addr_timeout); - assert(rc == 0); - } - - /* did we get passed an address */ - if(addr) { - memcpy(identity_addr, addr, 6); - identity_addr_type = BLE_HCI_ADV_OWN_ADDR_PUBLIC; - } else if (0) - { - /* if that fails, try to get a static random address from nvram */ - /* TODO */ - } else - { - /* generate a new static random address and store to memory */ - ble_hs_generate_static_random_addr(random_addr); - rc = ble_hs_util_set_random_addr(random_addr); - assert(rc == 0); - - identity_addr_type = BLE_HCI_ADV_OWN_ADDR_RANDOM; - memcpy(identity_addr, random_addr, 6); - /* TODO store it */ - } - - identity_initalized = 1; -} - -void -ble_hs_priv_update_irk(uint8_t *irk) -{ - uint8_t tmp_addr[6]; - int irk_changed; - uint8_t new_irk[16]; - - memset(new_irk, 0, sizeof(new_irk)); - - /* now try to get an IRK from internal nvram */ - if (irk) { - memcpy(new_irk, irk, 16); - } else if(0) { - /* TODO call to application internal nvram */ - } else { - /* if that fails, use the default IRK */ - memcpy(new_irk, default_irk, 16); - } - - irk_changed = memcmp(g_irk, new_irk, 16); - - /* if we are changing our IRK, we need to clear this. Also, for - * first time, clear this */ - if (irk_changed) { - memcpy(g_irk, new_irk, 16); - - /* we need to clear this cache since all the other entries used - * our IRK */ - ble_keycache_set_status(0); - ble_keycache_clear_irk_enties(); - ble_keycache_set_status(1); - /* push our identity to the controller as a keycache entry.with a zero - * MAC address. The controller uses this entry to generate a RPA when - * we do advertising with own addr type = rpa */ - memset(tmp_addr, 0, 6); - ble_keycache_write_irk_entry(tmp_addr, 0 ,g_irk); - } -} - -uint8_t * -bls_hs_priv_get_local_identity_addr(uint8_t *type) { - - if(!identity_initalized) { - ble_hs_priv_update_identity(NULL); - } - - if (type) { - *type = identity_addr_type; - } - return identity_addr; -} - -void -bls_hs_priv_copy_local_identity_addr(uint8_t *pdst, uint8_t* addr_type) { - uint8_t *addr = bls_hs_priv_get_local_identity_addr(addr_type); - memcpy(pdst,addr,6); -} - -uint8_t * -ble_hs_priv_get_local_irk(void) -{ - if(!identity_initalized) { - ble_hs_priv_update_identity(NULL); - } - return g_irk; -} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_hs_priv.h ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs_priv.h b/net/nimble/host/src/ble_hs_priv.h index d8e99f2..2cb12b4 100644 --- a/net/nimble/host/src/ble_hs_priv.h +++ b/net/nimble/host/src/ble_hs_priv.h @@ -104,15 +104,14 @@ int ble_hci_cmd_tx(void *cmd, void *evt_buf, uint8_t evt_buf_len, int ble_hci_cmd_tx_empty_ack(void *cmd); void ble_hci_cmd_rx_ack(uint8_t *ack_ev); void ble_hci_cmd_init(void); -int ble_hs_priv_set_nrpa(void); -void ble_hs_priv_get_nrpa(uint8_t *addr); -void ble_hs_priv_update_identity(uint8_t *addr); -void ble_hs_priv_update_irk(uint8_t *irk); -uint8_t *bls_hs_priv_get_local_identity_addr(uint8_t *type); -void bls_hs_priv_copy_local_identity_addr(uint8_t *pdst, uint8_t* addr_type); -uint8_t *ble_hs_priv_get_local_irk(void); -int ble_keycache_remove_irk_entry(uint8_t addr_type, uint8_t *addr); -int ble_keycache_write_irk_entry(uint8_t *addr, uint8_t addrtype, uint8_t *irk); +int ble_hs_pvcy_set_our_nrpa(void); +void ble_hs_pvcy_our_nrpa(uint8_t *addr); +void ble_hs_pvcy_set_our_id_addr(uint8_t *addr); +void ble_hs_pvcy_set_our_irk(uint8_t *irk); +uint8_t *ble_hs_pvcy_our_id_addr(uint8_t *type); +uint8_t *ble_hs_pvcy_our_irk(void); +int ble_hs_pvcy_remove_entry(uint8_t addr_type, uint8_t *addr); +int ble_hs_pvcy_add_entry(uint8_t *addr, uint8_t addrtype, uint8_t *irk); #if PHONY_HCI_ACKS typedef int ble_hci_cmd_phony_ack_fn(uint8_t *ack, int ack_buf_len); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_hs_pvcy.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs_pvcy.c b/net/nimble/host/src/ble_hs_pvcy.c new file mode 100644 index 0000000..1ea2f91 --- /dev/null +++ b/net/nimble/host/src/ble_hs_pvcy.c @@ -0,0 +1,245 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +#include +#include +#include +#include "ble_hs_priv.h" + +static int ble_hs_pvcy_initialized; +static uint8_t ble_hs_pvcy_id_addr[6]; +static uint8_t ble_hs_pvcy_id_addr_type; +static uint8_t ble_hs_pvcy_nrpa[6]; +uint8_t ble_hs_pvcy_irk[16]; + + +/** Use this as a default IRK if none gets set. */ +const uint8_t default_irk[16] = { + 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d, + 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8, +}; + +static int +ble_hs_pvcy_gen_static_random_addr(uint8_t *addr) +{ + int rc; + + rc = ble_hci_util_rand(addr, 6); + /* TODO -- set bits properly */ + addr[5] |= 0xc0; + + return rc; +} + +static int +ble_hs_pvcy_set_addr_timeout(uint16_t timeout) +{ + uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_RESOLV_PRIV_ADDR_TO_LEN]; + int rc; + + rc = host_hci_cmd_build_set_resolv_priv_addr_timeout( + timeout, buf, sizeof(buf)); + + return rc; +} + +static int +ble_hs_pvcy_set_resolve_enabled(int enable) +{ + uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_SET_ADDR_RESOL_ENA_LEN]; + int rc; + + rc = host_hci_cmd_build_set_addr_res_en(enable, buf, sizeof(buf)); + if (rc != 0) { + return rc; + } + + rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); + if (rc != 0) { + return rc; + } + + return 0; +} + +int +ble_hs_pvcy_remove_entry(uint8_t addr_type, uint8_t *addr) +{ + uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_RMV_FROM_RESOLV_LIST_LEN]; + int rc; + + rc = host_hci_cmd_build_remove_from_resolv_list( + addr_type, addr, buf, sizeof(buf)); + if (rc != 0) { + return rc; + } + + rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); + if (rc != 0) { + return rc; + } + + return 0; +} + +static int +ble_hs_pvcy_clear_entries(void) +{ + uint8_t buf[BLE_HCI_CMD_HDR_LEN ]; + int rc; + + rc = host_hci_cmd_build_clear_resolv_list(buf, sizeof(buf)); + if (rc != 0) { + return rc; + } + + rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); + if (rc != 0) { + return rc; + } + + return 0; +} + +int +ble_hs_pvcy_add_entry(uint8_t *addr, uint8_t addr_type, uint8_t *irk) +{ + struct hci_add_dev_to_resolving_list add; + uint8_t buf[BLE_HCI_CMD_HDR_LEN + BLE_HCI_ADD_TO_RESOLV_LIST_LEN]; + int rc; + + add.addr_type = addr_type; + memcpy(add.addr, addr, 6); + memcpy(add.local_irk, ble_hs_pvcy_our_irk(), 16); + memcpy(add.peer_irk, irk, 16); + + rc = host_hci_cmd_build_add_to_resolv_list(&add, buf, sizeof(buf)); + if (rc != 0) { + return rc; + } + + rc = ble_hci_cmd_tx(buf, NULL, 0, NULL); + if (rc != 0) { + return rc; + } + + return 0; +} + +void +ble_hs_pvcy_our_nrpa(uint8_t *addr) +{ + memcpy(addr, ble_hs_pvcy_nrpa, 6); +} + +int +ble_hs_pvcy_set_our_nrpa(void) +{ + int rc; + uint8_t addr[6]; + + rc = ble_hci_util_rand(addr, 6); + assert(rc == 0); + addr[5] &= ~(0xc0); + memcpy(ble_hs_pvcy_nrpa, addr, 6); + + return ble_hs_util_set_random_addr(addr); +} + +uint8_t * +ble_hs_pvcy_our_id_addr(uint8_t *type) +{ + if (!ble_hs_pvcy_initialized) { + ble_hs_pvcy_set_our_id_addr(NULL); + } + + if (type != NULL) { + *type = ble_hs_pvcy_id_addr_type; + } + + return ble_hs_pvcy_id_addr; +} + +void +ble_hs_pvcy_set_our_id_addr(uint8_t *addr) +{ + uint8_t random_addr[6]; + int rc; + + if (!ble_hs_pvcy_initialized) { + /* Set up the periodic change of our RPA. */ + rc = ble_hs_pvcy_set_addr_timeout(ble_hs_cfg.rpa_timeout); + assert(rc == 0); + } + + if (addr != NULL) { + memcpy(ble_hs_pvcy_id_addr, addr, 6); + ble_hs_pvcy_id_addr_type = BLE_HCI_ADV_OWN_ADDR_PUBLIC; + } else { + /* Generate a new static random address. */ + ble_hs_pvcy_gen_static_random_addr(random_addr); + rc = ble_hs_util_set_random_addr(random_addr); + assert(rc == 0); + + ble_hs_pvcy_id_addr_type = BLE_HCI_ADV_OWN_ADDR_RANDOM; + memcpy(ble_hs_pvcy_id_addr, random_addr, 6); + } + + ble_hs_pvcy_initialized = 1; +} + +void +ble_hs_pvcy_set_our_irk(uint8_t *irk) +{ + uint8_t tmp_addr[6]; + uint8_t new_irk[16]; + + memset(new_irk, 0, sizeof(new_irk)); + + if (irk != NULL) { + memcpy(new_irk, irk, 16); + } else { + memcpy(new_irk, default_irk, 16); + } + + /* Clear the resolving list if this is a new IRK. */ + if (memcmp(ble_hs_pvcy_irk, new_irk, 16) != 0) { + memcpy(ble_hs_pvcy_irk, new_irk, 16); + + ble_hs_pvcy_set_resolve_enabled(0); + ble_hs_pvcy_clear_entries(); + ble_hs_pvcy_set_resolve_enabled(1); + + /* Push our identity to the controller as a keycache entry with a null + * MAC address. The controller uses this entry to generate an RPA when + * we do advertising with own-addr-type = rpa. + */ + memset(tmp_addr, 0, 6); + ble_hs_pvcy_add_entry(tmp_addr, 0, ble_hs_pvcy_irk); + } +} + +uint8_t * +ble_hs_pvcy_our_irk(void) +{ + if (!ble_hs_pvcy_initialized) { + ble_hs_pvcy_set_our_id_addr(NULL); + } + + return ble_hs_pvcy_irk; +} http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_hs_startup.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_hs_startup.c b/net/nimble/host/src/ble_hs_startup.c index 16834ec..1973cf9 100644 --- a/net/nimble/host/src/ble_hs_startup.c +++ b/net/nimble/host/src/ble_hs_startup.c @@ -225,8 +225,8 @@ ble_hs_startup_go(void) } /* XXX: Read BD_ADDR. */ - ble_hs_priv_update_identity(g_dev_addr); - ble_hs_priv_update_irk(NULL); + ble_hs_pvcy_set_our_id_addr(g_dev_addr); + ble_hs_pvcy_set_our_irk(NULL); return rc; } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_sm.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_sm.c b/net/nimble/host/src/ble_sm.c index 3815aa6..92f75cc 100644 --- a/net/nimble/host/src/ble_sm.c +++ b/net/nimble/host/src/ble_sm.c @@ -1710,6 +1710,7 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res, uint8_t init_key_dist; uint8_t resp_key_dist; uint8_t our_key_dist; + uint8_t *our_id_addr; uint8_t *irk; int rc; @@ -1753,7 +1754,7 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res, if (our_key_dist & BLE_SM_PAIR_KEY_DIST_ID) { /* Send identity information. */ - irk = ble_hs_priv_get_local_irk(); + irk = ble_hs_pvcy_our_irk(); memcpy(id_info.irk, irk, 16); @@ -1764,8 +1765,8 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res, proc->our_keys.irk_valid = 1; /* Send identity address information. */ - bls_hs_priv_copy_local_identity_addr(addr_info.bd_addr, - &addr_info.addr_type); + our_id_addr = ble_hs_pvcy_our_id_addr(&addr_info.addr_type); + memcpy(addr_info.bd_addr, our_id_addr, 6); rc = ble_sm_id_addr_info_tx(proc->conn_handle, &addr_info); if (rc != 0) { goto err; http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/ble_store.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_store.c b/net/nimble/host/src/ble_store.c index fbc8c1e..2fee392 100644 --- a/net/nimble/host/src/ble_store.c +++ b/net/nimble/host/src/ble_store.c @@ -159,7 +159,7 @@ ble_store_write_peer_sec(struct ble_store_value_sec *value_sec) /* Write the peer IRK to the controller keycache * There is not much to do here if it fails */ - rc = ble_keycache_write_irk_entry(value_sec->peer_addr, + rc = ble_hs_pvcy_add_entry(value_sec->peer_addr, value_sec->peer_addr_type, value_sec->irk); if (rc != 0) { @@ -182,7 +182,7 @@ ble_store_delete_peer_sec(struct ble_store_key_sec *key_sec) if(key_sec->peer_addr_type == BLE_STORE_ADDR_TYPE_NONE) { /* don't error check this since we don't know without looking up * the value whether it had a valid IRK */ - ble_keycache_remove_irk_entry(key_sec->peer_addr_type, + ble_hs_pvcy_remove_entry(key_sec->peer_addr_type, key_sec->peer_addr); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/host_hci_cmd.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/host_hci_cmd.c b/net/nimble/host/src/host_hci_cmd.c index 09c6944..d638ed6 100644 --- a/net/nimble/host/src/host_hci_cmd.c +++ b/net/nimble/host/src/host_hci_cmd.c @@ -1043,11 +1043,9 @@ host_hci_cmd_build_set_data_len(uint16_t connection_handle, * IRKs are in little endian. */ static int -host_hci_cmd_body_add_device_to_resolving_list(uint8_t addr_type, - uint8_t *addr, - uint8_t *peer_irk, - uint8_t *local_irk, - uint8_t *dst) +host_hci_cmd_body_add_to_resolv_list(uint8_t addr_type, uint8_t *addr, + uint8_t *peer_irk, uint8_t *local_irk, + uint8_t *dst) { if (addr_type > BLE_ADDR_TYPE_RANDOM) { return BLE_ERR_INV_HCI_CMD_PARMS; @@ -1067,7 +1065,7 @@ host_hci_cmd_body_add_device_to_resolving_list(uint8_t addr_type, * IRKs are in little endian. */ int -host_hci_cmd_add_device_to_resolving_list( +host_hci_cmd_build_add_to_resolv_list( struct hci_add_dev_to_resolving_list *padd, uint8_t *dst, int dst_len) @@ -1080,7 +1078,7 @@ host_hci_cmd_add_device_to_resolving_list( host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_ADD_RESOLV_LIST, BLE_HCI_ADD_TO_RESOLV_LIST_LEN, dst); - rc = host_hci_cmd_body_add_device_to_resolving_list( + rc = host_hci_cmd_body_add_to_resolv_list( padd->addr_type, padd->addr, padd->peer_irk, padd->local_irk, dst + BLE_HCI_CMD_HDR_LEN); if (rc != 0) { @@ -1091,9 +1089,8 @@ host_hci_cmd_add_device_to_resolving_list( } static int -host_hci_cmd_body_remove_device_from_resolving_list(uint8_t addr_type, - uint8_t *addr, - uint8_t *dst) +host_hci_cmd_body_remove_from_resolv_list(uint8_t addr_type, uint8_t *addr, + uint8_t *dst) { if (addr_type > BLE_ADDR_TYPE_RANDOM) { return BLE_ERR_INV_HCI_CMD_PARMS; @@ -1106,10 +1103,8 @@ host_hci_cmd_body_remove_device_from_resolving_list(uint8_t addr_type, int -host_hci_cmd_remove_device_from_resolving_list(uint8_t addr_type, - uint8_t *addr, - uint8_t *dst, - int dst_len) +host_hci_cmd_build_remove_from_resolv_list(uint8_t addr_type, uint8_t *addr, + uint8_t *dst, int dst_len) { int rc; @@ -1119,7 +1114,7 @@ host_hci_cmd_remove_device_from_resolving_list(uint8_t addr_type, host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RMV_RESOLV_LIST, BLE_HCI_RMV_FROM_RESOLV_LIST_LEN, dst); - rc = host_hci_cmd_body_remove_device_from_resolving_list(addr_type, addr, + rc = host_hci_cmd_body_remove_from_resolv_list(addr_type, addr, dst + BLE_HCI_CMD_HDR_LEN); if (rc != 0) { return rc; @@ -1128,7 +1123,7 @@ host_hci_cmd_remove_device_from_resolving_list(uint8_t addr_type, } int -host_hci_cmd_clear_resolving_list(uint8_t *dst, int dst_len) +host_hci_cmd_build_clear_resolv_list(uint8_t *dst, int dst_len) { BLE_HS_DBG_ASSERT(dst_len >= BLE_HCI_CMD_HDR_LEN); @@ -1139,7 +1134,7 @@ host_hci_cmd_clear_resolving_list(uint8_t *dst, int dst_len) } int -host_hci_cmd_read_resolving_list_size(uint8_t *dst, int dst_len) +host_hci_cmd_build_read_resolv_list_size(uint8_t *dst, int dst_len) { BLE_HS_DBG_ASSERT(dst_len >= BLE_HCI_CMD_HDR_LEN); @@ -1150,9 +1145,9 @@ host_hci_cmd_read_resolving_list_size(uint8_t *dst, int dst_len) } static int -host_hci_cmd_body_read_peer_resolvable_address (uint8_t peer_identity_addr_type, - uint8_t *peer_identity_addr, - uint8_t *dst) +host_hci_cmd_body_read_peer_resolv_addr(uint8_t peer_identity_addr_type, + uint8_t *peer_identity_addr, + uint8_t *dst) { if (peer_identity_addr_type > BLE_ADDR_TYPE_RANDOM) { return BLE_ERR_INV_HCI_CMD_PARMS; @@ -1164,10 +1159,10 @@ host_hci_cmd_body_read_peer_resolvable_address (uint8_t peer_identity_addr_type, } int -host_hci_cmd_read_peer_resolvable_address(uint8_t peer_identity_addr_type, - uint8_t *peer_identity_addr, - uint8_t *dst, - int dst_len) +host_hci_cmd_build_read_peer_resolv_addr(uint8_t peer_identity_addr_type, + uint8_t *peer_identity_addr, + uint8_t *dst, + int dst_len) { int rc; @@ -1177,7 +1172,7 @@ host_hci_cmd_read_peer_resolvable_address(uint8_t peer_identity_addr_type, host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_PEER_RESOLV_ADDR, BLE_HCI_RD_PEER_RESOLV_ADDR_LEN, dst); - rc = host_hci_cmd_body_read_peer_resolvable_address(peer_identity_addr_type, + rc = host_hci_cmd_body_read_peer_resolv_addr(peer_identity_addr_type, peer_identity_addr, dst + BLE_HCI_CMD_HDR_LEN); if (rc != 0) { @@ -1187,8 +1182,9 @@ host_hci_cmd_read_peer_resolvable_address(uint8_t peer_identity_addr_type, } static int -host_hci_cmd_body_read_local_resolvable_address( - uint8_t local_identity_addr_type, uint8_t *local_identity_addr, +host_hci_cmd_body_read_lcl_resolv_addr( + uint8_t local_identity_addr_type, + uint8_t *local_identity_addr, uint8_t *dst) { if (local_identity_addr_type > BLE_ADDR_TYPE_RANDOM) { @@ -1204,10 +1200,10 @@ host_hci_cmd_body_read_local_resolvable_address( * OGF=0x08 OCF=0x002c */ int -host_hci_cmd_read_local_resolvable_address(uint8_t local_identity_addr_type, - uint8_t *local_identity_addr, - uint8_t *dst, - int dst_len) +host_hci_cmd_build_read_lcl_resolv_addr(uint8_t local_identity_addr_type, + uint8_t *local_identity_addr, + uint8_t *dst, + int dst_len) { int rc; @@ -1217,8 +1213,7 @@ host_hci_cmd_read_local_resolvable_address(uint8_t local_identity_addr_type, host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_RD_LOCAL_RESOLV_ADDR, BLE_HCI_RD_LOC_RESOLV_ADDR_LEN, dst); - rc = host_hci_cmd_body_read_local_resolvable_address - (local_identity_addr_type, + rc = host_hci_cmd_body_read_lcl_resolv_addr(local_identity_addr_type, local_identity_addr, dst + BLE_HCI_CMD_HDR_LEN); if (rc != 0) { @@ -1228,8 +1223,7 @@ host_hci_cmd_read_local_resolvable_address(uint8_t local_identity_addr_type, } static int -host_hci_cmd_body_set_addr_resolution_enable(uint8_t enable, - uint8_t *dst) +host_hci_cmd_body_set_addr_res_en(uint8_t enable, uint8_t *dst) { if (enable > 1) { return BLE_ERR_INV_HCI_CMD_PARMS; @@ -1243,8 +1237,7 @@ host_hci_cmd_body_set_addr_resolution_enable(uint8_t enable, * OGF=0x08 OCF=0x002d */ int -host_hci_cmd_set_addr_resolution_enable(uint8_t enable, uint8_t *dst, - int dst_len) +host_hci_cmd_build_set_addr_res_en(uint8_t enable, uint8_t *dst, int dst_len) { int rc; @@ -1254,8 +1247,7 @@ host_hci_cmd_set_addr_resolution_enable(uint8_t enable, uint8_t *dst, host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_ADDR_RES_EN, BLE_HCI_SET_ADDR_RESOL_ENA_LEN, dst); - rc = host_hci_cmd_body_set_addr_resolution_enable(enable, - dst + BLE_HCI_CMD_HDR_LEN); + rc = host_hci_cmd_body_set_addr_res_en(enable, dst + BLE_HCI_CMD_HDR_LEN); if (rc != 0) { return rc; } @@ -1263,10 +1255,9 @@ host_hci_cmd_set_addr_resolution_enable(uint8_t enable, uint8_t *dst, } static int -host_hci_cmd_body_set_resolvable_private_address_timeout(uint16_t timeout, - uint8_t *dst) +host_hci_cmd_body_set_resolv_priv_addr_timeout(uint16_t timeout, uint8_t *dst) { - if ((timeout == 0) || (timeout > 0xA1B8)) { + if (timeout == 0 || timeout > 0xA1B8) { return BLE_ERR_INV_HCI_CMD_PARMS; } @@ -1278,9 +1269,8 @@ host_hci_cmd_body_set_resolvable_private_address_timeout(uint16_t timeout, * OGF=0x08 OCF=0x002e */ int -host_hci_cmd_set_resolvable_private_address_timeout(uint16_t timeout, - uint8_t *dst, - int dst_len) +host_hci_cmd_build_set_resolv_priv_addr_timeout(uint16_t timeout, uint8_t *dst, + int dst_len) { int rc; @@ -1290,8 +1280,8 @@ host_hci_cmd_set_resolvable_private_address_timeout(uint16_t timeout, host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_RPA_TMO, BLE_HCI_SET_RESOLV_PRIV_ADDR_TO_LEN, dst); - rc = host_hci_cmd_body_set_resolvable_private_address_timeout(timeout, - dst + BLE_HCI_CMD_HDR_LEN); + rc = host_hci_cmd_body_set_resolv_priv_addr_timeout( + timeout, dst + BLE_HCI_CMD_HDR_LEN); if (rc != 0) { return rc; } @@ -1306,7 +1296,7 @@ host_hci_cmd_body_set_random_addr(struct hci_rand_addr *paddr, uint8_t *dst) } int -host_hci_cmd_set_random_addr(uint8_t *addr, uint8_t *dst, int dst_len) +host_hci_cmd_build_set_random_addr(uint8_t *addr, uint8_t *dst, int dst_len) { struct hci_rand_addr r_addr; int rc; @@ -1319,10 +1309,10 @@ host_hci_cmd_set_random_addr(uint8_t *addr, uint8_t *dst, int dst_len) host_hci_write_hdr(BLE_HCI_OGF_LE, BLE_HCI_OCF_LE_SET_RAND_ADDR, BLE_HCI_SET_RAND_ADDR_LEN, dst); - rc = host_hci_cmd_body_set_random_addr(&r_addr, - dst + BLE_HCI_CMD_HDR_LEN); + rc = host_hci_cmd_body_set_random_addr(&r_addr, dst + BLE_HCI_CMD_HDR_LEN); if (rc != 0) { return rc; } + return 0; } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/test/ble_hs_test_util.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_hs_test_util.c b/net/nimble/host/src/test/ble_hs_test_util.c index 5039736..782d359 100644 --- a/net/nimble/host/src/test/ble_hs_test_util.c +++ b/net/nimble/host/src/test/ble_hs_test_util.c @@ -792,7 +792,7 @@ ble_hs_test_util_tx_all(void) void ble_hs_test_util_set_public_addr(uint8_t *addr) { - ble_hs_priv_update_identity(addr); + ble_hs_pvcy_set_our_id_addr(addr); } void http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6970f587/net/nimble/host/src/test/ble_sm_test_util.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/test/ble_sm_test_util.c b/net/nimble/host/src/test/ble_sm_test_util.c index 48a8677..2225f30 100644 --- a/net/nimble/host/src/test/ble_sm_test_util.c +++ b/net/nimble/host/src/test/ble_sm_test_util.c @@ -228,7 +228,7 @@ ble_sm_test_util_init_good(struct ble_sm_test_params *params, ble_sm_dbg_set_next_ediv(out_us->ediv); ble_sm_dbg_set_next_master_id_rand(out_us->rand_num); ble_sm_dbg_set_next_ltk(out_us->ltk); - ble_hs_priv_update_irk(out_us->id_info->irk); + ble_hs_pvcy_set_our_irk(out_us->id_info->irk); ble_sm_dbg_set_next_csrk(out_us->sign_info->sig_key); if (out_us->public_key != NULL) { @@ -800,7 +800,7 @@ ble_sm_test_util_verify_tx_id_addr_info(struct ble_sm_id_addr_info *exp_cmd) uint8_t *our_id_addr; uint8_t our_id_addr_type; - our_id_addr = bls_hs_priv_get_local_identity_addr(&our_id_addr_type); + our_id_addr = ble_hs_pvcy_our_id_addr(&our_id_addr_type); ble_hs_test_util_tx_all(); om = ble_sm_test_util_verify_tx_hdr(BLE_SM_OP_IDENTITY_ADDR_INFO,