@@ -846,11 +846,19 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
846
846
const ble_gap_evt_sec_info_request_t & req =
847
847
gap_evt.params .sec_info_request ;
848
848
849
- handler->on_ltk_request (
850
- connection,
851
- ediv_t ((uint8_t *)(&req.master_id .ediv )),
852
- rand_t (req.master_id .rand )
853
- );
849
+ uint8_t invalid_rand[BLE_GAP_SEC_RAND_LEN] = { 0 };
850
+ if (req.master_id .ediv == 0 &&
851
+ memcmp (req.master_id .rand , invalid_rand, sizeof (invalid_rand) == 0 )
852
+ ) {
853
+ // request ltk generated with secure connection
854
+ handler->on_ltk_request (connection);
855
+ } else {
856
+ handler->on_ltk_request (
857
+ connection,
858
+ ediv_t ((uint8_t *)(&req.master_id .ediv )),
859
+ rand_t (req.master_id .rand )
860
+ );
861
+ }
854
862
855
863
return true ;
856
864
}
@@ -948,34 +956,41 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
948
956
peer_dist = pairing_cb->initiator_dist ;
949
957
}
950
958
951
- if (own_dist. get_encryption () ) {
952
- handler->on_keys_distributed_local_ltk (
959
+ if (status. lesc ) {
960
+ handler->on_secure_connections_ltk_generated (
953
961
connection,
954
962
ltk_t (pairing_cb->own_enc_key .enc_info .ltk )
955
963
);
964
+ } else {
965
+ if (own_dist.get_encryption ()) {
966
+ handler->on_keys_distributed_local_ltk (
967
+ connection,
968
+ ltk_t (pairing_cb->own_enc_key .enc_info .ltk )
969
+ );
970
+
971
+ handler->on_keys_distributed_local_ediv_rand (
972
+ connection,
973
+ ediv_t (reinterpret_cast <uint8_t *>(
974
+ &pairing_cb->own_enc_key .master_id .ediv
975
+ )),
976
+ pairing_cb->own_enc_key .master_id .rand
977
+ );
978
+ }
956
979
957
- handler->on_keys_distributed_local_ediv_rand (
958
- connection,
959
- ediv_t (reinterpret_cast <uint8_t *>(
960
- &pairing_cb->own_enc_key .master_id .ediv
961
- )),
962
- pairing_cb->own_enc_key .master_id .rand
963
- );
964
- }
965
-
966
- if (peer_dist.get_encryption ()) {
967
- handler->on_keys_distributed_ltk (
968
- connection,
969
- ltk_t (pairing_cb->peer_enc_key .enc_info .ltk )
970
- );
971
-
972
- handler->on_keys_distributed_ediv_rand (
973
- connection,
974
- ediv_t (reinterpret_cast <uint8_t *>(
975
- &pairing_cb->peer_enc_key .master_id .ediv
976
- )),
977
- pairing_cb->peer_enc_key .master_id .rand
978
- );
980
+ if (peer_dist.get_encryption ()) {
981
+ handler->on_keys_distributed_ltk (
982
+ connection,
983
+ ltk_t (pairing_cb->peer_enc_key .enc_info .ltk )
984
+ );
985
+
986
+ handler->on_keys_distributed_ediv_rand (
987
+ connection,
988
+ ediv_t (reinterpret_cast <uint8_t *>(
989
+ &pairing_cb->peer_enc_key .master_id .ediv
990
+ )),
991
+ pairing_cb->peer_enc_key .master_id .rand
992
+ );
993
+ }
979
994
}
980
995
981
996
if (peer_dist.get_identity ()) {
0 commit comments