Skip to content

Commit b8fe37a

Browse files
disable ECDH if the platform doesn't support it
otherwise you get linker errors
1 parent ebb50a6 commit b8fe37a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xPalSecurityManager.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ nRF5xSecurityManager::~nRF5xSecurityManager()
106106

107107
ble_error_t nRF5xSecurityManager::initialize()
108108
{
109+
#if defined(MBEDTLS_ECDH_C)
109110
if (_crypto.generate_keys(
110111
make_ArrayView(X),
111112
make_ArrayView(Y),
@@ -115,6 +116,8 @@ ble_error_t nRF5xSecurityManager::initialize()
115116
}
116117

117118
return BLE_ERROR_INTERNAL_STACK_FAILURE;
119+
#endif
120+
return BLE_ERROR_NONE;
118121
}
119122

120123
ble_error_t nRF5xSecurityManager::terminate()
@@ -210,6 +213,7 @@ nRF5xSecurityManager::get_resolving_list() {
210213

211214
const nRF5xSecurityManager::resolving_list_entry_t*
212215
nRF5xSecurityManager::resolve_address(const address_t& resolvable_address) {
216+
#if defined(MBEDTLS_ECDH_C)
213217
typedef byte_array_t<CryptoToolbox::hash_size_> hash_t;
214218

215219
for (size_t i = 0; i < resolving_list_entry_count; ++i) {
@@ -233,6 +237,7 @@ nRF5xSecurityManager::resolve_address(const address_t& resolvable_address) {
233237
return &entry;
234238
}
235239
}
240+
#endif
236241
return NULL;
237242
}
238243

@@ -715,6 +720,7 @@ ble_error_t nRF5xSecurityManager::send_keypress_notification(
715720

716721
ble_error_t nRF5xSecurityManager::generate_secure_connections_oob()
717722
{
723+
#if defined(MBEDTLS_ECDH_C)
718724
ble_gap_lesc_p256_pk_t own_secret;
719725
ble_gap_lesc_oob_data_t oob_data;
720726

@@ -734,6 +740,8 @@ ble_error_t nRF5xSecurityManager::generate_secure_connections_oob()
734740
}
735741

736742
return convert_sd_error(err);
743+
#endif
744+
return BLE_ERROR_NOT_IMPLEMENTED;
737745
}
738746

739747
nRF5xSecurityManager& nRF5xSecurityManager::get_security_manager()
@@ -877,6 +885,7 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
877885
}
878886

879887
case BLE_GAP_EVT_LESC_DHKEY_REQUEST: {
888+
#if defined(MBEDTLS_ECDH_C)
880889
const ble_gap_evt_lesc_dhkey_request_t& dhkey_request =
881890
gap_evt.params.lesc_dhkey_request;
882891

@@ -895,7 +904,7 @@ bool nRF5xSecurityManager::sm_handler(const ble_evt_t *evt)
895904
if (dhkey_request.oobd_req) {
896905
handler->on_secure_connections_oob_request(connection);
897906
}
898-
907+
#endif
899908
return true;
900909
}
901910

@@ -1138,9 +1147,10 @@ ble_gap_sec_keyset_t nRF5xSecurityManager::make_keyset(
11381147
}
11391148

11401149
// copy public keys used
1150+
#if defined(MBEDTLS_ECDH_C)
11411151
memcpy(pairing_cb.own_pk.pk, X.data(), X.size());
11421152
memcpy(pairing_cb.own_pk.pk + X.size(), Y.data(), Y.size());
1143-
1153+
#endif
11441154
return keyset;
11451155
}
11461156

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NRF5/source/nRF5xPalSecurityManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
#include "ble/BLETypes.h"
2121
#include "ble/pal/PalSecurityManager.h"
2222
#include "nrf_ble.h"
23+
#if defined(MBEDTLS_ECDH_C)
2324
#include "nRF5xCrypto.h"
25+
#endif
2426

2527
namespace ble {
2628
namespace pal {
@@ -381,10 +383,12 @@ class nRF5xSecurityManager : public ::ble::pal::SecurityManager {
381383
void release_all_pairing_cb();
382384

383385
pairing_control_block_t* _control_blocks;
386+
#if defined(MBEDTLS_ECDH_C)
384387
CryptoToolbox _crypto;
385388
ble::public_key_coord_t X;
386389
ble::public_key_coord_t Y;
387390
ble::public_key_coord_t secret;
391+
#endif
388392

389393
static const size_t MAX_RESOLVING_LIST_ENTRIES = BLE_GAP_WHITELIST_IRK_MAX_COUNT;
390394

0 commit comments

Comments
 (0)