Skip to content

Commit 8746f13

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: Disconnect if E0 is used for Level 4
E0 is not allowed with Level 4: BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C page 1319: '128-bit equivalent strength for link and encryption keys required using FIPS approved algorithms (E0 not allowed, SAFER+ not allowed, and P-192 not allowed; encryption key not shortened' SC enabled: > HCI Event: Read Remote Extended Features (0x23) plen 13 Status: Success (0x00) Handle: 256 Page: 1/2 Features: 0x0b 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Secure Simple Pairing (Host Support) LE Supported (Host) Secure Connections (Host Support) > HCI Event: Encryption Change (0x08) plen 4 Status: Success (0x00) Handle: 256 Encryption: Enabled with AES-CCM (0x02) SC disabled: > HCI Event: Read Remote Extended Features (0x23) plen 13 Status: Success (0x00) Handle: 256 Page: 1/2 Features: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Secure Simple Pairing (Host Support) LE Supported (Host) > HCI Event: Encryption Change (0x08) plen 4 Status: Success (0x00) Handle: 256 Encryption: Enabled with E0 (0x01) [May 8 20:23] Bluetooth: hci0: Invalid security: expect AES but E0 was used < HCI Command: Disconnect (0x01|0x0006) plen 3 Handle: 256 Reason: Authentication Failure (0x05) Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 5cbd3eb commit 8746f13

3 files changed

Lines changed: 31 additions & 16 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,11 +1481,13 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status)
14811481
else
14821482
encrypt = 0x01;
14831483

1484-
if (conn->sec_level == BT_SECURITY_SDP)
1485-
conn->sec_level = BT_SECURITY_LOW;
1484+
if (!status) {
1485+
if (conn->sec_level == BT_SECURITY_SDP)
1486+
conn->sec_level = BT_SECURITY_LOW;
14861487

1487-
if (conn->pending_sec_level > conn->sec_level)
1488-
conn->sec_level = conn->pending_sec_level;
1488+
if (conn->pending_sec_level > conn->sec_level)
1489+
conn->sec_level = conn->pending_sec_level;
1490+
}
14891491

14901492
mutex_lock(&hci_cb_list_lock);
14911493
list_for_each_entry(cb, &hci_cb_list, list) {

‎net/bluetooth/hci_conn.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,23 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
13221322
return 0;
13231323
}
13241324

1325+
/* AES encryption is required for Level 4:
1326+
*
1327+
* BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C
1328+
* page 1319:
1329+
*
1330+
* 128-bit equivalent strength for link and encryption keys
1331+
* required using FIPS approved algorithms (E0 not allowed,
1332+
* SAFER+ not allowed, and P-192 not allowed; encryption key
1333+
* not shortened)
1334+
*/
1335+
if (conn->sec_level == BT_SECURITY_FIPS &&
1336+
!test_bit(HCI_CONN_AES_CCM, &conn->flags)) {
1337+
bt_dev_err(conn->hdev,
1338+
"Invalid security: Missing AES-CCM usage");
1339+
return 0;
1340+
}
1341+
13251342
if (hci_conn_ssp_enabled(conn) &&
13261343
!test_bit(HCI_CONN_ENCRYPT, &conn->flags))
13271344
return 0;

‎net/bluetooth/hci_event.c‎

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,27 +3065,23 @@ static void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
30653065

30663066
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags);
30673067

3068+
/* Check link security requirements are met */
3069+
if (!hci_conn_check_link_mode(conn))
3070+
ev->status = HCI_ERROR_AUTH_FAILURE;
3071+
30683072
if (ev->status && conn->state == BT_CONNECTED) {
30693073
if (ev->status == HCI_ERROR_PIN_OR_KEY_MISSING)
30703074
set_bit(HCI_CONN_AUTH_FAILURE, &conn->flags);
30713075

3076+
/* Notify upper layers so they can cleanup before
3077+
* disconnecting.
3078+
*/
3079+
hci_encrypt_cfm(conn, ev->status);
30723080
hci_disconnect(conn, HCI_ERROR_AUTH_FAILURE);
30733081
hci_conn_drop(conn);
30743082
goto unlock;
30753083
}
30763084

3077-
/* In Secure Connections Only mode, do not allow any connections
3078-
* that are not encrypted with AES-CCM using a P-256 authenticated
3079-
* combination key.
3080-
*/
3081-
if (hci_dev_test_flag(hdev, HCI_SC_ONLY) &&
3082-
(!test_bit(HCI_CONN_AES_CCM, &conn->flags) ||
3083-
conn->key_type != HCI_LK_AUTH_COMBINATION_P256)) {
3084-
hci_connect_cfm(conn, HCI_ERROR_AUTH_FAILURE);
3085-
hci_conn_drop(conn);
3086-
goto unlock;
3087-
}
3088-
30893085
/* Try reading the encryption key size for encrypted ACL links */
30903086
if (!ev->status && ev->encrypt && conn->type == ACL_LINK) {
30913087
struct hci_cp_read_enc_key_size cp;

0 commit comments

Comments
 (0)