You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/06/14 16:27:33 UTC

[06/15] incubator-mynewt-core git commit: BLE Host - SM; remove obsolete KEY_EXCH flag.

BLE Host - SM; remove obsolete KEY_EXCH flag.


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/d2351cc4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d2351cc4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d2351cc4

Branch: refs/heads/upf54
Commit: d2351cc429c7484c8bb5eb2fe89f001cd2465835
Parents: 7fac0ad
Author: Christopher Collins <cc...@apache.org>
Authored: Thu Jun 9 19:56:00 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Jun 14 09:27:01 2016 -0700

----------------------------------------------------------------------
 net/nimble/host/src/ble_sm.c      | 20 ++++++--------------
 net/nimble/host/src/ble_sm_cmd.c  |  4 ++--
 net/nimble/host/src/ble_sm_priv.h |  5 ++---
 3 files changed, 10 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d2351cc4/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 8c57c3d..6027f50 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -960,7 +960,7 @@ ble_sm_enc_event_rx(uint16_t conn_handle, uint8_t evt_status, int encrypted)
             /* We are completing a pairing procedure; keys may need to be
              * exchanged.
              */
-            if (evt_status == 0 && proc->flags & BLE_SM_PROC_F_KEY_EXCHANGE) {
+            if (evt_status == 0) {
                 /* If the responder has any keys to send, it sends them
                  * first.
                  */
@@ -984,7 +984,7 @@ ble_sm_enc_event_rx(uint16_t conn_handle, uint8_t evt_status, int encrypted)
              * procedure.  Keys were exchanged during pairing; they don't
              * get exchanged again now.  Procedure is complete.
              */
-            BLE_HS_DBG_ASSERT(!(proc->flags & BLE_SM_PROC_F_KEY_EXCHANGE));
+            BLE_HS_DBG_ASSERT(proc->rx_key_flags == 0);
             proc->state = BLE_SM_PROC_STATE_NONE;
             if (proc->flags & BLE_SM_PROC_F_AUTHENTICATED) {
                 authenticated = 1;
@@ -1425,10 +1425,6 @@ ble_sm_pair_cfg(struct ble_sm_proc *proc)
     }
 
     ble_sm_key_dist(proc, &init_key_dist, &resp_key_dist);
-    if (init_key_dist != 0 || resp_key_dist != 0) {
-        proc->flags |= BLE_SM_PROC_F_KEY_EXCHANGE;
-    }
-
     if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
         rx_key_dist = resp_key_dist;
     } else {
@@ -1436,7 +1432,6 @@ ble_sm_pair_cfg(struct ble_sm_proc *proc)
     }
 
     proc->rx_key_flags = 0;
-
     if (rx_key_dist & BLE_SM_PAIR_KEY_DIST_ENC) {
         proc->rx_key_flags |= BLE_SM_KE_F_ENC_INFO |
                               BLE_SM_KE_F_MASTER_ID;
@@ -1735,6 +1730,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 *irk;
     int rc;
 
     ble_sm_key_dist(proc, &init_key_dist, &resp_key_dist);
@@ -1744,10 +1740,6 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
         our_key_dist = resp_key_dist;
     }
 
-    if (our_key_dist == 0) {
-        return;
-    }
-
     if (our_key_dist & BLE_SM_PAIR_KEY_DIST_ENC) {
         /* Send encryption information. */
         rc = ble_sm_gen_ltk(proc, enc_info.ltk);
@@ -1781,7 +1773,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. */
-        uint8_t *irk = ble_hs_priv_get_local_irk();
+        irk = ble_hs_priv_get_local_irk();
 
         memcpy(iden_info.irk, irk, 16);
 
@@ -1790,6 +1782,7 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
             goto err;
         }
 
+        /* Send identity address information. */
         bls_hs_priv_copy_local_identity_addr(addr_info.bd_addr,
                                              &addr_info.addr_type);
         rc = ble_sm_id_addr_info_tx(proc->conn_handle, &addr_info);
@@ -1797,7 +1790,6 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
             goto err;
         }
 
-        /* copy data to pass to application */
         proc->our_keys.addr_valid = 1;
         memcpy(proc->our_keys.irk, irk, 16);
         proc->our_keys.addr_type = addr_info.addr_type;
@@ -1818,7 +1810,7 @@ ble_sm_key_exch_exec(struct ble_sm_proc *proc, struct ble_sm_result *res,
         memcpy(proc->our_keys.csrk, sign_info.sig_key, 16);
     }
 
-    if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
+    if (proc->flags & BLE_SM_PROC_F_INITIATOR || proc->rx_key_flags == 0) {
         /* The procedure is now complete. */
         ble_sm_key_exch_success(proc, res);
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d2351cc4/net/nimble/host/src/ble_sm_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_cmd.c b/net/nimble/host/src/ble_sm_cmd.c
index 1d6ce31..40dfc79 100644
--- a/net/nimble/host/src/ble_sm_cmd.c
+++ b/net/nimble/host/src/ble_sm_cmd.c
@@ -440,7 +440,7 @@ ble_sm_id_info_tx(uint16_t conn_handle, struct ble_sm_id_info *cmd)
     }
 
     txom->om_data[0] = BLE_SM_OP_IDENTITY_INFO;
-    memcpy(txom->om_data + 1, cmd->irk, sizeof cmd->irk);
+    swap_buf(txom->om_data + 1, cmd->irk, sizeof cmd->irk);
 
     BLE_SM_LOG_CMD(1, "id info", conn_handle, ble_sm_id_info_log, cmd);
 
@@ -461,7 +461,7 @@ ble_sm_id_info_log(struct ble_sm_id_info *cmd)
 
 void
 ble_sm_id_addr_info_parse(void *payload, int len,
-                       struct ble_sm_id_addr_info *cmd)
+                          struct ble_sm_id_addr_info *cmd)
 {
     uint8_t *u8ptr = payload;
     cmd->addr_type = *u8ptr;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d2351cc4/net/nimble/host/src/ble_sm_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_priv.h b/net/nimble/host/src/ble_sm_priv.h
index d11853d..733d04d 100644
--- a/net/nimble/host/src/ble_sm_priv.h
+++ b/net/nimble/host/src/ble_sm_priv.h
@@ -217,9 +217,8 @@ struct ble_sm_dhkey_check {
 #define BLE_SM_PROC_F_IO_INJECTED           0x02
 #define BLE_SM_PROC_F_ADVANCE_ON_IO         0x04
 #define BLE_SM_PROC_F_AUTHENTICATED         0x08
-#define BLE_SM_PROC_F_KEY_EXCHANGE          0x10
-#define BLE_SM_PROC_F_SC                    0x20
-#define BLE_SM_PROC_F_BONDING               0x40
+#define BLE_SM_PROC_F_SC                    0x10
+#define BLE_SM_PROC_F_BONDING               0x20
 
 #define BLE_SM_KE_F_ENC_INFO                0x01
 #define BLE_SM_KE_F_MASTER_ID               0x02