Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Analyze cryptographic code to detect operations that leak secret data through execution timing variations.
.claude/skills/constant-time-analysis/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | — | — |
| case-20 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✗→✓ | ▲ Improved | — | — |
| case-08 | ✗→✓ | ▲ Improved | — | — |
| case-12 | ✗→✓ | ▲ Improved | — | — |
Analyze cryptographic code to detect operations that leak secret data through execution timing variations.
textUser writing crypto code? ──yes──> Use this skill │ no │ v User asking about timing attacks? ──yes──> Use this skill │ no │ v Code handles secret keys/tokens? ──yes──> Use this skill │ no │ v Skip this skill
Concrete triggers:
/ or % operators on secret-derived valuessign, verify, encrypt, decrypt, derive_keyBased on the file extension or language context, refer to the appropriate guide:
| Language | File Extensions | Guide | | ---------- | --------------------------------- | -------------------------------------------------------- | | C, C++ | .c, .h, .cpp, .cc, .hpp | references/compiled.md | | Go | .go | references/compiled.md | | Rust | .rs | references/compiled.md | | Swift | .swift | references/swift.md | | Java | .java | references/vm-compiled.md | | Kotlin | .kt, .kts | references/kotlin.md | | C# | .cs | references/vm-compiled.md | | PHP | .php | references/php.md | | JavaScript | .js, .mjs, .cjs | references/javascript.md | | TypeScript | .ts, .tsx | references/javascript.md | | Python | .py | references/python.md | | Ruby | .rb | references/ruby.md |
bash# Analyze any supported file type uv run {baseDir}/ct_analyzer/analyzer.py <source_file> # Include conditional branch warnings uv run {baseDir}/ct_analyzer/analyzer.py --warnings <source_file> # Filter to specific functions uv run {baseDir}/ct_analyzer/analyzer.py --func 'sign|verify' <source_file> # JSON output for CI uv run {baseDir}/ct_analyzer/analyzer.py --json <source_file>
bash# Cross-architecture testing (RECOMMENDED) uv run {baseDir}/ct_analyzer/analyzer.py --arch x86_64 crypto.c uv run {baseDir}/ct_analyzer/analyzer.py --arch arm64 crypto.c # Multiple optimization levels uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O0 crypto.c uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O3 crypto.c
bash# Analyze Java bytecode uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.java # Analyze Kotlin bytecode (Android/JVM) uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.kt # Analyze C# IL uv run {baseDir}/ct_analyzer/analyzer.py CryptoUtils.cs
Note: Java, Kotlin, and C# compile to bytecode (JVM/CIL) that runs on a virtual machine with JIT compilation. The analyzer examines the bytecode directly, not the JIT-compiled native code. The --arch and --opt-level flags do not apply to these languages.
bash# Analyze Swift for native architecture uv run {baseDir}/ct_analyzer/analyzer.py crypto.swift # Analyze for specific architecture (iOS devices) uv run {baseDir}/ct_analyzer/analyzer.py --arch arm64 crypto.swift # Analyze with different optimization levels uv run {baseDir}/ct_analyzer/analyzer.py --opt-level O0 crypto.swift
Note: Swift compiles to native code like C/C++/Go/Rust, so it uses assembly-level analysis and supports --arch and --opt-level flags.
| Language | Requirements | | ---------------------- | --------------------------------------------------------- | | C, C++, Go, Rust | Compiler in PATH (gcc/clang, go, rustc) | | Swift | Xcode or Swift toolchain (swiftc in PATH) | | Java | JDK with javac and javap in PATH | | Kotlin | Kotlin compiler (kotlinc) + JDK (javap) in PATH | | C# | .NET SDK + ilspycmd (dotnet tool install -g ilspycmd) | | PHP | PHP with VLD extension or OPcache | | JavaScript/TypeScript | Node.js in PATH | | Python | Python 3.x in PATH | | Ruby | Ruby with --dump=insns support |
macOS users: Homebrew installs Java and .NET as "keg-only". You must add them to your PATH:
bash# For Java (add to ~/.zshrc) export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH" # For .NET tools (add to ~/.zshrc) export PATH="$HOME/.dotnet/tools:$PATH"
See references/vm-compiled.md for detailed setup instructions and troubleshooting.
| Problem | Detection | Fix | | ---------------------- | ------------------------------- | -------------------------------------------- | | Division on secrets | DIV, IDIV, SDIV, UDIV | Barrett reduction or multiply-by-inverse | | Branch on secrets | JE, JNE, BEQ, BNE | Constant-time selection (cmov, bit masking) | | Secret comparison | Early-exit memcmp | Use crypto/subtle or constant-time compare | | Weak RNG | rand(), mt_rand, Math.random | Use crypto-secure RNG | | Table lookup by secret | Array subscript on secret index | Bit-sliced lookups |
PASSED - No variable-time operations detected.
FAILED - Dangerous instructions found. Example:
text[ERROR] SDIV Function: decompose_vulnerable Reason: SDIV has early termination optimization; execution time depends on operand values
CRITICAL: Not every flagged operation is a vulnerability. The tool has no data flow analysis - it flags ALL potentially dangerous operations regardless of whether they involve secrets.
For each flagged violation, ask: Does this operation's input depend on secret data?
c // FALSE POSITIVE: Division uses public constant, not secret int num_blocks = data_len / 16; // data_len is length, not content
// TRUE POSITIVE: Division involves secret-derived value int32_t q = secret_coef / GAMMA2; // secret_coef from private key
| Question | If Yes | If No | | ------------------------------------------------- | --------------------- | --------------------- | | Is the operand a compile-time constant? | Likely false positive | Continue | | Is the operand a public parameter (length, count)?| Likely false positive | Continue | | Is the operand derived from key/plaintext/secret? | TRUE POSITIVE | Likely false positive | | Can an attacker influence the operand value? | TRUE POSITIVE | Likely false positive |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-23 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-05 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +30 percentage points is the difference between those two pass rates over the 23 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.