Skip to content

BLE fixes (SM whitelist creation, Nordic scatter file fix, missing TLS initialisation) #7089

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 5 commits into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
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
26 changes: 15 additions & 11 deletions features/FEATURE_BLE/ble/generic/SecurityDb.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,28 +584,32 @@ class SecurityDb {
WhitelistDbCb_t cb,
::Gap::Whitelist_t *whitelist
) {
for (size_t i = 0; i < get_entry_count() && i < whitelist->capacity; i++) {
for (size_t i = 0; i < get_entry_count() && whitelist->size < whitelist->capacity; i++) {
entry_handle_t db_handle = get_entry_handle_by_index(i);
SecurityDistributionFlags_t* flags = get_distribution_flags(db_handle);

if (!flags) {
continue;
}

SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle);
if (!identity) {
continue;
}

memcpy(
whitelist->addresses[whitelist->size].address,
identity->identity_address.data(),
sizeof(BLEProtocol::AddressBytes_t)
);

if (flags->peer_address_is_public) {
whitelist->addresses[i].type = BLEProtocol::AddressType::PUBLIC;
whitelist->addresses[whitelist->size].type = BLEProtocol::AddressType::PUBLIC;
} else {
whitelist->addresses[i].type = BLEProtocol::AddressType::RANDOM_STATIC;
whitelist->addresses[whitelist->size].type = BLEProtocol::AddressType::RANDOM_STATIC;
}

SecurityEntryIdentity_t* identity = read_in_entry_peer_identity(db_handle);
if (identity) {
memcpy(
whitelist->addresses[i].address,
identity->identity_address.data(),
sizeof(BLEProtocol::AddressBytes_t)
);
}
whitelist->size++;
}

cb(whitelist);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ ble_error_t GenericSecurityManager::purgeAllBondingState(void) {
ble_error_t GenericSecurityManager::generateWhitelistFromBondTable(Gap::Whitelist_t *whitelist) const {
if (!_db) return BLE_ERROR_INITIALIZATION_INCOMPLETE;
if (eventHandler) {
if (!whitelist) {
return BLE_ERROR_INVALID_PARAM;
}
_db->generate_whitelist_from_bond_table(
mbed::callback(eventHandler, &::SecurityManager::EventHandler::whitelistFromBondTable),
whitelist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ void nRF5xGap::on_connection(Gap::Handle_t handle, const ble_gap_evt_connected_t
const resolving_list_entry_t* entry = get_sm().resolve_address(
evt.peer_addr.addr
);
MBED_ASSERT(entry == NULL);
MBED_ASSERT(entry != NULL);

peer_addr_type = convert_identity_address(entry->peer_identity_address_type);
peer_address = entry->peer_identity_address.data();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace vendor {
namespace nordic {

CryptoToolbox::CryptoToolbox() : _initialized(false) {
mbedtls_platform_setup(&_platform_context);
mbedtls_entropy_init(&_entropy_context);
mbedtls_ecp_group_init(&_group);
int err = mbedtls_ecp_group_load(
Expand All @@ -59,6 +60,7 @@ CryptoToolbox::CryptoToolbox() : _initialized(false) {
CryptoToolbox::~CryptoToolbox() {
mbedtls_ecp_group_free(&_group);
mbedtls_entropy_free(&_entropy_context);
mbedtls_platform_teardown(&_platform_context);
}

bool CryptoToolbox::generate_keys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class CryptoToolbox : mbed::NonCopyable<CryptoToolbox> {
void swap_endian(uint8_t* buf, size_t len);

bool _initialized;
mbedtls_platform_context _platform_context;
mbedtls_entropy_context _entropy_context;
mbedtls_ecp_group _group;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
ER_IROM1 MBED_APP_START MBED_APP_SIZE {
*.o (RESET, +First)
*(InRoot$$Sections)
__start_sdh_soc_observers *(sdh_soc_observers) __stop_sdh_soc_observers
__start_sdh_stack_observers *(sdh_stack_observers) __stop_sdh_stack_observers
__start_sdh_req_observers *(sdh_req_observers) __stop_sdh_req_observers
__start_sdh_state_observers *(sdh_state_observers) __stop_sdh_state_observers
__start_sdh_ble_observers *(sdh_ble_observers) __stop_sdh_ble_observers
.ANY (+RO)
}
RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
ER_IROM1 MBED_APP_START MBED_APP_SIZE {
*.o (RESET, +First)
*(InRoot$$Sections)
__start_sdh_soc_observers *(sdh_soc_observers) __stop_sdh_soc_observers
__start_sdh_stack_observers *(sdh_stack_observers) __stop_sdh_stack_observers
__start_sdh_req_observers *(sdh_req_observers) __stop_sdh_req_observers
__start_sdh_state_observers *(sdh_state_observers) __stop_sdh_state_observers
__start_sdh_ble_observers *(sdh_ble_observers) __stop_sdh_ble_observers
.ANY (+RO)
}
RW_IRAM0 MBED_RAM0_START UNINIT MBED_RAM0_SIZE { ;no init section
Expand Down