Full name: Low Energy legacy pairing.
Definition
LE legacy pairing is the pairing §7.17 procedure of Bluetooth Low Energy (BLE) §7.1 as first specified in Bluetooth 4.0, kept in later versions for devices without LE Secure Connections §7.21. The devices share a 128-bit temporary key (TK) that the association method fixes: zero for Just Works §7.22, the six-digit passkey for passkey entry §7.23, or a random value exchanged out of band. From the TK and two exchanged random numbers each computes a short-term key (STK). Legacy pairing uses no public-key cryptography §5.15, so the secrecy of every key rests on the TK alone.
The idea
A user pairs a phone with a fitness band by passkey entry. The band shows 019655 and the user types it on the phone. Those six digits are the only secret the two devices share; everything else they send before encryption starts travels over the air in the clear. An eavesdropper who records the pairing can later try every six-digit number on a laptop and test each guess against the recorded messages, without ever talking to either device, and neither device can notice. There are only one million numbers to try.
Picture a box with a six-digit combination lock. The devices put their real key in the box and send the box over the air. Anyone who records the box can try every combination at leisure. A bigger lock body does not help: the 128-bit short-term key that locks the box has no more possible values than the six digits it was computed from. The picture is incomplete in one respect: the eavesdropper also needs a way to recognize the right combination. Legacy pairing supplies one, the confirm value, a check value computed from the TK that each device sends to prove it knows the TK.
LE Secure Connections, added in Bluetooth 4.2, removes this search by adding a key agreement whose result an eavesdropper cannot compute.
How it works
Notation: is AES-128 encryption of the 16-byte block under the 16-byte key , where AES is the Advanced Encryption Standard block cipher §15.3; is bitwise exclusive-or; is followed by . Let and be 128-bit random numbers chosen by the initiator (the central) and by the responder (the peripheral). Version 6.2 of the specification names them LP_RAND_I and LP_RAND_R; older versions named them Mrand and Srand.
Feature exchange. The devices exchange Pairing Request and Pairing Response, the first two messages of the Security Manager Protocol (SMP) §7.19. At least one of them does not support LE Secure Connections, so LE legacy pairing runs, and the association method follows from their declared input and output capabilities and flags.
Temporary key. Just Works: TK = 0. Passkey entry: TK is the passkey as a 128-bit number; passkey
019655gives TK =0x4CC7, because . Out-of-band association §7.25: TK is a 128-bit random value passed over another channel, such as NFC (near-field communication).Confirm values. Each device computes a confirm value from the TK, its own random number, both feature-exchange messages and both device addresses, with a function the specification calls (stated below): and .
Exchange in a fixed order. The initiator sends ; the responder sends ; the initiator sends ; the responder recomputes from and, if it matches, sends ; the initiator recomputes . Each device thus commits to its random number before it sees the other’s. A mismatch ends pairing with reason confirm value failed. An initiator that receives a equal to its own also aborts, which stops an attacker from simply sending a device’s own values back to it.
Short-term key. Both compute STK = , where denotes the 64 least significant bits of , and shorten it to the negotiated key size.
Encryption. The initiator starts Link Layer §7.6 encryption with the STK.
Key distribution. Over the encrypted link, each device that was asked to sends its own long-term key §7.28 (LTK), a 128-bit key it generates itself, with two values that identify it,
EDIV(encrypted diversifier) andRand. It may also send its identity resolving key §7.29 and its signing key. The distributed keys inherit the security properties of the STK.Later connections are encrypted with the stored LTK.
Under out-of-band association with a secret, uniformly random 128-bit TK, the eavesdropper’s search below is infeasible. Under Just Works and passkey entry it is easy.
Worked example
The specification’s own example for uses TK = 0, exactly the Just Works case. Its values are written as hexadecimal numbers with the most significant byte first:
=
5783d52156ad6f0e6388274ec6702ee0
=05000800000302070710000001010001
=00000000a1a2a3a4a5a6b1b2b3b4b5b6
Here holds the 7-byte Pairing Response, the 7-byte Pairing Request, the responder’s address type 00 (public) and the initiator’s address type 01 (random); in this notation the first byte sent is the rightmost, so the command codes 02 and 01 stand at the right end of each message. holds four zero bytes, the initiator’s address a1a2a3a4a5a6 and the responder’s address b1b2b3b4b5b6. An eavesdropper reads all of these off the air.
The eavesdropper tests the candidate TK = 0, one step at a time, naming each intermediate value:
=
5283dd2156ae6d096498274ec7712ee1
=02c7aa2a9857ac866ff91232df0e3c95
=02c7aa2a39f50f22ca5fa3806cba8923
=1e1e3fef878988ead2a74dc5bef13b86
The last value equals the recorded , the value the specification prints, so TK = 0 is confirmed after two AES operations. Take as the responder’s random number the invented value = 000f0e0d0c0b0a091122334455667788. The 64 least significant bits of are 1122334455667788 and those of are 6388274ec6702ee0, so
=
11223344556677886388274ec6702ee0
STK = =d3e03c8f30742a6167262dd688f8a4a4
With the STK the eavesdropper decrypts the key distribution and reads the LTK.
Had the user typed passkey 123456 instead, TK would be 0x1E240, because . With the same , and , the initiator would send = e291fa937ed0b3fe22dc3712484e7acf. An eavesdropper that tries the candidates 0, 1, 2 and so on matches at candidate 123456, after trials and AES operations. The worst case is trials, AES operations, which an ordinary computer finishes within seconds.
Count the possibilities. Six decimal digits give values. A uniformly random choice among values has bits of entropy §5.26, the number of bits needed to count the values. For the passkey this is ; as a check, . A uniformly random 128-bit key has values, about times as many. The STK is 128 bits long, but given the recorded messages each TK candidate determines it, so it has at most possible values.
Stated precisely
Let and be the 7-byte Pairing Request and Pairing Response, and the one-byte address types of the initiator and the responder, and their 6-byte addresses, a string of 32 zero bits, and the 64 least significant bits of . For one pairing these values are fixed, and the specification’s function reduces to the two-argument form used here:
Every input except the TK is sent in the clear. Therefore, for an eavesdropper who records the pairing, the STK and every key sent under it are fixed by the TK. If the TK is uniformly distributed over values, the eavesdropper finds it after at most trials of , and after trials on average, each trial costing two AES operations. for Just Works, for a fresh random passkey, and for a uniformly random out-of-band TK that the eavesdropper cannot read. A TK that is not uniform, such as a passkey a person chose or a passkey printed on the device and used at every pairing, is easier still.
Version 6.2 of the specification says that legacy passkey entry “does not provide protection against active ‘man-in-the-middle §7.26’ (MITM) attacks” and gives “very limited protection against eavesdroppers”, and it classes the resulting keys as unauthenticated. The reason is that an active attacker can run the eavesdropper’s search during the pairing itself. Posing as the responder, it sends an arbitrary , receives , and finds the passkey by testing the candidates against , which takes at most seconds. Since consists of AES encryptions under a key the attacker now knows, the attacker can run them backwards and compute an whose confirm value is exactly the it already sent, so the initiator’s check passes. Under LE legacy pairing, only out-of-band association over a channel safe from eavesdropping gives an authenticated key.
The eavesdropping attack
Mike Ryan described the attack in “Bluetooth: With Low Energy Comes Low Security” at the 2013 USENIX Workshop on Offensive Technologies [278] (USENIX is a computing-systems professional association), and released a tool, crackle, that carries it out. The eavesdropper records one pairing:
both device addresses and address types,
, and ,
the random values that the two Link Layers exchange in the clear when encryption starts, and the encrypted key-distribution messages.
Then, offline:
For each candidate TK, compute and compare it with the recorded . Only the true TK matches, except with negligible probability.
Compute the STK from the TK, and .
Compute the Link Layer session key from the STK and the recorded random values, decrypt the key-distribution messages, and read the LTK.
Decrypt every later recorded connection between the two devices: each connection’s session key is computed from the LTK and random values sent in the clear.
Limits and common mistakes
A long key computed from a short secret is still a short secret. Output length does not create uncertainty that the input lacked.
The attack is silent. The eavesdropper sends nothing, so neither device can detect it, and limits on repeated pairing attempts do not slow it, because every trial runs on the attacker’s computer.
Just Works under LE legacy pairing protects against nobody who recorded the pairing. Later connections are confidential only if no attacker was present during pairing.
One recorded pairing exposes the future and the past: every later connection encrypted with the LTK can be decrypted, including connections recorded before the LTK was found.
The specification requires a new random passkey for every pairing. A fixed passkey, printed on the device and used at every pairing, is revealed by one recorded pairing and stays revealed.
Identify the procedure from the Secure Connections bits (the SC flags) of the feature exchange, not from the user interface: LE legacy pairing and LE Secure Connections can both show six digits. Statements about the security of passkey entry or Just Works are wrong unless they name the procedure.
Out-of-band association under LE legacy pairing is only as secret as the out-of-band channel and only as strong as the randomness of the TK.
Questions answered
Why is a short human passkey not equivalent to a uniformly random long-term key?
A short passkey is not equivalent because an attacker’s work depends on how many values the secret can take, not on how long the derived key is: a six-digit passkey has values, about 20 bits, against for a uniformly random 128-bit key. In LE legacy pairing, the Bluetooth Low Energy pairing procedure without public-key cryptography, the passkey is the temporary key (TK). The short-term key (STK) is computed from the TK and two random numbers sent in the clear, and the STK protects the long-term key (LTK) when it is sent across. Each of these keys is 128 bits long, but given the recorded messages each is fixed by the passkey, so there are still only possibilities.
The pairing transcript also lets an eavesdropper test guesses offline. Each device sends a confirm value computed from the TK and values sent in the clear, so the eavesdropper computes it for each candidate passkey and keeps the one that matches. At two AES (Advanced Encryption Standard) operations per candidate, all candidates take operations, seconds on an ordinary computer; Mike Ryan’s tool crackle (2013) does exactly this. A uniformly random 128-bit key would need up to trials. LE Secure Connections removes the offline test: its key comes from an elliptic-curve Diffie–Hellman §19.1.5 exchange that an eavesdropper cannot compute, and the passkey only authenticates that exchange.
Related entries: LE Secure Connections (§7.21), Passkey entry (§7.23), Entropy and min-entropy (§5.26), Key derivation function (KDF) (§5.20), Security Manager Protocol (SMP) (§7.19), Just Works (§7.22), Out-of-band (OOB) association (§7.25), Long-term key (LTK) (§7.28), Block cipher (§15.3). Further reading: [18, 278].