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/05 11:52:21 UTC

[34/43] incubator-mynewt-core git commit: BLE Host - Don't build SC unless so configured.

BLE Host - Don't build SC unless so configured.


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

Branch: refs/heads/develop
Commit: fa48add93707fd09e304b9f8247b56909a6c3db2
Parents: 8a13fa3
Author: Christopher Collins <cc...@apache.org>
Authored: Sat Jun 4 12:50:11 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Sun Jun 5 19:17:09 2016 +0800

----------------------------------------------------------------------
 net/nimble/host/include/host/ble_sm.h  |  2 +-
 net/nimble/host/pkg.yml                |  5 +++++
 net/nimble/host/src/ble_hs.c           |  2 --
 net/nimble/host/src/ble_sm.c           |  2 ++
 net/nimble/host/src/ble_sm_priv.h      | 29 +++++++++++++++--------------
 net/nimble/host/src/ble_sm_sc.c        |  5 +++++
 net/nimble/include/nimble/nimble_opt.h |  4 ++--
 7 files changed, 30 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa48add9/net/nimble/host/include/host/ble_sm.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_sm.h b/net/nimble/host/include/host/ble_sm.h
index 390a8d8..cf62a23 100644
--- a/net/nimble/host/include/host/ble_sm.h
+++ b/net/nimble/host/include/host/ble_sm.h
@@ -92,7 +92,7 @@ struct ble_sm_passkey {
 #if NIMBLE_OPT(SM)
 int ble_sm_set_tk(uint16_t conn_handle, struct ble_sm_passkey *pkey);
 #else
-#define ble_sm_set_tk(conn_handle, pkey) (BLE_HS_ENOTSUP)
+#define ble_sm_set_tk(conn_handle, pkey) ((void)(conn_handle), BLE_HS_ENOTSUP)
 #endif
 
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa48add9/net/nimble/host/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/pkg.yml b/net/nimble/host/pkg.yml
index e9dfd80..f597f34 100644
--- a/net/nimble/host/pkg.yml
+++ b/net/nimble/host/pkg.yml
@@ -32,6 +32,11 @@ pkg.deps:
     - libs/util
     - libs/mbedtls
     - net/nimble
+
+    # Tinycrypt is only required when secure connections (NIMBPLE_OPT_SM_SC)
+    # is enabled.  It always gets built as a dependency, but not is not
+    # included by the linker unless SC is enabled.  XXX: We should not build
+    # this library if it is not requiresd.
     - libs/tinycrypt
 
 pkg.req_apis:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa48add9/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index dc91ee7..d22a85b 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -433,8 +433,6 @@ ble_hs_init(struct os_eventq *app_evq, struct ble_hs_cfg *cfg)
     ble_hs_dbg_mutex_locked = 0;
 #endif
 
-    ble_sm_sc_init();
-
     return 0;
 
 err:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa48add9/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 a01542f..186ad79 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -2286,6 +2286,8 @@ ble_sm_init(void)
         }
     }
 
