mirror of https://github.com/ARMmbed/mbed-os.git
moved fucntion impl to match position in header
parent
eb899bc798
commit
d0c4186b9e
|
@ -434,6 +434,34 @@ void GenericSecurityManager::check_against_irk_cb(
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GenericSecurityManager::check_against_identity_address(
|
||||||
|
const address_t peer_address,
|
||||||
|
const irk_t *irk
|
||||||
|
) {
|
||||||
|
/* we need to verify the identity by encrypting the
|
||||||
|
* PRAND part with the IRK key and checking the result
|
||||||
|
* @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part H - 2.2.2 */
|
||||||
|
octet_type_t<6> prand_hash(peer_address.data(), 6);
|
||||||
|
|
||||||
|
/* remove the hash and leave only prand */
|
||||||
|
prand_hash[3] = 0;
|
||||||
|
prand_hash[4] = 0;
|
||||||
|
prand_hash[5] = 0;
|
||||||
|
|
||||||
|
_pal.encrypt_data(irk, prand_hash.data());
|
||||||
|
|
||||||
|
/* prand_hash now contains the hash result in the first 3 octects
|
||||||
|
* compare it with the hash in the peer identity address */
|
||||||
|
|
||||||
|
/* can't use memcmp because of address_t constness */
|
||||||
|
if ((prand_hash[0] == peer_address[3])
|
||||||
|
|| (prand_hash[1] == peer_address[4])
|
||||||
|
|| (prand_hash[2] == peer_address[5])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Keys
|
// Keys
|
||||||
//
|
//
|
||||||
|
@ -922,34 +950,6 @@ void GenericSecurityManager::on_connected(connection_handle_t connection, addres
|
||||||
entry->master = is_master;
|
entry->master = is_master;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GenericSecurityManager::check_against_identity_address(
|
|
||||||
const address_t peer_address,
|
|
||||||
const irk_t *irk
|
|
||||||
) {
|
|
||||||
/* we need to verify the identity by encrypting the
|
|
||||||
* PRAND part with the IRK key and checking the result
|
|
||||||
* @see BLUETOOTH SPECIFICATION Version 5.0 | Vol 3, Part H - 2.2.2 */
|
|
||||||
octet_type_t<6> prand_hash(peer_address.data(), 6);
|
|
||||||
|
|
||||||
/* remove the hash and leave only prand */
|
|
||||||
prand_hash[3] = 0;
|
|
||||||
prand_hash[4] = 0;
|
|
||||||
prand_hash[5] = 0;
|
|
||||||
|
|
||||||
_pal.encrypt_data(irk, prand_hash.data());
|
|
||||||
|
|
||||||
/* prand_hash now contains the hash result in the first 3 octects
|
|
||||||
* compare it with the hash in the peer identity address */
|
|
||||||
|
|
||||||
/* can't use memcmp because of address_t constness */
|
|
||||||
if ((prand_hash[0] == peer_address[3])
|
|
||||||
|| (prand_hash[1] == peer_address[4])
|
|
||||||
|| (prand_hash[2] == peer_address[5])) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} /* namespace generic */
|
} /* namespace generic */
|
||||||
} /* namespace ble */
|
} /* namespace ble */
|
||||||
|
|
Loading…
Reference in New Issue