Archive for the ‘Break IC’ Category

PostHeaderIcon Brute Force on EEPROM: Unlimited Reads, Limited Writes

A serial EEPROM attached to a microcontroller looks like the least interesting component on the board. It holds a few kilobytes, it has three or four pins, and it costs less than a connector. It is also, in a large fraction of designs, where the calibration constants, the serial number, the feature flags and sometimes the credential live — and unlike the microcontroller, it usually has no protection at all.

The reason is an asymmetry in the device’s physics. An EEPROM cell can be read an unlimited number of times. It can be written perhaps a million times, and the manufacturer will tell you so in the datasheet. Reading costs nothing; writing costs endurance. Every attack on an EEPROM is shaped by that asymmetry.

What the cell actually is

An EEPROM cell is a floating-gate transistor with a thin tunnel oxide. Charge placed on the floating gate shifts the threshold voltage, and the sense amplifier reads the shift. Writing moves charge onto the gate through Fowler–Nordheim tunnelling, which requires about 10 V and damages the oxide slightly each time. Reading applies a few volts to the control gate and compares the resulting current against a reference; it moves no charge and damages nothing.

This is why the endurance limit exists and why it applies only to writes. A device rated for a million write cycles will survive a billion reads. The read path is effectively free, and an attacker who understands this stops thinking about the secret and starts thinking about the array.

The array is small enough to enumerate

Serial EEPROMs come in three interface families, and all three support a sequential read that walks the entire array without any further addressing.

Family Typical sizes Read command Full array read time
I²C, 24Cxx 128 B – 512 KB Random read, then sequential 10 ms – 3 s at 400 kHz
SPI, 25Cxx 512 B – 1 MB READ 0x03 with 24-bit address 1 ms – 2 s at 20 MHz
Microwire, 93Cxx 64 B – 16 KB READ with auto-increment 1 ms – 100 ms

Even the largest device in the table is read in a couple of seconds. The smallest is read in milliseconds. There is no meaningful cost to reading the whole thing, which means there is no reason to be selective: the entire contents are on the bench before any analysis starts.

The practical consequence is that the enumeration is trivially complete. A 24C02 with 256 bytes is read byte by byte in a single burst; a 24C512 with 64 KB is read in one sequential transfer that the master can clock out as fast as the bus allows. There is no rate limit, no lockout, no attempt counter, because the protocol has no concept of authentication.

Where the attempt counter actually lives

The one thing an EEPROM cannot do is count. It has no state machine beyond the address pointer, no write-protect logic beyond a pin, and no notion of who is asking. So if a system needs to limit attempts at a PIN, the counter cannot be in the EEPROM’s logic — it has to be in the microcontroller, stored either in RAM or back in the EEPROM as a data byte.

That placement is the weakness. A counter in RAM is cleared by a reset if the design does not persist it, and a counter in EEPROM is a byte that the attacker can also write if the bus is accessible. The two common implementations therefore both fail against an attacker with bus access: one loses the count on power cycle, the other allows the count to be rewritten.

Counter location Survives power loss Attacker with bus access
RAM only No Reset clears it
EEPROM byte, written each attempt Yes Rewritable, and wears out
EEPROM byte, written on lockout only Yes Rewritable before lockout
MCU internal flash, protected Yes Requires MCU-level attack

Only the last row moves the problem to the microcontroller, and that is where the work becomes an MCU attack rather than an EEPROM attack.

Enumeration is not guessing

There is a distinction worth making explicit, because it changes the equipment. Guessing a secret means generating candidates and testing them; enumerating an address space means reading every location once and looking at what is there.

The second is almost always the correct approach on an EEPROM, because the secret is usually present rather than derived. A PIN stored as four ASCII digits occupies four bytes, and those four bytes are readable. A calibration constant is two bytes. A feature flag is one bit. Nothing is hidden by computation, because the device has no compute to hide it with.

Where the data is obfuscated, the obfuscation is almost always trivial: a byte-wise XOR with a constant, a nibble swap, or a byte-reversal of a multi-byte value. Each of these is detectable from statistics alone. A constant XOR preserves the distribution of byte values and produces a flat histogram where the plaintext would have had structure; a nibble swap produces a histogram with peaks at the swapped positions; a byte reversal leaves multi-byte counters running backwards, which is visible in any region that increments over time.

Reading it without the bus

When the EEPROM is on a bus that cannot be reached — because the microcontroller holds it, or because the board is potted — the device can be read directly. An SOIC-8 clip over the package is enough on most boards, and reading it in circuit works as long as the microcontroller is held in reset so that it does not drive the bus.

Holding the MCU in reset is the step that is usually skipped, and the symptom of skipping it is a read that returns plausible but inconsistent data: the MCU and the clip driver contend for the bus, and the resulting waveform is a wired-AND of two masters. The data looks like real data because the pull-ups make the idle state look like erased bytes.

Where the package is a TSOP or a BGA, in-circuit clipping is not possible and the part is read after removal. Removal is destructive to the board but not to the device, and it is the standard route for a one-off recovery.

What brute force contributes

The honest summary is that brute force contributes little to an EEPROM attack where the bus is accessible, and a great deal where it is not.

With bus access, the work is a complete read, and the analysis is pattern recognition. Without bus access, and where the only interface is a keypad or a serial command that accepts a PIN, the situation becomes a genuine brute force problem — and there the arithmetic is unforgiving. A four-digit PIN is 10,000 attempts; at one attempt per second that is under three hours. A six-digit PIN is 1,000,000 attempts, which is eleven days at the same rate. An eight-character alphanumeric is 2.8 × 10^12, which is ninety thousand years.

Secret Space At 1 attempt/s At 100 attempts/s
4-digit PIN 10^4 2.8 hours 100 seconds
6-digit PIN 10^6 11.6 days 2.8 hours
8-char alphanumeric 2.8 × 10^12 89,000 years 890 years

Those numbers are why the counter matters more than the space, and why a design that limits attempts to three is not defeated by arithmetic at all.

Where this sits in the service

The work we do at this layer is mostly not brute force. It is a complete read of the device, a statistical pass to identify structure, and a report that separates what is certainly stored from what is inferred. On EEPROMs with a trivial obfuscation we decode it and say so; on EEPROMs holding a genuine cryptographic key we extract the key and let the customer decide what to do with it.

Where the EEPROM’s contents are protected because the microcontroller enforces a read protection that covers the external bus, the problem stops being an EEPROM problem, and the route becomes the MCU-level one described in breaking IC code. Where the secret turns out not to be in the EEPROM at all — which happens more often than customers expect — the search moves to the four physical locations described in where the secret key lives. The feasibility arithmetic above is the same one that governs any other guessing problem, and it is set out in when brute force works.

PostHeaderIcon When Brute Force Works: The Attempts × Seconds Test

Every brute force proposal reduces to one line of arithmetic: the size of the space multiplied by the time each attempt takes. That line is easy to compute and almost never the reason a project fails. The reason projects fail is that the multiplication assumes attempts are free, and on real hardware they usually are not.

Sorting a request into “brute force is viable” or “brute force is not viable” therefore takes two questions, not one. How large is the space, and what does one attempt cost in the only currency that matters — wall-clock time before the device locks, slows, or dies.

The naive multiplication

Take a four-digit PIN. Ten thousand candidates. At one attempt per second, 2.8 hours. At ten attempts per second, seventeen minutes. The arithmetic is correct and the conclusion is usually right, which is why this class of problem is the one everybody quotes.

Now take a six-digit PIN. One million candidates, 11.6 days at one attempt per second. Still plausible if the device is on a bench and nobody is waiting. Eight characters of alphanumeric is 2.8 × 10^12, which is 89,000 years at the same rate, and that is the point at which the arithmetic stops being the interesting part of the conversation.

Space Size 1/s 10/s 1000/s
4-digit PIN 10^4 2.8 h 17 min 10 s
6-digit PIN 10^6 11.6 d 1.2 d 17 min
8 hex chars 4.3 × 10^9 136 y 13.6 y 50 d
16 hex chars 1.8 × 10^19 — — 580,000 y

The table makes the shape obvious: for anything above about 40 bits, online guessing is not a computational problem at all. No amount of parallelism fixes it, because the limit is the number of attempts the target will accept per second, not the number of candidates a machine can generate.

The counter is the real gate

A design that accepts attempts at one per second forever is defeated by arithmetic. A design that accepts three attempts and then locks is not defeated by arithmetic at all. The difference between those two designs is a few bytes of state, and it is the single most effective security measure in the entire product.

Counters are implemented in four ways, and each fails differently.

Implementation Where state lives How it fails
Volatile counter in RAM MCU SRAM Cleared by power cycle or reset pin
Counter in EEPROM, written per attempt External EEPROM Rewritable if bus is accessible; wears out
Counter in protected flash, written on lockout MCU flash Survives, but only after the lockout fires
Counter plus escalating delay MCU flash plus timer Survives and slows the attack

