Definition
Entropy is a measure, in bits, of how uncertain a value is to a stated observer, such as an attacker. It is computed from the probability that the observer gives to each possible value, using , the power to which 2 must be raised to give . Shannon entropy averages over all values, each weighted by its probability . Min-entropy is of the largest probability alone. A value with bits of min-entropy is guessed in one try with probability at most .
The idea
Bluetooth Low Energy §7.1 (LE) devices that use the older pairing method, which the Bluetooth Core Specification calls LE legacy pairing §7.20, derive their first encryption key from a 128-bit value named the temporary key (TK). With passkey entry §7.23, TK is the six-digit passkey written as a 128-bit number: the specification turns the passkey 019655 into 0x00000000000000000000000000004CC7. The field has possible bit patterns, but an attacker needs to consider only the one million that passkeys produce. With the method called Just Works §7.22, TK is zero, and there is nothing to guess. Length says how much room a value takes; entropy says how much an observer does not know about it.
Counting gives the intuition. One fair coin flip, a choice between two equally likely values, is one bit of uncertainty. A value drawn uniformly from possibilities, each equally likely, carries bits, the number of fair coin flips needed to select it: 4 values give 2 bits, and one million values give about 19.93 bits.
When the values are not equally likely, the attacker tries the most likely one first. If half of all users choose the same passkey, the first guess succeeds half the time, however many other passkeys exist. Min-entropy describes exactly that first guess. Shannon entropy, which Claude Shannon introduced as a measure of the information produced when a value is chosen, averages over all values, and it can be large even when one guess often succeeds.
Entropy belongs to an observer, not to a string of bits. NIST Special Publication (SP) 800-90B defines entropy relative to one’s knowledge of an outcome before it is observed [328]. A serial number is unknown to a stranger and known to anyone who reads the device’s label, and a passkey loses uncertainty when the attacker sees part of it.
How it works
Entropy is computed in four steps.
Fix the observer. Name who is guessing and everything that observer knows: printed labels, earlier messages, part of the value, the method that produced it.
List the possible values and their probabilities as that observer sees them. Write for the probability of value . Probabilities that take into account what the observer has learned are conditional probabilities §15.43.
Compute the surprise of each value, . Probability gives a surprise of 1 bit, gives 2 bits, gives 3 bits, and a certain value, of probability 1, gives 0 bits.
Combine the surprises. Shannon entropy is their average, each surprise weighted by the probability of its value. Min-entropy is the smallest surprise, the surprise of the most likely value.
Two rules follow. When all values are equally likely, every surprise is , so both measures equal . And processing a value never adds entropy. A function such as a cryptographic hash function §5.1 (which maps any input to a short fixed-length value), an encoding or zero padding gives each output the summed probability of all inputs that produce it, so the most likely output is at least as likely as the most likely input.
Worked example
Four unequal values. A source produces A, B, C or D with probabilities , , and . The surprises are bit, bits, and bits for each of C and D. Shannon entropy is the weighted average: Min-entropy is the surprise of the most likely value, A: 1 bit. An attacker who always guesses A is right half the time, as with one fair coin flip, although the source has four values and 1.75 bits of Shannon entropy. A function that reports only whether the value is A, B, or one of C and D has outputs of probability , and ; its Shannon entropy is bits, and its min-entropy stays 1 bit.
A six-digit passkey. A passkey drawn uniformly from 000000 to 999999 has equally likely values, so both measures equal bits. As a check, and , and one million lies between them. The Bluetooth Core Specification gives the same figure for a randomly generated passkey: approximately 20 bits of entropy. The 128-bit TK made from the passkey can take only those values, so its min-entropy is also about 19.93 bits. If the attacker learns the first two digits, values remain, and the uncertainty falls to bits.
Shannon entropy misleads. A faulty generator (invented for this example) outputs the all-zero 128-bit key half the time and otherwise a uniformly random 128-bit key. The all-zero key then has probability : one half from the fault, plus its share of the other half, which is spread evenly over keys. Each of the other keys has probability . Shannon entropy is about bits, which sounds strong. Min-entropy is , which is 1 bit to within less than bits, and it tells the truth: the guess “all zeros” succeeds half the time.
Stated precisely
Let be the uncertain value, let range over the values can take, and let be the probability, as the stated observer assigns it, that . Values with are left out. Then where is the Shannon entropy, is the min-entropy, adds over all values and is the largest probability. Shannon states the first formula in “Communication Theory of Secrecy Systems” (1949), taking it from Shannon’s “A Mathematical Theory of Communication” (1948) [329]; the base of the logarithm sets the unit, and base 2 gives bits. NIST SP 800-90B, Section 2.1, defines min-entropy by the second formula.
Let be the number of values with . Four facts hold.
, and both inequalities become equalities exactly when all values are equally likely. The first inequality holds because every surprise is at least the smallest surprise, , so their weighted average is too. SP 800-90B states that the largest possible min-entropy of a value with possibilities is , reached by the uniform distribution.
One guess is right with probability at most , and any different guesses together with probability at most .
Min-entropy also measures the work of the best strategy for guessing many secrets drawn independently from the same distribution. Appendix D of SP 800-90B shows that min-entropy equals of that strategy’s expected number of guesses per recovered secret, or exceeds it by at most one bit. For the uniform six-digit passkey the best strategy needs guesses on average, and , about one bit below the min-entropy of 19.93 bits.
For any function , and . Apart from renaming values, which changes neither measure, a function acts by merging values: two values with probabilities and become one value with probability . A merge cannot lower the largest probability. It cannot raise Shannon entropy either, because and , since and are each at most , and the two right-hand sides add up to .
When the observer learns something new, such as part of the value, a hash of it or a timing measurement, the probabilities are recomputed given what was learned, and the same formulas give the remaining uncertainty. Shannon calls the remaining uncertainty about a key, given the intercepted enciphered messages, the equivocation of the key.
Limits and common mistakes
Entropy is a property of how a value was produced and of what an observer knows, not of the value itself. The string 019655 may come from a uniform draw, or it may be the value its owner always uses. A value that looks random, or that passes statistical tests, may still be fully predictable to someone who knows how it was made.
Length is not entropy. A 128-bit field, a 32-byte hash output or a long hexadecimal string carries no more uncertainty than the value it was computed from. Uniqueness is not entropy either: serial numbers assigned in order are all different and all predictable.
Shannon entropy overstates resistance to guessing whenever some values are much more likely than others, as the 65-bit example shows. For secrets, use min-entropy.
The number of bits counts possibilities; whether it is enough depends on how many guesses the attacker gets. Against a random six-digit passkey and a device that allows three attempts, the attacker succeeds with probability at most . An attacker who can check guesses offline, for example against a recorded exchange that confirms the right guess, tries all values.
A key derivation function §5.20 or a CSPRNG §5.27 (cryptographically secure pseudorandom number generator) gives output that no feasible computation can tell apart from random bytes only if its seed has enough min-entropy, and it never has more possible outputs than possible seeds.
Estimating the entropy of a physical process, such as electronic noise, needs a model of the process and statistical testing; SP 800-90B is a whole standard for that task.
Questions answered
How many bits of uncertainty are in a predictable identifier or human passkey?
A predictable identifier or human passkey holds only of the probability that the attacker’s best single guess is right, its min-entropy as seen by that attacker, and that is usually far fewer bits than are used to store it. To count them, list the values the attacker still considers possible and how likely each is, given everything the attacker knows. Storing the value in a longer field, encoding it or hashing it adds nothing.
A predictable identifier. An identifier the attacker can read, such as a serial number printed on the device or sent unencrypted, has 0 bits: the attacker’s guess is right with probability 1, and . If the attacker knows only that it is one of 1,000 serial numbers in a known batch, all equally likely, it has bits.
A human passkey. A six-digit passkey drawn uniformly at random has bits, which the Bluetooth Core Specification rounds to about 20 bits. A passkey that a person chooses is not uniform. If 2% of people choose 123456 (an invented figure), the guess 123456 succeeds with probability 0.02, so the min-entropy is at most bits, whatever the other choices are. That one guess is times as likely to succeed as a guess against a uniformly random passkey.
Related entries: Key derivation function (KDF) (§5.20), CSPRNG (§5.27), Confidentiality (§1.8), Passkey entry (§7.23), LE legacy pairing (§7.20), HKDF (§5.21), Conditional probability (§15.43). Further reading: [18, 65, 328, 329].