1 /******************************************************************************
2  *
3  *  Copyright 1999-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 /******************************************************************************
20  *
21  *  This file contains functions for the Bluetooth Security Manager
22  *
23  ******************************************************************************/
24 
25 #pragma once
26 #include <cstdint>
27 #include <string>
28 
29 #include "stack/btm/security_device_record.h"
30 #include "stack/include/bt_device_type.h"
31 #include "stack/include/bt_octets.h"
32 #include "stack/include/btm_sec_api_types.h"
33 #include "stack/include/btm_status.h"
34 #include "stack/include/hci_error_code.h"
35 #include "stack/include/security_client_callbacks.h"
36 #include "stack/include/smp_api_types.h"
37 #include "types/ble_address_with_type.h"
38 #include "types/bt_transport.h"
39 #include "types/hci_role.h"
40 #include "types/raw_address.h"
41 
42 #define BTM_SEC_MAX_COLLISION_DELAY (5000)
43 
44 /*******************************************************************************
45  *
46  * Function         BTM_SecRegister
47  *
48  * Description      Application manager calls this function to register for
49  *                  security services.  There can be one and only one
50  *                  application saving link keys.  BTM allows only first
51  *                  registration.
52  *
53  * Returns          true if registered OK, else false
54  *
55  ******************************************************************************/
56 bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info);
57 
58 /*******************************************************************************
59  *
60  * Function         BTM_SecAddRmtNameNotifyCallback
61  *
62  * Description      Any profile can register to be notified when name of the
63  *                  remote device is resolved.
64  *
65  * Returns          true if registered OK, else false
66  *
67  ******************************************************************************/
68 bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);
69 
70 /*******************************************************************************
71  *
72  * Function         BTM_SecDeleteRmtNameNotifyCallback
73  *
74  * Description      Any profile can deregister notification when a new Link Key
75  *                  is generated per connection.
76  *
77  * Returns          true if OK, else false
78  *
79  ******************************************************************************/
80 bool BTM_SecDeleteRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);
81 
82 bool BTM_IsEncrypted(const RawAddress& bd_addr, tBT_TRANSPORT transport);
83 bool BTM_IsLinkKeyAuthed(const RawAddress& bd_addr, tBT_TRANSPORT transport);
84 bool BTM_IsLinkKeyKnown(const RawAddress& bd_addr, tBT_TRANSPORT transport);
85 bool BTM_IsAuthenticated(const RawAddress& bd_addr, tBT_TRANSPORT transport);
86 bool BTM_CanReadDiscoverableCharacteristics(const RawAddress& bd_addr);
87 
88 /*******************************************************************************
89  *
90  * Function         BTM_SetPinType
91  *
92  * Description      Set PIN type for the device.
93  *
94  * Returns          void
95  *
96  ******************************************************************************/
97 void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len);
98 
99 /*******************************************************************************
100  *
101  * Function         BTM_SetSecurityLevel
102  *
103  * Description      Register service security level with Security Manager
104  *
105  * Parameters:      is_originator - true if originating the connection
106  *                  p_name      - Name of the service relevant only if
107  *                                authorization will show this name to user.
108  *                                Ignored if BT_MAX_SERVICE_NAME_LEN is 0.
109  *                  service_id  - service ID for the service passed to
110  *                                authorization callback
111  *                  sec_level   - bit mask of the security features
112  *                  psm         - L2CAP PSM
113  *                  mx_proto_id - protocol ID of multiplexing proto below
114  *                  mx_chan_id  - channel ID of multiplexing proto below
115  *
116  * Returns          true if registered OK, else false
117  *
118  ******************************************************************************/
119 bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
120                           uint8_t service_id, uint16_t sec_level, uint16_t psm,
121                           uint32_t mx_proto_id, uint32_t mx_chan_id);
122 
123 /*******************************************************************************
124  *
125  * Function         BTM_SecClrService
126  *
127  * Description      Removes specified service record(s) from the security
128  *                  database. All service records with the specified name are
129  *                  removed. Typically used only by devices with limited RAM so
130  *                  that it can reuse an old security service record.
131  *
132  *                  Note: Unpredictable results may occur if a service is
133  *                      cleared that is still in use by an application/profile.
134  *
135  * Parameters       Service ID - Id of the service to remove. '0' removes all
136  *                          service records (except SDP).
137  *
138  * Returns          Number of records that were freed.
139  *
140  ******************************************************************************/
141 uint8_t BTM_SecClrService(uint8_t service_id);
142 
143 /*******************************************************************************
144  *
145  * Function         BTM_SecClrServiceByPsm
146  *
147  * Description      Removes specified service record from the security database.
148  *                  All service records with the specified psm are removed.
149  *                  Typically used by L2CAP to free up the service record used
150  *                  by dynamic PSM clients when the channel is closed.
151  *                  The given psm must be a virtual psm.
152  *
153  * Parameters       Service ID - Id of the service to remove. '0' removes all
154  *                          service records (except SDP).
155  *
156  * Returns          Number of records that were freed.
157  *
158  ******************************************************************************/
159 uint8_t BTM_SecClrServiceByPsm(uint16_t psm);
160 
161 /*******************************************************************************
162  *
163  * Function         BTM_PINCodeReply
164  *
165  * Description      This function is called after Security Manager submitted
166  *                  PIN code request to the UI.
167  *
168  * Parameters:      bd_addr      - Address of the device for which PIN was
169  *                                 requested
170  *                  res          - result of the operation BTM_SUCCESS
171  *                                 if success
172  *                  pin_len      - length in bytes of the PIN Code
173  *                  p_pin        - pointer to array with the PIN Code
174  *
175  ******************************************************************************/
176 void BTM_PINCodeReply(const RawAddress& bd_addr, tBTM_STATUS res,
177                       uint8_t pin_len, uint8_t* p_pin);
178 
179 /*******************************************************************************
180  *
181  * Function         btm_sec_bond_by_transport
182  *
183  * Description      this is the bond function that will start either SSP or SMP.
184  *
185  * Parameters:      bd_addr      - Address of the device to bond
186  *                  pin_len      - length in bytes of the PIN Code
187  *                  p_pin        - pointer to array with the PIN Code
188  *
189  *  Note: After 2.1 parameters are not used and preserved here not to change API
190  ******************************************************************************/
191 tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
192                                       tBLE_ADDR_TYPE addr_type,
193                                       tBT_TRANSPORT transport);
194 
195 /*******************************************************************************
196  *
197  * Function         BTM_SecBond
198  *
199  * Description      This function is called to perform bonding with peer device.
200  *                  If the connection is already up, but not secure, pairing
201  *                  is attempted.  If already paired BTM_SUCCESS is returned.
202  *
203  * Parameters:      bd_addr      - Address of the device to bond
204  *                  transport    - doing SSP over BR/EDR or SMP over LE
205  *
206  *  Note: After 2.1 parameters are not used and preserved here not to change API
207  ******************************************************************************/
208 tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
209                         tBT_TRANSPORT transport, tBT_DEVICE_TYPE device_type);
210 
211 /*******************************************************************************
212  *
213  * Function         BTM_SecBondCancel
214  *
215  * Description      This function is called to cancel ongoing bonding process
216  *                  with peer device.
217  *
218  * Parameters:      bd_addr      - Address of the peer device
219  *                  transport    - false for BR/EDR link; true for LE link
220  *
221  ******************************************************************************/
222 tBTM_STATUS BTM_SecBondCancel(const RawAddress& bd_addr);
223 
224 /*******************************************************************************
225  *
226  * Function         BTM_SecGetDeviceLinkKeyType
227  *
228  * Description      This function is called to obtain link key type for the
229  *                  device.
230  *                  it returns BTM_SUCCESS if link key is available, or
231  *                  BTM_UNKNOWN_ADDR if Security Manager does not know about
232  *                  the device or device record does not contain link key info
233  *
234  * Returns          BTM_LKEY_TYPE_IGNORE if link key is unknown, link type
235  *                  otherwise.
236  *
237  ******************************************************************************/
238 tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType(const RawAddress& bd_addr);
239 
240 /*******************************************************************************
241  *
242  * Function         BTM_SetEncryption
243  *
244  * Description      This function is called to ensure that connection is
245  *                  encrypted.  Should be called only on an open connection.
246  *                  Typically only needed for connections that first want to
247  *                  bring up unencrypted links, then later encrypt them.
248  *
249  * Parameters:      bd_addr       - Address of the peer device
250  *                  transport     - Link transport
251  *                  p_callback    - Pointer to callback function called if
252  *                                  this function returns PENDING after required
253  *                                  procedures are completed.  Can be set to
254  *                                  NULL if status is not desired.
255  *                  p_ref_data    - pointer to any data the caller wishes to
256  *                                  receive in the callback function upon
257  *                                  completion. can be set to NULL if not used.
258  *                  sec_act       - LE security action, unused for BR/EDR
259  *
260  * Returns          BTM_SUCCESS   - already encrypted
261  *                  BTM_PENDING   - command will be returned in the callback
262  *                  BTM_WRONG_MODE- connection not up.
263  *                  BTM_BUSY      - security procedures are currently active
264  *                  BTM_ERR_KEY_MISSING  - link key is missing.
265  *                  BTM_MODE_UNSUPPORTED - if security manager not linked in.
266  *
267  ******************************************************************************/
268 tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
269                               tBT_TRANSPORT transport,
270                               tBTM_SEC_CALLBACK* p_callback, void* p_ref_data,
271                               tBTM_BLE_SEC_ACT sec_act);
272 
273 bool BTM_SecIsSecurityPending(const RawAddress& bd_addr);
274 
275 /*******************************************************************************
276  *
277  * Function         BTM_ConfirmReqReply
278  *
279  * Description      This function is called to confirm the numeric value for
280  *                  Simple Pairing in response to BTM_SP_CFM_REQ_EVT
281  *
282  * Parameters:      res           - result of the operation BTM_SUCCESS if
283  *                                  success
284  *                  bd_addr       - Address of the peer device
285  *
286  ******************************************************************************/
287 void BTM_ConfirmReqReply(tBTM_STATUS res, const RawAddress& bd_addr);
288 
289 /*******************************************************************************
290  *
291  * Function         BTM_PasskeyReqReply
292  *
293  * Description      This function is called to provide the passkey for
294  *                  Simple Pairing in response to BTM_SP_KEY_REQ_EVT
295  *
296  * Parameters:      res     - result of the operation BTM_SUCCESS if success
297  *                  bd_addr - Address of the peer device
298  *                  passkey - numeric value in the range of
299  *                  BTM_MIN_PASSKEY_VAL(0) -
300  *                  BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
301  *
302  ******************************************************************************/
303 void BTM_PasskeyReqReply(tBTM_STATUS res, const RawAddress& bd_addr,
304                          uint32_t passkey);
305 
306 /*******************************************************************************
307  *
308  * Function         BTM_ReadLocalOobData
309  *
310  * Description      This function is called to read the local OOB data from
311  *                  LM
312  *
313  ******************************************************************************/
314 void BTM_ReadLocalOobData(void);
315 
316 /*******************************************************************************
317  *
318  * Function         BTM_RemoteOobDataReply
319  *
320  * Description      This function is called to provide the remote OOB data for
321  *                  Simple Pairing in response to BTM_SP_RMT_OOB_EVT
322  *
323  * Parameters:      bd_addr     - Address of the peer device
324  *                  c           - simple pairing Hash C.
325  *                  r           - simple pairing Randomizer  C.
326  *
327  ******************************************************************************/
328 void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr,
329                             const Octet16& c, const Octet16& r);
330 
331 /*******************************************************************************
332  *
333  * Function         BTM_PeerSupportsSecureConnections
334  *
335  * Description      This function is called to check if the peer supports
336  *                  BR/EDR Secure Connections.
337  *
338  * Parameters:      bd_addr - address of the peer
339  *
340  * Returns          true if BR/EDR Secure Connections are supported by the peer,
341  *                  else false.
342  *
343  ******************************************************************************/
344 bool BTM_PeerSupportsSecureConnections(const RawAddress& bd_addr);
345 
346 /*******************************************************************************
347  *
348  * Function         BTM_GetInitialSecurityMode
349  *
350  * Description      This function is called to retrieve the configured
351  *                  security mode.
352  *
353  ******************************************************************************/
354 uint8_t BTM_GetSecurityMode();
355 
356 /*******************************************************************************
357  *
358  * Function         btm_sec_l2cap_access_req
359  *
360  * Description      This function is called by the L2CAP to grant permission to
361  *                  establish L2CAP connection to or from the peer device.
362  *
363  * Parameters:      bd_addr       - Address of the peer device
364  *                  psm           - L2CAP PSM
365  *                  is_originator - true if protocol above L2CAP originates
366  *                                  connection
367  *                  p_callback    - Pointer to callback function called if
368  *                                  this function returns PENDING after required
369  *                                  procedures are complete. MUST NOT BE NULL.
370  *
371  * Returns          tBTM_STATUS
372  *
373  ******************************************************************************/
374 tBTM_STATUS btm_sec_l2cap_access_req(const RawAddress& bd_addr, uint16_t psm,
375                                      bool is_originator,
376                                      tBTM_SEC_CALLBACK* p_callback,
377                                      void* p_ref_data);
378 
379 // Allow enforcing security by specific requirement (from shim layer).
380 tBTM_STATUS btm_sec_l2cap_access_req_by_requirement(
381     const RawAddress& bd_addr, uint16_t security_required, bool is_originator,
382     tBTM_SEC_CALLBACK* p_callback, void* p_ref_data);
383 
384 /*******************************************************************************
385  *
386  * Function         btm_sec_mx_access_request
387  *
388  * Description      This function is called by all Multiplexing Protocols
389  *during establishing connection to or from peer device to grant permission
390  *to establish application connection.
391  *
392  * Parameters:      bd_addr       - Address of the peer device
393  *                  psm           - L2CAP PSM
394  *                  is_originator - true if protocol above L2CAP originates
395  *                                  connection
396  *                  mx_proto_id   - protocol ID of the multiplexer
397  *                  mx_chan_id    - multiplexer channel to reach application
398  *                  p_callback    - Pointer to callback function called if
399  *                                  this function returns PENDING after
400  *required procedures are completed p_ref_data    - Pointer to any reference
401  *data needed by the the callback function.
402  *
403  * Returns          BTM_CMD_STARTED
404  *
405  ******************************************************************************/
406 tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
407                                       bool is_originator,
408                                       uint16_t security_requirement,
409                                       tBTM_SEC_CALLBACK* p_callback,
410                                       void* p_ref_data);
411 
412 /*******************************************************************************
413  *
414  * Function         btm_sec_conn_req
415  *
416  * Description      This function is when the peer device is requesting
417  *                  connection
418  *
419  * Returns          void
420  *
421  ******************************************************************************/
422 void btm_sec_conn_req(const RawAddress& bda, const DEV_CLASS dc);
423 
424 /*******************************************************************************
425  *
426  * Function         btm_create_conn_cancel_complete
427  *
428  * Description      This function is called when the command complete message
429  *                  is received from the HCI for the create connection cancel
430  *                  command.
431  *
432  * Returns          void
433  *
434  ******************************************************************************/
435 void btm_create_conn_cancel_complete(uint8_t status, const RawAddress bd_addr,
436                                      uint32_t value);
437 
438 /*******************************************************************************
439  *
440  * Function         btm_sec_dev_reset
441  *
442  * Description      This function should be called after device reset
443  *
444  * Returns          void
445  *
446  ******************************************************************************/
447 void btm_sec_dev_reset(void);
448 
449 /*******************************************************************************
450  *
451  * Function         btm_sec_abort_access_req
452  *
453  * Description      This function is called by the L2CAP or RFCOMM to abort
454  *                  the pending operation.
455  *
456  * Parameters:      bd_addr       - Address of the peer device
457  *
458  * Returns          void
459  *
460  ******************************************************************************/
461 void btm_sec_abort_access_req(const RawAddress& bd_addr);
462 
463 /*******************************************************************************
464  *
465  * Function         btm_sec_rmt_name_request_complete
466  *
467  * Description      This function is called when remote name was obtained from
468  *                  the peer device
469  *
470  * Returns          void
471  *
472  ******************************************************************************/
473 void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr,
474                                        const uint8_t* p_bd_name,
475                                        tHCI_STATUS status);
476 
477 /*******************************************************************************
478  *
479  * Function         btm_sec_rmt_host_support_feat_evt
480  *
481  * Description      This function is called when the
482  *                  HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT is received
483  *
484  * Returns          void
485  *
486  ******************************************************************************/
487 void btm_sec_rmt_host_support_feat_evt(const RawAddress bd_addr,
488                                        uint8_t features_0);
489 
490 /*******************************************************************************
491  *
492  * Function         btm_io_capabilities_req
493  *
494  * Description      This function is called when LM request for the IO
495  *                  capability of the local device and
496  *                  if the OOB data is present for the device in the event
497  *
498  * Returns          void
499  *
500  ******************************************************************************/
501 void btm_io_capabilities_req(RawAddress p);
502 
503 /*******************************************************************************
504  *
505  * Function         btm_io_capabilities_rsp
506  *
507  * Description      This function is called when the IO capability of the
508  *                  specified device is received
509  *
510  * Returns          void
511  *
512  ******************************************************************************/
513 void btm_io_capabilities_rsp(const tBTM_SP_IO_RSP evt_data);
514 
515 /*******************************************************************************
516  *
517  * Function         btm_proc_sp_req_evt
518  *
519  * Description      This function is called to process/report
520  *                  HCI_USER_CONFIRMATION_REQUEST_EVT
521  *                  or HCI_USER_PASSKEY_REQUEST_EVT
522  *                  or HCI_USER_PASSKEY_NOTIFY_EVT
523  *
524  * Returns          void
525  *
526  ******************************************************************************/
527 void btm_proc_sp_req_evt(tBTM_SP_EVT event, const RawAddress bda,
528                          uint32_t value);
529 
530 /*******************************************************************************
531  *
532  * Function         btm_simple_pair_complete
533  *
534  * Description      This function is called when simple pairing process is
535  *                  complete
536  *
537  * Returns          void
538  *
539  ******************************************************************************/
540 void btm_simple_pair_complete(const RawAddress bd_addr, uint8_t status);
541 
542 /*******************************************************************************
543  *
544  * Function         btm_rem_oob_req
545  *
546  * Description      This function is called to process/report
547  *                  HCI_REMOTE_OOB_DATA_REQUEST_EVT
548  *
549  * Returns          void
550  *
551  ******************************************************************************/
552 void btm_rem_oob_req(const RawAddress bd_addr);
553 
554 /*******************************************************************************
555  *
556  * Function         btm_read_local_oob_complete
557  *
558  * Description      This function is called when read local oob data is
559  *                  completed by the LM
560  *
561  * Returns          void
562  *
563  ******************************************************************************/
564 void btm_read_local_oob_complete(const tBTM_SP_LOC_OOB evt_data);
565 
566 /*******************************************************************************
567  *
568  * Function         btm_sec_auth_complete
569  *
570  * Description      This function is when authentication of the connection is
571  *                  completed by the LM
572  *
573  * Returns          void
574  *
575  ******************************************************************************/
576 void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status);
577 
578 /*******************************************************************************
579  *
580  * Function         btm_sec_encryption_change_evt
581  *
582  * Description      This function is called to process an encryption change.
583  *
584  * Returns          void
585  *
586  ******************************************************************************/
587 void btm_sec_encryption_change_evt(uint16_t handle, tHCI_STATUS status,
588                                    uint8_t encr_enable);
589 
590 /*******************************************************************************
591  *
592  * Function         btm_sec_encrypt_change
593  *
594  * Description      This function is when encryption of the connection is
595  *                  completed by the LM
596  *
597  * Returns          void
598  *
599  ******************************************************************************/
600 void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status,
601                             uint8_t encr_enable);
602 
603 /*******************************************************************************
604  *
605  * Function         btm_sec_connected
606  *
607  * Description      This function is when a connection to the peer device is
608  *                  established
609  *
610  * Returns          void
611  *
612  ******************************************************************************/
613 void btm_sec_connected(const RawAddress& bda, uint16_t handle,
614                        tHCI_STATUS status, uint8_t enc_mode,
615                        tHCI_ROLE assigned_role = HCI_ROLE_PERIPHERAL);
616 
617 /*******************************************************************************
618  *
619  * Function         btm_sec_disconnect
620  *
621  * Description      This function is called to disconnect HCI link
622  *
623  * Returns          btm status
624  *
625  ******************************************************************************/
626 tBTM_STATUS btm_sec_disconnect(uint16_t handle, tHCI_STATUS reason,
627                                std::string);
628 
629 /*******************************************************************************
630  *
631  * Function         btm_sec_disconnected
632  *
633  * Description      This function is when a connection to the peer device is
634  *                  dropped
635  *
636  * Returns          void
637  *
638  ******************************************************************************/
639 void btm_sec_disconnected(uint16_t handle, tHCI_STATUS reason,
640                           std::string comment);
641 
642 /*******************************************************************************
643  *
644  * Function         btm_sec_role_changed
645  *
646  * Description      This function is called when receiving an HCI role change
647  *                  event
648  *
649  * Returns          void
650  *
651  ******************************************************************************/
652 void btm_sec_role_changed(tHCI_STATUS hci_status, const RawAddress& bd_addr,
653                           tHCI_ROLE new_role);
654 
655 /** This function is called when a new connection link key is generated */
656 void btm_sec_link_key_notification(const RawAddress& p_bda,
657                                    const Octet16& link_key, uint8_t key_type);
658 
659 /** This function is called for each encryption key refresh complete event */
660 void btm_sec_encryption_key_refresh_complete(uint16_t handle,
661                                              tHCI_STATUS status);
662 
663 /*******************************************************************************
664  *
665  * Function         btm_sec_link_key_request
666  *
667  * Description      This function is called when controller requests link key
668  *
669  * Returns          Pointer to the record or NULL
670  *
671  ******************************************************************************/
672 void btm_sec_link_key_request(const RawAddress bda);
673 
674 /*******************************************************************************
675  *
676  * Function         btm_sec_pin_code_request
677  *
678  * Description      This function is called when controller requests PIN code
679  *
680  * Returns          Pointer to the record or NULL
681  *
682  ******************************************************************************/
683 void btm_sec_pin_code_request(const RawAddress bda);
684 
685 /*******************************************************************************
686  *
687  * Function         btm_sec_update_clock_offset
688  *
689  * Description      This function is called to update clock offset
690  *
691  * Returns          void
692  *
693  ******************************************************************************/
694 void btm_sec_update_clock_offset(uint16_t handle, uint16_t clock_offset);
695 
696 /*******************************************************************************
697  *
698  * Function         btm_sec_dev_rec_cback_event
699  *
700  * Description      This function calls the callback function with the given
701  *                  result and clear the callback function.
702  *
703  * Parameters:      void
704  *
705  ******************************************************************************/
706 void btm_sec_dev_rec_cback_event(tBTM_SEC_DEV_REC* p_dev_rec, tBTM_STATUS res,
707                                  bool is_le_transport);
708 
709 /*******************************************************************************
710  *
711  * Function         btm_sec_clear_ble_keys
712  *
713  * Description      This function is called to clear out the BLE keys.
714  *                  Typically when devices are removed in BTM_SecDeleteDevice,
715  *                  or when a new BT Link key is generated.
716  *
717  * Returns          void
718  *
719  ******************************************************************************/
720 void btm_sec_clear_ble_keys(tBTM_SEC_DEV_REC* p_dev_rec);
721 
722 /*******************************************************************************
723  *
724  * Function         btm_sec_is_a_bonded_dev
725  *
726  * Description       Is the specified device is a bonded device
727  *
728  * Returns          true - dev is bonded
729  *
730  ******************************************************************************/
731 bool btm_sec_is_a_bonded_dev(const RawAddress& bda);
732 
733 /*******************************************************************************
734  *
735  * Function         btm_sec_set_peer_sec_caps
736  *
737  * Description      This function is called to set sm4 and rmt_sec_caps fields
738  *                  based on the available peer device features.
739  *
740  * Returns          void
741  *
742  ******************************************************************************/
743 void btm_sec_set_peer_sec_caps(uint16_t hci_handle, bool ssp_supported,
744                                bool sc_supported,
745                                bool hci_role_switch_supported,
746                                bool br_edr_supported, bool le_supported);
747 
748 /*******************************************************************************
749  *
750  * Function         btm_sec_cr_loc_oob_data_cback_event
751  *
752  * Description      This function is called to pass the local oob up to caller
753  *
754  * Returns          void
755  *
756  ******************************************************************************/
757 void btm_sec_cr_loc_oob_data_cback_event(const RawAddress& address,
758                                          tSMP_LOC_OOB_DATA loc_oob_data);
759 
760 // Return DEV_CLASS of bda. If record doesn't exist, create one.
761 DEV_CLASS btm_get_dev_class(const RawAddress& bda);
762