Skip to content

BLE: Fix Security Manager key generation #14125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ ble_error_t SecurityManager::init_signing()
sign_count_t local_sign_counter = _db->get_local_sign_counter();

csrk_t csrk;
if (!pcsrk) {
if (!pcsrk || *pcsrk == csrk_t{}) {
ble_error_t ret = get_random_data(csrk.data(), csrk.size());
if (ret != BLE_ERROR_NONE) {
return ret;
Expand Down Expand Up @@ -1125,7 +1125,7 @@ ble_error_t SecurityManager::get_random_data(uint8_t *buffer, size_t size)
while (size) {
/* fill out the buffer by reading the random data in chunks
* and copying it until reaching the set size */
size_t copy_size = std::max(size, random_data.size());
size_t copy_size = std::min(size, random_data.size());
ble_error_t ret = _pal.get_random_data(random_data);
if (ret != BLE_ERROR_NONE) {
return ret;
Expand Down