From: zhiweijian Date: Fri, 23 Nov 2018 10:06:02 +0000 (+0800) Subject: Component/bt: fix save keys when auth mode without bond X-Git-Tag: v3.2-beta3~71^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2c1e3d1ef2c4f647ea62793bfcabe0d192a9b594;p=esp-idf Component/bt: fix save keys when auth mode without bond --- diff --git a/components/bt/bluedroid/btc/core/btc_dm.c b/components/bt/bluedroid/btc/core/btc_dm.c index fa50a99c73..f8e6c3eaf8 100644 --- a/components/bt/bluedroid/btc/core/btc_dm.c +++ b/components/bt/bluedroid/btc/core/btc_dm.c @@ -261,6 +261,10 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl) BTC_TRACE_DEBUG ("%s, - pairing_cb.bd_addr: %08x%04x", __func__, (pairing_cb.bd_addr[0] << 24) + (pairing_cb.bd_addr[1] << 16) + (pairing_cb.bd_addr[2] << 8) + pairing_cb.bd_addr[3], (pairing_cb.bd_addr[4] << 8) + pairing_cb.bd_addr[5]); + // Check if need to save BLE keys + if((p_auth_cmpl->auth_mode & SMP_AUTH_GEN_BOND) == 0) { + return; + } if (btc_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) { btc_storage_set_remote_addr_type(&bdaddr, p_auth_cmpl->addr_type, true); } diff --git a/components/idf_test/integration_test/TC_IT_BTSTK_SMP.yml b/components/idf_test/integration_test/TC_IT_BTSTK_SMP.yml index 344913db8b..c6c34923cd 100644 --- a/components/idf_test/integration_test/TC_IT_BTSTK_SMP.yml +++ b/components/idf_test/integration_test/TC_IT_BTSTK_SMP.yml @@ -2028,22 +2028,18 @@ test cases: - ['P SSC2 C +BLE:GattsDisconnect', 'P SSC1 C +BLE:GattcDisconnect,OK'] - ID: BTSTK_SMP_07001 <<: *SMP_CASE - test point 2: BLE SMP bond and NVS test - summary: BLE SMP initiator bond with lagecy pairing + test point 2: BLE SMP no bond test and reconnect + summary: BLE SMP initiator with master passkey entry and reconnect steps: | - 1. DUT1 and DUT2 SMP bond with lagecy pairing + 1. DUT1 and DUT2 SMP with master passkey entry 2. DUT1 disconnect 3. DUT1 connect to DUT2 - 4. DUT1 disconnect - 5. DUT1 reboot - 6. DUT1 connect to DUT2 + 4. DUT2 send auth request expected result: | 1. succeed 2. succeed - 3. connect succeed without pairing again + 3. connect succeed 4. succeed - 5. succeed - 6. connect succeed without pairing again cmd set: - "" - *config_master_passkey_entry @@ -2059,56 +2055,31 @@ test cases: - - "SSC SSC1 bleconn -C -p 0x10 -a " - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC[1-2] reboot" - - ['P SSC[1-2] C !!!ready!!!'] - - - "SSC SSC[1-2] ble -R" - - ['R SSC[1-2] C +BLE:'] - - - "SSC SSC2 gatts -S -z load -p 0xA0" - - ['R SSC2 C +GATTS:StartService,OK,A000'] - - - "SSC SSC2 bleadv -L -c 0 -t 3" - - ['R SSC2 C +BLEADV:SetAdv,OK'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - - "SSC SSC[1-2] blesmp -L -c [1,0]" - - ['R SSC[1-2] C +BLESMP:OK'] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] + - ['P SSC[1-2] C +BLESMP:AuthComplete,Success'] - ID: BTSTK_SMP_07002 <<: *SMP_CASE - test point 2: BLE SMP bond and NVS test - summary: BLE SMP initiator bond with secure connection pairing + test point 2: BLE SMP no bond test and reboot + summary: BLE SMP initiator with master passkey entry and reboot steps: | - 1. DUT1 and DUT2 SMP bond with secure connection pairing - 2. DUT1 disconnect + 1. DUT1 and DUT2 SMP bond with lagecy pairing + 2. DUT1 reboot 3. DUT1 connect to DUT2 - 4. DUT1 disconnect - 5. DUT1 reboot - 6. DUT1 connect to DUT2 + 4. DUT2 send auth requst expected result: | 1. succeed 2. succeed - 3. connect succeed without pairing again - 4. succeed - 5. succeed - 6. connect succeed without pairing again + 3. connect succeed + 4. fail cmd set: - "" - - *config_numberic_comparision + - *config_master_passkey_entry - - "SSC SSC1 bleconn -C -p 0x10 -a " - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - "SSC SSC1 blesmp -E -r -z Enc" - ['P SSC2 C +BLESMP:SecReq'] - - "SSC SSC2 blesmp -R -a 1 -r " - - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] - - - "SSC SSC[1-2] blesmp -C -r -a 1" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - *disconnect - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" + - ['P SSC1 C +BLESMP:PassKeyReq', 'P SSC2 A :BLESMP:PassKeyNotify,(\d+)'] + - - "SSC SSC1 blesmp -K -r -a 1 -k " - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - "SSC SSC[1-2] reboot" - ['P SSC[1-2] C !!!ready!!!'] @@ -2125,76 +2096,63 @@ test cases: - - "SSC SSC1 bleconn -C -p 0x10 -a " - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] + - ['P SSC2 C +BLESMP:OK'] + - - DELAY 10 + - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - ID: BTSTK_SMP_07003 <<: *SMP_CASE - test point 2: BLE SMP bond and NVS test - summary: BLE SMP responder bond with lagecy pairing + test point 2: BLE SMP no bond test and reconnect + summary: BLE SMP initiator numberic comparision and reconnect steps: | - 1. DUT1 and DUT2 SMP bond with lagecy pairing + 1. DUT1 and DUT2 SMP with numberic comparision 2. DUT1 disconnect 3. DUT1 connect to DUT2 - 4. DUT1 disconnect - 5. DUT1 reboot - 6. DUT1 connect to DUT2 + 4. DUT2 send auth requst expected result: | 1. succeed 2. succeed - 3. connect succeed without pairing again + 3. connect succeed 4. succeed - 5. succeed - 6. connect succeed without pairing again cmd set: - "" - - *config_master_passkey_entry - - *master_passkey_entry_pair - - *disconnect + - *config_numberic_comparision - - "SSC SSC1 bleconn -C -p 0x10 -a " - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" + - - "SSC SSC1 blesmp -E -r -z Enc" + - ['P SSC2 C +BLESMP:SecReq'] + - - "SSC SSC2 blesmp -R -a 1 -r " + - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] + - - "SSC SSC[1-2] blesmp -C -r -a 1" - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - - "SSC SSC[1-2] reboot" - - ['P SSC[1-2] C !!!ready!!!'] - - - "SSC SSC[1-2] ble -R" - - ['R SSC[1-2] C +BLE:'] - - - "SSC SSC2 gatts -S -z load -p 0xA0" - - ['R SSC2 C +GATTS:StartService,OK,A000'] - - - "SSC SSC2 bleadv -L -c 0 -t 3" - - ['R SSC2 C +BLEADV:SetAdv,OK'] - - - "SSC SSC2 bleadv -D -z start" - - ['R SSC2 C +BLEADV:OK'] - - - "SSC SSC[1-2] blesmp -L -c [1,0]" - - ['R SSC[1-2] C +BLESMP:OK'] + - *disconnect - - "SSC SSC1 bleconn -C -p 0x10 -a " - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] + - ['P SSC[1-2] C +BLESMP:AuthComplete,Success'] - ID: BTSTK_SMP_07004 <<: *SMP_CASE - test point 2: BLE SMP bond and NVS test - summary: BLE SMP responder bond with secure connection pairing + test point 2: BLE SMP no bond test and reconnect + summary: BLE SMP initiator numberic comparision and reconnect steps: | - 1. DUT1 and DUT2 SMP bond with secure connection pairing + 1. DUT1 and DUT2 SMP with numberic comparision 2. DUT1 disconnect - 3. DUT1 connect to DUT2 - 4. DUT1 disconnect - 5. DUT1 reboot - 6. DUT1 connect to DUT2 + 3. DUT1 and DUT2 reboot + 4. DUT2 send auth requst expected result: | 1. succeed 2. succeed - 3. connect succeed without pairing again - 4. succeed - 5. succeed - 6. connect succeed without pairing again + 3. connect succeed + 4. failed cmd set: - "" - *config_numberic_comparision - - *numberic_comparision_pair - - *disconnect - - "SSC SSC1 bleconn -C -p 0x10 -a " - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - - "SSC SSC2 blesmp -E -r -z Enc" + - - "SSC SSC1 blesmp -E -r -z Enc" + - ['P SSC2 C +BLESMP:SecReq'] + - - "SSC SSC2 blesmp -R -a 1 -r " + - ['R SSC2 A :BLESMP:NCReq,(\d+)', 'R SSC1 C NCReq P '] + - - "SSC SSC[1-2] blesmp -C -r -a 1" - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] - - "SSC SSC[1-2] reboot" - ['P SSC[1-2] C !!!ready!!!'] @@ -2211,7 +2169,9 @@ test cases: - - "SSC SSC1 bleconn -C -p 0x10 -a " - ['P SSC1 C +BLE:GattcConnect,OK', 'P SSC2 C +BLE:GattsConnect'] - - "SSC SSC2 blesmp -E -r -z Enc" - - ['P SSC[1-2] C +BLESMP:AuthComplete,Success,0'] + - ['P SSC2 C +BLESMP:OK'] + - - DELAY 10 + - ['P SSC[1-2] C +BLESMP:AuthComplete,Fail'] - ID: BTSTK_SMP_08001 <<: *SMP_CASE test point 2: BLE SMP bond item management test