The first row is defeated by removing power. The second is defeated by any bus access. The third is the first one that actually works, and its weakness is that the lockout is a single event: an attacker who can interrupt power at attempt two never triggers it, and the count is only persisted at the moment of lockout, so interrupt-and-retry resets the count.

The fourth row closes that hole by making the delay part of the state, so that interrupting power does not reset the accumulated time. This is the implementation that turns a ten-thousand-attempt problem into an unfundable one, and it is not expensive to build.

Free attempts versus metered attempts

The distinction that matters commercially is whether an attempt is observable and whether it costs the target anything. Three cases exist.

An attempt against a device that answers instantly and never records anything is free. The attacker can run at the bus limit, and the only cost is the rig. This is the case for an EEPROM read, and it is why an EEPROM has no secrets.

An attempt against a device that records each failure is metered. The rate is now set by the recording mechanism, and the endurance of that mechanism becomes an attack surface in its own right: an EEPROM counter written on every attempt wears out after a million cycles, and a worn-out cell may read as erased, which resets the count. That is a real and underappreciated failure mode, and it means a counter in EEPROM is worse than a counter in flash.

An attempt against a device that records and delays is metered with a rising price. After a few failures the delay doubles, and the total time to exhaust the space becomes dominated by the delay rather than by the number of candidates. A ten-second delay after five failures turns ten thousand attempts into twenty-eight hours; a sixty-second delay turns it into a week.

Measuring the rate before believing the model

The single per-attempt time in the multiplication is an input, not a constant, and it is the one variable that has to be measured rather than assumed.

The measurement is a hundred attempts, timed end to end, divided by a hundred. Doing it properly requires that the hundred attempts be failures, because a success ends the loop early and biases the average downwards. It also requires that the device be in the same state at the start of each attempt as it will be during the campaign: a device that has been power-cycled has a different first-attempt cost from one that has been running.

Three effects make the measured rate differ from the datasheet’s response time.

The first is the reboot. A device that requires a power cycle between attempts adds the boot time to every attempt, and a two-second boot on a device that answers in ten milliseconds turns a rate of a hundred per second into one every two seconds. That single fact changes the campaign duration by two orders of magnitude and is discovered only by measuring.

The second is the backoff. Many designs delay after each failure, and the delay grows. The measured average over the first hundred attempts is then not the average over ten thousand, because the last thousand attempts are much slower than the first hundred. Where backoff is present, the rate has to be measured in the regime the campaign will actually occupy, which means measuring the tenth thousandth attempt rather than the first.

The third is the wear-out of the counter itself. A counter written on every attempt into an EEPROM with a million-cycle endurance will fail somewhere around attempt one million, and the failure mode is usually a cell that reads as erased. That is a route to a reset count rather than a barrier, but it is also a route to a device that no longer boots, and the customer should be told which risk applies before the campaign starts.

Measured quantity What it changes How to measure
Attempts per second The whole estimate 100 failures, timed
Reboot time per attempt Rate, by orders of magnitude Power cycle and time to first response
Backoff schedule Late-campaign rate Time attempts 1, 100, 1000, 10000
Counter wear limit Whether the campaign damages the device Datasheet endurance of the storage

Parallelism and its limits

Running many targets in parallel divides the wall-clock time by the number of targets, and this is the one form of parallelism that genuinely works. It requires many physical devices, which is unusual: a customer usually has one failed unit, not a thousand.

Running many generators in parallel — GPUs, FPGAs, clusters — divides nothing, because the target is still answering at one attempt per second. This is the most common misconception in the field, and it comes from confusing online guessing with offline cracking. Offline cracking, where the attacker holds the hash and can test candidates locally, is limited by compute and is exactly what GPUs are for. Online guessing is limited by the target’s response rate and is not helped by a single additional FLOP.

Attack mode Limited by Helped by GPU
Online, target answers each attempt Response rate and counters No
Offline, hash or ciphertext in hand Compute Yes
Offline, key derived from a known structure Compute plus structure Yes
Physical, per-device extraction Equipment and operator time No

The table is the reason a request that arrives as “we need the password brute forced” has to be classified before it is quoted. Two of the four rows are compute problems and two are not.

Side channels beat brute force

When the space is large and the counter is real, the productive route is usually not to reduce the space by guessing but to observe the device while it decides. A comparison that returns early leaks the position of the first wrong byte, which turns an n-byte search into n single-byte searches. A four-byte PIN becomes four searches of 256, which is a thousand attempts rather than four billion.

That transformation is worth more than any amount of compute, and it is the subject of the timing side of the problem: where timing leaks sets out the four leak shapes, and preventing timing attacks in code explains the defence that removes them.

What we actually do

The service at this layer is a feasibility assessment before a campaign, and it produces one of three answers. The counter classification that decides which answer applies is in brute force on a chip.

If the counter is defeatable — volatile state, or state written only at lockout — the campaign is viable and the time estimate is the multiplication above with the measured response rate. We run it and report the candidate when found.

If the counter is not defeatable and the space is small enough to survive the delay schedule, the campaign is viable but slow, and the estimate includes the delay escalation rather than just the candidate count. Customers frequently accept this and are glad to have been told the real number.

If neither holds, the answer is that online guessing will not work, and the route is a side channel or a physical extraction. Saying that in the first conversation is worth more than a month of attempts, and the alternative routes are set out in glitch attacks as a search problem and extracting IC flash. Where the target is an EEPROM on an accessible bus, the enumeration is a read rather than a guess, as described in brute force on EEPROM.

PostHeaderIcon A Brute Force Case Study: How Prior Knowledge Shrinks the Space

Two jobs arrived in the same week. Both involved a four-to-six character secret, both targets accepted roughly one attempt per second, and both customers had done the same arithmetic and concluded that the work would take days. One finished in under an hour. The other was abandoned. The difference was entirely in the order the candidates were tried.

What follows is what actually happened, because the arithmetic in the previous paragraph is the part everyone already understands and the ordering is the part nobody plans for.

Case one: a four-digit lock with no keypad

The target was a dosing controller with a service menu protected by a four-digit code entered through two buttons — up and enter. Ten thousand combinations. At one attempt per second the customer’s arithmetic gave 2.8 hours, and he had budgeted a day.

The device had two properties that changed the estimate by an order of magnitude.

First, the code was stored in the external EEPROM as four bytes of packed BCD, and the EEPROM was read in circuit in nine seconds. The brute force never happened. The “space” was 256 bytes of readable memory, and the code was at offset 0x41. That is the ordinary outcome for this class of device, and it is worth stating plainly: when the storage is reachable, there is no search at all.

Second — and this is the useful part — even if the EEPROM had been protected, the search order would not have been 0000 to 9999. The manufacturer’s service manual, found in fifteen minutes of searching, documented a factory code. The installation sheet documented a second. Between them, two candidates covered a meaningful fraction of shipped units, and both were tried first.

Priority Candidate class Count Cumulative coverage
1 Documented factory and installer codes 3 Estimated 40 % of units
2 Repeats and sequences (0000, 1111, 1234) 12 A few percent
3 Dates as MMDD 366 Larger but device-specific
4 Everything else 9,619 Remainder

The lesson is not that the fourth row is unreachable. It is that a search which spends its first fifteen attempts in rows one and two is a different experiment from one that starts at 0000 and counts up, even though both are “brute force”.

Case two: an eight-character bootloader password

The second target was a bootloader that demanded a password before accepting a firmware image. The password was eight hexadecimal characters, which is 4.3 × 10^9 — 136 years at one attempt per second. The customer had already decided the job was impossible and wanted confirmation.

It was not impossible. The password was the last three bytes of the Ethernet MAC address, printed on the label, in uppercase hex with a fixed prefix. The space was one candidate.

This is the single most common shape of a “large” secret on embedded hardware: it is not chosen at random, it is derived from something that identifies the unit. MAC addresses, serial numbers, production dates, model codes and ordinal numbers within a batch are all candidates, and all of them are either printed on the device or inferable from context.

Derivation Source of the value Search cost
Last 3 bytes of MAC Printed label 1
Full MAC, no separators Printed label 1
Serial number, decimal Printed label 1
Serial number, hex, padded Printed label A few format variants
Production date as YYMMDD Silkscreen or date code 1 per date candidate
Random, stored in flash Nowhere readable 16^8

The last row is the only one that is actually 4.3 billion candidates, and it is also the least common, because engineers who write bootloaders usually want the password to be recoverable for service.

Why ordering dominates throughput

The two cases above are both about ordering, and the reason ordering dominates is that real secrets are not uniformly distributed over their space. They are clustered at the low end, near values a human would pick or a factory would assign.

