Bluetooth Low Energy: Key generation I'm studying the BT core spec v5.1 to understand the security features and how everything fits together. I am looking at Secure Connections for now.



In the field "Key generation" it says it uses P-256 ECDH and HMAC-SHA-256 for this. However, when we read a little bit closer about the different functions themselves, it says that it uses AES-CMAC for key generation.



What's going on here?
The Diffie-Hellman key exchange is performed in the device pairing phase with P-256 elliptic curve to generate a shared secret DHKey. The function $\texttt{f}_5$ is then used to derive the long-term keys LTK and MacKey from DHKey according to this equation:

MacKey || LTK = $\texttt{f}_5$ (DHKey, N_master, N_slave, BD_ADDR_master, BD_ADDR_slave)

where N_master is the random number sent by the master to the slave, N_slave is the random number sent by the slave to the master, BD_ADDR_master is the device address of the master and BD_ADDR_slave is the device address of the slave.

This is very similar to TLS, where a master secret is generated using Diffie-Hellman key exchange and then the individual encryption keys are derived from the master secret using symmetric primitives.