constant-time-testing

Detect timing side channels in cryptographic code using statistical and dynamic analysis.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/marumo333/atrox --skill constant-time-testing-marumo333
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: constant-time-testing
Source: https://github.com/marumo333/atrox/tree/main/.claude/skills/trailofbits/plugins/testing-handbook-skills/skills/constant-time-testing
Command: npx skills add https://github.com/marumo333/atrox --skill constant-time-testing-marumo333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Cryptographic implementations can leak secret keys through timing variations caused by secret-dependent branches, array accesses, division, and shifts. This Skill guides you through detecting these timing side channels before attackers exploit them to extract private keys. ## Core Features & Use Cases - Violation Pattern Recognition: Identify the four common constant-time violations (conditional jumps, secret-dependent array access, variable-time division, and variable-time shifts) in C/C++ crypto code. - Tool Selection Guidance: Choose between formal verification (ct-verif, SideTrail, FaCT), symbolic execution (Binsec, pitchfork), dynamic tracing (Timecop/Valgrind), and statistical testing (dudect) based on your assurance needs. - Phased Testing Workflow: Follow a four-phase process from initial dudect statistical screening through Timecop root-cause analysis, remediation, and CI integration. - Use Case: When auditing an RSA implementation, write a dudect harness comparing fixed versus random exponents, detect a statistically significant timing difference, then use Timecop's poison/unpoison markers under Valgrind to pinpoint the exact conditional branch leaking exponent bits. ## Quick Start Audit my modular exponentiation function for timing side channels and show me how to write a dudect test harness for it.

Frequently Asked Questions about constant-time-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test cryptographic code for timing side channels?▼

Start with dudect statistical testing by writing a harness that compares execution time between fixed and random input classes using Welch's t-test. If leakage is detected, use Timecop with Valgrind to poison secret variables and pinpoint the exact line causing the timing dependency.

What are the most common constant-time violations in crypto code?▼

Four patterns cause most timing vulnerabilities: conditional branches on secret data, secret-dependent array lookups enabling cache-timing attacks, variable-time integer division, and variable-time shift operations. Conditional jumps cause the most severe timing differences.

dudect vs Timecop for constant-time analysis?▼

dudect performs statistical timing measurement on real compiled binaries but provides no root cause information. Timecop uses Valgrind dynamic tracing to pinpoint the exact line of a leak but cannot detect microarchitecture timing differences and only covers executed paths.

Can timing attacks extract keys remotely over a network?▼

Yes, Brumley and Boneh demonstrated remote extraction of RSA private keys from OpenSSL using network-observable timing differences in Montgomery multiplication. Exploitation requires oracle access through sufficient queries and a timing dependency correlated with secret data.

Why does my constant-time code still fail dudect tests?▼

Compiler optimizations at levels like -O3 can introduce branches or remove constant-time constructs, so inspect assembly output with objdump. Also test on the target CPU architecture, pin tests to an isolated core with taskset, and run measurements for at least 5-10 minutes.

What are the limitations of statistical timing analysis?▼

Statistical tools like dudect cannot guarantee absence of leaks, only provide confidence levels, and give no root cause information when leakage is found. Measurement noise can obscure weak signals, so for high assurance combine with formal verification tools like ct-verif or SideTrail.