1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #pragma once 19 20 #include <cstdint> 21 22 #include "stack/include/bt_dev_class.h" 23 #include "stack/include/bt_name.h" 24 #include "stack/include/bt_octets.h" 25 #include "stack/include/btm_api_types.h" 26 #include "stack/include/btm_status.h" 27 #include "types/bt_transport.h" 28 #include "types/raw_address.h" 29 30 /***************************************************************************** 31 * SECURITY MANAGEMENT FUNCTIONS 32 ****************************************************************************/ 33 34 /******************************************************************************* 35 * 36 * Function BTM_SecAddDevice 37 * 38 * Description Add/modify device. This function will be normally called 39 * during host startup to restore all required information 40 * stored in the NVRAM. 41 * dev_class, link_key are NULL if unknown 42 * 43 * Returns void 44 * 45 ******************************************************************************/ 46 void BTM_SecAddDevice(const RawAddress& bd_addr, const DEV_CLASS dev_class, 47 LinkKey link_key, uint8_t key_type, uint8_t pin_length); 48 49 /** Free resources associated with the device associated with |bd_addr| address. 50 * 51 * *** WARNING *** 52 * tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function 53 * is called, also any of its fields. i.e. if you use p_dev_rec->bd_addr, it is 54 * no longer valid! 55 * *** WARNING *** 56 * 57 * Returns true if removed OK, false if not found or ACL link is active. 58 */ 59 bool BTM_SecDeleteDevice(const RawAddress& bd_addr); 60 61 /******************************************************************************* 62 * 63 * Function BTM_SecClearSecurityFlags 64 * 65 * Description Reset the security flags (mark as not-paired) for a given 66 * remove device. 67 * 68 ******************************************************************************/ 69 void BTM_SecClearSecurityFlags(const RawAddress& bd_addr); 70 71 /******************************************************************************* 72 * 73 * Function btm_sec_is_a_bonded_dev 74 * 75 * Description Is the specified device is a bonded device 76 * 77 * Returns true - dev is bonded 78 * 79 ******************************************************************************/ 80 bool btm_sec_is_a_bonded_dev(const RawAddress& bda); 81 82 /******************************************************************************* 83 * 84 * Function BTM_DeleteStoredLinkKey 85 * 86 * Description This function is called to delete link key for the specified 87 * device addresses from the NVRAM storage attached to the 88 * Bluetooth controller. 89 * 90 * Parameters: bd_addr - Addresses of the devices 91 * p_cb - Call back function to be called to return 92 * the results 93 * 94 ******************************************************************************/ 95 tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr, 96 tBTM_CMPL_CB* p_cb); 97 98 /******************************************************************************* 99 * 100 * Function BTM_BleSirkConfirmDeviceReply 101 * 102 * Description This procedure confirms requested to validate set device. 103 * 104 * Parameter bd_addr - BD address of the peer 105 * res - confirmation result BTM_SUCCESS if success 106 * 107 * Returns void 108 * 109 ******************************************************************************/ 110 void BTM_BleSirkConfirmDeviceReply(const RawAddress& bd_addr, uint8_t res); 111 112 uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr); 113 114 /******************************************************************************* 115 * 116 * Function BTM_IsRemoteNameKnown 117 * 118 * Description This function checks if the remote name is known. 119 * 120 * Input Params: bd_addr: Address of remote 121 * transport: Transport, auto if unknown 122 * 123 * Returns 124 * true if name is known, false otherwise 125 * 126 ******************************************************************************/ 127 bool BTM_IsRemoteNameKnown(const RawAddress& remote_bda, 128 tBT_TRANSPORT transport); 129