@@ -760,6 +760,16 @@ nRF5xSecurityManager& nRF5xSecurityManager::get_security_manager()
760
760
return _security_manager;
761
761
}
762
762
763
+ bool is_rand_invalid (const uint8_t * rand)
764
+ {
765
+ for (int i = 0 ; i < 8 ; ++i) {
766
+ if (rand[i]) {
767
+ return false ;
768
+ }
769
+ }
770
+ return true ;
771
+ }
772
+
763
773
bool nRF5xSecurityManager::sm_handler (const ble_evt_t *evt)
764
774
{
765
775
nRF5xSecurityManager& self = nRF5xSecurityManager::get_security_manager ();
@@ -846,9 +856,8 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
846
856
const ble_gap_evt_sec_info_request_t & req =
847
857
gap_evt.params .sec_info_request ;
848
858
849
- uint8_t invalid_rand[BLE_GAP_SEC_RAND_LEN] = { 0 };
850
859
if (req.master_id .ediv == 0 &&
851
- memcmp (req.master_id .rand , invalid_rand, sizeof (invalid_rand) == 0 )
860
+ is_rand_invalid (req.master_id .rand )
852
861
) {
853
862
// request ltk generated with secure connection
854
863
handler->on_ltk_request (connection);
@@ -956,9 +965,8 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
956
965
peer_dist = pairing_cb->initiator_dist ;
957
966
}
958
967
959
- uint8_t invalid_rand[BLE_GAP_SEC_RAND_LEN] = { 0 };
960
968
if (pairing_cb->own_enc_key .master_id .ediv == 0 &&
961
- memcmp (pairing_cb->own_enc_key .master_id .rand , invalid_rand, sizeof (invalid_rand) == 0 )
969
+ is_rand_invalid (pairing_cb->own_enc_key .master_id .rand )
962
970
) {
963
971
handler->on_secure_connections_ltk_generated (
964
972
connection,
0 commit comments