Modules / M3

FieldEmbedded systemsDelivered, surveyed

Timing side channel

The topic

A timing side channel leaks the secret through execution time. This password check returns at the first mismatch, so a wrong first character finishes in fewer cycles than a wrong later character.

Where it belongs

Course: Embedded systems. At KU this was the third module in EECS 388.
Teach this after: the timer, cycle counting, and the serial port.

Files and how to use them

Use the two slide decks as the class lectures. Then assign the homework. Students time the check with the logic analyzer in Keil.

  • Lecture, part 1. Use in class after the timer lecture. Five emissions an attacker can measure, the data dependence of CMOS switching energy, and Kocher’s timing attack reduced to a string comparison.
  • Lecture, part 2. Use in class before the homework. How the lab instruments the comparison, and the demonstration cycle counts below.
  • Homework handout. The graded assignment. Spring 2024 scored it at two points. It uses its own password and its own guesses.
  • sca_sp24.c. The starter students build. It contains the early-exit check they measure, then replace.

Video lectures

These are links, not files stored with the module. Play one in class, or send the link to students.

Further reading

Optional papers for the instructor, or for a student who wants to read past the assignment.

  • Kocher, “Timing Attacks on Implementations of Diffie–Hellman, RSA, DSS, and Other Systems,” Advances in Cryptology (CRYPTO), pp. 104–113, 1996. The lecture reduces this attack to the string comparison in the lab.
  • Kocher, Jaffe, and Jun, “Differential Power Analysis,” Advances in Cryptology (CRYPTO), pp. 388–397, 1999. The power channel. This module measures time.

The exercise

The program grants access when a typed password matches a stored one. The comparison returns at the first mismatch, so the cycle count grows with the length of the correct prefix.

The lecture names five emissions an attacker can measure. One of them is the time this comparison takes. It reduces Kocher’s timing attack on modular exponentiation to that string comparison. The lab measures the comparison with the timer and the logic analyzer.

Outcome

The student turns in a timing table for the vulnerable check and a second table for a comparison that always walks the whole password, and discusses whether the leak is gone. This is the only module in which the defense is measured on the same instrument as the attack.

How the time is taken

  1. Configure the UART. The starter targets 9600 baud on a 12 MHz crystal, Timer 1 in mode 2.
  2. Set the timer run bit before the password check and clear it after. Read the interval between those edges on the logic analyzer in the debugger. The handout asks for five guesses, terminated with a period.
  3. Rewrite the comparison so every character is examined regardless of the first mismatch. Repeat the five guesses on the same instrument.

A lecture demonstration, not the graded passwords

The lecture deck reports eight guesses against a demonstration password. Cycle counts rise as the matching prefix gets longer. The graded assignment uses a different password and a different list of guesses. The figure below is the lecture measurement.

GuessMachine cycles
Howareyou122
Baaaa143
Aaaaa152
Hello152
Iello181
Iaaaa188
Iykpp240
Iykyk291

Support

This work was supported in part by the U.S. National Science Foundation (NSF) Secure and Trustworthy Cyberspace (SaTC) program under Award No. 2114157.

Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of the U.S. National Science Foundation.

The project is a collaboration of the University of Kansas, the University of Florida, and Florida International University.