This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problems pairing with iOS device using LE Secure Connections

Hello. I am trying using the nRF52832 with SoftDevice S132 v4.0.2 and SDK v13.0.0 along with the uECC.c/h files that I downloaded from github.com/.../micro-ecc. My device is acting in a peripheral role, and am trying to get LE Secure Connections working. I'm testing against an iPhone 7 running iOS 11.3.1. I am using a full-featured sniffer with BT 4.2 support.

What I see on the sniffer is that the iPhone is sending a LL_TERMINATE_IND to terminate the connection during SMP Authentication Stage 1, immediately after the peripheral has sent the SMP Pairing Confirm value containing the value of Cb. In some cases the iPhone first sends an SMP Pairing Failed packet with reason code 0x08 (Unspecified Reason) just before sending the terminate request, though in most cases the LL_TERMINATE_IND happens without any SMP Pairing Failed packet.

Before the failure happens, I can see the SMP Pairing Request and Response packets as well as the SMP Pairing Public Key packets from both the central and the peripheral, and those packets all appear to be properly formed.

I'm not sure why the iPhone is terminating the connection, though I can only speculate that there is something wrong with my SMP Pairing Confirm packet - perhaps the Cb value is incorrectly calculated?

Below is the code that I'm using to initialize the peer manager. Am I doing anything incorrectly here? Thanks for your help.

__ALIGN(4) static ble_gap_lesc_p256_pk_t lesc_publicKey; // LESC ECC Public Key
__ALIGN(4) static ble_gap_lesc_p256_pk_t lesc_secretKey; // LESC ECC Secret Key
__ALIGN(4) static ble_gap_lesc_dhkey_t lesc_dhKey; // LESC ECC DH Key
__ALIGN(4) static ble_gap_lesc_p256_pk_t lesc_peerEccKey; // LESC Peer

static void X_InitPeerManager()

static void X_InitPeerManager()
{

ble_gap_sec_params_t sec_param;
ret_code_t err_code;

err_code = nrf_drv_rng_init(NULL);
APP_ERROR_CHECK(err_code);

err_code = pm_init();
APP_ERROR_CHECK(err_code);

err_code = pm_register(X_PeerManagerEvent);
APP_ERROR_CHECK(err_code);

memset(&sec_param, 0, sizeof(ble_gap_sec_params_t));

sec_param.bond = 1;
sec_param.mitm = 0;
sec_param.lesc = 1;
sec_param.keypress = 0;
sec_param.io_caps = BLE_GAP_IO_CAPS_NONE;
sec_param.oob = SEC_PARAM_OOB;
sec_param.min_key_size = 16;
sec_param.max_key_size = 16;
sec_param.kdist_own.enc = 1;
sec_param.kdist_own.id = 1;
sec_param.kdist_peer.enc = 1;
sec_param.kdist_peer.id = 1;

err_code = pm_sec_params_set(&sec_param);
APP_ERROR_CHECK(err_code);

ecc_init(TRUE);

err_code = ecc_p256_keypair_gen(lesc_secretKey.pk, lesc_publicKey.pk);
APP_ERROR_CHECK(err_code);

err_code = pm_lesc_public_key_set(&lesc_publicKey);
APP_ERROR_CHECK(err_code);

}

Parents Reply Children
No Data
Related