Any measurement of real credentials shows the same shape: a small dictionary of a few hundred entries covers a large fraction of cases, and the coverage curve flattens hard after that. On a four-digit PIN, the top twenty candidates cover several percent of real devices; the top thousand cover a third. That means a search ordered by frequency finds a third of all devices in a thousand attempts, while a search ordered numerically finds the same third only after exhausting three thousand.

The effect compounds with the attempt rate. A thousand attempts at one per second is seventeen minutes; three thousand is fifty. Neither is a barrier, but the second one is the difference between finishing during a site visit and coming back tomorrow.

Case three: when derivation fails

A third job in the same period went the other way, and it is included because the failures are more instructive than the successes.

The target was a handheld instrument whose calibration menu was protected by a six-digit code. There was no documented factory code, the code was not derived from the serial number, and the device stored it as a hash rather than as plaintext, so reading the EEPROM produced thirty-two bytes that were not the code. Six digits is a million candidates, and the device locked for sixty seconds after five failures.

The arithmetic was not the problem. At five attempts per hour, a million candidates is twenty-two years. The counter and the backoff together had already solved the problem, and no amount of ordering would have helped because the space was uniform and the rate was one attempt per twelve minutes.

That job ended with a different answer: the calibration routine was reachable through a test point that the factory used, and the code was checked by the application rather than by the routine. Entering the routine directly bypassed the check entirely. The lesson is that the counter is a property of the entry path, not of the function, and finding a second path is often cheaper than any search.

Case Space Counter Outcome
One 10^4 None Read from EEPROM in seconds
Two 16^8 None Derived from the label
Three 10^6 Five per hour Bypassed via a test path

Building the ordered list before touching the device

The ordering that made the first two cases fast was assembled before any cable was connected, and assembling it takes about an hour.

The first source is documentation. Service manuals, installation sheets, quick-start cards and distributor catalogues frequently list a factory code, and the code is often the same across a product family for years because changing it requires reprinting the sheets. Searching for the model number plus the word “code” or “password” finds these more often than engineers expect.

The second source is the product’s own software. A configuration utility distributed for the product usually contains the default code as a string, and the utility is downloadable. Extracting strings from it is a two-minute job and yields candidates that the device will accept.

The third source is the shape of the secret. A four-digit code on a device with a date-stamping feature is often MMDD. A code on a device installed by contractors is often the installer’s initials plus a digit. A code on a device with a serial number printed on it is often the last four digits of that number.

The fourth source is the population. Codes that appear in breach lists and in default-credential databases are the codes people actually choose, and a list of the few hundred most common covers a disproportionate share of real devices.

What the case study does not show

It is important to be clear about the limits of these examples, because they are frequently generalised too far.

Both cases had a readable or derivable secret. Neither required defeating a counter, and neither involved a secret that was genuinely random. Where the secret is random and the counter is real, ordering does not help at all: uniform distribution means every candidate is equally likely, and the ordering is irrelevant because the space has no structure.

That is the case where the answer is a side channel rather than a search. If the device compares the supplied password byte by byte and returns early, the comparison leaks the matching prefix, and the search becomes n × 256 instead of 256^n. The four shapes that leak can take are set out in where timing leaks, and the conditions under which such a measurement is even possible are in before a timing attack.

What we do with this

The practical value of these case studies is that they change the first hour of a job. Before any attempt is made, we ask four questions: where is the secret stored, how was it chosen, is it derived from something printed on the unit, and is it compared in a way that leaks.

Answering those four costs less than a day and frequently removes the search entirely. When it does not, the campaign that follows is ordered by likelihood rather than by numeric sequence, and the estimate we give is based on the coverage curve rather than on the raw space size — which is why our estimates for this class of work are usually far shorter than the customer’s own arithmetic.

Where the secret turns out to be genuinely random and the comparison is constant time, we say so and the route changes to measurement rather than guessing; the arithmetic that governs that decision is in when brute force works, and the four physical locations a key can occupy are in where the secret key lives. Where the secret is stored in an EEPROM on an accessible bus, the read is a nine-second operation and the whole discussion is moot, as described in brute force on EEPROM.

PostHeaderIcon Four Kinds of Brute Force: Passwords, Keys, Addresses, States

“Can you brute force it” is a question with four different answers, and the answer depends on what is being guessed rather than on how large the space is. A password, a cryptographic key, a memory address and a protocol state are all things one might enumerate, and the four enumerations have nothing in common beyond the word.

Sorting a request into the correct category takes ten minutes and changes everything that follows: the equipment, the criterion for success, the expected duration and the reason the attempt will fail.

Category one: a password

A password is chosen by a person, which means it is drawn from a distribution that is nothing like uniform. That single fact is the whole reason password search is feasible at all, and it is why password search tools are dictionaries rather than counters.

The distribution is heavily skewed. A few hundred candidates cover a large fraction of real choices, because people pick dates, names, keyboard patterns, sports teams and the same handful of defaults that every product ships with. The tail is long, but the head is where the work happens.

Property Value
Chosen by A person, usually once, usually quickly
Distribution Highly skewed
Tool Ordered dictionary, then rules, then exhaustion
Success criterion Target accepts the input
Failure mode Retry counter

The distinguishing feature is that success is observable without any measurement. The device either opens or it does not. That makes password search the easiest category to run and the easiest to defend: a counter and a delay defeat it completely, which is why every serious product has both.

Category two: a cryptographic key

A key is generated by a random process, which means it is drawn from a uniform distribution. Nothing about one candidate makes it more likely than another, so dictionaries are useless and the only structure available is what the algorithm leaks.

For a modern key this category is not searchable by enumeration at all. A 128-bit key is 3.4 × 10^38 candidates; at a billion attempts per second that is ten thousand billion years. The number is so far beyond reach that the only sensible response is to stop treating it as a search problem.

What makes key recovery possible is not a smaller space but a leak. A comparison that returns early leaks the matching prefix. A table lookup that touches cache lines in a secret-dependent order leaks the index. A multiply whose timing depends on the operand leaks bits. Each of those converts one large search into many small ones, and the conversion is where the skill lies.

Property Value
Chosen by A random generator
Distribution Uniform
Tool Side channel, not enumeration
Success criterion Recovered key verifies
Failure mode Constant-time implementation

The commercial consequence is that a request to “brute force the AES key” is not a request that can be fulfilled. The honest answer is that the key has to be obtained by a leak or by reading the memory that holds it, and both of those are different jobs.

Category three: an address

An address space is ordered, finite and usually small. Enumerating it is not guessing at all; it is reading, one location at a time, and it succeeds by covering the space rather than by finding a match.

This category includes reading a serial EEPROM from 0x0000 to the end, walking a flash array in sectors, and scanning a memory-mapped peripheral region for registers that respond. In each case the “search” is a loop whose length is known in advance, and the result is a complete map rather than a single hit.

Property Value
Chosen by The memory map
Distribution Ordered, dense
Tool Read command with auto-increment
Success criterion Complete dump obtained
Failure mode Unmapped regions fault or alias

The failure mode is worth knowing because it produces convincing wrong answers. A read of an unmapped region often returns the last value on the bus, which looks like data. A dump that contains a long run of identical bytes may be an erased region, or may be an aliased unmapped region, and distinguishing them requires knowing the map — which is what the enumeration is supposed to produce.

Category four: a protocol state

A protocol state is the least obvious category and often the most productive. The “space” here is the set of states a state machine can be in, and the goal is to find a sequence of inputs that reaches a state the designer did not intend.

The space is not enumerable by counting, because the number of possible input sequences is unbounded. What makes it tractable is structure: state machines have far fewer reachable states than their input alphabet suggests, and the transitions are usually guarded by simple conditions.

Property Value
Chosen by The protocol designer
Distribution Structured, sparse
Tool Model extraction and graph search
Success criterion Reaching an unintended state
Failure mode Rate limiting and timeouts

The productive methods here are the ones from protocol analysis: send a valid sequence, change one field, observe whether the state advances, and build a transition graph from the observations. A device that reports its state through an LED, a status byte or a response code gives the graph away for free.

Mixed cases and how to split them

Real systems rarely present one category cleanly, and the split is where most of the analytical value lies.

A device that demands a PIN and locks after five failures is two categories at once: a password (category one) and a state machine that counts failures (category four). The password space is small, so the naive conclusion is that the job is a short dictionary run. But the counter is a state in the protocol sense, and reaching a state where attempts are unlimited is a different objective with a different technique — one that does not involve guessing the PIN at all.

The same applies to key provisioning. A device that generates a key at first boot and stores it in flash is category two at rest and category one during provisioning, because the provisioning trigger is often a factory command with a weak or default credential. Attacking the provisioning state is usually easier than attacking the key.

