mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
sm: use IRK prefix for address resolution state
This commit is contained in:
parent
9f9b1721e1
commit
7b8f2e5c7a
20
ble/sm.c
20
ble/sm.c
@ -918,7 +918,7 @@ static void sm_address_resolution_handle_event(address_resolution_event_t event)
|
|||||||
sm_connection = (sm_connection_t *) context;
|
sm_connection = (sm_connection_t *) context;
|
||||||
switch (event){
|
switch (event){
|
||||||
case ADDRESS_RESOLUTION_SUCEEDED:
|
case ADDRESS_RESOLUTION_SUCEEDED:
|
||||||
sm_connection->sm_csrk_lookup_state = CSRK_LOOKUP_SUCCEEDED;
|
sm_connection->sm_irk_lookup_state = IRK_LOOKUP_SUCCEEDED;
|
||||||
sm_connection->sm_le_db_index = matched_device_id;
|
sm_connection->sm_le_db_index = matched_device_id;
|
||||||
log_info("ADDRESS_RESOLUTION_SUCEEDED, index %d", sm_connection->sm_le_db_index);
|
log_info("ADDRESS_RESOLUTION_SUCEEDED, index %d", sm_connection->sm_le_db_index);
|
||||||
if (sm_connection->sm_role) break;
|
if (sm_connection->sm_role) break;
|
||||||
@ -933,7 +933,7 @@ static void sm_address_resolution_handle_event(address_resolution_event_t event)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ADDRESS_RESOLUTION_FAILED:
|
case ADDRESS_RESOLUTION_FAILED:
|
||||||
sm_connection->sm_csrk_lookup_state = CSRK_LOOKUP_FAILED;
|
sm_connection->sm_irk_lookup_state = IRK_LOOKUP_FAILED;
|
||||||
if (sm_connection->sm_role) break;
|
if (sm_connection->sm_role) break;
|
||||||
if (!sm_connection->sm_bonding_requested && !sm_connection->sm_security_request_received) break;
|
if (!sm_connection->sm_bonding_requested && !sm_connection->sm_security_request_received) break;
|
||||||
sm_connection->sm_security_request_received = 0;
|
sm_connection->sm_security_request_received = 0;
|
||||||
@ -1040,10 +1040,10 @@ static void sm_run(void){
|
|||||||
while(linked_list_iterator_has_next(&it)){
|
while(linked_list_iterator_has_next(&it)){
|
||||||
hci_connection_t * hci_connection = (hci_connection_t *) linked_list_iterator_next(&it);
|
hci_connection_t * hci_connection = (hci_connection_t *) linked_list_iterator_next(&it);
|
||||||
sm_connection_t * sm_connection = &hci_connection->sm_connection;
|
sm_connection_t * sm_connection = &hci_connection->sm_connection;
|
||||||
if (sm_connection->sm_csrk_lookup_state == CSRK_LOOKUP_W4_READY){
|
if (sm_connection->sm_irk_lookup_state == IRK_LOOKUP_W4_READY){
|
||||||
// and start lookup
|
// and start lookup
|
||||||
sm_address_resolution_start_lookup(sm_connection->sm_peer_addr_type, sm_connection->sm_peer_address, ADDRESS_RESOLUTION_FOR_CONNECTION, sm_connection);
|
sm_address_resolution_start_lookup(sm_connection->sm_peer_addr_type, sm_connection->sm_peer_address, ADDRESS_RESOLUTION_FOR_CONNECTION, sm_connection);
|
||||||
sm_connection->sm_csrk_lookup_state = CSRK_LOOKUP_STARTED;
|
sm_connection->sm_irk_lookup_state = IRK_LOOKUP_STARTED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1746,7 +1746,7 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
|
|||||||
sm_conn->sm_le_db_index = -1;
|
sm_conn->sm_le_db_index = -1;
|
||||||
|
|
||||||
// prepare CSRK lookup (does not involve setup)
|
// prepare CSRK lookup (does not involve setup)
|
||||||
sm_conn->sm_csrk_lookup_state = CSRK_LOOKUP_W4_READY;
|
sm_conn->sm_irk_lookup_state = IRK_LOOKUP_W4_READY;
|
||||||
|
|
||||||
// just connected -> everything else happens in sm_run()
|
// just connected -> everything else happens in sm_run()
|
||||||
if (sm_conn->sm_role){
|
if (sm_conn->sm_role){
|
||||||
@ -1956,11 +1956,11 @@ static void sm_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pac
|
|||||||
sm_pdu_received_in_wrong_state(sm_conn);
|
sm_pdu_received_in_wrong_state(sm_conn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sm_conn->sm_csrk_lookup_state == CSRK_LOOKUP_FAILED){
|
if (sm_conn->sm_irk_lookup_state == IRK_LOOKUP_FAILED){
|
||||||
sm_conn->sm_engine_state = SM_INITIATOR_PH1_W2_SEND_PAIRING_REQUEST;
|
sm_conn->sm_engine_state = SM_INITIATOR_PH1_W2_SEND_PAIRING_REQUEST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sm_conn->sm_csrk_lookup_state == CSRK_LOOKUP_SUCCEEDED){
|
if (sm_conn->sm_irk_lookup_state == IRK_LOOKUP_SUCCEEDED){
|
||||||
uint16_t ediv;
|
uint16_t ediv;
|
||||||
le_device_db_encryption_get(sm_conn->sm_le_db_index, &ediv, NULL, NULL, NULL, NULL, NULL);
|
le_device_db_encryption_get(sm_conn->sm_le_db_index, &ediv, NULL, NULL, NULL, NULL, NULL);
|
||||||
if (ediv){
|
if (ediv){
|
||||||
@ -2342,11 +2342,11 @@ void sm_request_authorization(uint8_t addr_type, bd_addr_t address){
|
|||||||
// used as a trigger to start central/master/initiator security procedures
|
// used as a trigger to start central/master/initiator security procedures
|
||||||
uint16_t ediv;
|
uint16_t ediv;
|
||||||
if (sm_conn->sm_engine_state == SM_INITIATOR_CONNECTED){
|
if (sm_conn->sm_engine_state == SM_INITIATOR_CONNECTED){
|
||||||
switch (sm_conn->sm_csrk_lookup_state){
|
switch (sm_conn->sm_irk_lookup_state){
|
||||||
case CSRK_LOOKUP_FAILED:
|
case IRK_LOOKUP_FAILED:
|
||||||
sm_conn->sm_engine_state = SM_INITIATOR_PH1_W2_SEND_PAIRING_REQUEST;
|
sm_conn->sm_engine_state = SM_INITIATOR_PH1_W2_SEND_PAIRING_REQUEST;
|
||||||
break;
|
break;
|
||||||
case CSRK_LOOKUP_SUCCEEDED:
|
case IRK_LOOKUP_SUCCEEDED:
|
||||||
le_device_db_encryption_get(sm_conn->sm_le_db_index, &ediv, NULL, NULL, NULL, NULL, NULL);
|
le_device_db_encryption_get(sm_conn->sm_le_db_index, &ediv, NULL, NULL, NULL, NULL, NULL);
|
||||||
if (ediv){
|
if (ediv){
|
||||||
log_info("sm: Setting up previous ltk/ediv/rand for device index %u", sm_conn->sm_le_db_index);
|
log_info("sm: Setting up previous ltk/ediv/rand for device index %u", sm_conn->sm_le_db_index);
|
||||||
|
14
src/hci.h
14
src/hci.h
@ -435,12 +435,12 @@ typedef enum {
|
|||||||
} security_manager_state_t;
|
} security_manager_state_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CSRK_LOOKUP_IDLE,
|
IRK_LOOKUP_IDLE,
|
||||||
CSRK_LOOKUP_W4_READY,
|
IRK_LOOKUP_W4_READY,
|
||||||
CSRK_LOOKUP_STARTED,
|
IRK_LOOKUP_STARTED,
|
||||||
CSRK_LOOKUP_SUCCEEDED,
|
IRK_LOOKUP_SUCCEEDED,
|
||||||
CSRK_LOOKUP_FAILED
|
IRK_LOOKUP_FAILED
|
||||||
} csrk_lookup_state_t;
|
} irk_lookup_state_t;
|
||||||
|
|
||||||
// Authorization state
|
// Authorization state
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -469,7 +469,7 @@ typedef struct sm_connection {
|
|||||||
uint8_t sm_peer_addr_type;
|
uint8_t sm_peer_addr_type;
|
||||||
bd_addr_t sm_peer_address;
|
bd_addr_t sm_peer_address;
|
||||||
security_manager_state_t sm_engine_state;
|
security_manager_state_t sm_engine_state;
|
||||||
csrk_lookup_state_t sm_csrk_lookup_state;
|
irk_lookup_state_t sm_irk_lookup_state;
|
||||||
uint8_t sm_connection_encrypted;
|
uint8_t sm_connection_encrypted;
|
||||||
uint8_t sm_connection_authenticated; // [0..1]
|
uint8_t sm_connection_authenticated; // [0..1]
|
||||||
uint8_t sm_actual_encryption_key_size;
|
uint8_t sm_actual_encryption_key_size;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user