Timing Attack Explained: How a Stopwatch Steals Secrets

Timing attack explained in plain terms means understanding how an attacker can steal a secret key without breaking any maths, simply by measuring how long a computer takes to answer. The central question is why time leaks anything at all when the maths itself is sound, and the answer is that real code takes different paths for different secret bits, so a careful stopwatch reads the secret one bit at a time.

A timing attack is a side-channel attack that recovers secret data from the running time of a cryptographic operation. It was introduced by Paul Kocher in his 1996 paper, Timing Attacks on Implementations of Diffie-Hellman, RSA, DSS, and Other Systems, and it showed that square-and-multiply modular exponentiation leaks the private exponent bit by bit, because a multiply runs only when the bit is one.

This article explains what a timing attack is, how it works, and where it runs in the real world.

Key takeaways

  • A timing attack steals secrets by measuring time.
  • Paul Kocher introduced it in a 1996 paper.
  • Square-and-multiply leaks exponent bits.
  • Brumley and Boneh attacked OpenSSL remotely in 2003.
  • Constant-time code and blinding are the defences.

What a timing attack is

A timing attack is a side-channel attack that turns a stopwatch into a key-recovery tool, and that indirectness is what makes it unusual among attacks. Each measurement reveals a tiny difference in running time, which means the attacker never sees the key itself, and because the differences are statistical, thousands of samples are combined until the secret emerges.

Its signature feature is the square-and-multiply leak. Most RSA implementations raise a message to a secret power one bit at a time, but the multiply step runs only when the current bit is one, which means the total time depends on the secret, and because the pattern repeats for every bit, the whole exponent can be read off.

The attack was a reaction to the belief that maths alone was enough. Cryptographers had proven their algorithms secure on paper, so Kocher asked whether real code kept that promise, because an implementation that branches on secrets is an implementation that talks, and that practicality is what made the timing attack worth publishing.

It became one of the best-known attacks in the world, and it is named in every discussion of the field. Brumley and Boneh mounted a remote timing attack against an OpenSSL server in 2003 and recovered the RSA private key over a network, OpenSSL enabled RSA blinding by default in version 0.9.7b on March 17, 2003, CacheBleed attacked OpenSSL’s constant-time RSA through cache banks in 2016, and it is still the first example engineers meet when they learn that code must be constant-time, which means the attack survives as a lesson even though it is nearly thirty years old.

Our guide to side-channel attacks explains the wider family the timing attack belongs to, and our guide to Diffie-Hellman explains one of the systems Kocher’s paper targeted.

How a timing attack works

Everything starts with the measurement, which sets the attacker’s baseline. A timing attack sends many requests to a server and records how long each takes, which means the data depends on careful timing, and because network noise is large, the attacker needs thousands of samples before any pattern shows.

Each step begins with a chosen input, which is crafted to expose one bit. A timing attack picks a message that makes the server’s work depend on a single secret bit, which means fresh information arrives at every step, and because the choice is deliberate, the measurement targets exactly one unknown.

The statistical analysis is what makes the design work as a whole. After gathering timings, the attacker compares the distributions for the bit being zero and the bit being one, which means the secret is read from averages rather than single runs, and because the difference is systematic, it survives the noise.

The bit-by-bit recovery spreads the effect further. A timing attack recovers the exponent from the most significant bit downwards, which means each recovered bit sharpens the next guess, and because the process is sequential, the whole key falls in order.

The remote version is what turns the lab trick into a real threat. Brumley and Boneh showed the attack works over a network against a real OpenSSL server, which means no physical access is needed, and because the timing travelled over the internet, the attack proved that distance is no defence.

The result comes from the completed exponent, read out as the private key. A timing attack ends with the full secret in hand, which means the result is a working key whatever the system, and that key is exactly what an attacker needs to impersonate the server.

A dim security lab with a stopwatch on the bench, a laptop showing timing graphs and a server rack glowing behind it
A dim security lab with a stopwatch on the bench, a laptop showing timing graphs and a server rack glowing behind it, shows how a timing attack works: thousands of measurements are compared, step after step, until a secret key emerges.

Comparing timing attacks with other side channels

