mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 12:40:42 +00:00
sm: extract sm_key_distribution_complete_responder
This commit is contained in:
parent
bbd73538bb
commit
6f7422f1b3
20
src/ble/sm.c
20
src/ble/sm.c
@ -2420,6 +2420,17 @@ static bool sm_ctkd_from_le(sm_connection_t *sm_connection) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void sm_key_distribution_complete_responder(sm_connection_t * connection){
|
||||
if (sm_ctkd_from_le(connection)){
|
||||
bool use_h7 = (sm_pairing_packet_get_auth_req(setup->sm_m_preq) & sm_pairing_packet_get_auth_req(setup->sm_s_pres) & SM_AUTHREQ_CT2) != 0;
|
||||
connection->sm_engine_state = use_h7 ? SM_SC_W2_CALCULATE_ILK_USING_H7 : SM_SC_W2_CALCULATE_ILK_USING_H6;
|
||||
} else {
|
||||
connection->sm_engine_state = SM_RESPONDER_IDLE;
|
||||
sm_pairing_complete(connection, ERROR_CODE_SUCCESS, 0);
|
||||
sm_done_for_handle(connection->sm_handle);
|
||||
}
|
||||
}
|
||||
|
||||
static void sm_run(void){
|
||||
|
||||
// assert that stack has already bootet
|
||||
@ -4255,14 +4266,7 @@ static void sm_pdu_handler(uint8_t packet_type, hci_con_handle_t con_handle, uin
|
||||
sm_key_distribution_handle_all_received(sm_conn);
|
||||
|
||||
if (IS_RESPONDER(sm_conn->sm_role)){
|
||||
if (sm_ctkd_from_le(sm_conn)){
|
||||
bool use_h7 = (sm_pairing_packet_get_auth_req(setup->sm_m_preq) & sm_pairing_packet_get_auth_req(setup->sm_s_pres) & SM_AUTHREQ_CT2) != 0;
|
||||
sm_conn->sm_engine_state = use_h7 ? SM_SC_W2_CALCULATE_ILK_USING_H7 : SM_SC_W2_CALCULATE_ILK_USING_H6;
|
||||
} else {
|
||||
sm_conn->sm_engine_state = SM_RESPONDER_IDLE;
|
||||
sm_pairing_complete(sm_conn, ERROR_CODE_SUCCESS, 0);
|
||||
sm_done_for_handle(sm_conn->sm_handle);
|
||||
}
|
||||
sm_key_distribution_complete_responder(sm_conn);
|
||||
} else {
|
||||
if (setup->sm_use_secure_connections){
|
||||
sm_conn->sm_engine_state = SM_PH3_DISTRIBUTE_KEYS;
|
||||
|
Loading…
x
Reference in New Issue
Block a user