Skip to content

Commit d5bb334

Browse files
holtmannJohan Hedberg
authored and
Johan Hedberg
committed
Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
The minimum encryption key size for LE connections is 56 bits and to align LE with BR/EDR, enforce 56 bits of minimum encryption key size for BR/EDR connections as well. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]> Cc: [email protected]
1 parent e668eb1 commit d5bb334

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ struct adv_info {
190190

191191
#define HCI_MAX_SHORT_NAME_LENGTH 10
192192

193+
/* Min encryption key size to match with SMP */
194+
#define HCI_MIN_ENC_KEY_SIZE 7
195+
193196
/* Default LE RPA expiry time, 15 minutes */
194197
#define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
195198

net/bluetooth/hci_conn.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
12761276
!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
12771277
return 0;
12781278

1279+
/* The minimum encryption key size needs to be enforced by the
1280+
* host stack before establishing any L2CAP connections. The
1281+
* specification in theory allows a minimum of 1, but to align
1282+
* BR/EDR and LE transports, a minimum of 7 is chosen.
1283+
*/
1284+
if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
1285+
return 0;
1286+
12791287
return 1;
12801288
}
12811289

0 commit comments

Comments
 (0)