Crypt-conf9
Crypt-conf9
1 Introduction
The KeeLoq technology [13] by Microchip Technology Inc. includes the KeeLoq
block cipher and several authentication protocols built on top of it. The KeeLoq
⋆
The final publication is available at www.springerlink.com.
⋆⋆
This work was supported in part by the Concerted Research Action (GOA) Ambior-
ics 2005/11 of the Flemish Government, by the IAP Programme P6/26 BCRYPT of
the Belgian State (Belgian Science Policy), and in part by the European Commission
through the IST Programme under Contract IST-2002-507932 ECRYPT.
⋆⋆⋆
F.W.O. Research Assistant, Fund for Scientific Research — Flanders (Belgium).
†
This author is supported by the Adams Fellowship Program of the Israel Academy
of Sciences and Humanities.
block cipher allows for very low cost and power efficient hardware implementa-
tions. This property has undoubtedly contributed to the popularity of the cipher
in various wireless authentication applications. For example, multiple car man-
ufacturers supposedly use, or have used KeeLoq to protect their cars against
theft [5,6,7,9,17].1
Despite its design in the 80’s, the first cryptanalysis of KeeLoq was only
published by Bogdanov [5] in February 2007. This attack is based on the slide
technique and a linear approximation of the non-linear Boolean function used
in KeeLoq. The attack has a time complexity of 252 KeeLoq encryptions and
requires 16 GB of storage. It also requires the entire codebook, i.e., 232 known
plaintexts.
Courtois et al. apply algebraic techniques to cryptanalyse KeeLoq [7,9]. Al-
though a direct algebraic attack fails for the full cipher, they reported various
successful slide-algebraic attacks. For example, they claim that an algebraic at-
tack can recover the key when given a slid pair in 2.9 seconds on average. As there
is no way to ensure or identify the existence of a slid pair in the data sample, the
attack is simply repeated 232 times, once for each pair generated from 216 known
plaintexts. They also described attacks requiring the entire codebook, which ex-
ploit certain assumptions with respect to fixed points of the internal state. The
fastest of these requires 227 KeeLoq encryptions and has an estimated success
probability of 44% [9].
In [6], Bogdanov published an updated version of his attack. A refined com-
plexity analysis yields a slightly smaller time complexity, i.e., 250.6 KeeLoq en-
cryptions while still requiring the entire codebook. This paper also includes an
improvement using the work of Courtois et al. [7] on the cycle structure of the
cipher. We note that the time complexity of the attack using the cycle struc-
ture given in [6] is based on an assumption from an earlier version of [7], that a
random word can be read from 16 GB of memory with a latency of only 1 clock
cycle. This is very unrealistic in a real machine, so the actual time complexity is
probably much higher. In a later version of [7], this assumption on the memory
latency was changed to be 16 clock cycles.
Our practical attack is based on the slide attack as well. However, unlike other
attacks, we combine it with a novel meet-in-the-middle attack. The optimised
version of the attack uses 216 known plaintexts and has a time complexity of
244.5 KeeLoq encryptions. We have implemented our attack and the total running
time is roughly 500 days. As the attack is fully parallelizable, given x CPU cores,
the total running time is only 500/x days. A variant which requires 216 chosen
plaintexts needs only 218/x days on x CPU cores. For example, for 10 000 euro,
one can obtain 50 dual core computers, which will take about two days to find
the key. Another, probably even cheaper, though illegal option would be to rent
a botnet to carry out the computations.
KeeLoq is used in two protocols, the “Code Hopping” and the “Identify
Friend or Foe (IFF)” protocol. In practice, the latter protocol, a simple challenge
1
We verified these claims to the best of our ability, however, no car manufacturer
seems eager to publically disclose which algorithms are used.
Table 1. An overview of the known attacks on KeeLoq.
response protocol, is the most interesting target to acquire the data that is nec-
essary to mount the attack. Because the challenges are not authenticated in any
way, an attacker can obtain as many chosen plaintext/ciphertext pairs as needed
from a transponder (e.g., a car key) implementing this protocol. Depending on
the transponder, it takes 65 or 98 minutes to gather 216 plaintext/ciphertext
pairs.
Finally, as was previously noted by Bogdanov [6], we show that one of the two
suggested key derivation algorithms is blatantly flawed, as it allows an attacker
to reconstruct many secret keys once a single secret key has been exposed.
ϕ(i) ?????
NLF
?
+i
6
k63 k0
-
The KeeLoq block cipher has a 32-bit block size and a 64-bit key. It consists of
528 identical rounds each using one bit of the key. A round is equivalent to an
iteration of a non-linear feedback shift register (NLFSR), as shown in Fig. 1.
(i) (i)
More specifically, let Y (i) = (y31 , . . . , y0 ) ∈ {0, 1}32 be the input to round i
(0 ≤ i < 528) and let K = (k63 , . . . , k0 ) ∈ {0, 1}64 be the key. The input
to round 0 is the plaintext: Y (0) = P . The ciphertext is the output after 528
rounds: C = Y (528) . The round function can be described as follows (see Fig. 1):
(i) (i) (i) (i) (i) (i) (i)
ϕ(i) = NLF y31 , y26 , y20 , y9 , y1 ⊕ y16 ⊕ y0 ⊕ ki mod 64 ,
(i) (i)
(1)
Y (i+1) = (ϕ(i) , y31 , . . . , y1 ) .
2
We list slightly better complexities for the attacks from [7,9] because we used a more
realistic conversion factor from CPU clocks to KeeLoq rounds (i.e., 12 rather than
4 CPU cycles per KeeLoq round).
The non-linear function NLF is a Boolean function of 5 variables with output
vector 3A5C742E x — i.e., NLF(i) is the i-th bit of this hexadecimal constant,
where bit 0 is the least significant bit. We can also represent the non-linear
function in its algebraic normal form (ANF):
NLF(x4 , x3 , x2 , x1 , x0 ) = x4 x3 x2 ⊕ x4 x3 x1 ⊕ x4 x2 x0 ⊕ x4 x1 x0 ⊕
x4 x2 ⊕ x4 x0 ⊕ x3 x2 ⊕ x3 x0 ⊕ x2 x1 ⊕ x1 x0 ⊕ (2)
x1 ⊕ x0 .
Decryption uses the inverse round function, where i now ranges from 528 down
to 1.
(i) (i) (i) (i) (i) (i) (i)
θ(i) = NLF y30 , y25 , y19 , y8 , y0 ⊕ y15 ⊕ y31 ⊕ ki−1 mod 64 ,
(i) (i)
(3)
Y (i−1) = (y30 , . . . , y0 , θ(i) ) .
There used to be some ambiguity about the correct position of the taps. Our
description agrees with the “official” documentation [5,6,9,15]. Additionally, we
have used test vectors generated by an actual HSC410 chip [14], manufactured by
Microchip Inc., to verify that our description and implementation of KeeLoq are
indeed correct. Finally, we note that our attacks are unaffected by this difference.
P2 - F - F - . . . - F - F - C2
C1
This section describes our attacks on KeeLoq. We combine a slide attack with a
novel meet-in-the-middle approach to recover the key from a slid pair. First we
explain some preliminaries that are used in the attacks. Then we proceed to the
description of the attack scenario using known plaintexts and a generalisation
thereof. Finally, we show how chosen plaintexts can be used to improve the
attack.
Slide attacks were introduced by Biryukov and Wagner [3] in 1999. The typical
candidate for a slide attack is a block cipher consisting of a potentially very
large number of iterations of an identical key dependent permutation F . In
other words, the subkeys are repeated and therefore the susceptible cipher can
be written as
C = F (F (. . . F (P ))) = F r (P ) . (4)
| {z }
r
This permutation does not necessarily have to coincide with the rounds of the
cipher, i.e., F might combine several rounds of the cipher.
A slide attack aims at exploiting such a self-similar structure to reduce the
strength of the entire cipher to the strength of F . Thus, it is independent of
the number of rounds of the cipher. To accomplish this, a so-called slid pair is
needed. This is a pair of plaintexts that satisfies the slide property
P2 = F (P1 ) . (5)
We depict such a slid pair in Fig. 2. For a slid pair, the corresponding ciphertexts
also satisfy the slide property, i.e., C2 = F (C1 ). By repeatedly encrypting this
slid pair, we can generate as many slid pairs as needed [4,10]. As each slid
pair gives us a pair of corresponding inputs and outputs of the key dependent
permutation F , it can be used to mount an attack against F .
KeeLoq has 528 identical rounds, each using one bit of the 64-bit key. After
64 rounds the key is repeated. So in the case of KeeLoq, we combine 64 rounds
into F . However, because the number of rounds in the cipher is not an integer
multiple of 64, a straightforward slid attack is not possible. A solution to this
problem is to guess the 16 least significant bits of the key and use this to strip
off the final 16 rounds. Then, a slide attack can be applied to the remaining 512
rounds [5,7,9].
In order to get a slid pair, 216 known plaintexts are used. As the block size
of KeeLoq is 32 bits, we expect that a random set of 216 plaintexts contains a
slid pair due to the birthday paradox.4 Determining which pair is a slid pair is
done by the attack itself. Simply put, the attack is attempted with every pair.
If it succeeds, the pair is a slid pair, otherwise it is not.
If two intermediate states of the KeeLoq cipher, separated by 32 rounds (or less)
are known, all the key bits used in these rounds can easily be recovered. This
was first described by Bogdanov [5], who refers to it as the “linear step” of his
attack.
(i) (i) (i+t) (i+t)
Let Y (i) = (y31 , . . . , y0 ) and Y (i+t) = (y31 , . . . , y0 ) be the two known
(i)
states; t ≤ 32. If we encrypt Y by one round, the newly generated bit is
(i) (i) (i) (i) (i) (i) (i)
ϕ(i) = NLF y31 , y26 , y20 , y9 , y1 ⊕ y16 ⊕ y0 ⊕ ki mod 64 . (6)
Because of the non-linear feedback shift register structure of the round function
(i+t)
and since t ≤ 32, the bit ϕ(i) is equal to y32−t , which is one of the bits of Y (i+t)
and thus known. Hence
(i) (i) (i) (i) (i) (i) (i) (i+t)
ki mod 64 = NLF y31 , y26 , y20 , y9 , y1 ⊕ y16 ⊕ y0 ⊕ y32−t . (7)
By repeating this t times, all t key bits can be recovered. The amount of
computations that need to be carried out is equivalent to t rounds of KeeLoq.
This simple step will prove to be very useful in our attack.
We now describe the basic attack scenario, which uses 216 known plaintexts.
For clarity, the notation used is shown in Fig. 3 and a pseudocode overview is
given in Fig. 4. We denote 16 rounds of KeeLoq by gk̂ , where k̂ denotes the 16
4
The probability that a set of 216 random plaintexts contains at least one slid pair is
´232
1 − 1 − 2−32
`
≈ 0.63. Hence, the attack has a success probability of about 63%.
With not much higher data complexity, higher success rates can be achieved.
Pi - gk̂0 - Xi - gk̂1 - Xi⋆ gk̂2 Pj⋆ gk̂3 Pj
key bits used in these rounds. The 64-bit key k is split into four equal parts:
k = (k̂3 , k̂2 , k̂1 , k̂0 ), where k̂0 contains the 16 least significant key bits.
As already mentioned in Sect. 3.1, the first step of the attack is to guess k̂0
— the 16 least significant bits of the key. This enables us to partially encrypt
each of the 216 plaintexts by 16 rounds (Pi to Xi ) and partially decrypt each of
the 216 ciphertexts by 16 rounds (Cj to Yj ).
Encrypting Xi by 16 more rounds yields Xi⋆ . Similarly, decrypting Pj by 16
rounds yields Pj⋆ (see Fig. 3). We denote the 16 most significant bits of Xi⋆ by
Xi⋆ , and the 16 least significant bits of Pj⋆ by Pj⋆ . Note that, because Xi⋆ and
Pj⋆ are separated by 16 rounds, it holds that Xi⋆ = Pj⋆ , provided that Pi and Pj
form a slid pair. This is due to the structure of the cipher.
The next step in the attack is to apply a meet-in-the-middle approach. We
guess the 16-bit value Pj⋆ . For each plaintext Pj we can then determine k̂3
using the algorithm described in Sect. 3.2. Indeed, as the other bits of Pj⋆ are
determined by Pj , we know all of Pj⋆ when given the plaintext. There is always
exactly one solution per plaintext. Using this part of the key, we can now partially
decrypt Yj to Yj⋆ . This result is saved in a hash table indexed by the 16-bit value
Yj⋆ . Each record in the hash table holds a tuple consisting of Pj⋆ , Yj⋆ and the 16
key bits k̂3 .
Now we do something similar from the other side. For each plaintext we use
the algorithm from Sect. 3.2 to determine k̂1 . Again this can be done because
we know all of Xi⋆ , and there is exactly one solution per plaintext. Knowing k̂1 ,
we partially encrypt Ci to Ci⋆ .
Note that if Pi and Pj are indeed a slid pair their partial encryptions and
decryptions (under the correct key) must “meet in the middle”. More specifically,
it must hold that Ci⋆ = Yj⋆ . So, we look for a record in the hash table for which
such a collision occurs. Because the hash table is indexed by Yj⋆ this can be done
very efficiently. A slid pair produces a collision, provided the guesses for k̂0 and
Pj⋆ are correct. Therefore, we are guaranteed that all slid pairs are found at some
point. Of course, a collision does not guarantee that the pair is actually a slid
pair.
Finally, we check each candidate slid pair found. We determine the remaining
key bits k̂2 from Xi⋆ and Pj⋆ and similarly k̂2′ from Ci⋆ and Yj⋆ . If k̂2 and k̂2′ are
not equal, the candidate pair is not a slid pair. Note that we can determine the
key bits one by one and stop as soon as there is a disagreement. This slightly
reduces the complexity of the attack.
If k̂2 = k̂2′ , we have found a pair of plaintexts and a key with the property
that encrypting Pi by 64 rounds gives Pj and encrypting Ci by 64 rounds gives
Cj . This is what is expected from a slid pair. It is however possible that the
recovered key is not the correct key, so we can verify it by a trial encryption
of one of the known plaintexts. Even if a wrong key is suggested during the
attack, and discarded by the trial encryption, we are still guaranteed to find the
correct key eventually, provided there is at least one slid pair among the given
plaintexts.
Complexity Analysis. Using one round of KeeLoq as a unit, the time com-
plexity of the attack can be expressed as
216 32 · 216 + 216 32 · 216 + 216 (32 + Ncoll · V ) , (8)
when Ncoll denotes the expected number of collisions for a single guess of k̂0 ,
Pj⋆ and a given plaintext Pi , and V denotes the average cost of verifying one
collision, i.e., checking if it leads to a candidate key and if this key is correct.
This follows directly from the description of the attack. As the hash table has
216 entries and a collision is equivalent to a 16-bit condition, Ncoll = 1. In the
verification step, we can determine one bit at a time and stop as soon as there
is a disagreement, which happens with probability 1/2. Only when there is no
disagreement after 16 key bits, we do two full trial encryptions to check the
recovered key. Of course the second trial encryption is only useful if the first one
gave the expected result. Hence, due to this early abort technique, the average
cost of verifying one collision is
15
X
V =2· 2−i + 2−16 · 528 + 528 · 2−32 ≈ 4 . (9)
i=0
Thus the overall complexity of the attack is 254.0 KeeLoq rounds, which amounts
to 245.0 full KeeLoq encryptions.
As mentioned before, the data complexity of the attack is 216 known plain-
texts. The storage requirements are very modest. The attack stores the plain-
text/ciphertext pairs, 216 values for Xi and Yi , and a hash table with 216 records
of 80 bits each. This amounts to a bit over 2 MB of RAM.
The attack presented in the previous section can be generalised by varying the
number of rounds to partially encrypt/decrypt in each step of the attack. We
denote by tp the number of rounds to partially encrypt from the plaintext side
(left on Fig. 3) and by tc the number of rounds to partially decrypt from the
ciphertext side (right on Fig. 3). More specifically, encrypting Xi by tp rounds
yields Xi⋆ , encrypting Ci by tp rounds yields Ci⋆ . On the ciphertext side, Pj⋆ is
obtained by decrypting Pj by tc rounds and Yj⋆ by decrypting Yj by tc rounds.
Also, the partial keys k̂0 through k̂3 are adapted accordingly to contain the
appropriate key bits.
Let to denote the number of bits that, provided Pi and Pj form a slid pair,
overlap between Xi⋆ and Pj⋆ . As Xi⋆ and Pj⋆ are separated by 48 − tp − tc rounds,
it holds that to = 32 − (48 − tp − tc ) = tp + tc − 16. The to least significant bits
of Pj⋆ are denoted by Pj⋆ and the to most significant bits of Xi⋆ are denoted by
Xi⋆ .
Depending on the choices for the parameters tp and tc , the attack scenario has
to be modified slightly. If tc < to , not all plaintexts necessarily yield a solution
for a given Pj⋆ when determining k̂3 = (k63 , . . . , k64−tc ) because to − tc of the
guessed bits overlap with plaintext bits. Similarly, if tc > to , each plaintext is
expected to offer multiple solutions because tc − to extra bits have to be guessed
before all of Pj⋆ is known. From the other side, similar observations can be made.
In Sect. 3.3, the parameters were tp = tc = 16 which results in to = 16. It is
clear that the choice of these parameters influences both the time and memory
complexity of the attack.
32 · 232 + 2tc · 232+tc + 2tp · 232+tp + 4 · 280−tp −tc + 528 · 232 . (12)
The optimum is found when tp = tc = 15 and thus to = 14, where the complexity
reduces to 253.524 KeeLoq rounds or 244.5 full KeeLoq encryptions.
The memory requirements in the generalised case can also easily be evaluated.
As before, 216 plaintext/ciphertext pairs and 216 values for Xi and Yi are stored.
The hash table now has 216+tp −to entries of 64 + tp bits each. For tp = tc = 15,
the required memory is still less than 3 MB.
Complexity Analysis. As chosen plaintexts are only useful for the attack
when tc < to , we will only consider this case. The time complexity of the attack,
in KeeLoq rounds, can be expressed as
216 32 · 216 + 2tc 2tc · 216 + 216+tp −to (2tp + Ncoll · V ) . (13)
The expected number of collisions is Ncoll = 216 /2to . The verification cost, V , is
given by (11). Simplification yields
32 · 232 + 2tc · 232+tc + 2tp · 248 + 4 · 280−tp −tc + 528 · 232 . (14)
The optimum is found when tp = 20, tc = 13 and thus to = 17, where the attack
has a time complexity of 253.500 KeeLoq rounds or 244.5 full KeeLoq encryptions.
It is clear that the (theoretical) advantage over the known plaintext attack from
Sect. 3.4 is not significant. However, as is discussed in the next section, the chosen
plaintext variant can provide a significant gain in our practical implementation,
because the verification cost V turns out to be higher there.
The memory complexity is about 2 MB as in Sect. 3.3 because the size of the
hash table is the same. The data complexity remains at 216 plaintext/ciphertext
pairs, but note that we now require chosen plaintexts instead of known plaintexts.
4 Experimental Results
We have fully implemented and tested the attacks, using both simulated data
and real data acquired from a HCS410 chip [14]. We made extensive use of bit
slicing to do many encryptions in parallel throughout the implementation. How-
ever, because this parallelisation is not useful while verifying a collision, this
verification step becomes more expensive in comparison. Hence, the optimal pa-
rameters for our implementation differ slightly from the theoretical ones. For
the known plaintext attack from Sect. 3.4, the optimal parameters for our im-
plementation were found to be tp = tc = 16. This means that, at least in our
implementation, the best attack is the basic attack from Sect. 3.3. For the chosen
plaintext attack, the optimal parameters are tp = 22 and tc = 13.
If we give the correct values for the 16 least significant key bits, the known
plaintext attack completes in 10.97 minutes on average.5 The chosen plaintext
attack needs just 4.79 minutes to complete the same task.6 This large difference
can be explained by considering the impact of V , the cost of the verification
step, on the time complexity of the attack. If V increases, and tp and tc are
adapted as needed because their optimal values may change, the time complexity
of the known plaintext attack increases much faster than the time complexity
of the chosen plaintext attack does. Hence, even though their theoretical time
complexities are the same, the chosen plaintext attack performs much better in
our practical implementation because V is higher than the theoretical value.
We did not stop either of the attacks once a slid pair and the correct key were
found, so we essentially tested the worst-case behaviour of the attack. This also
explains the very small standard deviations of the measured running times. The
machine used is an AMD Athlon 64 X2 4200+ with 1 GB of RAM (only one of
the two CPU cores was used) running Linux 2.6.17. The attack was implemented
in C and compiled with gcc version 4.1.2 (using the -O3 optimiser flag). Critical
parts of the code are written in assembly. Because the memory access pattern is
random, but predictable to some extent, prefetching helped us to make maximum
use of the cache memory.
The known plaintext attack performs over 288 times faster than the fastest
attack with the same data complexity from [7,9], although the actual increase
in speed is probably slightly smaller due to the difference in the machines used.
5
We performed 500 experiments. The average running time was 658.15 s and the
standard deviation was 1.69 s.
6
We performed 500 experiments. The average running time was 287.17 s and the
standard deviation was 0.55 s.
Courtois et al. used (a single core of) a 1.66 GHz Intel Centrino Duo micropro-
cessor [8]. The chosen plaintext attack performs more than 661 times faster, but
this comparison is not very fair because chosen plaintexts are used. We note
that the practicality of our results should also be compared with exhaustive key
search due to the small key size. For the price of about 10 000 euro, one can
obtain a Copacobana machine [12] with 120 FPGAs which is estimated to
take about 1000 days to find a single 64-bit KeeLoq key.7 Using our attack and
50 dual core computers (which can be obtained for roughly the same price), a
KeeLoq key can be found in only two days.
One might wonder if it is possible to gather 216 known, or even chosen plain-
texts from a practical KeeLoq authentication system. As mentioned in Sect. 2.2,
a device like the HCS410 by Microchip Technology Inc. [14] supports two au-
thentication protocols based on KeeLoq: “KeeLoq Hopping Codes” and “KeeLoq
Identify Friend or Foe (IFF)”. As the initial value of the counter used in “KeeLoq
Hopping Codes” is not known, it is not easy to acquire known plaintexts from
this protocol apart from trying all possible initial counter values. Also, since only
216 plaintexts are ever used, knowing this sequence of 216 ciphertexts suffices to
break the system as this sequence is simply repeated.
The second protocol, “KeeLoq Identify Friend or Foe (IFF)” [14], is more
appropriate for our attack. It is executed without any user interaction as soon
as the transponder comes within the range of a decoder and is sent an activation
signal. The challenges sent by the decoder are not authenticated in any way.
Because of this, an adversary can build a rogue decoder which can be used to
gather as many plaintext/ciphertext pairs as needed. The plaintexts can be fully
chosen by the adversary, so acquiring chosen plaintexts is no more difficult than
just known plaintexts. The only requirement is that the rogue decoder can be
placed within the range of the victim’s transponder for a certain amount of time.
From the timings given in [14], we can conclude that one authentication com-
pletes within 60 ms or 90 ms, depending on the baud rate used. This translates
into a required time of 65 or 98 minutes to gather the 216 plaintext/ciphertext
pairs. As these numbers are based on the maximum delay allowed by the specifi-
cation [14], a real chip may respond faster, as our experiments confirm. No data
is given with respect to the operational range in [14], because this depends on
the circuit built around the HCS410 chip. However, one can expect the range to
be short.
7
The estimate was done by adapting the 17 days (worst case) required for finding
a 56-bit DES key, taking into consideration the longer key size, the fact that more
KeeLoq implementations fit on each FPGA, but in exchange take more clocks to
test a key.
5.2 Key Derivation
The impact of the attack becomes even larger when considering the method
used to establish the secret keys, as was previously noted by Bogdanov [6].
To simplify key management, the shared secret keys are derived from a 64-bit
master secret (the manufacturer’s code), a serial number and optionally a seed
value [6,15,16]. The manufacturer’s code is supposed to be constant for a large
number of products (e.g., an entire series from a certain manufacturer) and the
serial number of a transponder chip is public, i.e., it can easily be read out from
the chip. The seed value is only used in the case of so-called “Secure Learning”,
and can also be obtained from a chip with relative ease [6,15,16]. The other
option, “Normal Learning”, does not use a seed value.
In both types of key derivation mechanisms, a 64-bit identifier is constructed,
which contains the serial number, the (optional) seed and some fixed padding.
Then, the secret key is derived from this identifier and the master secret using
one of two possible methods. The first method simply uses XOR to combine the
identifier and the master key. The consequence of this is that once a single key is
known, together with the corresponding serial number and (optional) seed value,
the master secret can be found very easily.
The second method is based on decryption with the KeeLoq block cipher. The
identifier is split into two 32-bit halves which are decrypted using the KeeLoq
block cipher, and concatenated again to form the 64-bit secret key. The master
secret is used as the decryption key. Although much stronger than the first
method, the master secret can still be found using a brute force search. Evidently,
once the master secret is known, all keys that were derived from it are also
compromised, and the security of the entire system falls to its knees. Thus, it is
a much more interesting target than a single secret key. This may convince an
adversary to legitimately obtain a car key, for the sole purpose of recovering the
master key from its secret key.
6 Conclusion
In this paper we have presented a slide and meet-in-the middle attack on the
KeeLoq block cipher which requires 216 known plaintexts and has a time com-
plexity of 244.5 KeeLoq encryptions, and a variant using 216 chosen plaintexts
with the same theoretical time complexity.
We have fully implemented and tested both attacks. When given 16 key
bits, the known plaintext attack completes successfully in 10.97 minutes. Due to
implementation details, the chosen plaintext attack requires only 4.79 minutes
when given 16 key bits. To the best of our knowledge, this is the fastest known
attack on the KeeLoq block cipher.
Finally, we have shown that our attack can be used to attack real systems
using KeeLoq due to the way it is intended to be used in practice. Moreover, one
of the two suggested ways to derive individual Keeloq keys from a master secret
is extremely weak, with potentially serious consequences for the overall security
of systems built using the Keeloq algorithm.
Acknowledgements. We would like to thank Wim Aerts and Elke De Mulder
for their help with the experiments. Also, we would like to thank the reviewers
for their helpful comments.
References
1. Eli Biham, New Types of Cryptanalytic Attacks Using Related Keys, Journal of
Cryptology, Vol. 7, No. 4, pp. 229–246, Springer-Verlag, 1994.
2. Alex Biryukov, Sourav Mukhopadhyay and Palash Sarkar, Improved Time-Memory
Tradeoffs with Multiple Data, Proceedings of Selected Areas in Cryptography 2005,
Lecture Notes in Computer Science 3897, pp. 245–260, Springer-Verlag, 2006.
3. Alex Biryukov and David Wagner, Slide Attacks, Proceedings of Fast Software
Encryption ’99, Lecture Notes in Computer Science 1636, pp. 245–259, Springer-
Verlag, 1999.
4. Alex Biryukov and David Wagner, Advanced Slide Attacks, Advances in Cryptol-
ogy, Proceedings of EUROCRYPT 2000, Lecture Notes in Computer Science 1807,
pp. 586–606, Springer-Verlag, 2000.
5. Andrey Bogdanov, Cryptanalysis of the KeeLoq block cipher,
Cryptology ePrint Archive, Report 2007/055, 16 February 2007,
http://eprint.iacr.org/2007/055/.
6. Andrey Bogdanov, Attacks on the KeeLoq Block Cipher and Authentication Sys-
tems, 3rd Conference on RFID Security 2007 (RFIDSec 2007), available online at
http://rfidsec07.etsit.uma.es/slides/papers/paper-22.pdf.
7. Nicolas T. Courtois and Gregory V. Bard, Algebraic and Slide Attacks
on KeeLoq, Cryptology ePrint Archive, Report 2007/062, 8 May 2007,
http://eprint.iacr.org/2007/062/.
8. Nicolas T. Courtois, personal communication, 31 May 2007.
9. Nicolas T. Courtois, Gregory V. Bard and David Wagner, Algebraic and Slide
Attacks on KeeLoq, Proceedings of Fast Software Encryption 2008, Lecture Notes
in Computer Science, Springer-Verlag, to appear.
10. Soichi Furuya, Slide Attacks with a Known-Plaintext Cryptanalysis, Proceedings
of Information and Communication Security 2001, Lecture Notes in Computer
Science 2288, pp. 214–225, Springer-Verlag, 2002.
11. Martin E. Hellman, A Cryptanalytic Time-Memory Trade-Off, IEEE Transactions
on Information Theory, vol. 26, pp. 401–406, 1980.
12. Sandeep Kumar, Christof Paar, Jan Pelzl, Gerd Pfeiffer, Manfred Schimm-
ler, Breaking Ciphers with COPACOBANA — A Cost-Optimized Parallel Code
Breaker, Proceedings of Cryptographic Hardware and Embedded Systems 2006,
Lecture Notes in Computer Science 4249, pp. 101–118, Springer, 2006.
13. Microchip Technology Inc. KeeLoq R Authentication Products,
http://www.microchip.com/keeloq/
14. Microchip Technology Inc., HCS410 KeeLoq R Code
Hopping Encoder and Transponder Data Sheet,
http://ww1.microchip.com/downloads/en/DeviceDoc/40158e.pdf
15. Microchip Technology Inc., AN642: Code Hopping Decoder using a PIC16C56,
http://www.keeloq.boom.ru/decryption.pdf
16. Microchip Technology Inc., TB001: Secure Learning RKE Systems using KeeLoq
Encoders, http://ww1.microchip.com/downloads/en/AppNotes/91000a.pdf
17. Wikipedia, KeeLoq , http://en.wikipedia.org/wiki/KeeLoq , August 2007.
P′
P - fk0 - fk1 - . . . - . . . - fk15 - C (K)
525 rounds
P ′ - fk1 - . . . - . . . - fk15 - fk16 - C ′ (K ′ = K ≫ 1)
C
1. Using r = 16, we can recover 32 key bits, and then the rest of the key can
be recovered using exhaustive key search. The data complexity of the attack
is 512 chosen plaintexts encrypted under two related-keys (256 plaintexts
under each key), and the time complexity is 232 KeeLoq encryptions.
2. Using r = 8 twice (for the pairs (K, K ≫ 8), and (K ≫ 8, K ≫ 16))
we retrieve 32 key bits, and exhaustively search the remaining bits. The
data complexity of the attack is 64 chosen plaintexts encrypted under three
related-keys (16 plaintexts under two keys, and 32 plaintexts under the third
key), and the time complexity is 232 KeeLoq encryptions.
3. Using r = 8 four times (for the pairs (K, K ≫ 8), (K ≫ 8, K ≫ 16),
(K ≫ 32, K ≫ 40), and (K ≫ 40, K ≫ 48)) we can retrieve the full key.
The data complexity of the attack is 128 chosen plaintexts encrypted under
six related-keys (16 plaintexts under four keys, and 32 plaintexts under two
keys), and the time complexity is negligible.
Other variants are also possible, and provide a trade-off between the number of
chosen plaintexts and the number of related-keys.
Simplification yields:
48 · 232 + 3tc · 232+tc + 3tp · 232+tp + 3.33 · 296−2tp −2tc + 528 · 232 . (17)
The optimum is situated at tp = tc = 12 where the time complexity of the attack
is 250.9 KeeLoq rounds, or 241.9 full KeeLoq encryptions.
Summarising the attack, the data complexity is 217 chosen plaintexts en-
crypted under two related-keys (216 plaintexts under each key), and the time
complexity is 241.9 KeeLoq encryptions. The memory complexity is about 16 MB.