You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2024/09/02 19:41:05 UTC

(mynewt-nimble) branch master updated (05cef9b1f -> baf2930d3)

This is an automated email from the ASF dual-hosted git repository.

janc pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


    from 05cef9b1f apps/auracast: Make the code compile on native target
     new 22d5e0e04 host: sm: ignore security request
     new 2ed13eb7f host: test: fix SM test case
     new baf2930d3 host: tests: add SM test case

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nimble/host/src/ble_sm.c                |  8 ++++++++
 nimble/host/test/src/ble_sm_test.c      | 36 +++++++++++++++++++++++++++++++--
 nimble/host/test/src/ble_sm_test_util.c |  2 +-
 nimble/host/test/src/ble_sm_test_util.h |  3 +++
 4 files changed, 46 insertions(+), 3 deletions(-)


(mynewt-nimble) 01/03: host: sm: ignore security request

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 22d5e0e042cacce4e6bd7f4a1463637c307bed96
Author: Piotr Narajowski <pi...@codecoup.pl>
AuthorDate: Thu Aug 1 16:47:03 2024 +0200

    host: sm: ignore security request
    
    We should ignore second security request pairing has already started
---
 nimble/host/src/ble_sm.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/nimble/host/src/ble_sm.c b/nimble/host/src/ble_sm.c
index bb1dfe084..eed5e3638 100644
--- a/nimble/host/src/ble_sm.c
+++ b/nimble/host/src/ble_sm.c
@@ -2007,6 +2007,14 @@ ble_sm_sec_req_rx(uint16_t conn_handle, struct os_mbuf **om,
     ble_hs_lock();
 
     conn = ble_hs_conn_find_assert(conn_handle);
+
+    /* Check if pairing procedure is already in progress */
+    if (ble_sm_proc_find(conn_handle, BLE_SM_PROC_STATE_PAIR, 1, NULL)) {
+        ble_hs_unlock();
+        res->app_status = 0;
+        return;
+    }
+
     if (!(conn->bhc_flags & BLE_HS_CONN_F_MASTER)) {
         res->app_status = BLE_HS_SM_US_ERR(BLE_SM_ERR_CMD_NOT_SUPP);
         res->sm_err = BLE_SM_ERR_CMD_NOT_SUPP;


(mynewt-nimble) 02/03: host: test: fix SM test case

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit 2ed13eb7f4de575c70357a855784db109e16b296
Author: Piotr Narajowski <pi...@codecoup.pl>
AuthorDate: Thu Aug 8 09:50:37 2024 +0200

    host: test: fix SM test case
    
    This test case should check if security request from peer sent after
    pairing request was ignored.
---
 nimble/host/test/src/ble_sm_test.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/nimble/host/test/src/ble_sm_test.c b/nimble/host/test/src/ble_sm_test.c
index 2ba1678d7..7a2994be7 100644
--- a/nimble/host/test/src/ble_sm_test.c
+++ b/nimble/host/test/src/ble_sm_test.c
@@ -415,13 +415,14 @@ TEST_CASE_SELF(ble_sm_test_case_peer_sec_req_inval)
     fail.reason = BLE_SM_ERR_CMD_NOT_SUPP;
     ble_sm_test_util_verify_tx_pair_fail(&fail);
 
-    /*** Pairing already in progress; ignore security request. */
+    /*** Pairing already in progress; ignore security request before pairing
+     * response was received. */
     ble_hs_atomic_conn_set_flags(2, BLE_HS_CONN_F_MASTER, 1);
     rc = ble_sm_pair_initiate(2);
     TEST_ASSERT_FATAL(rc == 0);
     ble_hs_test_util_prev_tx_queue_clear();
 
-    ble_sm_test_util_rx_sec_req(2, &sec_req, BLE_HS_EALREADY);
+    ble_sm_test_util_rx_sec_req(2, &sec_req, 0);
     TEST_ASSERT(ble_hs_test_util_prev_tx_queue_sz() == 0);
 
     ble_hs_test_util_assert_mbufs_freed(NULL);


(mynewt-nimble) 03/03: host: tests: add SM test case

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

janc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git

commit baf2930d32c21222b77086181d842301bff9721f
Author: Piotr Narajowski <pi...@codecoup.pl>
AuthorDate: Fri Aug 23 16:11:31 2024 +0200

    host: tests: add SM test case
    
    This covers the case where security request sent from peer should be rejected
    after pairing response was received.
    Move ble_sm_test_util_rx_pair_rsp() declaration.
---
 nimble/host/test/src/ble_sm_test.c      | 31 +++++++++++++++++++++++++++++++
 nimble/host/test/src/ble_sm_test_util.c |  2 +-
 nimble/host/test/src/ble_sm_test_util.h |  3 +++
 3 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/nimble/host/test/src/ble_sm_test.c b/nimble/host/test/src/ble_sm_test.c
index 7a2994be7..dcdbaf01e 100644
--- a/nimble/host/test/src/ble_sm_test.c
+++ b/nimble/host/test/src/ble_sm_test.c
@@ -428,6 +428,36 @@ TEST_CASE_SELF(ble_sm_test_case_peer_sec_req_inval)
     ble_hs_test_util_assert_mbufs_freed(NULL);
 }
 
+TEST_CASE_SELF(ble_sm_test_case_peer_sec_req_reject)
+{
+    struct ble_sm_sec_req sec_req;
+    int rc;
+
+    struct ble_sm_pair_cmd pair_rsp = {0x04, 0, 0x0D, 10, 0x02, 0x02};
+
+    ble_sm_test_util_init();
+
+    ble_sm_dbg_set_next_pair_rand(((uint8_t[16]) {0}));
+
+    ble_hs_test_util_create_conn(2, ((uint8_t[6]) {1,2,3,5,6,7}),
+                                 ble_sm_test_util_conn_cb,
+                                 NULL);
+
+    /*** Pairing already in progress; reject security request after pairing
+     * response was received. */
+
+    ble_hs_atomic_conn_set_flags(2, BLE_HS_CONN_F_MASTER, 1);
+    rc = ble_sm_pair_initiate(2);
+    TEST_ASSERT_FATAL(rc == 0);
+    ble_hs_test_util_prev_tx_queue_clear();
+
+    ble_sm_test_util_rx_pair_rsp(2, &pair_rsp, 0);
+    ble_sm_test_util_rx_sec_req(2, &sec_req, BLE_HS_EALREADY);
+    TEST_ASSERT(ble_hs_test_util_prev_tx_queue_sz() != 0);
+
+    ble_hs_test_util_assert_mbufs_freed(NULL);
+}
+
 /*****************************************************************************
  * $us                                                                       *
  *****************************************************************************/
@@ -509,5 +539,6 @@ TEST_SUITE(ble_sm_gen_test_suite)
     ble_sm_test_case_peer_bonding_bad();
     ble_sm_test_case_conn_broken();
     ble_sm_test_case_peer_sec_req_inval();
+    ble_sm_test_case_peer_sec_req_reject();
 }
 #endif
