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 @@ -2507,35 +2507,11 @@ uint8_t bt_conn_enc_key_size(const struct bt_conn *conn)
25072507 return 0 ;
25082508 }
25092509
2510- if (IS_ENABLED (CONFIG_BT_CLASSIC ) &&
2511- conn -> type == BT_CONN_TYPE_BR ) {
2512- struct bt_hci_cp_read_encryption_key_size * cp ;
2513- struct bt_hci_rp_read_encryption_key_size * rp ;
2514- struct net_buf * buf ;
2515- struct net_buf * rsp ;
2516- uint8_t key_size ;
2517-
2518- buf = bt_hci_cmd_alloc (K_FOREVER );
2519- if (!buf ) {
2520- return 0 ;
2521- }
2522-
2523- cp = net_buf_add (buf , sizeof (* cp ));
2524- cp -> handle = sys_cpu_to_le16 (conn -> handle );
2525-
2526- if (bt_hci_cmd_send_sync (BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE ,
2527- buf , & rsp )) {
2528- return 0 ;
2529- }
2530-
2531- rp = (void * )rsp -> data ;
2532-
2533- key_size = rp -> status ? 0 : rp -> key_size ;
2534-
2535- net_buf_unref (rsp );
2536-
2537- return key_size ;
2510+ #if defined(CONFIG_BT_CLASSIC )
2511+ if (conn -> type == BT_CONN_TYPE_BR ) {
2512+ return conn -> br .link_key ? conn -> br .link_key -> enc_key_size : 0 ;
25382513 }
2514+ #endif /* CONFIG_BT_CLASSIC */
25392515
25402516 if (IS_ENABLED (CONFIG_BT_SMP )) {
25412517 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 @@ -223,6 +223,7 @@ enum {
223223
224224struct bt_keys_link_key {
225225 bt_addr_t addr ;
226+ uint8_t enc_key_size ;
226227 uint8_t storage_start [0 ] __aligned (sizeof (void * ));
227228 uint8_t flags ;
228229 uint8_t val [16 ];
You can’t perform that action at this time.
0 commit comments