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/17 04:04:09 UTC
[9/9] incubator-mynewt-core git commit: BLE Host - More SM unit tests.
BLE Host - More SM unit tests.
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/39dd36c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/39dd36c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/39dd36c8
Branch: refs/heads/develop
Commit: 39dd36c86734aa438fd6a4b583007c612e0ca420
Parents: e347a0d
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Jun 15 20:47:20 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Thu Jun 16 21:01:34 2016 -0700
----------------------------------------------------------------------
net/nimble/host/include/host/ble_hs_test.h | 4 +-
net/nimble/host/src/ble_sm.c | 5 +-
net/nimble/host/src/ble_sm_cmd.c | 35 +-
net/nimble/host/src/test/ble_hs_test.c | 3 +-
net/nimble/host/src/test/ble_sm_lgcy_test.c | 702 +++++++
net/nimble/host/src/test/ble_sm_sc_test.c | 68 +-
net/nimble/host/src/test/ble_sm_test.c | 2239 ++--------------------
net/nimble/host/src/test/ble_sm_test_util.c | 1610 +++++++++-------
net/nimble/host/src/test/ble_sm_test_util.h | 67 +-
9 files changed, 1883 insertions(+), 2850 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/39dd36c8/net/nimble/host/include/host/ble_hs_test.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs_test.h b/net/nimble/host/include/host/ble_hs_test.h
index 375a85e..787ec41 100644
--- a/net/nimble/host/include/host/ble_hs_test.h
+++ b/net/nimble/host/include/host/ble_hs_test.h
@@ -43,8 +43,10 @@ int ble_hs_adv_test_all(void);
int ble_hs_conn_test_all(void);
int ble_l2cap_test_all(void);
int ble_os_test_all(void);
-int ble_sm_sc_test_all(void);
int ble_sm_test_all(void);
int ble_uuid_test_all(void);
+int ble_sm_lgcy_test_suite(void);
+int ble_sm_sc_test_suite(void);
+
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/39dd36c8/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 76cbbd0..62e2501 100644
--- a/net/nimble/host/src/ble_sm.c
+++ b/net/nimble/host/src/ble_sm.c
@@ -1572,11 +1572,12 @@ ble_sm_pair_rsp_rx(uint16_t conn_handle, uint8_t op, struct os_mbuf **om,
} else {
ble_sm_pair_cfg(proc);
+ proc->state = ble_sm_state_after_pair(proc);
ioact = ble_sm_io_action(proc);
if (ble_sm_ioact_state(ioact) == proc->state) {
res->passkey_action.action = ioact;
- } else {
- proc->state = ble_sm_state_after_pair(proc);
+ }
+ if (ble_sm_proc_can_advance(proc)) {
res->execute = 1;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/39dd36c8/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 ebb1e54..4151856 100644
--- a/net/nimble/host/src/ble_sm_cmd.c
+++ b/net/nimble/host/src/ble_sm_cmd.c
@@ -347,6 +347,19 @@ ble_sm_enc_info_parse(void *payload, int len, struct ble_sm_enc_info *cmd)
memcpy(cmd->ltk, payload, sizeof cmd->ltk);
}
+void
+ble_sm_enc_info_write(void *payload, int len, struct ble_sm_enc_info *cmd)
+{
+ uint8_t *u8ptr;
+
+ BLE_HS_DBG_ASSERT(len >= BLE_SM_HDR_SZ + BLE_SM_ENC_INFO_SZ);
+
+ u8ptr = payload;
+
+ u8ptr[0] = BLE_SM_OP_ENC_INFO;
+ memcpy(u8ptr + 1, cmd->ltk, sizeof cmd->ltk);
+}
+
int
ble_sm_enc_info_tx(uint16_t conn_handle, struct ble_sm_enc_info *cmd)
{
@@ -359,8 +372,7 @@ ble_sm_enc_info_tx(uint16_t conn_handle, struct ble_sm_enc_info *cmd)
goto done;
}
- txom->om_data[0] = BLE_SM_OP_ENC_INFO;
- memcpy(txom->om_data + 1, cmd->ltk, sizeof cmd->ltk);
+ ble_sm_enc_info_write(txom->om_data, txom->om_len, cmd);
BLE_SM_LOG_CMD(1, "enc info", conn_handle, ble_sm_enc_info_log, cmd);
@@ -382,11 +394,28 @@ ble_sm_enc_info_log(struct ble_sm_enc_info *cmd)
void
ble_sm_master_id_parse(void *payload, int len, struct ble_sm_master_id *cmd)
{
- uint8_t *u8ptr = payload;
+ uint8_t *u8ptr;
+
+ u8ptr = payload;
+
cmd->ediv = le16toh(u8ptr);
cmd->rand_val = le64toh(u8ptr + 2);
}
+void
+ble_sm_master_id_write(void *payload, int len, struct ble_sm_master_id *cmd)
+{
+ uint8_t *u8ptr;
+
+ BLE_HS_DBG_ASSERT(len >= BLE_SM_HDR_SZ + BLE_SM_MASTER_ID_SZ);
+
+ u8ptr = payload;
+
+ u8ptr[0] = BLE_SM_OP_MASTER_ID;
+ htole16(u8ptr + 1, cmd->ediv);
+ htole64(u8ptr + 3, cmd->rand_val);
+}
+
int
ble_sm_master_id_tx(uint16_t conn_handle, struct ble_sm_master_id *cmd)
{
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/39dd36c8/net/nimble/host/src/test/ble_hs_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_hs_test.c b/net/nimble/host/src/test/ble_hs_test.c
index f6a139b..88a2c0c 100644
--- a/net/nimble/host/src/test/ble_hs_test.c
+++ b/net/nimble/host/src/test/ble_hs_test.c
@@ -66,10 +66,9 @@ main(int argc, char **argv)
ble_host_hci_test_all();
ble_hs_adv_test_all();
ble_hs_conn_test_all();
- ble_sm_test_all();
- ble_sm_sc_test_all();
ble_l2cap_test_all();
ble_os_test_all();
+ ble_sm_test_all();
ble_uuid_test_all();
return tu_any_failed;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/39dd36c8/net/nimble/host/src/test/ble_sm_lgcy_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_sm_lgcy_test.c b/net/nimble/host/src/test/ble_sm_lgcy_test.c
new file mode 100644
index 0000000..09a7756
--- /dev/null
+++ b/net/nimble/host/src/test/ble_sm_lgcy_test.c
@@ -0,0 +1,702 @@
+/**
+ * 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 <stddef.h>
+#include <string.h>
+#include <errno.h>
+#include "testutil/testutil.h"
+#include "nimble/hci_common.h"
+#include "nimble/nimble_opt.h"
+#include "host/host_hci.h"
+#include "host/ble_sm.h"
+#include "host/ble_hs_test.h"
+#include "ble_hs_test_util.h"
+#include "ble_sm_test_util.h"
+
+#if NIMBLE_OPT(SM)
+
+/**
+ * Legacy pairing
+ * Master: peer
+ * Pair algorithm: just works
+ * Initiator IO capabilities: 4
+ * Responder IO capabilities: 3
+ * Bonding: true
+ * Initiator address type: BLE_ADDR_TYPE_PUBLIC
+ * Responder address type: BLE_ADDR_TYPE_PUBLIC
+ * Initiator key distribution: 7
+ * Responder key distribution: 7
+ */
+TEST_CASE(ble_sm_lgcy_peer_jw_iio4_rio3_b1_iat0_rat0_ik7_rk7)
+{
+ struct ble_sm_test_params params;
+
+ params = (struct ble_sm_test_params) {
+ .init_id_addr = {
+ 0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c,
+ },
+ .resp_id_addr = {
+ 0x33, 0x22, 0x11, 0x00, 0x45, 0x0a,
+ },
+ .pair_req = {
+ .io_cap = 0x04,
+ .oob_data_flag = 0x00,
+ .authreq = 0x05,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .pair_rsp = {
+ .io_cap = 0x03,
+ .oob_data_flag = 0x00,
+ .authreq = 0x09,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .confirm_req[0] = {
+ .value = {
+ 0xcd, 0x5b, 0x79, 0x29, 0x53, 0x31, 0x56, 0x23,
+ 0x2c, 0x08, 0xed, 0x81, 0x16, 0x55, 0x8e, 0x01,
+ },
+ },
+ .confirm_rsp[0] = {
+ .value = {
+ 0x49, 0x39, 0x22, 0x0f, 0x7b, 0x1b, 0x80, 0xcd,
+ 0xbe, 0x89, 0xd1, 0x4c, 0xbd, 0x6f, 0xda, 0x2c,
+ },
+ },
+ .random_req[0] = {
+ .value = {
+ 0x7f, 0x42, 0xc0, 0x2f, 0x1d, 0x07, 0x37, 0xfc,
+ 0x04, 0x5b, 0x05, 0x9a, 0xed, 0x67, 0xa5, 0x68,
+ },
+ },
+ .random_rsp[0] = {
+ .value = {
+ 0x42, 0x1a, 0x58, 0xa2, 0x3b, 0x80, 0xde, 0xef,
+ 0x95, 0x0d, 0xf7, 0xca, 0x06, 0x05, 0x01, 0x3c,
+ },
+ },
+ .enc_info_req = {
+ .ltk = {
+ 0x2f, 0x9b, 0x16, 0xff, 0xf3, 0x73, 0x30, 0x08,
+ 0xa8, 0xe5, 0x01, 0xb1, 0x3b, 0xe1, 0x87, 0x00,
+ },
+ },
+ .master_id_req = {
+ .ediv = 0xf8e0,
+ .rand_val = 0xef7c818b00000000,
+ },
+ .id_info_req = {
+ .irk = {
+ 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d,
+ 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8,
+ },
+ },
+ .id_addr_info_req = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0x33, 0x22, 0x11, 0x00, 0x45, 0x0a,
+ },
+ },
+ .sign_info_req = {
+ .sig_key = {
+ 0xc6, 0x17, 0xc0, 0x02, 0x40, 0x0d, 0x27, 0x51,
+ 0x8a, 0x77, 0xb5, 0xae, 0xd8, 0xa9, 0x7a, 0x7a,
+ },
+ },
+ .enc_info_rsp = {
+ .ltk = {
+ 0xd7, 0x07, 0x22, 0x79, 0x24, 0xc6, 0xcb, 0x4d,
+ 0xa3, 0xdd, 0x01, 0xfb, 0x48, 0x87, 0xd4, 0xcf,
+ },
+ },
+ .master_id_rsp = {
+ .ediv = 0x9a39,
+ .rand_val = 0x8e76d9b00000000,
+ },
+ .id_info_rsp = {
+ .irk = {
+ 0xeb, 0x8a, 0x06, 0xc4, 0x93, 0x51, 0x04, 0xb3,
+ 0x8b, 0xbf, 0xe8, 0x1f, 0x0e, 0x96, 0x2a, 0x54,
+ },
+ },
+ .id_addr_info_rsp = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c,
+ },
+ },
+ .sign_info_rsp = {
+ .sig_key = {
+ 0x14, 0x55, 0x93, 0xe1, 0xd1, 0xe7, 0xc4, 0x5d,
+ 0x35, 0x97, 0xd3, 0x05, 0x30, 0xc8, 0x9d, 0x83,
+ },
+ },
+ .stk = {
+ 0x1c, 0xd7, 0xb6, 0x35, 0x48, 0xfc, 0x9f, 0xef,
+ 0x0e, 0x2f, 0x51, 0x77, 0xed, 0xdd, 0xbc, 0xaf,
+ },
+ .pair_alg = 0,
+ .authenticated = false,
+ .passkey_info = {
+ .passkey = {
+ .action = BLE_SM_IOACT_NONE,
+ },
+ },
+ };
+ ble_sm_test_util_peer_lgcy_good(¶ms);
+}
+
+/**
+ * Legacy pairing
+ * Master: peer
+ * Pair algorithm: passkey entry
+ * Initiator IO capabilities: 4
+ * Responder IO capabilities: 0
+ * Bonding: true
+ * Initiator address type: BLE_ADDR_TYPE_PUBLIC
+ * Responder address type: BLE_ADDR_TYPE_PUBLIC
+ * Initiator key distribution: 7
+ * Responder key distribution: 7
+ */
+TEST_CASE(ble_sm_lgcy_peer_pk_iio4_rio0_b1_iat0_rat0_ik7_rk7)
+{
+ struct ble_sm_test_params params;
+
+ params = (struct ble_sm_test_params) {
+ .init_id_addr = {
+ 0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c,
+ },
+ .resp_id_addr = {
+ 0x33, 0x22, 0x11, 0x00, 0x45, 0x0a,
+ },
+ .pair_req = {
+ .io_cap = 0x04,
+ .oob_data_flag = 0x00,
+ .authreq = 0x05,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .pair_rsp = {
+ .io_cap = 0x00,
+ .oob_data_flag = 0x00,
+ .authreq = 0x09,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .confirm_req[0] = {
+ .value = {
+ 0xa0, 0x10, 0x4a, 0xaa, 0x8b, 0x53, 0x78, 0xbb,
+ 0xd2, 0xae, 0x71, 0x1f, 0x4e, 0x00, 0x70, 0x8b,
+ },
+ },
+ .confirm_rsp[0] = {
+ .value = {
+ 0x62, 0xf3, 0xba, 0x0e, 0xe5, 0xbe, 0x2e, 0xd8,
+ 0x25, 0xb2, 0xec, 0x4c, 0x28, 0x77, 0x28, 0x60,
+ },
+ },
+ .random_req[0] = {
+ .value = {
+ 0x84, 0xcf, 0xe4, 0x04, 0x7d, 0xf3, 0xfc, 0xa1,
+ 0x3f, 0x75, 0xd6, 0x5a, 0x7c, 0xb7, 0xa4, 0x39,
+ },
+ },
+ .random_rsp[0] = {
+ .value = {
+ 0xef, 0x6a, 0x61, 0x6e, 0x02, 0x60, 0x7f, 0x5d,
+ 0x7f, 0x0d, 0xa6, 0x3c, 0x06, 0x1a, 0x5d, 0xd6,
+ },
+ },
+ .enc_info_req = {
+ .ltk = {
+ 0xad, 0x01, 0x6d, 0x76, 0xa9, 0xd0, 0x23, 0xc9,
+ 0x40, 0x0c, 0xbf, 0x2a, 0x4c, 0x23, 0x31, 0xc5,
+ },
+ },
+ .master_id_req = {
+ .ediv = 0xa74f,
+ .rand_val = 0x81cab3fd00000000,
+ },
+ .id_info_req = {
+ .irk = {
+ 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d,
+ 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8,
+ },
+ },
+ .id_addr_info_req = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0x33, 0x22, 0x11, 0x00, 0x45, 0x0a,
+ },
+ },
+ .sign_info_req = {
+ .sig_key = {
+ 0x60, 0x08, 0x49, 0x00, 0x6d, 0x76, 0x98, 0x73,
+ 0x9c, 0x95, 0xc4, 0xd9, 0xe8, 0x3a, 0x69, 0xbb,
+ },
+ },
+ .enc_info_rsp = {
+ .ltk = {
+ 0x5b, 0x73, 0x39, 0xd9, 0x51, 0x3d, 0x92, 0xa4,
+ 0x34, 0x65, 0xa5, 0x70, 0x49, 0xbe, 0x11, 0x28,
+ },
+ },
+ .master_id_rsp = {
+ .ediv = 0x9705,
+ .rand_val = 0x592f1e8d00000000,
+ },
+ .id_info_rsp = {
+ .irk = {
+ 0xeb, 0x8a, 0x06, 0xc4, 0x93, 0x51, 0x04, 0xb3,
+ 0x8b, 0xbf, 0xe8, 0x1f, 0x0e, 0x96, 0x2a, 0x54,
+ },
+ },
+ .id_addr_info_rsp = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0xe1, 0xfc, 0xda, 0xf4, 0xb7, 0x6c,
+ },
+ },
+ .sign_info_rsp = {
+ .sig_key = {
+ 0xc9, 0x9b, 0xf2, 0x75, 0xb7, 0x0d, 0xe8, 0x60,
+ 0x3d, 0xf0, 0xd6, 0xa8, 0x16, 0xc5, 0x6c, 0x2a,
+ },
+ },
+ .stk = {
+ 0xf2, 0x3c, 0x36, 0xc4, 0xa1, 0xfb, 0x5a, 0xa7,
+ 0x96, 0x20, 0xe4, 0x29, 0xb7, 0x58, 0x22, 0x7a,
+ },
+ .pair_alg = 1,
+ .authenticated = true,
+ .passkey_info = {
+ .passkey = {
+ .action = BLE_SM_IOACT_DISP,
+ .passkey = 46128,
+ },
+ },
+ };
+ ble_sm_test_util_peer_lgcy_good(¶ms);
+}
+
+/**
+ * Legacy pairing
+ * Master: us
+ * Pair algorithm: just works
+ * Initiator IO capabilities: 3
+ * Responder IO capabilities: 3
+ * Bonding: true
+ * Initiator address type: BLE_ADDR_TYPE_PUBLIC
+ * Responder address type: BLE_ADDR_TYPE_RANDOM
+ * Initiator key distribution: 7
+ * Responder key distribution: 5
+ */
+TEST_CASE(ble_sm_lgcy_us_jw_iio3_rio3_b1_iat0_rat1_ik7_rk5)
+{
+ struct ble_sm_test_params params;
+
+ params = (struct ble_sm_test_params) {
+ .init_id_addr = {
+ 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a,
+ },
+ .resp_addr_type = BLE_ADDR_TYPE_RANDOM,
+ .resp_id_addr = {
+ 0x11, 0x22, 0x11, 0x22, 0x11, 0xcc,
+ },
+ .pair_req = {
+ .io_cap = 0x03,
+ .oob_data_flag = 0x00,
+ .authreq = 0x01,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .pair_rsp = {
+ .io_cap = 0x03,
+ .oob_data_flag = 0x00,
+ .authreq = 0x01,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x05,
+ },
+ .confirm_req[0] = {
+ .value = {
+ 0x1c, 0xb6, 0x10, 0xea, 0x02, 0x08, 0x90, 0x64,
+ 0xc7, 0xf8, 0xe5, 0x9c, 0xb4, 0x3a, 0x18, 0xca,
+ },
+ },
+ .confirm_rsp[0] = {
+ .value = {
+ 0xb8, 0x6f, 0xd1, 0xc6, 0x74, 0x35, 0xa3, 0x94,
+ 0x68, 0x2f, 0xf1, 0x4c, 0x78, 0x44, 0xe8, 0x0d,
+ },
+ },
+ .random_req[0] = {
+ .value = {
+ 0x40, 0x48, 0x17, 0x4d, 0x42, 0xa0, 0xf8, 0xd5,
+ 0xbf, 0x65, 0x67, 0xb8, 0x5e, 0x57, 0x38, 0xac,
+ },
+ },
+ .random_rsp[0] = {
+ .value = {
+ 0x2c, 0xa1, 0xb1, 0xf5, 0x54, 0x9b, 0x43, 0xe9,
+ 0xb0, 0x62, 0x6a, 0xb0, 0x02, 0xb8, 0x6c, 0xca,
+ },
+ },
+ .enc_info_req = {
+ .ltk = {
+ 0x01, 0x15, 0xb6, 0x93, 0xc9, 0xff, 0xfe, 0x27,
+ 0x02, 0x41, 0xfd, 0x7b, 0x0e, 0x31, 0xd4, 0xa6,
+ },
+ },
+ .master_id_req = {
+ .ediv = 0xe4fb,
+ .rand_val = 0x8eee76b100000000,
+ },
+ .sign_info_req = {
+ .sig_key = {
+ 0x00, 0x2d, 0xf6, 0x3e, 0x5e, 0x0f, 0xd1, 0xe8,
+ 0x4e, 0x5f, 0x61, 0x1c, 0x2c, 0x0b, 0xa5, 0x51,
+ },
+ },
+ .enc_info_rsp = {
+ .ltk = {
+ 0x88, 0xbc, 0x95, 0x8d, 0xaa, 0x26, 0x8d, 0xd5,
+ 0x18, 0xc9, 0x06, 0x70, 0xc2, 0x30, 0x56, 0x4c,
+ },
+ },
+ .master_id_rsp = {
+ .ediv = 0x4413,
+ .rand_val = 0xfad1c27300000000,
+ },
+ .id_info_rsp = {
+ .irk = {
+ 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d,
+ 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8,
+ },
+ },
+ .id_addr_info_rsp = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a,
+ },
+ },
+ .sign_info_rsp = {
+ .sig_key = {
+ 0x03, 0xad, 0xa4, 0xe1, 0x34, 0x76, 0x95, 0x54,
+ 0xe5, 0x8f, 0xa4, 0x06, 0x72, 0xe6, 0xfc, 0x65,
+ },
+ },
+ .stk = {
+ 0x31, 0x54, 0x42, 0x6c, 0x1c, 0x03, 0x36, 0x44,
+ 0x0b, 0x72, 0x90, 0xa5, 0x1f, 0x79, 0x5b, 0xe9,
+ },
+ .pair_alg = 0,
+ .authenticated = false,
+ .passkey_info = {
+ .passkey = {
+ .action = BLE_SM_IOACT_NONE,
+ },
+ },
+ };
+ ble_sm_test_util_us_lgcy_good(¶ms);
+}
+
+/**
+ * Legacy pairing
+ * Master: us
+ * Pair algorithm: passkey entry
+ * Initiator IO capabilities: 4
+ * Responder IO capabilities: 2
+ * Bonding: true
+ * Initiator address type: BLE_ADDR_TYPE_PUBLIC
+ * Responder address type: BLE_ADDR_TYPE_RANDOM
+ * Initiator key distribution: 7
+ * Responder key distribution: 5
+ */
+TEST_CASE(ble_sm_lgcy_us_pk_iio4_rio2_b1_iat0_rat1_ik7_rk5)
+{
+ struct ble_sm_test_params params;
+
+ params = (struct ble_sm_test_params) {
+ .init_id_addr = {
+ 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a,
+ },
+ .resp_addr_type = BLE_ADDR_TYPE_RANDOM,
+ .resp_id_addr = {
+ 0x11, 0x22, 0x11, 0x22, 0x11, 0xcc,
+ },
+ .pair_req = {
+ .io_cap = 0x04,
+ .oob_data_flag = 0x00,
+ .authreq = 0x0d,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .pair_rsp = {
+ .io_cap = 0x02,
+ .oob_data_flag = 0x00,
+ .authreq = 0x05,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x05,
+ },
+ .confirm_req[0] = {
+ .value = {
+ 0xb5, 0xd4, 0xc5, 0xe8, 0xef, 0xef, 0xd8, 0xd7,
+ 0x2b, 0x14, 0x34, 0x35, 0x29, 0x18, 0xda, 0x12,
+ },
+ },
+ .confirm_rsp[0] = {
+ .value = {
+ 0x1a, 0x03, 0x20, 0xda, 0x60, 0x21, 0x9b, 0x4b,
+ 0x5d, 0x45, 0x90, 0x64, 0xe1, 0x24, 0x2c, 0xb6,
+ },
+ },
+ .random_req[0] = {
+ .value = {
+ 0x45, 0xa3, 0x1a, 0x0b, 0xf6, 0x0f, 0x7c, 0xcf,
+ 0x1a, 0xfb, 0xfc, 0x1a, 0xad, 0x62, 0x0e, 0x76,
+ },
+ },
+ .random_rsp[0] = {
+ .value = {
+ 0x82, 0xbb, 0x9f, 0x67, 0xc4, 0x88, 0xcb, 0x58,
+ 0xee, 0xf9, 0x34, 0x35, 0x23, 0xa3, 0xd0, 0x22,
+ },
+ },
+ .enc_info_req = {
+ .ltk = {
+ 0xfa, 0x43, 0x8f, 0x1f, 0xe6, 0x2a, 0x94, 0x5b,
+ 0x54, 0x89, 0x2b, 0x0f, 0xd7, 0x23, 0x77, 0x9e,
+ },
+ },
+ .master_id_req = {
+ .ediv = 0x88b3,
+ .rand_val = 0x7c970e18dec74560,
+ },
+ .sign_info_req = {
+ .sig_key = {
+ 0x2e, 0x70, 0x3c, 0xbf, 0x20, 0xbe, 0x7d, 0x2d,
+ 0xb3, 0x50, 0x46, 0x33, 0x4c, 0x20, 0x0e, 0xc8,
+ },
+ },
+ .enc_info_rsp = {
+ .ltk = {
+ 0xc1, 0x64, 0x33, 0x10, 0x0f, 0x70, 0x2f, 0x9c,
+ 0xe7, 0x31, 0xc5, 0x32, 0xdd, 0x98, 0x16, 0x75,
+ },
+ },
+ .master_id_rsp = {
+ .ediv = 0x1c19,
+ .rand_val = 0xef308872dc2a4cc2,
+ },
+ .id_info_rsp = {
+ .irk = {
+ 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d,
+ 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8,
+ },
+ },
+ .id_addr_info_rsp = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a,
+ },
+ },
+ .sign_info_rsp = {
+ .sig_key = {
+ 0xd7, 0x75, 0xfa, 0xed, 0xd7, 0xdd, 0x7b, 0xb3,
+ 0xa4, 0x20, 0xea, 0x2f, 0x75, 0x60, 0xb1, 0x84,
+ },
+ },
+ .stk = {
+ 0x9e, 0xe8, 0x35, 0x22, 0xb6, 0xbb, 0x54, 0x0d,
+ 0x48, 0x1b, 0x25, 0xa0, 0xd8, 0xe2, 0xa5, 0x08,
+ },
+ .pair_alg = 1,
+ .authenticated = true,
+ .passkey_info = {
+ .passkey = {
+ .action = BLE_SM_IOACT_DISP,
+ .passkey = 46128,
+ },
+ },
+ };
+ ble_sm_test_util_us_lgcy_good(¶ms);
+}
+
+/**
+ * Legacy pairing
+ * Master: us
+ * Pair algorithm: out of band
+ * Initiator IO capabilities: 3
+ * Responder IO capabilities: 3
+ * Bonding: true
+ * Initiator address type: BLE_ADDR_TYPE_PUBLIC
+ * Responder address type: BLE_ADDR_TYPE_PUBLIC
+ * Initiator key distribution: 7
+ * Responder key distribution: 7
+ */
+TEST_CASE(ble_sm_lgcy_us_ob_iio3_rio3_b1_iat0_rat0_ik7_rk7)
+{
+ struct ble_sm_test_params params;
+
+ params = (struct ble_sm_test_params) {
+ .init_id_addr = {
+ 0x01, 0x01, 0x01, 0x07, 0x08, 0x01,
+ },
+ .resp_id_addr = {
+ 0x66, 0x33, 0x22, 0x66, 0x55, 0x11,
+ },
+ .pair_req = {
+ .io_cap = 0x03,
+ .oob_data_flag = 0x01,
+ .authreq = 0x05,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .pair_rsp = {
+ .io_cap = 0x03,
+ .oob_data_flag = 0x01,
+ .authreq = 0x05,
+ .max_enc_key_size = 0x10,
+ .init_key_dist = 0x07,
+ .resp_key_dist = 0x07,
+ },
+ .confirm_req[0] = {
+ .value = {
+ 0x2c, 0x3f, 0x3e, 0xf5, 0x39, 0x50, 0x78, 0x4a,
+ 0x3e, 0x14, 0x1a, 0x51, 0xfb, 0x8d, 0x6c, 0x10,
+ },
+ },
+ .confirm_rsp[0] = {
+ .value = {
+ 0xa9, 0x5c, 0x18, 0xb1, 0xdb, 0x51, 0x53, 0xa5,
+ 0xd3, 0xe7, 0x72, 0x17, 0xfb, 0xa8, 0xfb, 0xeb,
+ },
+ },
+ .random_req[0] = {
+ .value = {
+ 0x40, 0x2f, 0x42, 0xba, 0x10, 0x7b, 0x22, 0x65,
+ 0x84, 0xef, 0x63, 0xdf, 0x84, 0x7b, 0x04, 0xef,
+ },
+ },
+ .random_rsp[0] = {
+ .value = {
+ 0x94, 0xdc, 0x3c, 0xef, 0x65, 0xf7, 0x99, 0x2e,
+ 0x50, 0x29, 0x97, 0x2a, 0x57, 0xfd, 0xe6, 0x6a,
+ },
+ },
+ .enc_info_req = {
+ .ltk = {
+ 0x8c, 0x8e, 0x57, 0xba, 0x17, 0xbb, 0x04, 0xb5,
+ 0x16, 0xad, 0x31, 0x37, 0xf8, 0x3e, 0x4f, 0x21,
+ },
+ },
+ .master_id_req = {
+ .ediv = 0xaaa4,
+ .rand_val = 0xc0c830e300000000,
+ },
+ .id_info_req = {
+ .irk = {
+ 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d,
+ 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8,
+ },
+ },
+ .id_addr_info_req = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0x66, 0x33, 0x22, 0x66, 0x55, 0x11,
+ },
+ },
+ .sign_info_req = {
+ .sig_key = {
+ 0x5a, 0xe4, 0x2b, 0x40, 0x3a, 0x34, 0x1d, 0x94,
+ 0x56, 0x7d, 0xf4, 0x41, 0x23, 0x81, 0xc4, 0x11,
+ },
+ },
+ .enc_info_rsp = {
+ .ltk = {
+ 0xa6, 0x8e, 0xa0, 0xa4, 0x02, 0x64, 0x4c, 0x09,
+ 0x31, 0x25, 0x8a, 0x4f, 0x49, 0x35, 0xb0, 0x1f,
+ },
+ },
+ .master_id_rsp = {
+ .ediv = 0x57a3,
+ .rand_val = 0x8276af9000000000,
+ },
+ .id_info_rsp = {
+ .irk = {
+ 0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d,
+ 0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8,
+ },
+ },
+ .id_addr_info_rsp = {
+ .addr_type = 0,
+ .bd_addr = {
+ 0x01, 0x01, 0x01, 0x07, 0x08, 0x01,
+ },
+ },
+ .sign_info_rsp = {
+ .sig_key = {
+ 0x8e, 0xef, 0x53, 0x5c, 0x1b, 0x21, 0x67, 0x8d,
+ 0x07, 0x5e, 0xaa, 0xe8, 0x41, 0xa9, 0x36, 0xcf,
+ },
+ },
+ .stk = {
+ 0x4c, 0xd4, 0xa7, 0xee, 0x83, 0xcd, 0xd1, 0x9e,
+ 0x84, 0xeb, 0xb8, 0xd2, 0xaf, 0x4a, 0x71, 0x2e,
+ },
+ .pair_alg = 2,
+ .authenticated = 1,
+ .passkey_info = {
+ .passkey = {
+ .action = BLE_SM_IOACT_OOB,
+ .oob = {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
+ },
+ },
+ },
+ };
+ ble_sm_test_util_us_lgcy_good(¶ms);
+}
+
+TEST_SUITE(ble_sm_lgcy_test_suite)
+{
+ /*** No privacy. */
+
+ /* Peer as initiator. */
+ ble_sm_lgcy_peer_jw_iio4_rio3_b1_iat0_rat0_ik7_rk7();
+ ble_sm_lgcy_peer_pk_iio4_rio0_b1_iat0_rat0_ik7_rk7();
+
+ /* Us as initiator. */
+ ble_sm_lgcy_us_jw_iio3_rio3_b1_iat0_rat1_ik7_rk5();
+ ble_sm_lgcy_us_pk_iio4_rio2_b1_iat0_rat1_ik7_rk5();
+ ble_sm_lgcy_us_ob_iio3_rio3_b1_iat0_rat0_ik7_rk7();
+}
+
+#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/39dd36c8/net/nimble/host/src/test/ble_sm_sc_test.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/test/ble_sm_sc_test.c b/net/nimble/host/src/test/ble_sm_sc_test.c
index a237510..4d60f0c 100644
--- a/net/nimble/host/src/test/ble_sm_sc_test.c
+++ b/net/nimble/host/src/test/ble_sm_sc_test.c
@@ -45,9 +45,9 @@
*/
TEST_CASE(ble_sm_sc_peer_jw_iio3_rio3_b1_iat0_rat0_ik5_rk7)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0,
},
@@ -187,9 +187,9 @@ TEST_CASE(ble_sm_sc_peer_jw_iio3_rio3_b1_iat0_rat0_ik5_rk7)
*/
TEST_CASE(ble_sm_sc_peer_pk_iio0_rio2_b1_iat0_rat0_ik5_rk7)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0,
},
@@ -792,9 +792,9 @@ TEST_CASE(ble_sm_sc_peer_pk_iio0_rio2_b1_iat0_rat0_ik5_rk7)
*/
TEST_CASE(ble_sm_sc_peer_pk_iio2_rio0_b1_iat0_rat0_ik5_rk7)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0,
},
@@ -1397,9 +1397,9 @@ TEST_CASE(ble_sm_sc_peer_pk_iio2_rio0_b1_iat0_rat0_ik5_rk7)
*/
TEST_CASE(ble_sm_sc_peer_nc_iio1_rio1_b1_iat0_rat0_ik5_rk7)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0xca, 0x61, 0xa0, 0x67, 0x94, 0xe0,
},
@@ -1541,9 +1541,9 @@ TEST_CASE(ble_sm_sc_peer_nc_iio1_rio1_b1_iat0_rat0_ik5_rk7)
*/
TEST_CASE(ble_sm_sc_us_jw_iio3_rio4_b1_iat0_rat0_ik7_rk5)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0x01, 0x01, 0x01, 0x07, 0x08, 0x01,
},
@@ -1683,9 +1683,9 @@ TEST_CASE(ble_sm_sc_us_jw_iio3_rio4_b1_iat0_rat0_ik7_rk5)
*/
TEST_CASE(ble_sm_sc_us_pk_iio2_rio4_b1_iat0_rat0_ik7_rk5)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0x01, 0x01, 0x01, 0x07, 0x08, 0x01,
},
@@ -2288,9 +2288,9 @@ TEST_CASE(ble_sm_sc_us_pk_iio2_rio4_b1_iat0_rat0_ik7_rk5)
*/
TEST_CASE(ble_sm_sc_us_pk_iio0_rio4_b1_iat0_rat0_ik7_rk5)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0x01, 0x01, 0x01, 0x07, 0x08, 0x01,
},
@@ -2893,9 +2893,9 @@ TEST_CASE(ble_sm_sc_us_pk_iio0_rio4_b1_iat0_rat0_ik7_rk5)
*/
TEST_CASE(ble_sm_sc_us_nc_iio1_rio4_b1_iat0_rat0_ik7_rk5)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_id_addr = {
0x01, 0x01, 0x01, 0x07, 0x08, 0x01,
},
@@ -3037,9 +3037,9 @@ TEST_CASE(ble_sm_sc_us_nc_iio1_rio4_b1_iat0_rat0_ik7_rk5)
*/
TEST_CASE(ble_sm_sc_peer_jw_iio3_rio3_b1_iat2_rat2_ik7_rk7)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT,
.init_id_addr = {
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
@@ -3199,9 +3199,9 @@ TEST_CASE(ble_sm_sc_peer_jw_iio3_rio3_b1_iat2_rat2_ik7_rk7)
*/
TEST_CASE(ble_sm_sc_peer_nc_iio1_rio1_b1_iat2_rat2_ik3_rk3)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT,
.init_id_addr = {
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
@@ -3351,9 +3351,9 @@ TEST_CASE(ble_sm_sc_peer_nc_iio1_rio1_b1_iat2_rat2_ik3_rk3)
*/
TEST_CASE(ble_sm_sc_peer_pk_iio2_rio0_b1_iat2_rat2_ik7_rk3)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT,
.init_id_addr = {
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
@@ -3970,9 +3970,9 @@ TEST_CASE(ble_sm_sc_peer_pk_iio2_rio0_b1_iat2_rat2_ik7_rk3)
*/
TEST_CASE(ble_sm_sc_us_jw_iio3_rio3_b1_iat2_rat2_ik3_rk3)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT,
.init_id_addr = {
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
@@ -4120,9 +4120,9 @@ TEST_CASE(ble_sm_sc_us_jw_iio3_rio3_b1_iat2_rat2_ik3_rk3)
*/
TEST_CASE(ble_sm_sc_us_nc_iio1_rio1_b1_iat2_rat2_ik3_rk3)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT,
.init_id_addr = {
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
@@ -4272,9 +4272,9 @@ TEST_CASE(ble_sm_sc_us_nc_iio1_rio1_b1_iat2_rat2_ik3_rk3)
*/
TEST_CASE(ble_sm_sc_us_pk_iio2_rio0_b1_iat2_rat2_ik7_rk3)
{
- struct ble_sm_test_sc_params params;
+ struct ble_sm_test_params params;
- params = (struct ble_sm_test_sc_params) {
+ params = (struct ble_sm_test_params) {
.init_addr_type = BLE_ADDR_TYPE_RPA_PUB_DEFAULT,
.init_id_addr = {
0x06, 0x05, 0x04, 0x03, 0x02, 0x01,
@@ -4907,15 +4907,3 @@ TEST_SUITE(ble_sm_sc_test_suite)
}
#endif /* NIMBLE_OPT_SM */
-
-int
-ble_sm_sc_test_all(void)
-{
-#if !NIMBLE_OPT(SM_SC)
- return 0;
-#else
- ble_sm_sc_test_suite();
-
- return tu_any_failed;
-#endif
-}