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:07 UTC
[20/43] incubator-mynewt-core git commit: BLE Host - Initial numeric
comparison work.
BLE Host - Initial numeric comparison work.
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/67fbdd4e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/67fbdd4e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/67fbdd4e
Branch: refs/heads/develop
Commit: 67fbdd4e132f4a9b0b4550112f084b7cf162ad03
Parents: 2a59140
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jun 1 10:01:58 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Sun Jun 5 19:15:48 2016 +0800
----------------------------------------------------------------------
net/nimble/host/include/host/ble_gap.h | 1 +
net/nimble/host/include/host/ble_sm.h | 2 +-
net/nimble/host/src/ble_sm_sc.c | 68 ++++++++++++++++++++++++-----
3 files changed, 59 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/67fbdd4e/net/nimble/host/include/host/ble_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_gap.h b/net/nimble/host/include/host/ble_gap.h
index e30fb1b..6e7f76b 100644
--- a/net/nimble/host/include/host/ble_gap.h
+++ b/net/nimble/host/include/host/ble_gap.h
@@ -208,6 +208,7 @@ struct ble_gap_conn_ctxt {
struct {
uint8_t action;
+ uint32_t numcmp;
} passkey_action;
struct {
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/67fbdd4e/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 1c3edeb..b92d99b 100644
--- a/net/nimble/host/include/host/ble_sm.h
+++ b/net/nimble/host/include/host/ble_sm.h
@@ -42,7 +42,7 @@
#define BLE_SM_PAIR_ALG_JW 0
#define BLE_SM_PAIR_ALG_PASSKEY 1
#define BLE_SM_PAIR_ALG_OOB 2
-#define BLE_SM_PAIR_ALG_NUM_CMP 3
+#define BLE_SM_PAIR_ALG_NUMCMP 3
#define BLE_SM_PAIR_KEY_DIST_ENC 0x01
#define BLE_SM_PAIR_KEY_DIST_ID 0x02
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/67fbdd4e/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 9e6ccee..8672447 100644
--- a/net/nimble/host/src/ble_sm_sc.c
+++ b/net/nimble/host/src/ble_sm_sc.c
@@ -23,6 +23,10 @@
#include "ble_hs_priv.h"
#include "ble_sm_priv.h"
+static uint8_t ble_sm_sc_pub_key[64];
+static uint8_t ble_sm_sc_priv_key[32];
+static uint8_t ble_sm_sc_keys_generated;
+
/**
* Create some shortened names for the passkey actions so that the table is
* easier to read.
@@ -57,9 +61,53 @@ static const uint8_t ble_sm_lgcy_resp_pka[5 /*init*/ ][5 /*resp */] =
{PKACT_INPUT, PKACT_NUMCMP, PKACT_DISP, PKACT_NONE, PKACT_NUMCMP},
};
-static uint8_t ble_sm_sc_pub_key[64];
-static uint8_t ble_sm_sc_priv_key[32];
-static uint8_t ble_sm_sc_keys_generated;
+int
+ble_sm_sc_passkey_action(struct ble_sm_proc *proc)
+{
+ int action;
+
+ if (proc->pair_req.oob_data_flag || proc->pair_rsp.oob_data_flag) {
+ action = BLE_SM_PKACT_OOB;
+ } else if (!(proc->pair_req.authreq & BLE_SM_PAIR_AUTHREQ_MITM) &&
+ !(proc->pair_rsp.authreq & BLE_SM_PAIR_AUTHREQ_MITM)) {
+
+ action = BLE_SM_PKACT_NONE;
+ } else if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
+ action = ble_sm_lgcy_init_pka[proc->pair_rsp.io_cap]
+ [proc->pair_req.io_cap];
+ } else {
+ action = ble_sm_lgcy_resp_pka[proc->pair_rsp.io_cap]
+ [proc->pair_req.io_cap];
+ }
+
+ switch (action) {
+ case BLE_SM_PKACT_NONE:
+ proc->pair_alg = BLE_SM_PAIR_ALG_JW;
+ break;
+
+ case BLE_SM_PKACT_OOB:
+ proc->pair_alg = BLE_SM_PAIR_ALG_OOB;
+ proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
+ break;
+
+ case BLE_SM_PKACT_INPUT:
+ case BLE_SM_PKACT_DISP:
+ proc->pair_alg = BLE_SM_PAIR_ALG_PASSKEY;
+ proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
+ break;
+
+ case BLE_SM_PKACT_NUMCMP:
+ proc->pair_alg = BLE_SM_PAIR_ALG_NUMCMP;
+ proc->flags |= BLE_SM_PROC_F_AUTHENTICATED;
+ break;
+
+ default:
+ BLE_HS_DBG_ASSERT(0);
+ break;
+ }
+
+ return action;
+}
static int
ble_sm_sc_ensure_keys_generated(void)
@@ -89,7 +137,7 @@ ble_sm_sc_initiator_txes_confirm(struct ble_sm_proc *proc)
* (vol. 3, part H, 2.3.5.6.2)
*/
return proc->pair_alg != BLE_SM_PAIR_ALG_JW &&
- proc->pair_alg != BLE_SM_PAIR_ALG_NUM_CMP;
+ proc->pair_alg != BLE_SM_PAIR_ALG_NUMCMP;
}
static int
@@ -104,13 +152,7 @@ ble_sm_sc_responder_verifies_random(struct ble_sm_proc *proc)
* (vol. 3, part H, 2.3.5.6.2)
*/
return proc->pair_alg != BLE_SM_PAIR_ALG_JW &&
- proc->pair_alg != BLE_SM_PAIR_ALG_NUM_CMP;
-}
-
-int
-ble_sm_sc_passkey_action(struct ble_sm_proc *proc)
-{
- return 0;
+ proc->pair_alg != BLE_SM_PAIR_ALG_NUMCMP;
}
void
@@ -214,6 +256,10 @@ ble_sm_sc_rx_pair_random(struct ble_sm_proc *proc, struct ble_sm_result *res)
if (proc->flags & BLE_SM_PROC_F_INITIATOR) {
proc->state = BLE_SM_PROC_STATE_DHKEY_CHECK;
+
+ if (proc->pair_alg == BLE_SM_PAIR_ALG_NUMCMP) {
+
+ }
}
res->execute = 1;