Constant-time support lands in LLVM: Protecting cryptographic code at the compiler level

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Cryptography engineers can now get compiler-level guarantees that optimisation passes will not silently reintroduce timing leaks into code they deliberately wrote to be constant-time.

Read this as

Trail of Bits has added constant-time support to LLVM 21, the compiler toolkit behind Clang. Timing attacks happen when a computer's actions take slightly longer depending on secret data, such as a cryptographic key. Programmers write code to take the same time regardless, but compilers sometimes undo that while optimising. This change lets the compiler preserve those guarantees instead of breaking them.

For any company shipping cryptographic software, this closes a real and largely invisible risk: a compiler update quietly reintroducing timing vulnerabilities into code that was carefully hardened against them. Trail of Bits' contribution to LLVM 21 makes those guarantees explicit at build time, reducing audit burden and security exposure. Competing compilers without equivalent support leave this class of bug undetected.

Trail of Bits contributed constant-time support to LLVM 21, landing in mainline. It introduces the __builtin_ct_select family of intrinsics plus supporting infrastructure that stops Clang, and other LLVM-based compilers, from transforming deliberately constant-time cryptographic code into time-varying equivalents during optimisation. The mechanism guards against branching-related timing attacks specifically. The article gives no benchmark numbers and does not address cache-timing side channels.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

LLVM LLVM 21 Clang Trail of Bits __builtin_ct_select

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading