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 #define LOG_TAG "sec_interf"
19
20 #include <bluetooth/log.h>
21
22 #include "os/log.h"
23 #include "stack/btm/btm_dev.h"
24 #include "stack/btm/btm_sec.h"
25 #include "stack/btm/btm_sec_cb.h"
26 #include "stack/include/btm_ble_sec_api.h"
27 #include "stack/include/btm_sec_api.h"
28 #include "stack/include/security_client_callbacks.h"
29 #include "types/bt_transport.h"
30
31 using namespace bluetooth;
32
BTM_SecConfirmReqReply(tBTM_STATUS res,tBT_TRANSPORT transport,const RawAddress bd_addr)33 static void BTM_SecConfirmReqReply(tBTM_STATUS res, tBT_TRANSPORT transport,
34 const RawAddress bd_addr) {
35 if (transport == BT_TRANSPORT_BR_EDR) {
36 BTM_ConfirmReqReply(res, bd_addr);
37 } else if (transport == BT_TRANSPORT_LE) {
38 BTM_BleConfirmReply(bd_addr, res);
39 } else {
40 log::error("Unexpected transport:{}", transport);
41 }
42 }
43
44 static SecurityClientInterface security = {
45 .BTM_Sec_Init = BTM_Sec_Init,
46 .BTM_Sec_Free = BTM_Sec_Free,
47 .BTM_SecRegister = BTM_SecRegister,
48
49 .BTM_BleLoadLocalKeys = BTM_BleLoadLocalKeys,
50
51 .BTM_SecAddDevice = BTM_SecAddDevice,
52 .BTM_SecAddBleDevice = BTM_SecAddBleDevice,
53 .BTM_SecDeleteDevice = BTM_SecDeleteDevice,
54 .BTM_SecAddBleKey = BTM_SecAddBleKey,
55 .BTM_SecClearSecurityFlags = BTM_SecClearSecurityFlags,
56 .BTM_SetEncryption = BTM_SetEncryption,
57 .BTM_IsEncrypted = BTM_IsEncrypted,
58 .BTM_SecIsSecurityPending = BTM_SecIsSecurityPending,
59 .BTM_IsLinkKeyKnown = BTM_IsLinkKeyKnown,
60
61 .BTM_SetSecurityLevel = BTM_SetSecurityLevel,
62 .BTM_SecClrService = BTM_SecClrService,
63 .BTM_SecClrServiceByPsm = BTM_SecClrServiceByPsm,
64
65 .BTM_SecBond = BTM_SecBond,
66 .BTM_SecBondCancel = BTM_SecBondCancel,
67 .BTM_RemoteOobDataReply = BTM_RemoteOobDataReply,
68 .BTM_PINCodeReply = BTM_PINCodeReply,
69 .BTM_SecConfirmReqReply = BTM_SecConfirmReqReply,
70 .BTM_BleSirkConfirmDeviceReply = BTM_BleSirkConfirmDeviceReply,
71 .BTM_BlePasskeyReply = BTM_BlePasskeyReply,
72
73 .BTM_GetSecurityMode = BTM_GetSecurityMode,
74
75 .BTM_SecReadDevName = BTM_SecReadDevName,
76 .BTM_SecAddRmtNameNotifyCallback = BTM_SecAddRmtNameNotifyCallback,
77 .BTM_SecDeleteRmtNameNotifyCallback = BTM_SecDeleteRmtNameNotifyCallback,
78 };
79
get_security_client_interface()80 const SecurityClientInterface& get_security_client_interface() {
81 return security;
82 }
83