Hi,
I am trying to implement OOB pairing via USB. I have the USB portion sorted out. The idea is for a peripheral device to send over OOB data over this medium, which then can be used by central during the pairing process.
My security parameters are:
#define SEC_PARAM_BOND 1 /**< Perform bonding. */ #define SEC_PARAM_MITM 1 /**< Man In The Middle protection not required. */ #define SEC_PARAM_LESC 1 /**< LE Secure Connections not enabled. */ #define SEC_PARAM_KEYPRESS 0 /**< Keypress notifications not enabled. */ #define SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /**< No I/O capabilities. */ #define SEC_PARAM_OOB 1 /**< Out Of Band data not available. */ #define SEC_PARAM_MIN_KEY_SIZE 7 /**< Minimum encryption key size. */ #define SEC_PARAM_MAX_KEY_SIZE 16 /**< Maximum encryption key size. */
In my main function I am generating an LESC keypair and generating OOB data:
ret = nrf_ble_lesc_keypair_generate(); APP_ERROR_CHECK(ret); ret = nrf_ble_lesc_own_oob_data_generate(); APP_ERROR_CHECK(ret);
During the pairing process, on BLE_GAP_EVT_LESC_DHKEY_REQUEST event, sd_ble_gap_lesc_oob_data_set() fails with error code 0x07 / NRF_ERROR_INVALID_PARAM. OOB own key is passed into this function, while the peer key is NULL.
This issue seems related:
One odd thing that I don't quite understand is the following comment in the nfc_ble_pair_lib.c:
case NFC_PAIRING_MODE_LESC_OOB: case NFC_PAIRING_MODE_LESC_JUST_WORKS: // Enable LESC pairing - OOB and MITM flags are cleared because it is the central device // who decides if the connection will be authorized with LESC OOB data. m_sec_param.mitm = 0; m_sec_param.oob = 0; m_sec_param.lesc = 1; break;
So, the central has to have an OOB flag set to on, but the peripheral does not?
Reading through this Bluetooth OOB article, it states the following:
- Both devices MUST set their OOB data flag if they want to use OOB for pairing;
- If one of device sets OOB data flag, but the other does not, both devices will check MITM flag which is in“AutheReq” field, Table 1, marked in green. If any device sets its MITM flag, the pairing method will be selected by the mapping of IO Capabilities to pairing method. Please refer to Bluetooth Core Specification v5.0, Vol3, Part H, Table 2.8 for the mapping detail.
- Otherwise, use “Just Works” as pairing method.
However, the above is regarding to LE Legacy pairing, so it might not apply.