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

Device Manager Query?

I have been reading device manager of SDK10.0 for nrf51822. I looked at dm_ble_evt_handler and whole device manager source code but i didn't found where keys like IRK, LTK are passed.

My goal is to write my own device manager. I need access to LTK, IRK so that my own persistent storage can store it.

Please help me.


EDIT:

I have posted some part of the code of the function dm_ble_evt_handler. The part of the code is executed when BLE_GAP_EVT_SEC_PARAMS_REQUEST event is generated.

 ble_gap_sec_keyset_t keys_exchanged;

DM_LOG("[DM]: 0x%02X, 0x%02X, 0x%02X, 0x%02X\r\n",
               p_ble_evt->evt.gap_evt.params.sec_params_request.peer_params.kdist_periph.enc,
               p_ble_evt->evt.gap_evt.params.sec_params_request.peer_params.kdist_central.id,
               p_ble_evt->evt.gap_evt.params.sec_params_request.peer_params.kdist_periph.sign,
               p_ble_evt->evt.gap_evt.params.sec_params_request.peer_params.bond);

keys_exchanged.keys_central.p_enc_key  = NULL;
keys_exchanged.keys_central.p_id_key   = &m_peer_table[m_connection_table[index].bonded_dev_id].peer_id; 
keys_exchanged.keys_central.p_sign_key = NULL;
keys_exchanged.keys_periph.p_enc_key   = &m_bond_table[index].peer_enc_key;
keys_exchanged.keys_periph.p_id_key    = NULL;
keys_exchanged.keys_periph.p_sign_key  = NULL;

As it can be seen in the section of the code, the key is being passed from the device manager in a call to a function:

 err_code = sd_ble_gap_sec_params_reply(p_ble_evt->evt.gap_evt.conn_handle,
                                               BLE_GAP_SEC_STATUS_SUCCESS,
                                               &m_application_table[0].sec_param, 
                                               &keys_exchanged);

But I can't found the section of code where this keys are being received/generated (or first received)? Which function should be called on what event to get the keys of LTK and IRK?

Parents
  • I had a look. I'm not sure how to explain this in a better way, maybe the API documentation is clearer:

    Pointer to a ble_gap_sec_keyset_t security keyset structure. Any keys distributed as a result of the ongoing security procedure will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application upon reception of a BLE_GAP_EVT_AUTH_STATUS event.

    It is an in,out argument.

Reply
  • I had a look. I'm not sure how to explain this in a better way, maybe the API documentation is clearer:

    Pointer to a ble_gap_sec_keyset_t security keyset structure. Any keys distributed as a result of the ongoing security procedure will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application upon reception of a BLE_GAP_EVT_AUTH_STATUS event.

    It is an in,out argument.

Children
Related