The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2009-2012 Broadcom Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
| 19 | #ifndef BTIF_DM_H |
| 20 | #define BTIF_DM_H |
| 21 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 22 | #include "bta_api.h" |
| 23 | /************************************************************************************ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 24 | ** Functions |
| 25 | ********************************************************************************/ |
| 26 | |
| 27 | /** |
| 28 | * BTIF callback to switch context from bte to btif |
| 29 | */ |
| 30 | void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data); |
| 31 | |
| 32 | /** |
| 33 | * Notify BT disable being initiated. DM may chose to abort |
| 34 | * pending commands, like pairing |
| 35 | */ |
| 36 | void btif_dm_on_disable(void); |
| 37 | |
| 38 | /** |
Ganesh Ganapathi Batta | a217ab9 | 2014-04-28 16:30:55 -0700 | [diff] [blame^] | 39 | * Callout for handling io_capabilities request |
| 40 | */ |
| 41 | void btif_dm_proc_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, tBTA_OOB_DATA *p_oob_data, |
| 42 | tBTA_AUTH_REQ *p_auth_req, BOOLEAN is_orig); |
| 43 | /** |
| 44 | * Callout for handling io_capabilities response |
| 45 | */ |
| 46 | void btif_dm_proc_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap, |
| 47 | tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req); |
| 48 | |
| 49 | /** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 50 | * Out-of-band functions |
| 51 | */ |
| 52 | #if (BTM_OOB_INCLUDED == TRUE) |
| 53 | void btif_dm_set_oob_for_io_req(tBTA_OOB_DATA *p_oob_data); |
| 54 | #ifdef BTIF_DM_OOB_TEST |
| 55 | void btif_dm_load_local_oob(void); |
| 56 | void btif_dm_proc_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r); |
| 57 | BOOLEAN btif_dm_proc_rmt_oob(BD_ADDR bd_addr, BT_OCTET16 p_c, BT_OCTET16 p_r); |
| 58 | #endif /* BTIF_DM_OOB_TEST */ |
| 59 | #endif /* BTM_OOB_INCLUDED */ |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 60 | #if (BLE_INCLUDED == TRUE) |
| 61 | |
| 62 | typedef struct |
| 63 | { |
| 64 | UINT8 ltk[BT_OCTET16_LEN]; |
| 65 | UINT8 rand[BT_OCTET8_LEN]; |
| 66 | UINT16 ediv; |
| 67 | UINT8 sec_level; |
| 68 | UINT8 key_size; |
| 69 | }btif_dm_ble_penc_keys_t; |
| 70 | |
| 71 | typedef struct |
| 72 | { |
| 73 | UINT32 counter; |
| 74 | UINT8 csrk[BT_OCTET16_LEN]; |
| 75 | UINT8 sec_level; |
| 76 | }btif_dm_ble_pcsrk_keys_t; |
| 77 | |
| 78 | typedef struct |
| 79 | { |
| 80 | UINT16 div; |
| 81 | UINT8 key_size; |
| 82 | UINT8 sec_level; |
| 83 | }btif_dm_ble_lenc_keys_t; |
| 84 | |
| 85 | typedef struct |
| 86 | { |
| 87 | UINT32 counter; |
| 88 | UINT16 div; |
| 89 | UINT8 sec_level; |
| 90 | |
| 91 | }btif_dm_ble_lcsrk_keys_t; |
| 92 | |
| 93 | typedef struct |
| 94 | { |
| 95 | BOOLEAN is_penc_key_rcvd; |
| 96 | btif_dm_ble_penc_keys_t penc_key; /* received peer encryption key */ |
| 97 | BOOLEAN is_pcsrk_key_rcvd; |
| 98 | btif_dm_ble_pcsrk_keys_t pcsrk_key; /* received peer device SRK */ |
| 99 | BOOLEAN is_pid_key_rcvd; |
| 100 | UINT8 pid_key[BT_OCTET16_LEN]; /* peer device ID key */ |
| 101 | BOOLEAN is_lenc_key_rcvd; |
| 102 | btif_dm_ble_lenc_keys_t lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/ |
| 103 | BOOLEAN is_lcsrk_key_rcvd; |
| 104 | btif_dm_ble_lcsrk_keys_t lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/ |
| 105 | } btif_dm_ble_cb_t; |
| 106 | |
| 107 | #define BTIF_DM_LE_KEY_PENC BTA_LE_KEY_PENC |
| 108 | #define BTIF_DM_LE_KEY_PID BTA_LE_KEY_PID |
| 109 | #define BTIF_DM_LE_KEY_PCSRK BTA_LE_KEY_PCSRK |
| 110 | #define BTIF_DM_LE_KEY_LENC BTA_LE_KEY_LENC |
| 111 | #define BTIF_DM_LE_KEY_LID BTA_LE_KEY_LID |
| 112 | #define BTIF_DM_LE_KEY_LCSRK BTA_LE_KEY_LCSRK |
| 113 | |
| 114 | #define BTIF_DM_LE_LOCAL_KEY_IR (1<<0) |
| 115 | #define BTIF_DM_LE_LOCAL_KEY_IRK (1<<1) |
| 116 | #define BTIF_DM_LE_LOCAL_KEY_DHK (1<<2) |
| 117 | #define BTIF_DM_LE_LOCAL_KEY_ER (1<<3) |
| 118 | |
| 119 | void btif_dm_load_ble_local_keys(void); |
| 120 | void btif_dm_get_ble_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er, |
| 121 | tBTA_BLE_LOCAL_ID_KEYS *p_id_keys); |
| 122 | void btif_dm_save_ble_bonding_keys(void); |
| 123 | void btif_dm_remove_ble_bonding_keys(void); |
| 124 | void btif_dm_ble_sec_req_evt(tBTA_DM_BLE_SEC_REQ *p_ble_req); |
| 125 | |
| 126 | void btif_dm_update_ble_remote_properties( BD_ADDR bd_addr, BD_NAME bd_name, |
| 127 | tBT_DEVICE_TYPE dev_type); |
| 128 | |
| 129 | #endif /* BLE_INCLUDED */ |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 130 | |
| 131 | #endif |