Rolling code
A rolling code changes each use to thwart replay attacks.
A rolling code, also called a hopping code, is a cryptographic technique used in keyless entry systems to prevent replay attacks. In such systems, an eavesdropper who records a transmission cannot reuse it later because the code changes with every use. Rolling codes are commonly found in garage door openers and keyless car entry systems.
- Common algorithm
- KeeLoq
- Typical code length
- 66 data bits (34 unencrypted, 32 encrypted)
- Unencrypted bits
- 28-bit serial number, 4 bits button info, 2 status bits
- Encrypted rolling code bits
- 4 bits button info, 2 bits OVR, 10 bits DISC, 16-bit counter
- Typical receiver tolerance
- next 256 codes
- Vulnerability demonstrated
- Rolljam attack
Lore & Background
Rolling code systems rely on a pseudorandom number generator (PRNG), preferably cryptographically secure, in both transmitter and receiver. The transmitter sends the next code in the sequence, and the receiver compares it to its own calculated next code. To account for missed keypresses, a typical implementation accepts any of the next 256 codes. The HMAC-based one-time password used in multi-factor authentication follows a similar approach but uses a pre-shared secret key and HMAC instead of a PRNG and pre-shared random seed.
In RF remote control applications, a rolling code transmitter improves security by interleaving a trinary bit fixed code with the rolling code. The receiver demodulates the encrypted transmission, recovers both codes, and performs algorithmic checks before actuating a motor to open or close a movable component. Simple fixed-code systems are vulnerable because the same code works indefinitely; rolling code systems make captured codes unusable for future access.
The Microchip HCS301, using the KeeLoq algorithm, was once the most widely used system for garage and gate remotes. It transmits 66 bits: 34 unencrypted (serial number, button info, status bits) and 32 encrypted (button info, OVR bits, discrimination value, and a 16-bit counter). In resyncing situations, the encrypted portion is replaced with a 32-bit seed. KeeLoq has been shown vulnerable to a variety of attacks and has been completely broken.
Reader's Guide
Rolling code technology represents a significant advancement over fixed-code systems in radio frequency remote control. By ensuring that each transmitted code is unique and unpredictable to an observer, it prevents simple replay attacks where a recorded signal could later be used to gain unauthorized access. The approach is widely deployed in garage door openers and keyless car entry systems.
However, rolling code systems are not invulnerable. The KeeLoq algorithm, once the industry standard in the Microchip HCS301, has been completely broken through various cryptographic attacks. Additionally, the rolljam vulnerability demonstrated that a rolling code transmitted by radio can be intercepted and falsified using a device that jams the receiver while recording two successive codes from the owner's fob. The first recorded code is replayed to the vehicle during the owner's second attempt, while the second code is retained for future use. This vulnerability was reported as widely known for years but previously undemonstrated.
Despite these weaknesses, rolling code remains a foundational security measure in consumer and commercial access systems. Its legacy lies in raising the bar for attackers compared to fixed codes, though ongoing cryptographic weaknesses and practical attacks show that no single-layer solution is absolute.
Did You Know?
- A rolling code is also called a hopping code.
- The Microchip HCS301 KeeLoq system transmits 66 data bits total.
- A typical rolling code receiver accepts any of the next 256 codes to account for missed keypresses.
Frequently Asked Questions
What is a rolling code in radio electronics?
A rolling code (sometimes called a hopping code) is a cryptographic method used in keyless entry systems like garage door openers and car remotes. It generates a fresh, unique code every single time the button is pressed so that a recorded transmission becomes useless after one use.
How does a rolling code stop replay attacks?
Because the code advances with every activation, an eavesdropper who captures one transmission cannot simply re-broadcast it later—the receiver will reject any code it has already seen. This one-time-use property is the core defense that distinguishes rolling codes from static fixed codes.
Which algorithm is most commonly used to implement rolling codes?
The KeeLoq algorithm is the industry-standard cipher for generating rolling codes in consumer keyless entry hardware. It handles the encryption of the counter and status fields while leaving identification bits in the clear.
What does a typical rolling code packet look like in terms of bits?
A standard KeeLoq rolling code carries 66 data bits: 34 unencrypted bits (a 28-bit serial number, 4 bits of button info, and 2 status bits) plus 32 encrypted bits (4 button-info bits, 2 OVR bits, 10 DISC bits, and a 16-bit counter). The receiver typically accepts the next 256 sequential codes to tolerate missed transmissions.
Are rolling codes completely secure against modern attacks?
Not entirely—the Rolljam attack demonstrated that an adversary can jam the receiver while simultaneously capturing the code, forcing the counter to advance without the receiver ever registering the new value. This desynchronisation can eventually lock out a legitimate user or, in some implementations, open the door to further exploitation.
More in Radio Electronics, Part 3 1-24
Spotted an error? Know more?
Reader corrections go straight into our review queue. Suggest an edit · How this site is sourced