Apparent category Often actually The cheaper object
Password with a lockout Password plus protocol state The lockout state
Key in flash Key plus provisioning path The provisioning command
Address read refused Address plus permission state The permission check
Encrypted protocol Protocol state plus a key The state machine

The general rule is that a system with more than one secret has a weakest one, and the weakest one is almost never the one the customer is worried about. Establishing the full set before choosing a target is the difference between attacking the designed defence and attacking the implementation around it.

Why the classification decides the quote

The four categories differ in duration by several orders of magnitude, and a quote that assumes the wrong one is wrong by the same factor.

Category Realistic duration Reason it ends
Password, no counter Hours Found
Password, with counter Never Attempts exhausted
Key, with a leak Days to weeks Found
Key, constant time Never No leak to measure
Address Seconds to minutes Space covered
Protocol state Days Unintended state reached

The table is the practical reason for classifying first. Two requests that both say “brute force” can be the second row and the fifth row, and those are a refusal and a coffee break.

What we do with a request

The first question we ask is what the secret is a property of: a person, a generator, a memory map, or a protocol. The answer is usually available from the product description without touching hardware.

Where the answer is a person, the work is a dictionary and the counter is the whole story, which is why the rate measurement described in when brute force works comes before any attempt. Where the answer is a generator, the work is a side channel or a memory read, and the relevant route is where timing leaks or extracting IC flash. Where the answer is a memory map, the work is an enumeration of the kind described in brute force on EEPROM, and where it is a protocol, the work is the graph search in reverse engineering IC firmware.

The service here is the classification and, when the classification says the work is impossible, the refusal. Most of the value of this page is in the second case.

PostHeaderIcon Preventing Timing Attacks at System Level: Why Random Delays Fail

When a timing leak cannot be fixed in the code — because the code is in a vendor library, or because the leak is in the platform, or because the constant-time rewrite is too expensive — the defence moves up a layer. Three options exist at that layer, and they are not variations on a theme. Two of them multiply the attacker’s work by a constant. One of them removes the observable.

The distinction matters because the first two are what most products implement, and they are the reason most products are still attackable.

Option one: random delays

The idea is intuitive. If the response time leaks information, add a random delay so that the response time no longer means anything.

The arithmetic that kills it is short. A uniform random delay over an interval of width D has a standard deviation of about 0.29 D. Averaging N independent observations reduces the standard deviation by √N, so after N observations the residual noise is 0.29 D / √N. To hide a real signal of magnitude S, the residual noise must exceed S, which requires:

N > (0.29 D / S)²

Put in numbers for a realistic embedded case: a delay uniform over one millisecond, and a signal of twenty nanoseconds.

Delay width D Signal S Samples needed At 100 ms each
100 µs 20 ns 2,100 3.5 min
1 ms 20 ns 210,000 5.8 hours
10 ms 20 ns 21,000,000 24 days
100 ms 20 ns 2.1 × 10^9 6.6 years

The first two rows are the ones that matter, because delays of a hundred microseconds to a millisecond are what a firmware engineer considers a reasonable randomisation. Two thousand samples is a coffee break and two hundred thousand is a long weekend. Neither is a defence.

Only at the bottom of the table does the delay become a real obstacle, and a device that randomly delays every authentication response by up to a hundred milliseconds is a device with a hundred-millisecond latency, which the product owner will reject.

There is a second problem. The random delay has to be genuinely random. A delay derived from a linear congruential generator seeded at boot, with the same seed on every unit, is a fixed sequence, and an attacker who recovers the sequence removes the defence entirely. This is common in low-cost firmware, where the RNG is a timer reading.

Option two: a fixed time base

The second option abandons randomness and makes the response time constant. The routine runs to completion, then waits until a fixed deadline before responding.

This works, and it works completely, because the observable becomes independent of the secret rather than noisy. The difference from randomisation is categorical: after averaging, a randomised response converges to the true value plus a constant, while a fixed-time response converges to the constant.

The cost is the worst-case latency. If the operation takes between one and three milliseconds depending on the input, the deadline must be three milliseconds, and every response takes three. That is acceptable for an authentication attempt, which happens once per session, and unacceptable for a data path that runs thousands of times per second.

Defence Observable after averaging Cost Works
Random delay Signal plus a constant Average latency No
Fixed deadline A constant Worst-case latency Yes
Fixed-period polling A quantised constant Slot granularity Yes

Option three: fixed-period polling

The third option is the most elegant and the least used. The device does not respond when it finishes; it responds at the next tick of a free-running timer.

The implementation is a queue. The routine places its result in a slot, and a timer interrupt at a fixed period drains the slot and transmits. Because the transmission instant is decided by the timer rather than by the routine, the observable is quantised to the tick period, and every response that lands in the same tick is indistinguishable.

This is strictly better than a fixed deadline in one respect: it does not require the routine to be padded to its worst case, only that the worst case be shorter than the tick period. A routine that takes one to three milliseconds behind a five-millisecond tick produces responses that all appear at the same instant, and the routine’s internal variance is invisible.

The cost is granularity. A response that arrives at a tick boundary is quantised to five milliseconds, so the maximum throughput is two hundred responses per second regardless of how fast the routine is. For a command interface that is fine; for a bulk data path it is not.

Quantisation is the key property and it is worth stating precisely. A quantised observable takes one of a small number of values, and the number of values is the same regardless of the secret. That is a stronger guarantee than any amount of noise, because noise leaves the underlying value recoverable in the limit while quantisation leaves it unrecoverable at any sample count.

Which one to use

The decision is made by where the leak is and how often the operation runs.

If the operation is rare — authentication, key derivation, a service unlock — use a fixed deadline or a tick. The latency cost is invisible to the user and the defence is complete.

If the operation is frequent and the latency matters, the defence has to move back into the code, because no system-level trick can hide a leak on a path that must respond in microseconds. That is the case for the constant-time rewrite described in preventing timing attacks in code.

If the operation is in a library that cannot be changed, wrap it: run it, store the result, and release the result on a tick. The wrapper does not need to know what the library does, only that its output can be delayed.

Situation Recommended Why
Rare, latency tolerant Fixed tick Complete and cheap
Frequent, latency critical Constant-time code Only option that works
Third-party library Tick wrapper No source access needed
Vendor crypto with own timing Tick plus audit Wrapper hides, audit finds

Measuring whether the defence holds

A quantised response is a claim, and it is a cheap claim to test.

The test is to run the same operation a thousand times with the same input, record the arrival time of each response, and look at the distribution. A defended device produces one of two shapes: a single spike, where every response lands on the same tick, or a distribution truncated at the tick boundary, where the fastest responses are delayed to a common floor and the slowest are not.

The second shape is the interesting failure. It means the padding covers the fast path but not the slow one, so the slow cases still leak. This happens when the deadline is set from the typical execution time rather than the worst case, which is a natural mistake when the worst case is rare.

The second half of the test is to vary the input across the range that would matter to an attacker and confirm the response time does not move. Ten thousand samples per input class, means compared. If the means are identical to within the tick resolution, the quantisation is complete; if they differ by a fraction of a tick, the padding is partial and the residual leak is visible to anyone who averages.

Test Passes when Typical failure
Repeated identical input One spike at the tick Jitter larger than the tick
Worst-case input Arrives at the same tick Deadline set from the mean
Input sweep Means identical Partial padding
Current probe No data-dependent steps Leak moved to the supply

The fourth row is not a timing test at all, and it is included because a defence that quantises the response can leave the current draw untouched. A device that takes a variable amount of charge to complete an operation leaks that variation through its supply even when its digital response is perfectly quantised.

The mistake that undoes all three

All three defences are defeated by one implementation error: allowing a second observable to escape.

A device that quantises its response but logs the failure time to a flash page has moved the leak to the flash write. A device that pads its response but returns a different error code for a malformed input has kept the leak in the code. A device that uses a fixed deadline but blinks an LED inside the routine has published the timing optically.

The audit question is therefore not “is the response time constant” but “what else can be observed”. Current draw, indicator pins, bus traffic, log writes and the response itself are all observables, and a defence that covers one of them is a defence against a specific measurement rather than against the class.

What the assessment delivers

The service at this layer is an observable inventory rather than a code review. We list every channel that carries timing information out of the device — response latency, current, indicator pins, bus activity, logs — measure the magnitude on each, and report which ones are quantised and which are not.

That inventory is what tells a customer whether their randomisation is worth anything. In most cases the answer is that it is not, the arithmetic in the table above shows why, and the fix is a tick rather than a delay. The measurement budget that decides whether a residual leak is exploitable at all is set out in before a timing attack, and the shapes a leak takes in the first place are in where timing leaks. Where the leak is in the silicon rather than the software, the defence is a different discussion entirely, and the five-generation history in the smartcard arms race is the honest summary of how that goes.

