Cordio PAL security manager: Copy locally own CSRK

The stack does not copy csrk when DmSecSetLocalCsrk is invoked; it just retains a pointer to it. Therefore a copy is kept inside the pal.
pull/6932/head
Vincent Coubard 2018-05-01 11:35:16 +01:00
parent e4813f4fe9
commit 2da6fa3947
2 changed files with 5 additions and 1 deletions

View File

@ -327,6 +327,7 @@ private:
bool _lesc_keys_generated;
uint8_t _public_key_x[SEC_ECC_KEY_LEN];
irk_t _irk;
csrk_t _csrk;
};
} // cordio

View File

@ -273,8 +273,11 @@ ble_error_t CordioSecurityManager::set_csrk(
const csrk_t& csrk,
sign_count_t sign_counter
) {
_csrk = csrk;
DmSecSetLocalCsrk(_csrk.data());
// extra set the sign counter used by the client
CordioAttClient::get_client().set_sign_counter(sign_counter);
DmSecSetLocalCsrk(const_cast<uint8_t*>(csrk.data()));
return BLE_ERROR_NONE;
}