constant-time-testing

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

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill constant-time-testing-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: constant-time-testing
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/constant-time-testing
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill constant-time-testing-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Cryptographic implementations can leak secret keys through timing variations in execution, even when the underlying algorithms are mathematically secure. This Skill helps you detect these timing side channels before attackers exploit them to extract private keys, passwords, or other sensitive material. ## Core Features & Use Cases - Violation Pattern Recognition: Identify the four common constant-time violations—secret-dependent branches, array accesses, division, and shifts—in C/C++ crypto code. - Tool Selection Guidance: Choose between formal verification (ct-verif, SideTrail), symbolic execution (Binsec), dynamic tracing (Timecop/Valgrind), and statistical testing (dudect) based on your assurance needs. - Phased Testing Workflow: Follow a four-phase process from initial statistical screening through root-cause analysis, remediation, and CI integration. - Use Case: You are reviewing a pull request that modifies RSA modular exponentiation code. Use this Skill to write a dudect harness that compares timing between fixed and random exponents, then use Timecop to pinpoint the exact conditional branch leaking exponent bits. ## Quick Start Audit my cryptographic function for timing side channels by writing a dudect test harness and explaining any leakage it detects.

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, which measures execution time for fixed versus random input classes and applies Welch's t-test to detect statistically significant differences. If leakage appears, use Timecop with Valgrind to pinpoint the exact line where secret data influences branching or memory access.

What is the difference between dudect and Timecop for constant-time analysis?

dudect performs statistical testing on real compiled binaries, detecting timing differences without identifying root causes. Timecop wraps Valgrind to trace poisoned secret memory at runtime, pinpointing exact leak locations but only covering executed paths and missing microarchitectural effects.

What code patterns cause timing vulnerabilities in cryptography?

Four patterns cause most leaks: conditional branches on secrets, secret-dependent array indexing enabling cache-timing attacks, integer division with secret operands, and variable-time shift operations. Modular exponentiation with square-and-multiply is a classic vulnerable construction.

Can timing attacks work over a network against remote servers?

Yes. Brumley and Boneh demonstrated remote extraction of RSA private keys from OpenSSL by measuring network-observable timing differences in Montgomery multiplication. Sufficient query access to a timing oracle plus secret-dependent execution time enables practical remote attacks.

Why does dudect not detect a leak in short test runs?

Short runs under one minute collect insufficient measurements for weak timing signals to reach statistical significance. Run dudect for five to ten minutes minimum, pin it to an isolated CPU core with taskset, and test at production optimization levels like -O3.

When should I use formal verification instead of statistical timing tests?

Use formal tools like ct-verif, SideTrail, or FaCT when you need mathematical proof of leak absence for high-assurance code. Statistical tools like dudect only provide confidence levels and cannot guarantee absence of leaks, while formal methods require more expertise and modeling effort.