PostHeaderIcon Where Timing Leaks: Branches, Caches, Early Returns, Data-Dependent Delays

Once the measurement budget is known, the next question is what to measure. Timing does not leak from a single place, and the mechanisms differ enough that a technique which finds one will miss the others entirely.

Four mechanisms account for almost every practical leak. They are listed here in order of how easy they are to find, which is roughly the inverse of how much information they carry.

Mechanism one: the early return

This is the classic and the easiest to exploit. A comparison loop that exits at the first mismatching byte takes an amount of time proportional to the length of the matching prefix, and that length is the secret.

“ for (i = 0; i < 16; i++) { if (a[i] != b[i]) return 0; // leaks the prefix length } “

The magnitude is large: each iteration costs one load, one compare and one branch, which is a handful of cycles, so a sixteen-byte comparison spans perhaps a hundred cycles between the fastest and slowest case. On a 16 MHz core that is six microseconds, which is enormous compared with the noise floor of a well-triggered measurement.

The measurement is a single-timing histogram: run the comparison ten thousand times with the first mismatch at each position, and the means separate. No special equipment is needed beyond a trigger, because the effect is bigger than the noise.

The information per measurement is high. Recovering one byte costs 256 attempts, so a sixteen-byte tag costs 4,096 rather than 2^128. That ratio is why this mechanism is the one that appears in every textbook.

Mechanism two: the branch

A conditional branch on a secret bit produces two paths of different length. The magnitude is usually one to a few cycles, which is three orders of magnitude smaller than the early return.

“ if (key_bit) { x = rotate_left(x, 1); } else { x = x ^ constant; } “

On a simple core, the branch itself is the cost: a taken branch flushes the prefetch buffer, and the flush costs a few cycles. On a core with branch prediction, the cost becomes harder to predict but does not vanish — the misprediction rate depends on the pattern, and the pattern depends on the secret.

The measurement requirement is different from the first case. A three-cycle difference against a noise floor of a hundred nanoseconds on a 16 MHz core is a ratio of two to one in favour of the noise, so thousands of samples are needed and the trigger has to be precise.

Mechanism Typical Δ Noise immunity Samples needed
Early return 1–10 µs Very good Hundreds
Branch on secret 2–10 cycles Poor 10,000+
Cache or wait state 10–100 cycles Moderate 1,000+
Data-dependent arithmetic 5–50 cycles Moderate 5,000+

Mechanism three: the cache or the wait state

A table lookup indexed by a secret touches a cache line determined by the secret. If the table is larger than the cache, the hit rate depends on which entries are used, and the timing reflects the access pattern.

On microcontrollers this mechanism shows up in two forms, and the second is often the dominant one.

The first is a genuine data cache, found on higher-end parts. A table of a few kilobytes against a 32-byte line size gives a measurable hit-rate difference, and the classic attack on table-based AES recovers the key from it.

The second is flash wait states. On parts running above the flash’s rated frequency, the flash controller inserts wait states, and the number depends on whether the access is sequential and whether the prefetch buffer hits. A table lookup that breaks a sequential run costs more than one that continues it. This mechanism exists on parts with no cache at all, and it is frequently overlooked because the datasheet describes wait states as a fixed configuration rather than a data-dependent cost.

Sub-mechanism Where it exists Magnitude
Data cache miss High-end MCU with cache Tens of cycles
Flash wait state plus prefetch Most MCUs above 24 MHz 1–3 cycles per access
TCM versus flash placement Parts with tightly coupled memory Large, if code moves

The third row is a design detail that becomes an attack: code or tables placed in fast memory run at a different speed from the same code in flash, and if the placement depends on a configuration value, the timing reveals the configuration.

Mechanism four: data-dependent arithmetic

Some operations take an amount of time that depends on their operands. Integer division is the canonical example: the number of shift-subtract iterations depends on the magnitude of the divisor and the dividend. Floating-point operations on soft-float libraries are worse, because the library implements normalisation loops whose iteration count depends on the exponent.

Software delay loops of the form for (i = 0; i < n; i++) where n derives from the secret are the crudest version and are still written, usually as a “security delay” that inadvertently publishes the value it is protecting.

Operation Dependence On a core without hardware divide
Integer divide Operand magnitude Up to 32 iterations
Soft float normalise Exponent Up to 24 shifts
Multiply-accumulate chain Loop count Proportional
Software delay loop The secret directly Fully proportional

A routine usually has more than one

The mechanisms above are not alternatives. A single authentication routine typically contains an early return in the comparison, a branch on the result, a table lookup in the key schedule and a division in the certificate check. Four leaks in one function, with magnitudes spanning three orders of magnitude.

The practical consequence is that fixing the obvious one changes which mechanism dominates. After the early return is removed, the next largest effect is the branch, and after the branch is removed, the table lookup becomes visible. An audit that stops after the first fix has removed the loudest leak and left the quiet ones, which is exactly the state most “hardened” libraries are in.

This is also why the defence is a rewrite rather than a patch. Removing four mechanisms from a routine one at a time produces code that is constant in four dimensions and probably not in a fifth that nobody looked for. The disciplined approach is to specify constant time as a property of the whole path, which is the subject of preventing timing attacks in code.

What time does not see

The four mechanisms above all describe time. There is a fifth channel that is not time at all, and knowing its boundary is what stops a timing audit from being mistaken for a security audit.

Every operation the core performs draws current, and the current depends on which transistors switched. A multiply that processes a secret-dependent operand draws a different current profile from one that does not, regardless of how many cycles it takes. So a routine that is perfectly constant in time can still be a strong emitter, and the measurement that finds it is a current or electromagnetic probe rather than a timer.

The relationship between the two channels is worth stating precisely, because it is frequently confused.

Property Timing channel Power or EM channel
Observable Arrival time of the response Current or field during execution
Resolution needed Nanoseconds Megasamples per second
Removed by constant-time code Yes No
Removed by quantised response Yes No
Requires physical access to the die No Usually not, but close proximity

The fourth row is the one that surprises people. A device that quantises its response has hidden the timing completely and hidden nothing else, because the energy consumed during the operation is still proportional to the work done, and the work done is still proportional to the secret.

This matters for assessment because a customer who has been told their device is constant time may reasonably conclude that side channels are handled. They are not; one of the two channels is handled, and which one was addressed determines what remains.

Identifying which one applies

Identification is an experiment, not an inspection. Change one input bit at a time, hold everything else fixed, and measure. The shape of the response identifies the mechanism.

A response that is flat until a byte boundary and then steps is an early return. A response that alternates with individual bits is a branch. A response that depends on the index modulo a power of two is a cache or a wait state. A response that grows smoothly with a numeric value is arithmetic.

That mapping is worth building once per target, because it determines both the attack and the fix. The budget that decides whether any of it is measurable on the actual board is in before a timing attack, and the system-level defences that make the measurement moot are in preventing timing attacks at system level.

In assessment work this is the first analysis we perform: a per-bit response map of the target routine, classified by mechanism, with the magnitude of each. It takes a day and it tells the customer which of their four leaks is the one that matters. Where the map shows a single dominant mechanism and a good trigger, the route to a recovered credential is the one in where the secret key lives; where it shows four comparable mechanisms, the honest report is that the routine needs a rewrite before any measurement is worth taking.

PostHeaderIcon Preventing Timing Attacks in Code: Constant Time, Not Slower Time

The first instinct when a timing leak is discovered is to add a delay. It is the wrong instinct, and understanding why takes about thirty seconds of arithmetic. If a comparison takes 100 ns when the first byte is wrong and 140 ns when the first two bytes are right, the difference is 40 ns. Adding a random delay of 0 to 1 µs makes each individual measurement useless. Averaging a thousand measurements reduces the noise by a factor of about thirty, and the 40 ns signal reappears, because the signal is constant and the noise is not.

Delays hide leaks. They do not remove them. The only code-level defence that survives averaging is code whose execution time is independent of the secret, which is a property of the code’s structure rather than of its speed.

The leak is in the control flow

Timing leaks on a microcontroller come from four sources, and three of them are the compiler’s doing rather than the programmer’s.

Source Mechanism Typical magnitude
Early return in a comparison Loop exits at first mismatch Tens of ns to µs
Branch on a secret bit Two paths, different lengths A few cycles
Table lookup with secret index Cache or flash wait states Tens of ns
Data-dependent arithmetic Multiply/divide by secret Cycles to tens of cycles

The first is the classic. A function that compares a supplied MAC against a computed one, byte by byte, and returns as soon as a byte differs, leaks the length of the matching prefix. An attacker who can measure that length recovers the MAC one byte at a time: 256 guesses per byte, times the length, instead of 256 to the length. A sixteen-byte tag drops from 2^128 to 4096.

The second is subtler because it looks harmless. A branch that tests a bit of the key and does one extra operation is a one-cycle difference on a fast core, and one cycle out of twenty is a two percent difference that averaging can resolve given enough samples. On a part with a cache, or with flash wait states that depend on the access pattern, the difference becomes much larger.

The pattern that replaces it

A constant-time comparison replaces the early return with an accumulator that runs to completion regardless of where the first mismatch is.

“ diff = 0 for i in range(n): diff |= a[i] ^ b[i] return diff == 0 “

Every iteration executes. There is no branch on the data, no early exit, and the loop count is public — it is the length of the tag, which is not a secret. The result is a boolean that depends on all bytes equally.

The same shape applies to other operations. A conditional selection becomes a mask: instead of if (bit) r = x; else r = y;, compute mask = -(bit & 1) and then r = (x & mask) | (y & ~mask). A conditional swap becomes an XOR swap gated by the mask. A table lookup with a secret index becomes a linear scan over the whole table with a mask per entry, which is slower by the table size and constant in time.

Dangerous pattern Constant-time replacement Cost
if (a[i] != b[i]) return 0; OR-accumulate XOR Same
if (secret) x++ ; Masked add A few cycles
table[secret] Full scan with mask O(n) instead of O(1)
while (secret) {...} Fixed iteration count Bounded by worst case

The last row is the one that hurts, because a loop whose trip count depends on the secret cannot be made constant without running the maximum number of iterations every time. Where that cost is unacceptable, the design has to change so that the trip count is public.

The compiler will undo your work

This is the failure mode that wastes the most time, and it is invisible in source review. A modern optimiser recognises the mask-and-select pattern as a conditional move and may convert it back into a branch, or may vectorise the OR-accumulator into a reduction whose length depends on the data. Either transformation restores the leak.

The defence is to check the generated code rather than the source. Compiling the function, disassembling it, and looking for conditional branches inside the loop is a two-minute check that catches most of these. Where the compiler insists on transforming, the options are to compile that translation unit at a lower optimisation level, to insert an optimisation barrier that the compiler cannot see through, or to write the loop in assembly.

The same applies to the loop bound. for (i = 0; i < n; i++) where n is a variable is fine if n is public, and is a leak if n is secret, regardless of what the body does. Making the bound a compile-time constant is often the simplest fix.

Where the leak moves next

Fixing the comparison moves the leak rather than removing it, and the new location is predictable. There are four places it typically goes.

The first is the error path. A function that now compares in constant time but returns a different error code for “wrong length” than for “wrong content” has told the attacker which of the two failed, and the length is often the more useful fact. Making both paths return the same code, after the same amount of work, is part of the same fix.

The second is the format check. A parser that validates a checksum before comparing the payload spends time proportional to how far the payload got before the checksum failed. If the checksum is over the secret, the parser leaks it. The fix is to validate in an order that does not depend on secret data, or to validate everything and combine the results at the end.

The third is the response transmission. A device that replies with a fixed-length frame is fine; a device that replies with a variable-length frame, or that pads to a block boundary derived from the secret, leaks the length. Length is a weak secret but it is often enough to narrow a search.

The fourth is the log. A device that writes a log entry on failure and a different one on success has a timing difference in the flash write, and flash writes are slow enough to be visible without any equipment beyond a current probe.

New leak location What it reveals Fix
Distinct error codes Which check failed Single code, equal work
Early format rejection Prefix validity Validate all, combine at end
Variable response length Secret length Fixed frame, public padding
Different log writes Outcome Same write path, dummy record

The general principle is that constant time is a property of the whole observable path, from the first input byte to the last output byte, and not of any single function. Auditing one function and declaring the device safe is the most common way this work is done badly.

Measuring whether it worked

A constant-time implementation is a claim, and claims about timing are testable. The test is straightforward: run the function many times with inputs that differ in the position of the first mismatch, collect the execution time distribution for each class, and compare the means.

With ten thousand samples per class, a difference of one clock cycle is usually detectable on a microcontroller with a cycle counter, because the measurement noise on a deterministic loop is small. If the distributions overlap completely across all mismatch positions, the implementation is constant in the dimension tested.

Test What it catches Sample count
Mismatch position sweep Early return 10k per position
Secret bit flip Branch on secret 10k per bit
Input length variation Length-dependent loop 1k per length
Power or EM correlation Data-dependent arithmetic 100k traces

The fourth row is beyond a timing test and belongs to the power side channel, but it is worth knowing that a function can pass the timing test and still leak through its current draw. Constant time is necessary and not sufficient.

What constant time cannot fix

Two limits are worth stating because customers sometimes expect more.

A constant-time implementation cannot fix a leak that comes from the platform rather than the code. If the flash controller’s wait states depend on the address, and the address depends on the secret, the leak is in the memory system. The fix is to make the access pattern public, which may mean copying the table into RAM, which may be impossible on a small part.

Nor can it fix a leak in a library that the code calls. A vendor crypto library that returns early inside its own comparison is a leak no amount of careful code around it will remove. Checking the library is part of the job, and a surprising number of production libraries fail this.

Where this fits with the rest

Code-level constant time is one of three defences, and it is the only one that removes the leak rather than masking it. The system-level defences, including why random delays fail against averaging, are covered in preventing timing attacks at system level. What the attacker is measuring in the first place, and the four shapes a leak can take, is in where timing leaks.

On the offensive side, the same knowledge drives assessment work: we build a timing profile of a protected routine, identify which of the four shapes it exhibits, and report whether the measurement budget on the actual board is sufficient to exploit it. That assessment is described in before a timing attack. Where the leak is real and the counter-measure is absent, the recovery of a credential from a device is covered in where the secret key lives. The service here is the audit and the measurement, and it is honest about the difference between a leak that exists and a leak that is reachable with the equipment the customer’s board allows.

PostHeaderIcon Before a Timing Attack: The Observability Budget

Timing attacks acquire a reputation for being either trivial or impossible, and the reputation comes from people attempting them without doing the arithmetic first. The arithmetic takes ten minutes and answers the question definitively. Everything after that is execution.

Four quantities have to be known before the first measurement. They are not independent, and the relationship between them is the whole analysis.

One: can the input be controlled

A timing attack needs the attacker to choose the input and to know exactly when the target operation begins. Both halves matter.

Choosing the input is usually easy: a command over a serial port, a keypad entry, a value written to a register. It becomes hard when the input passes through a state machine that transforms it, or when the target only accepts one attempt per power cycle, or when the input is a physical quantity such as a supply voltage that the attacker can only influence within a range.

Knowing when the operation begins is the part that is frequently underestimated. A trigger has to be derived from something the device does at the start of the operation: a GPIO toggling, a bus transaction, a current step, or an instruction fetch on an address bus. Without a trigger, the measurement window is the whole command-response interval, which is milliseconds long, and the timing difference of twenty nanoseconds is lost in the placement error.

The practical test is whether the trigger jitters. A trigger derived from a GPIO that the firmware sets at the start of the routine jitters by the GPIO write latency, which is one or two cycles, so the placement error is a few nanoseconds. A trigger derived from the first byte of a UART reply jitters by the baud-rate quantisation, which is 8.7 µs at 115200 baud. That difference decides whether the attack is possible, and it has nothing to do with the target’s protection.

Two: what resolution is available

The measurement has to resolve the effect, and the effect is typically one to fifty nanoseconds.

Measurement method Resolution Placement jitter
Oscilloscope, 1 GS/s, hardware trigger 1 ns 1–5 ns
Oscilloscope, 100 MS/s 10 ns 5–20 ns
MCU cycle counter around the call 1 cycle (62 ns at 16 MHz) Trigger overhead
GPIO toggle plus logic analyser 1 sample (2–10 ns) 1–2 cycles
Software timestamp read before and after 1 µs or worse Interrupt dependent

The fifth row is where most home-grown attempts fail. Reading a timer before and after the call measures the call plus the timestamp read, and the timestamp read itself is affected by interrupts, by flash wait states, and by whether the counter is in a peripheral that requires a bus wait. The measured value is dominated by that overhead, and the effect being sought is smaller than the overhead’s variance.

The second row is the common bench situation and it is marginal: a 10 ns resolution against a 20 ns effect means the effect is two quantisation steps, which is detectable with enough averaging but leaves little margin for anything that shrinks the effect.

Three: what the noise is

Noise is the largest term and the least often measured. It has four sources, and they differ in how they respond to averaging.

Noise source Magnitude Reduced by averaging
Thermal and quantisation Sub-nanosecond Yes, as 1/√N
Clock and PLL jitter 1–20 ns Partially, if uncorrelated
Interrupt and scheduler jitter 100 ns–10 µs Poorly, if periodic
Host scheduling (USB, OS) 1–10 ms No

The last row is fatal and is the reason USB-connected instruments are unsuitable for this work at nanosecond scale. USB transfers are scheduled in one-millisecond frames, so the arrival time of a command has a one-millisecond uncertainty. Averaging does not reduce it, because it is not random: it is a quantisation that repeats.

The third row is the one that catches embedded targets. A timer interrupt that fires every millisecond and takes two microseconds perturbs the measurement whenever it lands inside the window. Averaging helps, but slowly, and the perturbation is correlated with the loop’s own timing if the loop is periodic.

Four: how many repetitions are affordable

The formula that ties the three quantities together is the standard one. To resolve a difference Δ against a noise standard deviation σ, the number of samples needed is roughly (σ/Δ)² per class, doubled for two classes.

Putting numbers to it makes the decision concrete.

Δ (effect) σ (noise) N per class Time at 100 ms/attempt
20 ns 20 ns 4 0.4 s
20 ns 200 ns 200 20 s
20 ns 2 µs 20,000 33 min
20 ns 20 µs 2,000,000 55 hours
1 ns 200 ns 80,000 2.2 hours

The fourth row is where a technically possible attack stops being a practical one. Two million attempts at a tenth of a second each is fifty-five hours of continuous measurement on a single device, and any interruption — a watchdog, a thermal shutdown, a bus error — invalidates the run.

The fifth row is the case that looks impossible on paper and is fine in practice, because the effect there is one nanosecond and the noise is two hundred, but a device that can be measured at a hundred microseconds per attempt makes the required eighty thousand samples a two-hour job.

The decision

With the four quantities measured, the answer is one of three.

If N is below a thousand, the attack is a morning’s work and the only remaining question is which byte to attack first. Start with the byte whose effect is largest, which is usually the first and last byte of a comparison rather than a middle one.

If N is between a thousand and a million, the attack is viable but has to be planned: the device must be able to run for hours without intervention, the trigger must be stable, and the measurement chain must not depend on a host operating system.

If N is above a million, the honest answer is that the measurement budget does not permit it, and the effort should move to a different side channel or to a physical route. Saying this early is the most valuable thing an assessment can produce.

What changes the budget

Two levers can move a marginal case into the viable range, and both are about the target rather than the equipment.

Raising the signal: some implementations amplify the effect without any change to the attacker’s setup. A comparison that processes more bytes per iteration, or that includes a checksum over the whole buffer, produces a larger Δ than one that exits early. Finding an input that maximises the difference is worth more than a better oscilloscope.

Lowering the noise: removing the device’s own interrupts is sometimes possible by choosing an operating mode — a bootloader path instead of the application, a service mode instead of normal operation. A bootloader often has interrupts disabled and a simple polling loop, which reduces σ by an order of magnitude. This is a legitimate and often decisive step.

Where the analysis sits in the work

This budget is computed before anything else, and it is what makes the difference between an assessment and a campaign. The four leak shapes an attacker is looking for are described in where timing leaks, and the code-level defence that removes them is in preventing timing attacks in code. When the budget is insufficient, the alternative is usually a fault injection route, whose own feasibility test is in glitch attacks as a search problem.

The service at this layer is a measurement report: the trigger jitter, the noise floor, the achievable Δ, and the resulting sample count, with a recommendation. Customers are sometimes surprised that the answer is a number rather than an opinion, and that is the point. Where the number is too large, we say so, and the work moves to a route that has a budget of its own — for instance the physical read in extracting IC flash. What we will not do is spend a month averaging in the hope that a budget which does not close will close later.

PostHeaderIcon Is It an ASIC? Five Physical Tests and What a Wrong Answer Costs

The question sounds academic and is entirely commercial. An ASIC has no firmware. It has no instruction set, no boot code, no memory to dump. Its function is the wiring. A microcontroller has all four, and a request to recover code from one is a routine job.

So when a customer sends a part and asks what can be recovered from it, the first fact that has to be established is which of the two it is. Five observations settle it, and they can be made in an order that puts the cheapest first.

Test one: the pad ring

The strongest single indicator is the relationship between the die area and the number of bond pads.

A die whose area is set by its logic is core-limited: the logic fills the area, and the pads sit in a ring around the edge with whatever spacing the design allows. A die whose area is set by its pin count is pad-limited: the pads are large, evenly spaced, and occupy the entire periphery, and there is empty silicon between the pad ring and the logic.

Pad-limited designs are characteristic of small, high-pin-count devices — exactly the shape of a custom ASIC built for a cost-sensitive product. A microcontroller is usually core-limited, because its logic is complex and its pin count is modest.

The observation is made under a microscope after decapsulation, and it takes a minute.

Observation Inference
Pads evenly spaced, logic fills the die Core-limited, likely MCU or complex ASIC
Large pads, empty ring between pads and logic Pad-limited, likely small ASIC
Pads clustered with gaps Multiple power domains or a mixed-signal part
Very few pads, large die High-pin-count in a large package, or a test vehicle

Test two: the cell structure

Standard-cell logic appears as horizontal rows of uniform height. The row height is set by the library, and it is constant across the die for a given library.

A microcontroller has rows across the whole digital area, with the row height matching a modern library — a few microns. An ASIC has the same structure if it was built from standard cells, so this test distinguishes standard-cell designs from full-custom ones rather than ASIC from MCU.

The distinction that matters here is between a regular row structure and a regular array structure. An array of identical cells, repeated in two dimensions, is memory. A field of identical cells in a regular grid with no row structure is an FPGA’s logic fabric. Rows plus arrays is a normal microcontroller.

Test three: the metal layer count

Counting the metal layers requires either a cross-section or careful inspection of the upper layers under high magnification, and it is the test most often skipped because it is the most laborious.

It is also the most informative about vintage and cost. Two or three metal layers indicate an old or a low-cost process, which is typical of a mature MCU or a cheap ASIC. Six or more indicate a modern process and a design that needed the routing resources.

The test’s real value is in combination with the others. A die with few metal layers, a pad-limited layout and no memory array is an old, cheap, custom part with no firmware. The same die with a memory array is an old MCU.

Test four: on-die non-volatile storage

This is the test that answers the commercial question directly, and it is worth doing even when the first three have already suggested an answer.

Non-volatile storage on a die has visible structure. Flash appears as a regular array with a distinctive texture, and in a modern process the floating-gate stack has a different thickness from the surrounding oxide, which shows as a colour difference under bright-field illumination. Mask ROM appears as a dense array with a programmed pattern that is often visible as a variation in the diffusion.

A die with neither has no firmware. That is the definitive statement, and it does not depend on interpretation of pad rings or metal counts.

Storage visible What it means Recovery route
Flash array Programmable, likely an MCU Electrical or optical
Mask ROM with visible pattern Factory-programmed, not rewritable Optical read of the pattern
Neither Fixed function None; the value is the netlist
Large SRAM only Volatile, boots from elsewhere Look for an external flash

The fourth row is worth remembering: a die with a large SRAM and no non-volatile memory boots from something else, and that something else is usually an external serial flash. The recovery then targets the flash, not the die.

Test five: the package and the board

The last test is the cheapest and it is done before anything is opened.

A microcontroller almost always has a programming path. On a production board that path may be an unpopulated header, a set of test pads, or nothing at all, but the die’s pinout will show the characteristic pattern: a reset line with a pull-up and a capacitor, a clock input or a crystal footprint, and one or two pins with series resistors leading to a connector footprint.

An ASIC usually has none of that. Its pins are functional: a bus, an analog input, a driver output, a power supply. There is no reason to bring out a programming interface for a part that is programmed by its mask.

The package marking adds a weaker signal. An ASIC built for one customer often carries a house number and a date code with no vendor logo, and the same number appears on no distributor’s list. A microcontroller under a house number usually has a recognisable package style and a marking font that matches a known vendor.

The two ways to be wrong

Getting the answer wrong in one direction is annoying. Getting it wrong in the other direction is expensive.

Calling an MCU an ASIC leads to a refusal or an over-quote. The customer is told the work is impossible when it is routine, and the loss is a job.

Calling an ASIC an MCU leads to a commitment that cannot be met. The quotation is based on a firmware extraction that has no object, the schedule assumes a deliverable that does not exist, and the discovery happens after a decapsulation and often after a purchase order. The loss is a contract and a relationship.

Misjudgement What follows Cost
MCU called ASIC Work declined or overpriced One job
ASIC called MCU Impossible commitment Contract, reputation
COB called custom Weeks spent on identity Schedule
FPGA called ASIC Deliverable misunderstood Dispute over what was promised

The third row is the most common benign error. A chip on board is a standard die under epoxy, and it is routinely mistaken for a custom part because there is no package to read. Once identified, the job becomes ordinary, and the route is the one for any other protected microcontroller, set out in MCU attack surfaces.

Why the tests are ordered by observability

The five tests are presented in the order a laboratory would perform them, which is also the order of increasing cost: package and board inspection costs nothing, decapsulation costs a device, and a cross-section costs a device and a day.

In practice the first, fourth and fifth tests settle more than ninety percent of cases. The second and third are for the residual cases where the die has been opened and the answer is still ambiguous — usually a mixed-signal part with a small digital core, which can be either.

What the assessment delivers

The output of this work is a short document: the classification, the evidence for it, the confidence, and the recovery route that follows. Where the part is an MCU in disguise, the document names the protection state and the route described in breaking IC code. Where it is a mask-ROM part, the route is optical and the document says that the device will not survive. Where it is a fixed-function ASIC, the document says there is nothing to recover and names the alternative, which is usually a behavioural rebuild rather than an extraction.

The broader investigation that follows a “custom” classification — including the question of where an undocumented system actually keeps its contents — is set out in attacking a custom IC. The one thing this assessment exists to prevent is a decapsulation performed on a part whose contents were never in the die to begin with.

PostHeaderIcon Custom ICs: Three Steps to Identify What You Cannot Look Up

An ordinary microcontroller gives you a starting point: a part number, a datasheet, a known instruction set, a documented debug interface. A custom IC gives you none of that. The marking may be a house number, the pinout is unknown, and there is nothing to search for. Work on such a part begins with an investigation that has no equivalent in standard recovery jobs.

The investigation has three steps, and they are ordered by cost. The first is free, the second costs a decapsulation, and the third costs a cross-section. Doing them in order avoids paying for the third when the first two have already answered the question.

What “custom” actually covers

The word covers at least four different things, and they have almost nothing in common technically.

A full-custom ASIC is designed transistor by transistor. It has no instruction set, no firmware, and no memory in the usual sense; its function is the wiring.

A gate array or structured ASIC uses a prefabricated array of gates personalised by the upper metal layers. It looks like an ASIC from outside and behaves like one, but the underlying array is standard.

A COB — chip on board — is an ordinary die mounted directly on the PCB under a blob of epoxy. It is almost always a standard microcontroller, and the absence of a package is what makes it look exotic.

An FPGA with a hardened processor is a different thing again: programmable fabric plus a real CPU, with the configuration in an external flash.

Type Has firmware Has known ISA Where the value sits
Full-custom ASIC No No Netlist, unrecoverable
Gate array No No Netlist, partly recoverable
COB of a standard MCU Yes Yes Flash, easy once identified
FPGA plus CPU Yes, in the fabric Yes, for the CPU Bitstream and software

The third row is the one that matters commercially, because a large fraction of “custom” parts sent for analysis turn out to be standard microcontrollers under a blob. Identifying that early converts an unbounded project into a routine one.

Step one: the package and the marking

The first step costs nothing and eliminates half the possibilities.

The package tells you the pin count, which bounds the complexity. A 48-pin QFN can be a small ASIC or a small MCU. A 256-ball BGA with a large thermal pad and a ring of decoupling capacitors around it is not a microcontroller; it is a device with a fast parallel interface, which suggests memory, an FPGA, or a processor with external bus.

The marking tells you the vendor, if not the part. House numbers are common, but the date code format, the font, the laser versus ink process and the presence of a logo are all vendor signatures. A die marked in a particular fine-pitch dot matrix is from one of a handful of foundries, and the package’s tooling marks narrow it further.

The board tells you the interface. A part surrounded by 22-ohm series resistors on eight parallel lines is driving a bus. A part with a single SPI flash beside it and nothing else is a small processor booting from that flash. A part with a crystal, a reset supervisor and a programming header is a microcontroller almost certainly.

That last observation is the most useful one in the entire investigation: look for a programming header. If the board has a five-pin or six-pin unpopulated footprint near the part, the part is programmable, and programmable parts are usually standard.

Step two: the pad ring and the cell structure

If step one does not settle it, the die has to be exposed. Under a microscope at 200 to 500 times, three features answer the question.

The pad ring is the ring of bond pads around the periphery. A ring with evenly spaced pads and a power ring behind them is a standard-cell design. A ring with pads grouped in clusters, with large gaps between groups, is a pad-limited design where the die size was set by the number of pads rather than by the logic — typical of a small controller in a large package.

The standard-cell rows are the horizontal bands of logic. They have a constant height, usually between two and ten microns, and the height is characteristic of the library. A die with perfectly regular rows across the whole area is a standard-cell ASIC or a microcontroller. A die with a large regular array of identical cells in one region and rows in another is an FPGA or a device with embedded memory.

The metal layers count is the third feature and the most diagnostic. Two or three layers suggests a mature process and a simple device. Six or more suggests a modern process and a fast design. A die with visible upper-metal personalisation over a regular base array is a gate array, and the personalisation layer is the part that carries the design.

Observation Inference
Regular cell rows across the die, few metal layers Small standard-cell ASIC or MCU
Repeated identical array plus logic rows FPGA or embedded memory
Uniform base array with sparse upper metal Gate array
Large analog blocks beside small digital area Mixed-signal ASSP
Bond pads clustered, large empty areas Pad-limited small controller

Step three: on-die storage

The third step is only needed if the first two leave the question open, and it answers the one question that decides the commercial route: is there non-volatile storage on this die?

Flash is visible as a regular array with a distinctive texture and, in newer processes, as a region with a different colour under bright-field illumination because the floating-gate stack has a different thickness. A die with no such region has no on-chip firmware, which means the function is either mask-programmed or wired, and neither is extractable as code.

Mask ROM is visible as a dense array with a programmed pattern, usually near the bottom or the edge. It is readable optically, and the pattern is the data. This is the one case where an ASIC-like part yields recoverable contents without any electrical interface.

SRAM is visible as a large regular array with a fine pitch, and it is volatile. Its size tells you the class of the device: a few kilobytes suggests a controller, hundreds of kilobytes suggests a processor or a buffer-heavy design.

Reading the power tree

One observation that is available before any decapsulation and that is frequently decisive: the board’s power distribution.

A single-die device usually has one regulator feeding it, with a handful of decoupling capacitors and possibly a small LC filter. A multi-die package, or a board with two significant digital loads, shows two regulators or one regulator with two separately filtered branches. Counting regulators on a board is a two-minute inspection and it tells you how many substantial pieces of silicon are present.

Board observation Inference
One regulator, one decoupling cluster Single die
Two regulators, similar current ratings Two significant dies
One regulator plus a small LDO near the part Core plus analog, or an IO supply
Regulator with a ferrite bead to a small cluster Sensitive analog or RF section

The fourth row is common on parts that mix a digital core with an analog front end, and it explains a die that looks like an MCU with an unusually large analog block. Those parts are custom in the sense that matters — the analog behaviour is undocumented — while the digital half is often an ordinary core that can be attacked normally.

Power sequencing is the second observation from the same inspection. A device that requires two supplies in a particular order has a power-on state machine, and that state machine is frequently less protected than the main interface. Sequencing faults are a recognised attack class in their own right, and the relevant mechanisms are the ones described in power glitches.

Where the firmware usually is

The single most useful statistical fact about undocumented parts is that their firmware is frequently not inside them. A custom ASIC paired with an external SPI flash is an extremely common architecture, and in that arrangement the ASIC is the fixed function and the flash holds everything that varies.

This is why the investigation’s third step often ends with a redirection rather than a result. A die with no floating-gate region and a nearby eight-pin SOIC is a system whose contents are in the SOIC, and the SOIC is readable in ten seconds with a clip.

Architecture Where the contents are Effort
ASIC plus external serial flash The flash Low
ASIC with mask ROM The die, optically Moderate
ASIC with embedded flash The die, electrically or optically High
FPGA plus configuration flash The flash, but as a bitstream Low, different meaning
MCU under a blob The die, via standard interface Low once identified

What the service actually delivers

For an undocumented part the first deliverable is a written identification: what class of device it is, what process it appears to be built in, whether it has on-die non-volatile storage, and where the system’s contents most likely reside. That document is produced from a package inspection, a board inspection, and where necessary a decapsulation, and it costs a fraction of an extraction campaign.

Only after that does a route get named. Where the contents are in an external flash, the work is a read, and the relevant techniques are in extracting IC flash. Where the die carries the contents in mask ROM, the work is optical and the device does not survive. Where the part is a standard microcontroller under a blob, the work becomes a normal job, and the route depends on the protection state described in breaking IC code.

We decline one category outright: full-custom ASICs whose function is wiring and whose value is the netlist. Delivering a netlist from a metal image is possible for small arrays and uneconomic for anything else, and saying so before a decapsulation is more useful than a report that explains it afterwards. The narrower question of whether a given part is an ASIC at all is treated separately in identifying an ASIC.