sm.c (20964aa9e7ee2bc87a693445e13b45ac6c5b6b2c) sm.c (d44cdc4aa10821be894b746ace7e00cf3ca4ee4d)
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 3782 unchanged lines hidden (view full) ---

3791}
3792
3793#ifdef ENABLE_CROSS_TRANSPORT_KEY_DERIVATION
3794static void sm_event_handle_classic_encryption_event(sm_connection_t * sm_conn, hci_con_handle_t con_handle){
3795 // CTKD requires BR/EDR Secure Connection
3796 if (sm_conn->sm_connection_encrypted != 2) return;
3797 // prepare for pairing request
3798 if (IS_RESPONDER(sm_conn->sm_role)){
1/*
2 * Copyright (C) 2014 BlueKitchen GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright

--- 3782 unchanged lines hidden (view full) ---

3791}
3792
3793#ifdef ENABLE_CROSS_TRANSPORT_KEY_DERIVATION
3794static void sm_event_handle_classic_encryption_event(sm_connection_t * sm_conn, hci_con_handle_t con_handle){
3795 // CTKD requires BR/EDR Secure Connection
3796 if (sm_conn->sm_connection_encrypted != 2) return;
3797 // prepare for pairing request
3798 if (IS_RESPONDER(sm_conn->sm_role)){
3799 log_info("CTKD: SM_BR_EDR_RESPONDER_W4_PAIRING_REQUEST");
3799 sm_conn->sm_engine_state = SM_BR_EDR_RESPONDER_W4_PAIRING_REQUEST;
3800 } else if (sm_conn->sm_pairing_requested){
3801 // check if remote supports fixed channels
3802 bool defer = true;
3803 const hci_connection_t * hci_connection = hci_connection_for_handle(con_handle);
3804 if (hci_connection->l2cap_state.information_state == L2CAP_INFORMATION_STATE_DONE){
3805 // check if remote supports SMP over BR/EDR
3806 if ((hci_connection->l2cap_state.fixed_channels_supported & (1 << L2CAP_CID_BR_EDR_SECURITY_MANAGER)) != 0){

--- 102 unchanged lines hidden (view full) ---

3909 BD_ADDR_TYPE_LE_PUBLIC,
3910 addr);
3911 // classic connection corresponds to public le address
3912 sm_conn->sm_own_addr_type = BD_ADDR_TYPE_LE_PUBLIC;
3913 gap_local_bd_addr(sm_conn->sm_own_address);
3914 sm_conn->sm_cid = L2CAP_CID_BR_EDR_SECURITY_MANAGER;
3915 sm_conn->sm_engine_state = SM_BR_EDR_W4_ENCRYPTION_COMPLETE;
3916 break;
3800 sm_conn->sm_engine_state = SM_BR_EDR_RESPONDER_W4_PAIRING_REQUEST;
3801 } else if (sm_conn->sm_pairing_requested){
3802 // check if remote supports fixed channels
3803 bool defer = true;
3804 const hci_connection_t * hci_connection = hci_connection_for_handle(con_handle);
3805 if (hci_connection->l2cap_state.information_state == L2CAP_INFORMATION_STATE_DONE){
3806 // check if remote supports SMP over BR/EDR
3807 if ((hci_connection->l2cap_state.fixed_channels_supported & (1 << L2CAP_CID_BR_EDR_SECURITY_MANAGER)) != 0){

--- 102 unchanged lines hidden (view full) ---

3910 BD_ADDR_TYPE_LE_PUBLIC,
3911 addr);
3912 // classic connection corresponds to public le address
3913 sm_conn->sm_own_addr_type = BD_ADDR_TYPE_LE_PUBLIC;
3914 gap_local_bd_addr(sm_conn->sm_own_address);
3915 sm_conn->sm_cid = L2CAP_CID_BR_EDR_SECURITY_MANAGER;
3916 sm_conn->sm_engine_state = SM_BR_EDR_W4_ENCRYPTION_COMPLETE;
3917 break;
3918
3919 case HCI_EVENT_ROLE_CHANGE:
3920 // needed
3921 hci_event_role_change_get_bd_addr(packet, addr);
3922 sm_conn = sm_get_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL);
3923 if (sm_conn == NULL) break;
3924 sm_conn->sm_role = hci_event_role_change_get_role(packet);
3925 break;
3917#endif
3918
3919#ifdef ENABLE_CROSS_TRANSPORT_KEY_DERIVATION
3920 case HCI_EVENT_SIMPLE_PAIRING_COMPLETE:
3921 if (hci_event_simple_pairing_complete_get_status(packet) != ERROR_CODE_SUCCESS) break;
3922 hci_event_simple_pairing_complete_get_bd_addr(packet, addr);
3923 sm_conn = sm_get_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL);
3924 if (sm_conn == NULL) break;

--- 1696 unchanged lines hidden ---
3926#endif
3927
3928#ifdef ENABLE_CROSS_TRANSPORT_KEY_DERIVATION
3929 case HCI_EVENT_SIMPLE_PAIRING_COMPLETE:
3930 if (hci_event_simple_pairing_complete_get_status(packet) != ERROR_CODE_SUCCESS) break;
3931 hci_event_simple_pairing_complete_get_bd_addr(packet, addr);
3932 sm_conn = sm_get_connection_for_bd_addr_and_type(addr, BD_ADDR_TYPE_ACL);
3933 if (sm_conn == NULL) break;

--- 1696 unchanged lines hidden ---