Programming/Web Development News

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

Simon Willison…
2025-11-26 4 min read

<p><strong><a href="https://blog.trailofbits.com/2025/11/25/constant-time-support-lands-in-llvm-protecting-cryptographic-code-at-the-compiler-level/">Constant-time support lands in LLVM: Protecting cr...

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

Substantial LLVM contribution from Trail of Bits. Timing attacks against cryptography algorithms are a gnarly problem: if an attacker can precisely time a cryptographic algorithm they can often derive details of the key based on how long it takes to execute.

Cryptography implementers know this and deliberately use constant-time comparisons to avoid these attacks... but sometimes an optimizing compiler will undermine these measures and reintroduce timing vulnerabilities.

Trail of Bits has developed constant-time coding support for LLVM 21, providing developers with compiler-level guarantees that their cryptographic implementations remain secure against branching-related timing attacks. This work introduces the __builtin_ct_select family of intrinsics and supporting infrastructure that prevents the Clang compiler, and potentially other compilers built with LLVM, from inadvertently breaking carefully crafted constant-time code.

Via Lobste.rs

Tags: c, cryptography, llvm

Source: Simon Willison's Weblog Word count: 1408 words
Published on 2025-11-26 02:32