This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do you check "App completes DHKey calculation"?

Hi,

We are using SDK13 and nrf52832.

I will use BLE security mode 1 level 4.

It is in progress referring to "ble_app_multirole_lesc".

How do you check "App completes DHKey calculation"?

TIMEOUT occurs because that part cannot be identified.

I need your help.

Parents
  • Hi,

    Referring to the ble_app_multirole_lesc example in SDK 13 this happens in the handling of the BLE_GAP_EVT_LESC_DHKEY_REQUEST event.

            case BLE_GAP_EVT_LESC_DHKEY_REQUEST:
                NRF_LOG_INFO("%s: BLE_GAP_EVT_LESC_DHKEY_REQUEST\r\n", nrf_log_push(roles_str[role]));
    
                static nrf_value_length_t peer_public_key_raw = {0};
    
                peer_public_key_raw.p_value = &p_ble_evt->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer->pk[0];
                peer_public_key_raw.length = BLE_GAP_LESC_P256_PK_LEN;
    
                err_code = nrf_crypto_ecc_public_key_from_raw(NRF_CRYPTO_BLE_ECDH_CURVE_INFO,
                                                              &peer_public_key_raw,
                                                              &m_peer_public_key);
                APP_ERROR_CHECK(err_code);
    
                err_code = nrf_crypto_ecdh_shared_secret_compute(NRF_CRYPTO_BLE_ECDH_CURVE_INFO,
                                                                &m_private_key,
                                                                &m_peer_public_key,
                                                                &m_dh_key);
                APP_ERROR_CHECK(err_code);
    
                err_code = sd_ble_gap_lesc_dhkey_reply(conn_handle, &m_lesc_dh_key);
                APP_ERROR_CHECK(err_code);
                break;
    

    Do you miss this in your implementation?

    By the way, note that this was changed in later SDK versions as it is a time consuming operation, and it makes sense to do this in the main loop rather than in an interrupt (which is the case in the SDK 13 example).

Reply
  • Hi,

    Referring to the ble_app_multirole_lesc example in SDK 13 this happens in the handling of the BLE_GAP_EVT_LESC_DHKEY_REQUEST event.

            case BLE_GAP_EVT_LESC_DHKEY_REQUEST:
                NRF_LOG_INFO("%s: BLE_GAP_EVT_LESC_DHKEY_REQUEST\r\n", nrf_log_push(roles_str[role]));
    
                static nrf_value_length_t peer_public_key_raw = {0};
    
                peer_public_key_raw.p_value = &p_ble_evt->evt.gap_evt.params.lesc_dhkey_request.p_pk_peer->pk[0];
                peer_public_key_raw.length = BLE_GAP_LESC_P256_PK_LEN;
    
                err_code = nrf_crypto_ecc_public_key_from_raw(NRF_CRYPTO_BLE_ECDH_CURVE_INFO,
                                                              &peer_public_key_raw,
                                                              &m_peer_public_key);
                APP_ERROR_CHECK(err_code);
    
                err_code = nrf_crypto_ecdh_shared_secret_compute(NRF_CRYPTO_BLE_ECDH_CURVE_INFO,
                                                                &m_private_key,
                                                                &m_peer_public_key,
                                                                &m_dh_key);
                APP_ERROR_CHECK(err_code);
    
                err_code = sd_ble_gap_lesc_dhkey_reply(conn_handle, &m_lesc_dh_key);
                APP_ERROR_CHECK(err_code);
                break;
    

    Do you miss this in your implementation?

    By the way, note that this was changed in later SDK versions as it is a time consuming operation, and it makes sense to do this in the main loop rather than in an interrupt (which is the case in the SDK 13 example).

Children
No Data
Related