# 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?

• Interesting. It could be that a master key is generated using HMAC-SHA-256 and that the subsequent keys are generated by CMAC, but that's just guesswork. – Maarten Bodewes Jun 27 at 16:28

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)