All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 00/11] Bluetooth: btnxpuart: Add secure interface support for NXP chipsets
@ 2025-11-18 14:20 Neeraj Sanjay Kale
  2025-11-18 14:20 ` [PATCH v1 01/11] Bluetooth: btnxpuart: Add firmware metadata parsing for secure interface Neeraj Sanjay Kale
                   ` (10 more replies)
  0 siblings, 11 replies; 19+ messages in thread
From: Neeraj Sanjay Kale @ 2025-11-18 14:20 UTC (permalink / raw)
  To: marcel, luiz.dentz
  Cc: linux-bluetooth, linux-kernel, amitkumar.karwar, sherry.sun,
	dmitrii.lebed, neeraj.sanjaykale

This patch series adds secure interface support for NXP Bluetooth chipsets 
to protect against UART-based attacks on Bluetooth security keys.

Problem Statement:
==================
Bluetooth UART drivers are vulnerable to physical attacks where adversaries
can monitor UART TX/RX lines to extract sensitive cryptographic material.
As demonstrated in research [1], attackers can capture H4 packets 
containing Link Keys, LTKs, and other pairing data transmitted in plaintext
over UART.

Once an attacker obtains these keys from UART traffic, they can:
- Decrypt all Bluetooth communication for paired devices
- Impersonate trusted devices
- Perform man-in-the-middle attacks

This vulnerability affects any Bluetooth implementation using UART
transport, making physical access to UART lines equivalent to compromising
all paired device security.

Solution:
=========
Implement a TLS 1.3-inspired secure interface that:
- Authenticates the chipset using ECDSA signature verification
- Establishes shared encryption keys via ECDH key exchange
- Encrypts sensitive HCI commands (Link Key Reply, LTK Reply, etc.) using
  AES-GCM
- Decrypts encrypted vendor events from the chipset

This ensures that even with full UART access, attackers cannot extract
usable cryptographic keys from the communication channel.

Implementation Overview:
========================
The solution is implemented in 11 incremental patches:

1-2:   Add firmware metadata parsing and version detection
3-4:   Establish secure interface framework and crypto setup
5-7:   Implement TLS handshake (Host Hello, Device Hello, authentication)
8:     Derive application traffic keys for encryption/decryption
9-10:  Add command encryption and event decryption support
11:    Add required crypto algorithm dependencies

The implementation automatically detects secure interface capability via
firmware version strings and enables encryption only when needed. Legacy
chipsets continue to work without modification.

Security Properties:
===================
- Chipset authentication prevents rogue device substitution
- Forward secrecy through ephemeral ECDH key exchange
- Authenticated encryption (AES-GCM) prevents tampering
- Per-session keys limit exposure from key compromise

Testing:
========
Tested on AW693 chipsets with secure firmware. Verified that:
- Authentication handshake completes successfully
- Sensitive commands are encrypted before transmission
- Encrypted events are properly decrypted
- UART monitoring shows only encrypted payloads for sensitive operations
- Legacy chipsets remain unaffected

[1] "BLAP: Bluetooth Low Energy Attacks on Pairing" - DSN 2022
    https://netsec.ethz.ch/publications/papers/dsn22_blap.pdf




Neeraj Sanjay Kale (11):
  Bluetooth: btnxpuart: Add firmware metadata parsing for secure
    interface
  Bluetooth: btnxpuart: Print FW version and enable chip specific
    features
  Bluetooth: btnxpuart: Add secure interface TLS authentication support
  Bluetooth: btnxpuart: Implement TLS authentication crypto framework
  Bluetooth: btnxpuart: Add TLS host hello handshake implementation
  Bluetooth: btnxpuart: Add TLS device hello processing
  Bluetooth: btnxpuart: Add device authentication
  Bluetooth: btnxpuart: Derive traffic keys from TLS 1.3 handshake
  Bluetooth: btnxpuart: Add command encryption for sensitive HCI
    commands
  Bluetooth: btnxpuart: Add encrypted event handling
  Bluetooth: btnxpuart: Select crypto algorithms for secure interface

 drivers/bluetooth/Kconfig     |    7 +
 drivers/bluetooth/btnxpuart.c | 1442 ++++++++++++++++++++++++++++++++-
 2 files changed, 1440 insertions(+), 9 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 19+ messages in thread
