1 From d5bb334a8e171b262e48f378bd2096c0ea458265 Mon Sep 17 00:00:00 2001
2 From: Marcel Holtmann <marcel@holtmann.org>
3 Date: Wed, 24 Apr 2019 22:19:17 +0200
4 Subject: Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
6 From: Marcel Holtmann <marcel@holtmann.org>
8 commit d5bb334a8e171b262e48f378bd2096c0ea458265 upstream.
10 The minimum encryption key size for LE connections is 56 bits and to
11 align LE with BR/EDR, enforce 56 bits of minimum encryption key size for
12 BR/EDR connections as well.
14 Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
15 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
16 Cc: stable@vger.kernel.org
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 include/net/bluetooth/hci_core.h | 3 +++
21 net/bluetooth/hci_conn.c | 8 ++++++++
22 2 files changed, 11 insertions(+)
24 --- a/include/net/bluetooth/hci_core.h
25 +++ b/include/net/bluetooth/hci_core.h
26 @@ -182,6 +182,9 @@ struct adv_info {
28 #define HCI_MAX_SHORT_NAME_LENGTH 10
30 +/* Min encryption key size to match with SMP */
31 +#define HCI_MIN_ENC_KEY_SIZE 7
33 /* Default LE RPA expiry time, 15 minutes */
34 #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
36 --- a/net/bluetooth/hci_conn.c
37 +++ b/net/bluetooth/hci_conn.c
38 @@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_
39 !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
42 + /* The minimum encryption key size needs to be enforced by the
43 + * host stack before establishing any L2CAP connections. The
44 + * specification in theory allows a minimum of 1, but to align
45 + * BR/EDR and LE transports, a minimum of 7 is chosen.
47 + if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)