File tree Expand file tree Collapse file tree 4 files changed +19
-31
lines changed Expand file tree Collapse file tree 4 files changed +19
-31
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,10 @@ static bool br_sufficient_key_size(struct bt_conn *conn)
143143 key_size = rp -> key_size ;
144144 net_buf_unref (rsp );
145145
146+ if (conn -> br .link_key ) {
147+ conn -> br .link_key -> enc_key_size = key_size ;
148+ }
149+
146150 LOG_DBG ("Encryption key size is %u" , key_size );
147151
148152 if (conn -> sec_level == BT_SECURITY_L4 ) {
Original file line number Diff line number Diff line change @@ -2493,35 +2493,11 @@ uint8_t bt_conn_enc_key_size(const struct bt_conn *conn)
24932493 return 0 ;
24942494 }
24952495
2496- if (IS_ENABLED (CONFIG_BT_CLASSIC ) &&
2497- conn -> type == BT_CONN_TYPE_BR ) {
2498- struct bt_hci_cp_read_encryption_key_size * cp ;
2499- struct bt_hci_rp_read_encryption_key_size * rp ;
2500- struct net_buf * buf ;
2501- struct net_buf * rsp ;
2502- uint8_t key_size ;
2503-
2504- buf = bt_hci_cmd_alloc (K_FOREVER );
2505- if (!buf ) {
2506- return 0 ;
2507- }
2508-
2509- cp = net_buf_add (buf , sizeof (* cp ));
2510- cp -> handle = sys_cpu_to_le16 (conn -> handle );
2511-
2512- if (bt_hci_cmd_send_sync (BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE ,
2513- buf , & rsp )) {
2514- return 0 ;
2515- }
2516-
2517- rp = (void * )rsp -> data ;
2518-
2519- key_size = rp -> status ? 0 : rp -> key_size ;
2520-
2521- net_buf_unref (rsp );
2522-
2523- return key_size ;
2496+ #if defined(CONFIG_BT_CLASSIC )
2497+ if (conn -> type == BT_CONN_TYPE_BR ) {
2498+ return conn -> br .link_key ? conn -> br .link_key -> enc_key_size : 0 ;
25242499 }
2500+ #endif /* CONFIG_BT_CLASSIC */
25252501
25262502 if (IS_ENABLED (CONFIG_BT_SMP )) {
25272503 return conn -> le .keys ? conn -> le .keys -> enc_size : 0 ;
Original file line number Diff line number Diff line change @@ -1077,9 +1077,16 @@ static void hci_disconn_complete(struct net_buf *buf)
10771077 * If only for one connection session bond was set, clear keys
10781078 * database row for this connection.
10791079 */
1080- if (conn -> type == BT_CONN_TYPE_BR && conn -> br .link_key != NULL &&
1081- atomic_test_and_clear_bit (conn -> flags , BT_CONN_BR_NOBOND )) {
1082- bt_keys_link_key_clear (conn -> br .link_key );
1080+ if (conn -> type == BT_CONN_TYPE_BR && conn -> br .link_key != NULL ) {
1081+ /*
1082+ * If the connection link is paired but not bond, remove
1083+ * the link key upon disconnection.
1084+ */
1085+ if (atomic_test_and_clear_bit (conn -> flags , BT_CONN_BR_NOBOND )) {
1086+ bt_keys_link_key_clear (conn -> br .link_key );
1087+ }
1088+
1089+ conn -> br .link_key -> enc_key_size = 0 ;
10831090 }
10841091#endif
10851092 bt_conn_unref (conn );
Original file line number Diff line number Diff line change @@ -217,6 +217,7 @@ enum {
217217
218218struct bt_keys_link_key {
219219 bt_addr_t addr ;
220+ uint8_t enc_key_size ;
220221 uint8_t storage_start [0 ] __aligned (sizeof (void * ));
221222 uint8_t flags ;
222223 uint8_t val [16 ];
You can’t perform that action at this time.
0 commit comments