+    ble_sm_sc_init();
+
     return 0;
 
 err:

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa48add9/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 89e7898..f7c0d0e 100644
--- a/net/nimble/host/src/ble_sm_priv.h
+++ b/net/nimble/host/src/ble_sm_priv.h
@@ -268,12 +268,14 @@ struct ble_sm_proc {
     uint16_t ediv;
     uint64_t rand_num;
 
+#if NIMBLE_OPT(SM_SC)
     /* Secure connections. */
     uint8_t passkey_bits_exchanged;
     uint8_t ri;
     struct ble_sm_public_key pub_key_peer;
     uint8_t mackey[16];
     uint8_t dhkey[32];
+#endif
 };
 
 struct ble_sm_result {
@@ -378,7 +380,6 @@ int ble_sm_dhkey_check_tx(uint16_t conn_handle,
 void ble_sm_rx_encryption_change(struct hci_encrypt_change *evt);
 int ble_sm_rx_lt_key_req(struct hci_le_lt_key_req *evt);
 
-int ble_sm_lgcy_next_state(struct ble_sm_proc *proc);
 int ble_sm_lgcy_passkey_action(struct ble_sm_proc *proc);
 void ble_sm_lgcy_confirm_go(struct ble_sm_proc *proc,
                             struct ble_sm_result *res);
@@ -387,7 +388,7 @@ void ble_sm_lgcy_random_go(struct ble_sm_proc *proc,
 void ble_sm_lgcy_rx_pair_random(struct ble_sm_proc *proc,
                                struct ble_sm_result *res);
 
-int ble_sm_sc_next_state(struct ble_sm_proc *proc);
+#if NIMBLE_OPT(SM_SC)
 int ble_sm_sc_passkey_action(struct ble_sm_proc *proc);
 void ble_sm_sc_confirm_go(struct ble_sm_proc *proc, struct ble_sm_result *res);
 void ble_sm_sc_random_go(struct ble_sm_proc *proc, struct ble_sm_result *res);
@@ -396,9 +397,6 @@ void ble_sm_sc_random_rx(struct ble_sm_proc *proc,
 void ble_sm_sc_public_key_go(struct ble_sm_proc *proc,
                              struct ble_sm_result *res,
                              void *arg);
-void ble_sm_sc_public_key_handle(struct ble_sm_proc *proc,
-                                 struct ble_sm_public_key *cmd,
-                                 struct ble_sm_result *res);
 void ble_sm_sc_public_key_rx(uint16_t conn_handle, uint8_t op,
                              struct os_mbuf **om, struct ble_sm_result *res);
 void ble_sm_sc_dhkey_check_go(struct ble_sm_proc *proc,
@@ -406,6 +404,18 @@ void ble_sm_sc_dhkey_check_go(struct ble_sm_proc *proc,
 void ble_sm_sc_dhkey_check_rx(uint16_t conn_handle, uint8_t op,
                               struct os_mbuf **om, struct ble_sm_result *res);
 void ble_sm_sc_init(void);
+#else
+#define ble_sm_sc_passkey_action(proc) (BLE_SM_PKACT_NONE)
+#define ble_sm_sc_confirm_go(proc, res)
+#define ble_sm_sc_random_go(proc, res)
+#define ble_sm_sc_random_rx(proc, res)
+#define ble_sm_sc_public_key_go(proc, res, arg)
+#define ble_sm_sc_public_key_rx(conn_handle, op, om, res)
+#define ble_sm_sc_dhkey_check_go(proc, res, arg)
+#define ble_sm_sc_dhkey_check_rx(conn_handle, op, om, res)
+#define ble_sm_sc_init()
+
+#endif
 
 struct ble_sm_proc *ble_sm_proc_find(uint16_t conn_handle, uint8_t state,
                                      int is_initiator,
@@ -439,15 +449,6 @@ int ble_sm_init(void);
 
 #define ble_sm_create_chan() NULL
 
-#define ble_sm_pair_cmd_tx(conn_handle, is_req, cmd) BLE_HS_ENOTSUP
-#define ble_sm_pair_confirm_tx(conn_handle, cmd) BLE_HS_ENOTSUP
-#define ble_sm_pair_random_tx(conn_handle, cmd) BLE_HS_ENOTSUP
-#define ble_sm_pair_fail_tx(conn_handle, cmd) BLE_HS_ENOTSUP
-
-#define ble_sm_alg_s1(k, r1, r2, out) BLE_HS_ENOTSUP
-#define ble_sm_alg_c1(k, r, preq, pres, iat, rat, ia, ra, out_enc_data) \
-    BLE_HS_ENOTSUP
-
 #define ble_sm_rx_encryption_change(evt) ((void)(evt))
 #define ble_sm_rx_lt_key_req(evt) ((void)(evt))
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa48add9/net/nimble/host/src/ble_sm_sc.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_sm_sc.c b/net/nimble/host/src/ble_sm_sc.c
index 39b7f0a..5da9cc1 100644
--- a/net/nimble/host/src/ble_sm_sc.c
+++ b/net/nimble/host/src/ble_sm_sc.c
@@ -19,10 +19,13 @@
 
 #include <string.h>
 
+#include "nimble/nimble_opt.h"
 #include "host/ble_sm.h"
 #include "ble_hs_priv.h"
 #include "ble_sm_priv.h"
 
+#if NIMBLE_OPT(SM_SC)
+
 #define BLE_SM_SC_PASSKEY_BYTES     4
 #define BLE_SM_SC_PASSKEY_BITS      20
 
@@ -679,3 +682,5 @@ ble_sm_sc_init(void)
 {
     ble_sm_sc_keys_generated = 0;
 }
+
+#endif  /* NIMBLE_OPT_SM_SC */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fa48add9/net/nimble/include/nimble/nimble_opt.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/nimble_opt.h b/net/nimble/include/nimble/nimble_opt.h
index 4e42f99..4e88a95 100644
--- a/net/nimble/include/nimble/nimble_opt.h
+++ b/net/nimble/include/nimble/nimble_opt.h
@@ -58,10 +58,10 @@
 #define NIMBLE_OPT_SM                           1
 #endif
 
-/** HOST: Security connections (4.2).  Enabled by default. */
+/** HOST: Security connections (4.2).  Disabled by default. */
 
 #ifndef NIMBLE_OPT_SM_SC
-#define NIMBLE_OPT_SM_SC                        1
+#define NIMBLE_OPT_SM_SC                        0
 #endif
 
 /** HOST: Supported GATT procedures.  By default, all are enabled. */