• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #pragma once
20 
21 #include <base/strings/stringprintf.h>
22 #include <string.h>
23 
24 #include <cstdint>
25 #include <string>
26 
27 #include "gd/crypto_toolbox/crypto_toolbox.h"
28 #include "main/shim/dumpsys.h"
29 #include "osi/include/alarm.h"
30 #include "stack/include/bt_device_type.h"
31 #include "stack/include/bt_octets.h"
32 #include "stack/include/btm_api_types.h"
33 #include "types/hci_role.h"
34 #include "types/raw_address.h"
35 
36 typedef struct {
37   uint16_t min_conn_int;
38   uint16_t max_conn_int;
39   uint16_t peripheral_latency;
40   uint16_t supervision_tout;
41 
42 } tBTM_LE_CONN_PRAMS;
43 
44 /* The MSB of the clock offset field indicates whether the offset is valid. */
45 #define BTM_CLOCK_OFFSET_VALID 0x8000
46 
47 /*
48  * Define structure for Security Service Record.
49  * A record exists for each service registered with the Security Manager
50  */
51 #define BTM_SEC_OUT_FLAGS (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT)
52 #define BTM_SEC_IN_FLAGS (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT)
53 
54 #define BTM_SEC_OUT_LEVEL4_FLAGS                                       \
55   (BTM_SEC_OUT_AUTHENTICATE | BTM_SEC_OUT_ENCRYPT | BTM_SEC_OUT_MITM | \
56    BTM_SEC_MODE4_LEVEL4)
57 
58 #define BTM_SEC_IN_LEVEL4_FLAGS                                     \
59   (BTM_SEC_IN_AUTHENTICATE | BTM_SEC_IN_ENCRYPT | BTM_SEC_IN_MITM | \
60    BTM_SEC_MODE4_LEVEL4)
61 typedef struct {
62   uint32_t mx_proto_id;     /* Service runs over this multiplexer protocol */
63   uint32_t orig_mx_chan_id; /* Channel on the multiplexer protocol    */
64   uint32_t term_mx_chan_id; /* Channel on the multiplexer protocol    */
65   uint16_t psm;             /* L2CAP PSM value */
66   uint16_t security_flags;  /* Bitmap of required security features */
67   uint8_t service_id;       /* Passed in authorization callback */
68   uint8_t orig_service_name[BT_MAX_SERVICE_NAME_LEN + 1];
69   uint8_t term_service_name[BT_MAX_SERVICE_NAME_LEN + 1];
70 } tBTM_SEC_SERV_REC;
71 
72 /* LE Security information of device in Peripheral Role */
73 typedef struct {
74   Octet16 irk;   /* peer diverified identity root */
75   Octet16 pltk;  /* peer long term key */
76   Octet16 pcsrk; /* peer SRK peer device used to secured sign local data  */
77 
78   Octet16 lltk;  /* local long term key */
79   Octet16 lcsrk; /* local SRK peer device used to secured sign local data  */
80 
81   BT_OCTET8 rand;        /* random vector for LTK generation */
82   uint16_t ediv;         /* LTK diversifier of this peripheral device */
83   uint16_t div;          /* local DIV  to generate local LTK=d1(ER,DIV,0) and
84                             CSRK=d1(ER,DIV,1)  */
85   uint8_t sec_level;     /* local pairing security level */
86   uint8_t key_size;      /* key size of the LTK delivered to peer device */
87   uint8_t srk_sec_level; /* security property of peer SRK for this device */
88   uint8_t local_csrk_sec_level; /* security property of local CSRK for this
89                                    device */
90 
91   uint32_t counter;       /* peer sign counter for verifying rcv signed cmd */
92   uint32_t local_counter; /* local sign counter for sending signed write cmd*/
93 } tBTM_SEC_BLE_KEYS;
94 
95 typedef struct {
96   RawAddress pseudo_addr; /* LE pseudo address of the device if different from
97                           device address  */
98  private:
99   tBLE_ADDR_TYPE ble_addr_type_; /* LE device type: public or random address */
100 
101  public:
AddressType__anonad31f1ac0408102   tBLE_ADDR_TYPE AddressType() const { return ble_addr_type_; }
SetAddressType__anonad31f1ac0408103   void SetAddressType(tBLE_ADDR_TYPE ble_addr_type) {
104     if (is_ble_addr_type_known(ble_addr_type)) ble_addr_type_ = ble_addr_type;
105   }
106 
107   tBLE_BD_ADDR identity_address_with_type;
108 
109 #define BTM_ACCEPTLIST_BIT 0x01
110 #define BTM_RESOLVING_LIST_BIT 0x02
111   uint8_t in_controller_list; /* in controller resolving list or not */
112   uint8_t resolving_list_index;
113   RawAddress cur_rand_addr; /* current random address */
114 
115   typedef enum : uint8_t {
116     BTM_BLE_ADDR_PSEUDO = 0,
117     BTM_BLE_ADDR_RRA = 1,
118     BTM_BLE_ADDR_STATIC = 2,
119   } tADDRESS_TYPE;
120   tADDRESS_TYPE active_addr_type;
121 
122   tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */
123   tBTM_SEC_BLE_KEYS keys;    /* LE device security info in peripheral rode */
124 } tBTM_SEC_BLE;
125 
126 enum : uint16_t {
127   BTM_SEC_AUTHENTICATED = 0x0002,
128   BTM_SEC_ENCRYPTED = 0x0004,
129   BTM_SEC_NAME_KNOWN = 0x0008,
130   BTM_SEC_LINK_KEY_KNOWN = 0x0010,
131   BTM_SEC_LINK_KEY_AUTHED = 0x0020,
132   BTM_SEC_ROLE_SWITCHED = 0x0040,  // UNUSED - only cleared
133   BTM_SEC_IN_USE = 0x0080,         // UNUSED - only set
134   /* LE link security flag */
135   /* LE link is encrypted after pairing with MITM */
136   BTM_SEC_LE_AUTHENTICATED = 0x0200,
137   /* LE link is encrypted */
138   BTM_SEC_LE_ENCRYPTED = 0x0400,
139   /* not used */
140   BTM_SEC_LE_NAME_KNOWN = 0x0800,  // UNUSED
141   /* bonded with peer (peer LTK and/or SRK is saved) */
142   BTM_SEC_LE_LINK_KEY_KNOWN = 0x1000,
143   /* pairing is done with MITM */
144   BTM_SEC_LE_LINK_KEY_AUTHED = 0x2000,
145   /* pairing is done with 16 digit pin */
146   BTM_SEC_16_DIGIT_PIN_AUTHED = 0x4000,
147 };
148 
149 #define CASE_RETURN_TEXT(code) \
150   case code:                   \
151     return #code
152 
153 typedef enum : uint8_t {
154   BTM_SEC_STATE_IDLE = 0,
155   BTM_SEC_STATE_AUTHENTICATING = 1,
156   BTM_SEC_STATE_ENCRYPTING = 2,
157   BTM_SEC_STATE_GETTING_NAME = 3,
158   BTM_SEC_STATE_AUTHORIZING = 4,
159   BTM_SEC_STATE_SWITCHING_ROLE = 5,
160   /* disconnecting BR/EDR */
161   BTM_SEC_STATE_DISCONNECTING = 6,
162   /* delay to check for encryption to work around */
163   /* controller problems */
164   BTM_SEC_STATE_DELAY_FOR_ENC = 7,
165   BTM_SEC_STATE_DISCONNECTING_BLE = 8,
166   BTM_SEC_STATE_DISCONNECTING_BOTH = 9,
167 } tSECURITY_STATE;
168 
security_state_text(const tSECURITY_STATE & state)169 static inline std::string security_state_text(const tSECURITY_STATE& state) {
170   switch (state) {
171     CASE_RETURN_TEXT(BTM_SEC_STATE_IDLE);
172     CASE_RETURN_TEXT(BTM_SEC_STATE_AUTHENTICATING);
173     CASE_RETURN_TEXT(BTM_SEC_STATE_ENCRYPTING);
174     CASE_RETURN_TEXT(BTM_SEC_STATE_GETTING_NAME);
175     CASE_RETURN_TEXT(BTM_SEC_STATE_AUTHORIZING);
176     CASE_RETURN_TEXT(BTM_SEC_STATE_SWITCHING_ROLE);
177     CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING);
178     CASE_RETURN_TEXT(BTM_SEC_STATE_DELAY_FOR_ENC);
179     CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BLE);
180     CASE_RETURN_TEXT(BTM_SEC_STATE_DISCONNECTING_BOTH);
181     default:
182       return base::StringPrintf("UNKNOWN[%hhu]", state);
183   }
184 }
185 
186 typedef enum : uint8_t {
187   BTM_SM4_UNKNOWN = 0x00,
188   BTM_SM4_KNOWN = 0x10,
189   BTM_SM4_TRUE = 0x11,
190   BTM_SM4_REQ_PEND = 0x08, /* set this bit when getting remote features */
191   BTM_SM4_UPGRADE = 0x04,  /* set this bit when upgrading link key */
192   BTM_SM4_RETRY = 0x02,    /* set this bit to retry on HCI_ERR_KEY_MISSING or \
193                               HCI_ERR_LMP_ERR_TRANS_COLLISION */
194   BTM_SM4_DD_ACP =
195       0x20, /* set this bit to indicate peer initiated dedicated bonding */
196   BTM_SM4_CONN_PEND = 0x40, /* set this bit to indicate accepting acl conn; to
197                              be cleared on \ btm_acl_created */
198 } tBTM_SM4_BIT;
199 
class_of_device_text(const DEV_CLASS & cod)200 inline std::string class_of_device_text(const DEV_CLASS& cod) {
201   return base::StringPrintf("0x%02x%02x%02x", cod[2], cod[1], cod[0]);
202 }
203 
204 /*
205  * Define structure for Security Device Record.
206  * A record exists for each device authenticated with this device
207  */
208 struct tBTM_SEC_DEV_REC {
209   /* Peering bond type */
210   typedef enum : uint8_t {
211     BOND_TYPE_UNKNOWN = 0,
212     BOND_TYPE_PERSISTENT = 1,
213     BOND_TYPE_TEMPORARY = 2
214   } tBTM_BOND_TYPE;
215 
216   uint32_t required_security_flags_for_pairing;
217   tBTM_SEC_CALLBACK* p_callback;
218   void* p_ref_data;
219   uint32_t timestamp; /* Timestamp of the last connection   */
220   uint16_t hci_handle;     /* Handle to connection when exists   */
221   uint16_t clock_offset;   /* Latest known clock offset          */
222   RawAddress bd_addr;      /* BD_ADDR of the device              */
223   DEV_CLASS dev_class;     /* DEV_CLASS of the device            */
224   LinkKey link_key;        /* Device link key                    */
225   tHCI_STATUS sec_status;      /* status for pin_or_key_missing      */
226 
227  public:
RemoteAddresstBTM_SEC_DEV_REC228   RawAddress RemoteAddress() const { return bd_addr; }
get_br_edr_hci_handletBTM_SEC_DEV_REC229   uint16_t get_br_edr_hci_handle() const { return hci_handle; }
230 
231  private:
232   friend bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
233                                const BD_NAME& bd_name, uint8_t* features,
234                                LinkKey* p_link_key, uint8_t key_type,
235                                uint8_t pin_length);
236   friend void BTM_PINCodeReply(const RawAddress& bd_addr, tBTM_STATUS res,
237                                uint8_t pin_len, uint8_t* p_pin);
238   friend void btm_sec_auth_complete(uint16_t handle, tHCI_STATUS status);
239   friend void btm_sec_connected(const RawAddress& bda, uint16_t handle,
240                                 tHCI_STATUS status, uint8_t enc_mode,
241                                 tHCI_ROLE);
242   friend void btm_sec_encrypt_change(uint16_t handle, tHCI_STATUS status,
243                                      uint8_t encr_enable);
244   friend void btm_sec_link_key_notification(const RawAddress& p_bda,
245                                             const Octet16& link_key,
246                                             uint8_t key_type);
247   friend tBTM_STATUS btm_sec_bond_by_transport(const RawAddress& bd_addr,
248                                                tBLE_ADDR_TYPE addr_type,
249                                                tBT_TRANSPORT transport,
250                                                uint8_t pin_len, uint8_t* p_pin);
251   uint8_t pin_code_length; /* Length of the pin_code used for paring */
252 
253  public:
254   uint16_t sec_flags; /* Current device security state      */
is_device_authenticatedtBTM_SEC_DEV_REC255   bool is_device_authenticated() const {
256     return sec_flags & BTM_SEC_AUTHENTICATED;
257   }
set_device_authenticatedtBTM_SEC_DEV_REC258   void set_device_authenticated() { sec_flags |= BTM_SEC_AUTHENTICATED; }
reset_device_authenticatedtBTM_SEC_DEV_REC259   void reset_device_authenticated() { sec_flags &= ~BTM_SEC_AUTHENTICATED; }
260 
is_device_encryptedtBTM_SEC_DEV_REC261   bool is_device_encrypted() const { return sec_flags & BTM_SEC_ENCRYPTED; }
set_device_encryptedtBTM_SEC_DEV_REC262   void set_device_encrypted() { sec_flags |= BTM_SEC_ENCRYPTED; }
reset_device_encryptedtBTM_SEC_DEV_REC263   void reset_device_encrypted() { sec_flags &= ~BTM_SEC_ENCRYPTED; }
264 
is_name_knowntBTM_SEC_DEV_REC265   bool is_name_known() const { return sec_flags & BTM_SEC_NAME_KNOWN; }
set_device_knowntBTM_SEC_DEV_REC266   void set_device_known() { sec_flags |= BTM_SEC_NAME_KNOWN; }
reset_device_knowntBTM_SEC_DEV_REC267   void reset_device_known() { sec_flags &= ~BTM_SEC_NAME_KNOWN; }
268 
is_link_key_knowntBTM_SEC_DEV_REC269   bool is_link_key_known() const { return sec_flags & BTM_SEC_LINK_KEY_KNOWN; }
set_link_key_knowntBTM_SEC_DEV_REC270   void set_link_key_known() { sec_flags |= BTM_SEC_LINK_KEY_KNOWN; }
reset_link_key_knowntBTM_SEC_DEV_REC271   void reset_link_key_known() { sec_flags &= ~BTM_SEC_LINK_KEY_KNOWN; }
272 
is_link_key_authenticatedtBTM_SEC_DEV_REC273   bool is_link_key_authenticated() const {
274     return sec_flags & BTM_SEC_LINK_KEY_AUTHED;
275   }
set_link_key_authenticatedtBTM_SEC_DEV_REC276   void set_link_key_authenticated() { sec_flags |= BTM_SEC_LINK_KEY_AUTHED; }
reset_link_key_authenticatedtBTM_SEC_DEV_REC277   void reset_link_key_authenticated() { sec_flags &= ~BTM_SEC_LINK_KEY_AUTHED; }
278 
is_le_device_authenticatedtBTM_SEC_DEV_REC279   bool is_le_device_authenticated() const {
280     return sec_flags & BTM_SEC_LE_AUTHENTICATED;
281   }
set_le_device_authenticatedtBTM_SEC_DEV_REC282   void set_le_device_authenticated() { sec_flags |= BTM_SEC_LE_AUTHENTICATED; }
reset_le_device_authenticatedtBTM_SEC_DEV_REC283   void reset_le_device_authenticated() {
284     sec_flags &= ~BTM_SEC_LE_AUTHENTICATED;
285   }
286 
is_le_device_encryptedtBTM_SEC_DEV_REC287   bool is_le_device_encrypted() const {
288     return sec_flags & BTM_SEC_LE_ENCRYPTED;
289   }
set_le_device_encryptedtBTM_SEC_DEV_REC290   void set_le_device_encrypted() { sec_flags |= BTM_SEC_LE_ENCRYPTED; }
reset_le_device_encryptedtBTM_SEC_DEV_REC291   void reset_le_device_encrypted() { sec_flags &= ~BTM_SEC_LE_ENCRYPTED; }
292 
is_le_link_key_knowntBTM_SEC_DEV_REC293   bool is_le_link_key_known() const {
294     return sec_flags & BTM_SEC_LE_LINK_KEY_KNOWN;
295   }
set_le_link_key_knowntBTM_SEC_DEV_REC296   void set_le_link_key_known() { sec_flags |= BTM_SEC_LE_LINK_KEY_KNOWN; }
reset_le_link_key_knowntBTM_SEC_DEV_REC297   void reset_le_link_key_known() { sec_flags &= ~BTM_SEC_LE_LINK_KEY_KNOWN; }
298 
is_le_link_key_authenticatedtBTM_SEC_DEV_REC299   bool is_le_link_key_authenticated() const {
300     return sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED;
301   }
set_le_link_key_authenticatedtBTM_SEC_DEV_REC302   void set_le_link_key_authenticated() {
303     sec_flags |= BTM_SEC_LE_LINK_KEY_AUTHED;
304   }
reset_le_link_key_authenticatedtBTM_SEC_DEV_REC305   void reset_le_link_key_authenticated() {
306     sec_flags &= ~BTM_SEC_LE_LINK_KEY_AUTHED;
307   }
308 
is_le_link_16_digit_key_authenticatedtBTM_SEC_DEV_REC309   bool is_le_link_16_digit_key_authenticated() const {
310     return sec_flags & BTM_SEC_16_DIGIT_PIN_AUTHED;
311   }
set_le_link_16_digit_key_authenticatedtBTM_SEC_DEV_REC312   void set_le_link_16_digit_key_authenticated() {
313     sec_flags |= BTM_SEC_16_DIGIT_PIN_AUTHED;
314   }
reset_le_link_16_digit_key_authenticatedtBTM_SEC_DEV_REC315   void reset_le_link_16_digit_key_authenticated() {
316     sec_flags &= ~BTM_SEC_16_DIGIT_PIN_AUTHED;
317   }
318 
319   tBTM_BD_NAME sec_bd_name; /* User friendly name of the device. (may be
320                                truncated to save space in dev_rec table) */
321 
322   tSECURITY_STATE sec_state; /* Operating state                    */
is_security_state_idletBTM_SEC_DEV_REC323   bool is_security_state_idle() const {
324     return sec_state == BTM_SEC_STATE_IDLE;
325   }
is_security_state_authenticatingtBTM_SEC_DEV_REC326   bool is_security_state_authenticating() const {
327     return sec_state == BTM_SEC_STATE_AUTHENTICATING;
328   }
is_security_state_encryptingtBTM_SEC_DEV_REC329   bool is_security_state_encrypting() const {
330     return sec_state == BTM_SEC_STATE_ENCRYPTING;
331   }
is_security_state_getting_nametBTM_SEC_DEV_REC332   bool is_security_state_getting_name() const {
333     return sec_state == BTM_SEC_STATE_GETTING_NAME;
334   }
is_security_state_authorizingtBTM_SEC_DEV_REC335   bool is_security_state_authorizing() const {
336     return sec_state == BTM_SEC_STATE_AUTHORIZING;
337   }
is_security_state_switching_roletBTM_SEC_DEV_REC338   bool is_security_state_switching_role() const {
339     return sec_state == BTM_SEC_STATE_SWITCHING_ROLE;
340   }
is_security_state_disconnectingtBTM_SEC_DEV_REC341   bool is_security_state_disconnecting() const {
342     return sec_state == BTM_SEC_STATE_DISCONNECTING;
343   }
is_security_state_wait_for_encryptiontBTM_SEC_DEV_REC344   bool is_security_state_wait_for_encryption() const {
345     return sec_state == BTM_SEC_STATE_DELAY_FOR_ENC;
346   }
is_security_state_ble_disconnectingtBTM_SEC_DEV_REC347   bool is_security_state_ble_disconnecting() const {
348     return sec_state == BTM_SEC_STATE_DISCONNECTING_BLE;
349   }
is_security_state_br_edr_and_bletBTM_SEC_DEV_REC350   bool is_security_state_br_edr_and_ble() const {
351     return sec_state == BTM_SEC_STATE_DISCONNECTING_BOTH;
352   }
353 
354  private:
355   bool is_originator;         /* true if device is originating connection */
356   friend tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
357                                        tBT_TRANSPORT transport,
358                                        tBTM_SEC_CALLBACK* p_callback,
359                                        void* p_ref_data,
360                                        tBTM_BLE_SEC_ACT sec_act);
361   friend tBTM_STATUS btm_sec_l2cap_access_req_by_requirement(
362       const RawAddress& bd_addr, uint16_t security_required, bool is_originator,
363       tBTM_SEC_CALLBACK* p_callback, void* p_ref_data);
364   friend tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
365                                                bool is_originator,
366                                                uint16_t security_required,
367                                                tBTM_SEC_CALLBACK* p_callback,
368                                                void* p_ref_data);
369 
370  public:
IsLocallyInitiatedtBTM_SEC_DEV_REC371   bool IsLocallyInitiated() const { return is_originator; }
372 
373   bool role_central;          /* true if current mode is central     */
374   uint16_t security_required; /* Security required for connection   */
375   bool link_key_not_sent; /* link key notification has not been sent waiting for
376                              name */
377   uint8_t link_key_type;  /* Type of key used in pairing   */
378 
379   uint8_t sm4;                /* BTM_SM4_TRUE, if the peer supports SM4 */
380   tBTM_IO_CAP rmt_io_caps;    /* IO capability of the peer device */
381   tBTM_AUTH_REQ rmt_auth_req; /* the auth_req flag as in the IO caps rsp evt */
382 
383   bool remote_supports_secure_connections;
384   friend void btm_sec_set_peer_sec_caps(uint16_t hci_handle, bool ssp_supported,
385                                         bool sc_supported,
386                                         bool hci_role_switch_supported,
387                                         bool br_edr_supported,
388                                         bool le_supported);
389 
390  public:
SupportsSecureConnectionstBTM_SEC_DEV_REC391   bool SupportsSecureConnections() const {
392     return remote_supports_secure_connections;
393   }
394 
395   bool remote_features_needed; /* set to true if the local device is in */
396   /* "Secure Connections Only" mode and it receives */
397   /* HCI_IO_CAPABILITY_REQUEST_EVT from the peer before */
398   /* it knows peer's support for Secure Connections */
399   bool remote_supports_hci_role_switch = false;
400   bool remote_supports_bredr;
401   bool remote_supports_ble;
402   bool remote_feature_received = false;
403 
404   uint16_t ble_hci_handle; /* use in DUMO connection */
get_ble_hci_handletBTM_SEC_DEV_REC405   uint16_t get_ble_hci_handle() const { return ble_hci_handle; }
406 
407   uint8_t enc_key_size;    /* current link encryption key size */
get_encryption_key_sizetBTM_SEC_DEV_REC408   uint8_t get_encryption_key_size() const { return enc_key_size; }
409 
410   tBT_DEVICE_TYPE device_type;
is_device_type_br_edrtBTM_SEC_DEV_REC411   bool is_device_type_br_edr() const {
412     return device_type == BT_DEVICE_TYPE_BREDR;
413   }
is_device_type_bletBTM_SEC_DEV_REC414   bool is_device_type_ble() const { return device_type == BT_DEVICE_TYPE_BLE; }
is_device_type_dual_modetBTM_SEC_DEV_REC415   bool is_device_type_dual_mode() const {
416     return device_type == BT_DEVICE_TYPE_DUMO;
417   }
418 
is_device_type_has_bletBTM_SEC_DEV_REC419   bool is_device_type_has_ble() const {
420     return device_type & BT_DEVICE_TYPE_BLE;
421   }
422   bool new_encryption_key_is_p256; /* Set to true when the newly generated LK
423                                    ** is generated from P-256.
424                                    ** Link encrypted with such LK can be used
425                                    ** for SM over BR/EDR.
426                                    */
427   tBTM_BOND_TYPE bond_type; /* peering bond type */
is_bond_type_unknowntBTM_SEC_DEV_REC428   bool is_bond_type_unknown() const { return bond_type == BOND_TYPE_UNKNOWN; }
is_bond_type_persistenttBTM_SEC_DEV_REC429   bool is_bond_type_persistent() const {
430     return bond_type == BOND_TYPE_PERSISTENT;
431   }
is_bond_type_temporarytBTM_SEC_DEV_REC432   bool is_bond_type_temporary() const {
433     return bond_type == BOND_TYPE_TEMPORARY;
434   }
435 
436   tBTM_SEC_BLE ble;
437   tBTM_LE_CONN_PRAMS conn_params;
438 
439   tREMOTE_VERSION_INFO remote_version_info;
440 
ToStringtBTM_SEC_DEV_REC441   std::string ToString() const {
442     return base::StringPrintf(
443         "%s %6s cod:%s remote_info:%-14s sm4:0x%02x SecureConn:%c name:\"%s\"",
444         PRIVATE_ADDRESS(bd_addr), DeviceTypeText(device_type).c_str(),
445         class_of_device_text(dev_class).c_str(),
446         remote_version_info.ToString().c_str(), sm4,
447         (remote_supports_secure_connections) ? 'T' : 'F',
448         PRIVATE_NAME(sec_bd_name));
449   }
450 };
451