diff --git a/nimble/host/test/src/ble_sm_test_util.c b/nimble/host/test/src/ble_sm_test_util.c
index e3becdf86..74d40e8b5 100644
--- a/nimble/host/test/src/ble_sm_test_util.c
+++ b/nimble/host/test/src/ble_sm_test_util.c
@@ -717,7 +717,7 @@ ble_sm_test_util_rx_pair_req(uint16_t conn_handle,
                                  req, rx_status);
 }
 
-static void
+void
 ble_sm_test_util_rx_pair_rsp(uint16_t conn_handle, struct ble_sm_pair_cmd *rsp,
                              int rx_status)
 {
diff --git a/nimble/host/test/src/ble_sm_test_util.h b/nimble/host/test/src/ble_sm_test_util.h
index d9aa3805c..3ddc86c1f 100644
--- a/nimble/host/test/src/ble_sm_test_util.h
+++ b/nimble/host/test/src/ble_sm_test_util.h
@@ -96,6 +96,9 @@ void ble_sm_test_util_io_check_post(
 void ble_sm_test_util_rx_sec_req(uint16_t conn_handle,
                                  struct ble_sm_sec_req *cmd,
                                  int exp_status);
+void ble_sm_test_util_rx_pair_rsp(uint16_t conn_handle,
+                                  struct ble_sm_pair_cmd *rsp,
+                                  int rx_status);
 void ble_sm_test_util_verify_tx_pair_fail(struct ble_sm_pair_fail *exp_cmd);
 void ble_sm_test_util_us_lgcy_good(struct ble_sm_test_params *params);
 void ble_sm_test_util_peer_fail_inval(int we_are_master,