Skip to content

Commit 7795e30

Browse files
committed
Remove own_oob and peer_oob flags from Nordic PAL
the own_oob and peer_oob flags were not being set to 1 even though an OOB pairing request was in progress, which therefore prevented OOB data from being passed down to the softdevice during a OOB pairing operation, thus causing the OOB pairing process to fail.
1 parent 24d793c commit 7795e30

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_SOFTDEVICE/TARGET_NRF52/source/nRF5xPalSecurityManager.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ struct nRF5xSecurityManager::pairing_control_block_t {
8181
ble_gap_id_key_t peer_id_key;
8282
ble_gap_sign_info_t peer_sign_key;
8383
ble_gap_lesc_p256_pk_t peer_pk;
84-
85-
// flag required to help DHKey computation/process; should be removed with
86-
// later versions of the softdevice
87-
uint8_t own_oob:1;
88-
uint8_t peer_oob:1;
8984
};
9085

9186
nRF5xSecurityManager::nRF5xSecurityManager()
@@ -663,26 +658,37 @@ ble_error_t nRF5xSecurityManager::secure_connections_oob_request_reply(
663658
const oob_lesc_value_t &peer_random,
664659
const oob_confirm_t &peer_confirm
665660
) {
661+
bool have_oob_own;
662+
bool have_oob_peer;
663+
const oob_lesc_value_t zerokey;
664+
ble_gap_lesc_oob_data_t oob_own;
665+
ble_gap_lesc_oob_data_t oob_peer;
666+
666667
pairing_control_block_t* pairing_cb = get_pairing_cb(connection);
667668
if (!pairing_cb) {
668669
return BLE_ERROR_INVALID_STATE;
669670
}
670671

671-
ble_gap_lesc_oob_data_t oob_own;
672-
ble_gap_lesc_oob_data_t oob_peer;
673-
674-
// is own address important ?
675-
memcpy(oob_own.r, local_random.data(), local_random.size());
676-
// FIXME: What to do with local confirm ???
672+
have_oob_own = false;
673+
if (local_random != zerokey) {
674+
have_oob_own = true;
675+
// is own address important ?
676+
memcpy(oob_own.r, local_random.data(), local_random.size());
677+
// FIXME: What to do with local confirm ???
678+
}
677679

678-
// is peer address important ?
679-
memcpy(oob_peer.r, peer_random.data(), peer_random.size());
680-
memcpy(oob_peer.c, peer_confirm.data(), peer_confirm.size());
680+
have_oob_peer = false;
681+
if (peer_random != zerokey && peer_confirm != zerokey) {
682+
have_oob_peer = true;
683+
// is peer address important ?
684+
memcpy(oob_peer.r, peer_random.data(), peer_random.size());
685+
memcpy(oob_peer.c, peer_confirm.data(), peer_confirm.size());
686+
}
681687

682688
uint32_t err = sd_ble_gap_lesc_oob_data_set(
683689
connection,
684-
pairing_cb->own_oob ? &oob_own : NULL,
685-
pairing_cb->peer_oob ? &oob_peer : NULL
690+
have_oob_own ? &oob_own : NULL,
691+
have_oob_peer ? &oob_peer : NULL
686692
);
687693

688694
return convert_sd_error(err);

0 commit comments

Comments
 (0)