diff --git a/libraries/Bluefruit52Lib/examples/Central/central_pairing/central_pairing.ino b/libraries/Bluefruit52Lib/examples/Central/central_pairing/central_pairing.ino index 673856a9..50c24f06 100644 --- a/libraries/Bluefruit52Lib/examples/Central/central_pairing/central_pairing.ino +++ b/libraries/Bluefruit52Lib/examples/Central/central_pairing/central_pairing.ino @@ -39,7 +39,6 @@ #include #include #include -#include #ifdef USE_ARCADA #include diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino index e064f8fa..42677994 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/pairing_passkey/pairing_passkey.ino @@ -37,7 +37,6 @@ #include #include #include -#include #ifdef USE_ARCADA #include diff --git a/libraries/Bluefruit52Lib/src/BLEPairing.cpp b/libraries/Bluefruit52Lib/src/BLEPairing.cpp index c4b4e8b4..b4edbdfa 100644 --- a/libraries/Bluefruit52Lib/src/BLEPairing.cpp +++ b/libraries/Bluefruit52Lib/src/BLEPairing.cpp @@ -86,7 +86,6 @@ BLEPairing::BLEPairing(void) bool BLEPairing::begin(void) { - #ifdef NRF_CRYPTOCELL // Initalize Crypto lib for LESC (safe to call multiple times) nRFCrypto.begin(); @@ -275,22 +274,21 @@ void BLEPairing::_eventHandler(ble_evt_t* evt) .p_enc_key = &_bond_keys.own_enc, .p_id_key = NULL, .p_sign_key = NULL, - .p_pk = (ble_gap_lesc_p256_pk_t*) (_pubkey+1) + .p_pk = NULL }, .keys_peer = { .p_enc_key = &_bond_keys.peer_enc, .p_id_key = &_bond_keys.peer_id, .p_sign_key = NULL, - .p_pk = (ble_gap_lesc_p256_pk_t*) (_peer_pubkey+1) + .p_pk = NULL } }; - // use LESC when both support it - if ( peer->lesc && _sec_param.lesc ) - { -// keyset. - } + #ifdef NRF_CRYPTOCELL + keyset.keys_own.p_pk = (ble_gap_lesc_p256_pk_t*) (_pubkey+1); + keyset.keys_peer.p_pk = (ble_gap_lesc_p256_pk_t*) (_peer_pubkey+1); + #endif VERIFY_STATUS(sd_ble_gap_sec_params_reply(conn_hdl, BLE_GAP_SEC_STATUS_SUCCESS, conn->getRole() == BLE_GAP_ROLE_PERIPH ? &_sec_param : NULL, &keyset), ); @@ -310,6 +308,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt) } break; +#ifdef NRF_CRYPTOCELL case BLE_GAP_EVT_LESC_DHKEY_REQUEST: { ble_gap_evt_lesc_dhkey_request_t* dhkey_req = &evt->evt.gap_evt.params.lesc_dhkey_request; @@ -348,6 +347,7 @@ void BLEPairing::_eventHandler(ble_evt_t* evt) sd_ble_gap_lesc_dhkey_reply(conn_hdl, &dhkey); } break; +#endif // Pairing process completed case BLE_GAP_EVT_AUTH_STATUS: diff --git a/libraries/Bluefruit52Lib/src/BLEPairing.h b/libraries/Bluefruit52Lib/src/BLEPairing.h index 57705bf4..8f17bb70 100644 --- a/libraries/Bluefruit52Lib/src/BLEPairing.h +++ b/libraries/Bluefruit52Lib/src/BLEPairing.h @@ -73,10 +73,11 @@ class BLEPairing private: ble_gap_sec_params_t _sec_param; +#ifdef NRF_CRYPTOCELL nRFCrypto_ECC_PrivateKey _private_key; - uint8_t _pubkey[1+BLE_GAP_LESC_P256_PK_LEN]; // our public key: 1 header + 64 data uint8_t _peer_pubkey[1+BLE_GAP_LESC_P256_PK_LEN]; // peer public key when using LESC +#endif bond_keys_t _bond_keys; // Shared keys with bonded device during securing connection, size ~ 80 bytes