Formal verification of a constant-time preserving C compiler
Gilles Barthe, Sandrine Blazy, Benjamin Grégoire, Rémi Hutin, Vincent Laporte, David Pichardie, Alix Trieu
Abstract
Timing side-channels are arguably one of the main sources of vulnerabilities in cryptographic implementations. One effective mitigation against timing side-channels is to write programs that do not perform secret-dependent branches and memory accesses. This mitigation, known as łcryptographic constant-timež, is adopted by several popular cryptographic libraries.
This paper focuses on compilation of cryptographic constant-time programs, and more specifically on the following question: is the code generated by a realistic compiler for a constant-time source program itself provably constant-time? Surprisingly, we answer the question positively for a mildly modified version of the CompCert compiler, a formally verified and moderately optimizing compiler for C. Concretely, we modify the CompCert compiler to eliminate sources of potential leakage. Then, we instrument the operational semantics of CompCert intermediate languages so as to be able to capture cryptographic constant-time. Finally, we prove that the modified CompCert compiler preserves constant-time. Our mechanization maximizes reuse of the CompCert correctness proof, through the use of new proof techniques for proving preservation of constant-time. These techniques achieve complementary trade-offs between generality and tractability of proof effort, and are of independent interest.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
33 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- DICE: A Formally Verified Implementation of DICE Measured Boot cites HACL: A Verified Modern Cryptographic Library
- SoK: Computer-Aided Cryptography cites Verified Correctness and Security of mbedTLS HMAC-DRBG
- SoK: Computer-Aided Cryptography cites The Last Mile: High-Assurance and High-Speed Cryptographic Implementations
- SoK: Computer-Aided Cryptography cites Verifying Constant-Time Implementations
- SoK: Computer-Aided Cryptography cites HACL: A Verified Modern Cryptographic Library
- SoK: Computer-Aided Cryptography cites Jasmin: High-Assurance and High-Speed Cryptography
- Hardware-Software Contracts for Secure Speculation cites Verifying Constant-Time Implementations
- The Last Mile: High-Assurance and High-Speed Cryptographic Implementations cites Verified Correctness and Security of mbedTLS HMAC-DRBG
- The Last Mile: High-Assurance and High-Speed Cryptographic Implementations cites Verifying Constant-Time Implementations
- The Last Mile: High-Assurance and High-Speed Cryptographic Implementations cites HACL: A Verified Modern Cryptographic Library
- The Last Mile: High-Assurance and High-Speed Cryptographic Implementations cites Jasmin: High-Assurance and High-Speed Cryptography
- High-Assurance Cryptography in the Spectre Era cites SoK: Computer-Aided Cryptography
- High-Assurance Cryptography in the Spectre Era cites Hardware-Software Contracts for Secure Speculation
- High-Assurance Cryptography in the Spectre Era cites The Last Mile: High-Assurance and High-Speed Cryptographic Implementations
- High-Assurance Cryptography in the Spectre Era cites Verifying Constant-Time Implementations
- High-Assurance Cryptography in the Spectre Era cites HACL: A Verified Modern Cryptographic Library
- High-Assurance Cryptography in the Spectre Era cites Jasmin: High-Assurance and High-Speed Cryptography
- Automatically eliminating speculative leaks from cryptographic code with blade cites Verifying Constant-Time Implementations
- Automatically eliminating speculative leaks from cryptographic code with blade cites HACL: A Verified Modern Cryptographic Library
- Automatically eliminating speculative leaks from cryptographic code with blade cites Jasmin: High-Assurance and High-Speed Cryptography
- HACL: A Verified Modern Cryptographic Library cites Verifying Constant-Time Implementations
- Jasmin: High-Assurance and High-Speed Cryptography cites Verified Correctness and Security of mbedTLS HMAC-DRBG
- Jasmin: High-Assurance and High-Speed Cryptography cites Verifying Constant-Time Implementations
- Jasmin: High-Assurance and High-Speed Cryptography cites HACL: A Verified Modern Cryptographic Library
Cited by top-tier papers33
- SoK: Computer-Aided CryptographyManuel Barbosa, Gilles Barthe, Karthik Bhargavan, Bruno Blanchet et al.S&P 2021 · 169 citations
- Hardware-Software Contracts for Secure SpeculationMarco Guarnieri, Boris Köpf, Jan Reineke, Pepe VilaS&P 2021 · 111 citations
- Automatically eliminating speculative leaks from cryptographic code with bladeMarco Vassena, Craig Disselkoen, Klaus von Gleissenthall, Sunjay Cauligi et al.POPL 2021 · 53 citations
- High-Assurance Cryptography in the Spectre EraGilles Barthe, Sunjay Cauligi, Benjamin Grégoire, Adrien Koutsos et al.S&P 2021 · 42 citations
- DICE*: A Formally Verified Implementation of DICE Measured BootZhe Tao, Aseem Rastogi, Naman Gupta, Kapil Vaswani et al.USENIX Security 2021 · 25 citations
Builds on9
- Verifying Constant-Time ImplementationsJosé Bacelar Almeida, Manuel Barbosa, Gilles Barthe, François Dupressoir et al.USENIX Security 2016 · 274 citations
- HACL*: A Verified Modern Cryptographic LibraryJean Karim Zinzindohoué, Karthikeyan Bhargavan, Jonathan Protzenko, Benjamin BeurdoucheCCS 2017 · 258 citations
- Jasmin: High-Assurance and High-Speed CryptographyJosé Bacelar Almeida, Manuel Barbosa, Gilles Barthe, Arthur Blot et al.CCS 2017 · 157 citations
- The Last Mile: High-Assurance and High-Speed Cryptographic ImplementationsJosé Bacelar Almeida, Manuel Barbosa, Gilles Barthe, Benjamin Grégoire et al.S&P 2020 · 67 citations
- Verified Correctness and Security of mbedTLS HMAC-DRBGKatherine Q. Ye, Matthew Green, Naphat Sanguansin, Lennart Beringer et al.CCS 2017 · 59 citations
Related papers
- Preservation of Speculative Constant-Time by CompilationSantiago Arranz-Olmos, Gilles Barthe, Lionel Blatter, Benjamin Grégoire et al.POPL 2025 · 8 citations
- "They're not that hard to mitigate": What Cryptographic Library Developers Think About Timing AttacksJan Jancar, Marcel Fourné, Daniel De Almeida Braga, Mohamed Sabt et al.S&P 2022 · 61 citations
- Decompiling for Constant-Time AnalysisSantiago Arranz-Olmos, Gilles Barthe, Lionel Blatter, Youcef Bouzid et al.OOPSLA 2026 · 1 citation
- Enforcing Fine-grained Constant-time PoliciesBasavesh Ammanaghatta Shivakumar, Gilles Barthe, Benjamin Grégoire, Vincent Laporte et al.CCS 2022 · 11 citations
- Towards Efficient Verification of Constant-Time Cryptographic ImplementationsLuwei Cai, Fu Song, Taolue ChenFSE 2024 · 4 citations
