Skip to content

Commit 4cfcadd

Browse files
committed
BLE: Fix SM random number generation.
Ensure the more than 8 random bytes are fetched from the stack.
1 parent b28e115 commit 4cfcadd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

connectivity/FEATURE_BLE/source/generic/SecurityManagerImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ ble_error_t SecurityManager::get_random_data(uint8_t *buffer, size_t size)
11251125
while (size) {
11261126
/* fill out the buffer by reading the random data in chunks
11271127
* and copying it until reaching the set size */
1128-
size_t copy_size = std::max(size, random_data.size());
1128+
size_t copy_size = std::min(size, random_data.size());
11291129
ble_error_t ret = _pal.get_random_data(random_data);
11301130
if (ret != BLE_ERROR_NONE) {
11311131
return ret;

0 commit comments

Comments
 (0)