An Introduction to Keeloq Code Hopping
Total Page:16
File Type:pdf, Size:1020Kb
TB003 An Introduction to KEELOQ® Code Hopping Author: Kobus Marneweck A remote control transmitter of the type normally used Microchip Technology Inc. in vehicle security systems, is nothing but a small radio transmitter that transmits a code number on a certain frequency. This code number is normally generated by INTRODUCTION an integrated circuit encoder. The transmit frequency is normally fixed by legislation within a particular country, Remote Control Systems enabling anybody to build a simple receiver that can Remote control via RF or IR is popular for many appli- receive signals from all such transmitters. cations, including vehicle alarms and automatic garage It is a simple matter to build a circuit to record such doors. Conventional remote control systems are based transmissions captured by the receiver. Such a device on unidirectional transmission and have limited secu- is known as a code or key grabber. A would-be vehicle rity. More sophisticated devices based on bi-directional thief would typically lurk in a parking lot, waiting until a transmission are also available but, because of their vehicle owner arms his alarm with a remote control. high cost and certain practical disadvantages, they are The key grabber would capture the transmitted code, not widely used in commercial remote control devices. enabling the thief to retransmit this code as soon as the The popular unidirectional transmission systems cur- owner leaves the parking lot. Typically, this would leave rently have two very important security shortcomings: the alarm and/or immobilizer disabled and even the the codes they transmit are usually fixed and the num- central locking unlocked. ber of possible code combinations is relatively small. The Solution Either of these shortcomings can lead to unauthorized It is apparent that secure remote control systems can access. only be implemented if two conditions are met. The Code Scanning KEELOQ® code hopping system meets both these con- The limited number of possible combinations available in ditions with ease. most remote control systems makes it possible to trans- • A large number of possible combinations must be mit all possible combinations in a relatively short time. A available. hand held microprocessor-based system for this pur- A 66-bit transmission code is used to make scan- pose (called a code scanner) can easily be constructed. ning impossible. The 32-bit encrypted portion pro- In systems using eight DIP switches (256 combina- vides for more than 4 billion code combinations. A tions), this scanning process can typically be accom- complete scan would take 17 years! If the 34-bit plished in less than 32 seconds (when trying eight fixed portion is taken into account, the time combinations per second). Even in systems using required for a complete scan jumps to 5,600 bil- 16-bit keys (yielding roughly 65,000 combinations), lion years! only 2.25 hours would be required to try all possible • The system may never respond twice to the same combinations. It should also be noted that the scanner transmitted code. may gain access in far less than this maximum time— The random code algorithm will never respond to the average time would in fact be half of the total time. the same code twice over several lifetimes of a Scanning is counteracted by increasing the number of typical system. possible code combinations. A 66-bit code will yield Every time a remote control button is pushed, the sys- 19 11 7.3 x 10 combination and will take 2.3 x 10 years to tem will transmit a different code. These codes appear scan. random to an outsider – there is no apparent relation- Code Grabbing ship between any code and the previous or next code. A far easier way of gaining unauthorized access to a security system is freely available—such a unit is being advertised as a tool for the “legal repossession of vehi- cles.” To understand its operation, it is useful to know something about remote controls. KEELOQ is a registered trademark of Microchip Technology, Inc. Microchip’s Secure Data Products are covered by some or all of the following patents: Code hopping encoder patents issued in Europe, U.S.A., and R.S.A. — U.S.A.: 5,517,187; Europe: 0459781; R.S.A.: ZA93/4726 Secure learning patents issued in the U.S.A. and R.S.A. — U.S.A.: 5,686,904; R.S.A.: 95/5429 Ó 1996 Microchip Technology Inc. DS91002A-page 1 TB003 Once the system has responded to a valid code, about encoding) differs only in one bit from the information in 65,000 valid codes will have to be received before the the previous transmission, the next transmission will be same code will be used again. If the remote control is totally different. used eight times daily, 22 years will pass before the Checks exist that can be used to verify the security system responds to the same code again - once! characteristics of an encoding algorithm and, in this Therefore, a retransmitted code (like when a code instance, to determine whether the next transmitted grabber is used) will never activate the system. code is predictable to any degree. The Avalanche The KEELOQ algorithm also features sophisticated syn- Effect and a subset thereof, the Strict Avalanche Crite- chronization techniques. The system will continue to rion, have been tested on the KEELOQ algorithm. The function even if the transmitter is activated repeatedly results give a good indication of the security offered by while not in range of the receiver (as would happen if a the system. child played with the remote control). If a button is • Avalanche Effect (AE) pressed out of range more than 16 times, synchroniza- A block cipher satisfies the AE if changing one bit tion will be lost. However, two successive transmis- of the information causes, on average, half of the sions in range will restore synchronization. When no bits in the transmission to change. In the KEELOQ response occurs to a transmitter operation, the user's algorithm, this implies that changing one bit in the natural reaction is to press the button a second time. function and/or synchronization information will Synchronization will be restored when he does. Opera- cause an average of 16 of the 32 bits in the trans- tion is totally transparent — the user may not even mitted code to change. become aware that synchronization has been lost and restored. • Strict Avalanche Criterion (SAC) The SAC requires that, if one bit of the encoded These obvious security benefits are attainable at a cost information is changed, each bit in the output comparable to existing fixed code systems. The revolu- must have a chance of 0.5 of changing as well. tionary nature of the KEELOQ algorithm, full custom IC Consequently, the probability of guessing any one implementation, and reduced external component bit correctly is 0.5, and the probability of guessing requirements help to make this level of cost effective- an entire 32-bit string correctly is one in about ness possible. 4,300,000,000! The KEELOQ Algorithm The tests involved using a random 64-bit key and KEELOQ is a proprietary block cipher based on a block a Gray counter (starting at zero) as input to the length of 32 bits and a key length of 64 bits. The algo- algorithm. In each case, the output was compared rithm is characterized by a very economical hardware with a reference (SAC) or with the previous code implementation, while retaining a level of security com- (AE). In both cases, the results were as expected: parable to Data Encryption Standards (DES). This level For the AE, the average number of bits changed of security makes it eminently suitable for code commu- was 16.0 (50%), with a standard deviation of 2.83 nication applications such as code hopping antitheft or (8.8%). For the SAC, each individual bit changed access control devices. an average of 50% of the time, with a standard deviation of 8.8%. Information regarding transmitter identity and synchro- nization is encoded so as to render it unintelligible to an outsider. For decoding, it is necessary to have the same 64-bit key originally used for encoding. There- fore, even though the decoder (which has the key) can identify the transmitter unambiguously, an outsider (who does not have access to the key and/or the algo- rithm) can glean no information at all from the transmis- sions. As it is impossible to insert information into the system from outside, strategies used to attack FEAL and other DES-like ciphers are not usable against this system. The KEELOQ algorithm is designed to make it impossi- ble for a potential assailant to predict the next code that will be transmitted by a valid transmitter. Even if the assailant makes a reasonable guess regarding the way in which transmitted information changes with each transmission, the algorithm obscures this information sufficiently that the next code can not be anticipated. In particular, even if the transmitted information (before DS91002A-page 2 Ó 1996 Microchip Technology Inc. TB003 DEFINITIONS USED IN CODE HOPPING Transmitter Serial Number Each transmitter is programmed with a unique 28- or 32-bit serial number at the time of transmitter manufacture. This ensures that each transmitter will be unique within a system. Secret Key This 64-bit secret key is generated by a key generation function from the 28- or 32-bit serial number or the 32- or 48-bit seed and 64-bit manufacturer's key as inputs. A manufacturer’s key can be used to control the key generation func- tion. The secret key is not readable and is never transmitted.