* Re: [PATCH v1 05/11] Bluetooth: btnxpuart: Add TLS host hello handshake implementation
@ 2025-11-19 23:10 kernel test robot
  0 siblings, 0 replies; 19+ messages in thread
From: kernel test robot @ 2025-11-19 23:10 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Julia Lawall

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20251118142025.1982263-6-neeraj.sanjaykale@nxp.com>
References: <20251118142025.1982263-6-neeraj.sanjaykale@nxp.com>
TO: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
TO: marcel@holtmann.org
TO: luiz.dentz@gmail.com
CC: linux-bluetooth@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: amitkumar.karwar@nxp.com
CC: sherry.sun@nxp.com
CC: dmitrii.lebed@nxp.com
CC: neeraj.sanjaykale@nxp.com

Hi Neeraj,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bluetooth/master]
[also build test WARNING on bluetooth-next/master linus/master v6.18-rc6 next-20251119]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Neeraj-Sanjay-Kale/Bluetooth-btnxpuart-Add-firmware-metadata-parsing-for-secure-interface/20251118-223605
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
patch link:    https://lore.kernel.org/r/20251118142025.1982263-6-neeraj.sanjaykale%40nxp.com
patch subject: [PATCH v1 05/11] Bluetooth: btnxpuart: Add TLS host hello handshake implementation
:::::: branch date: 33 hours ago
:::::: commit date: 33 hours ago
config: x86_64-randconfig-103-20251119 (https://download.01.org/0day-ci/archive/20251120/202511200650.6IddJ89j-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202511200650.6IddJ89j-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> drivers/bluetooth/btnxpuart.c:1781:12-13: WARNING opportunity for kfree_sensitive/kvfree_sensitive (memset at line 1780)

vim +1781 drivers/bluetooth/btnxpuart.c

9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1708  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1709  static struct sk_buff *nxp_host_do_hello(struct hci_dev *hdev)
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1710  {
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1711  	struct btnxpuart_dev *nxpdev = hci_get_drvdata(hdev);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1712  	union nxp_tls_host_hello_payload tls_hello;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1713  	struct nxp_tls_host_hello *host_hello = &tls_hello.host_hello;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1714  	struct ecdh p = {0};
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1715  	u8 *buf = NULL;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1716  	unsigned int buf_len;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1717  	struct sk_buff *skb;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1718  	int ret;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1719  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1720  	nxp_tls_hdr_init(&host_hello->hdr, sizeof(*host_hello), NXP_TLS_HOST_HELLO);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1721  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1722  	host_hello->sig_alg = cpu_to_le16(NXP_TLS_ECDSA_SECP256R1_SHA256);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1723  	host_hello->key_exchange_type = cpu_to_le16(NXP_TLS_ECDHE_SECP256R1);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1724  	host_hello->cipher_suite = cpu_to_le16(NXP_TLS_AES_128_GCM_SHA256);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1725  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1726  	get_random_bytes(host_hello->random, sizeof(host_hello->random));
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1727  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1728  	/* Generate random private key */
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1729  	p.key_size = 32;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1730  	p.key = kzalloc(p.key_size, GFP_KERNEL);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1731  	if (!p.key)
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1732  		return ERR_PTR(-ENOMEM);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1733  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1734  	get_random_bytes(p.key, p.key_size);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1735  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1736  	buf_len = crypto_ecdh_key_len(&p);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1737  	buf = kzalloc(buf_len, GFP_KERNEL);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1738  	if (!buf) {
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1739  		ret = -ENOMEM;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1740  		goto free_key;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1741  	}
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1742  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1743  	ret = crypto_ecdh_encode_key(buf, buf_len, &p);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1744  	if (ret) {
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1745  		bt_dev_err(hdev, "crypto_ecdh_encode_key() failed");
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1746  		goto free_buf;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1747  	}
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1748  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1749  	ret = crypto_kpp_set_secret(nxpdev->crypto.kpp, buf, buf_len);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1750  	if (ret) {
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1751  		bt_dev_err(hdev, "crypto_kpp_set_secret() failed");
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1752  		goto free_buf;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1753  	}
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1754  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1755  	ret = nxp_generate_ecdh_public_key(nxpdev->crypto.kpp, host_hello->pubkey);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1756  	if (ret) {
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1757  		bt_dev_err(hdev, "Failed to generate ECDH public key: %d", ret);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1758  		goto free_buf;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1759  	}
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1760  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1761  	ret = crypto_shash_update(nxpdev->crypto.tls_handshake_hash_desc,
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1762  				  (u8 *)host_hello, sizeof(*host_hello));
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1763  	if (ret) {
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1764  		bt_dev_err(hdev, "Failed to update handshake hash: %d", ret);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1765  		goto free_buf;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1766  	}
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1767  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1768  	tls_hello.msg_type = 0;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1769  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1770  	skb = __hci_cmd_sync(hdev, HCI_NXP_SHI_ENCRYPT, sizeof(tls_hello),
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1771  			     tls_hello.buf, HCI_CMD_TIMEOUT);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1772  	if (IS_ERR(skb)) {
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1773  		bt_dev_err(hdev, "Host Hello command failed: %ld", PTR_ERR(skb));
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1774  		ret = PTR_ERR(skb);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1775  	}
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1776  
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1777  free_buf:
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1778  	kfree(buf);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1779  free_key:
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18 @1780  	memset(p.key, 0, p.key_size);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18 @1781  	kfree(p.key);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1782  	if (ret)
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1783  		return ERR_PTR(ret);
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1784  	else
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1785  		return skb;
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1786  }
9e92c12afdb6eb Neeraj Sanjay Kale 2025-11-18  1787  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-11-22 11:04 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 14:20 [PATCH v1 00/11] Bluetooth: btnxpuart: Add secure interface support for NXP chipsets Neeraj Sanjay Kale
2025-11-18 14:20 ` [PATCH v1 01/11] Bluetooth: btnxpuart: Add firmware metadata parsing for secure interface Neeraj Sanjay Kale
2025-11-18 15:07   ` Bluetooth: btnxpuart: Add secure interface support for NXP chipsets bluez.test.bot
2025-11-20  7:12   ` [PATCH v1 01/11] Bluetooth: btnxpuart: Add firmware metadata parsing for secure interface kernel test robot
2025-11-18 14:20 ` [PATCH v1 02/11] Bluetooth: btnxpuart: Print FW version and enable chip specific features Neeraj Sanjay Kale
2025-11-18 14:20 ` [PATCH v1 03/11] Bluetooth: btnxpuart: Add secure interface TLS authentication support Neeraj Sanjay Kale
2025-11-18 14:20 ` [PATCH v1 04/11] Bluetooth: btnxpuart: Implement TLS authentication crypto framework Neeraj Sanjay Kale
2025-11-18 14:20 ` [PATCH v1 05/11] Bluetooth: btnxpuart: Add TLS host hello handshake implementation Neeraj Sanjay Kale
2025-11-22  3:31   ` kernel test robot
2025-11-18 14:20 ` [PATCH v1 06/11] Bluetooth: btnxpuart: Add TLS device hello processing Neeraj Sanjay Kale
2025-11-18 14:20 ` [PATCH v1 07/11] Bluetooth: btnxpuart: Add device authentication Neeraj Sanjay Kale
2025-11-20 14:46   ` kernel test robot
2025-11-22 11:03   ` kernel test robot
2025-11-18 14:20 ` [PATCH v1 08/11] Bluetooth: btnxpuart: Derive traffic keys from TLS 1.3 handshake Neeraj Sanjay Kale
2025-11-18 14:20 ` [PATCH v1 09/11] Bluetooth: btnxpuart: Add command encryption for sensitive HCI commands Neeraj Sanjay Kale
2025-11-20  8:40   ` kernel test robot
2025-11-18 14:20 ` [PATCH v1 10/11] Bluetooth: btnxpuart: Add encrypted event handling Neeraj Sanjay Kale
2025-11-18 14:20 ` [PATCH v1 11/11] Bluetooth: btnxpuart: Select crypto algorithms for secure interface Neeraj Sanjay Kale
  -- strict thread matches above, loose matches on Subject: below --
2025-11-19 23:10 [PATCH v1 05/11] Bluetooth: btnxpuart: Add TLS host hello handshake implementation kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.