A timing attack is one of several side-channel attacks built to steal secrets without breaking maths, and each was built with a different emphasis. A power-analysis attack is the lab method built on measuring electricity, a cache attack is the local method built on memory timing, and a timing attack is the one built to work remotely over a network, while each approach trades something for something else.

The table below sets out the main contrasts between the leading approaches.

Aspect Timing attack Power analysis Cache attack
Signal measured Running time Power draw Cache timing
Needs physical access No, works remotely Yes Usually local
First shown Kocher, 1996 Kocher, 1999 Later, 2000s
Main defence Constant-time code Masking Cache partitioning
Best for Remote key theft Smart-card theft Shared-host theft

The practical result is that a timing attack is the right choice for remote key theft, power analysis suits smart-card theft, and a cache attack fits shared-host theft instead.

Where timing attacks are used

Researchers use them to test implementations. Cryptographers measure real libraries for timing leaks, because a proven algorithm can still fail in code, and that gap is the reason the attack earns its keep in security testing.

Attackers use them against network servers. A remote timing attack needs only a connection and patience, because the server answers every query, and that openness is the reason the design was a real threat to production systems.

Auditors use them inside compliance reviews. A security audit checks that crypto code runs in constant time, because a variable-time routine is a finding, and that rule is the reason the timing attack appears in checklists far beyond its research origins.

Benchmarking uses them as the side-channel reference. Engineers still quote Kocher’s attack when they discuss how an implementation should behave, because it is the clearest example of time leaking secrets, and that number shapes how new code is measured.

Teaching uses them as the side-channel example. Courses introduce timing attacks when they explain that secure maths is not enough, because it is the clearest case of an implementation betraying its algorithm, and a student who understands timing attacks understands why constant time matters in crypto code.

Strengths and limits

The greatest strength of a timing attack is that it needs no broken maths. An attack that works against a sound algorithm is hard to dismiss, and that strength is real, measured in the keys actually recovered and confirmed by the defences it forced.

It is also a strength that the attack works remotely. A threat that needs only network access reaches every server on the internet, and that reach is worth more than cleverness in a field where an attack that needs physical access is an attack with a small audience.

The limits are real, though, and the biggest is the noise. A timing attack needs thousands of samples and careful statistics, which means a noisy network or a patched server can defeat it, and a system that needs certainty must still use constant-time code rather than hope for noise.

Timing attack checklist

  • Use constant-time code for crypto, never branching on secrets.
  • Remember Kocher introduced the attack in 1996.
  • Note square-and-multiply leaks exponent bits.
  • Compare it with power analysis to see two side channels.
  • Study blinding, which is what hides the timing signal.
  • Check the Montgomery ladder, since it runs in fixed time.
  • Keep real secrets behind constant-time implementations.
  • Read Kocher’s paper to see how the attack was built.
  • Choose blinding and constant time when servers handle keys.

Frequently asked questions

What is a timing attack in simple terms?

It is an attack that recovers a secret key by measuring how long a computer takes to do cryptography, because the time depends on the secret bits.

Who created the timing attack?

Paul Kocher, who published it in 1996 in a paper on timing attacks against Diffie-Hellman, RSA, DSS and other systems.

How is a timing attack different from breaking the maths?

Both recover keys, but a timing attack exploits the implementation’s running time, while breaking the maths would defeat the algorithm itself.

Is a timing attack still a threat?

It is a known and defended threat, but constant-time code and blinding are needed, since variable-time code still leaks.

Where are timing attacks used?

In security research, in remote attacks on servers, in audits, and in teaching about side-channel attacks.

When should I worry about timing attacks?

When you write or choose cryptographic code, when servers handle private keys, or when you study side-channel security.

The bottom line

Timing attack explained in one line is this: a stopwatch that steals secrets, a 1996 discovery that showed secure maths can fail in slow code and taught the field that how long you take is part of what you say.

It is proof that implementation is half of security, and the reason it still matters is that every crypto library written since has been judged partly by the lesson the timing attack taught.

This article is general information about how a timing attack works, not advice about choosing encryption for a particular device or system.

Latest articles

Scroll to Top