1

Device Manager Query?

abhiarora4 gravatar image

asked 2017-01-11 19:21:31 +0200

updated 2017-01-12 16:59:41 +0200

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?

edit retag flag offensive close delete report spam

Comments

2 answers

Sort by » oldest newest most voted
1
Petter gravatar image

answered 2017-01-12 17:28:53 +0200

abhiarora4 gravatar image

updated 2017-01-12 18:39:28 +0200

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.

edit flag offensive delete publish link more

Comments

1

I was looking at [S110] (https://devzone.nordicsemi.com/docume...) Documentation of sd_ble_gap_sec_params_reply(). And then i found out other definitation of it in S120. The APIs declaration in these two documentation is different. The parameter of type ble_gap_sec_keyset_t is not available in S110.

abhiarora ( 2017-01-16 08:21:14 +0200 )editconvert to answer
1
Petter gravatar image

answered 2017-01-12 11:00:31 +0200

If distributed, the keys should be available in the ble_gap_sec_keyset_t struct you give a pointer to when you call sd_ble_gap_sec_params_reply().

The key should be available after you have received the BLE_GAP_EVT_AUTH_STATUS event.

Also see this MSC.

edit flag offensive delete publish link more

Comments

If i am looking into struct ble_gap_evt_auth_status_t when i receive BLE_GAP_EVT_AUTH_STATUS event. I didn't find ble_gap_sec_keyset_t struct over there. Also, if i make key pointers in struct ble_gap_sec_keyset_t NULL in a reply to BLE_GAP_EVT_SEC_PARAMS_REQUEST by calling sd_ble_gap_sec_params_reply(), does that mean the SoftDevice will generate random keys for LTK? How can i get those keys after receiving the event BLE_GAP_EVT_AUTH_STATUS.

abhiarora ( 2017-01-12 12:04:50 +0200 )editconvert to answer

No, it is not in ble_gap_evt_auth_status_t. The keys will be available in the ble_gap_sec_keyset_t struct that you give a pointer to whn you call sd_ble_gap_sec_params_reply(). It should not be a NULL pointer, it should only be a NULL pointer if you do pairing, and then there will not be any LTK. The LTK is always random. You get the keys by accessing the struct that you gave a pointer to when you called sd_ble_gap_sec_params_reply() after you get the BLE_GAP_EVT_AUTH_STATUS event.

Petter Myhre ( 2017-01-12 12:20:15 +0200 )editconvert to answer

I have edited my question. Please have a look.

abhiarora ( 2017-01-12 17:00:05 +0200 )editconvert to answer

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer. Do not ask a new question or reply to an answer here.

[hide preview]

Question Tools

1 follower

Stats

Asked: 2017-01-11 19:21:31 +0200

Seen: 92 times

Last updated: Jan 12