Constant Time Analysis logo

Constant Time Analysis

Organization
RedHatProductSecurity
constant-time-analysis

Detects timing side-channel vulnerabilities in cryptographic code. Use when implementing or reviewing crypto code, encountering division on secrets, secret-dependent branches, or constant-time programming questions in C, C++, Go, Rust, Swift, Java, Kotlin, C#, PHP, JavaScript, TypeScript, Python, or Ruby.

Overview

PublisherRedHatProductSecurity
Repositoryprodsec-skills
Skill nameconstant-time-analysis
Stars
56
Forks
9
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by RedHatProductSecurity on GitHub. Read the source before you install it.

Installation

Install the Constant Time Analysis AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/constant-time-analysis
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/RedHatProductSecurity/prodsec-skills.git /tmp/prodsec-skills
mkdir -p .claude/skills
cp -r /tmp/prodsec-skills/module/skills/constant-time-analysis .claude/skills/constant-time-analysis
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Constant Time Analysis in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Constant Time Analysis on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Constant Time Analysis is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Constant-Time Analysis

Analyze cryptographic code to detect operations that leak secret data through execution timing variations.

Companion analyzer: The upstream Trail of Bits prodsec-skills constant-time-analysis plugin ships ct_analyzer/analyzer.py and per-language reference docs (see upstream Trail of Bits prodsec-skills for companion files).

When to Use

text
User 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:

  • User implements signature, encryption, or key derivation
  • Code contains / or % operators on secret-derived values
  • User mentions "constant-time", "timing attack", "side-channel", "KyberSlash"
  • Reviewing functions named sign, verify, encrypt, decrypt, derive_key

When NOT to Use

  • Non-cryptographic code (business logic, UI, etc.)
  • Public data processing where timing leaks don't matter
  • Code that doesn't handle secrets, keys, or authentication tokens
  • High-level API usage where timing is handled by the library

Language Selection

Based on the file extension or language context, use the matching upstream reference under plugins/constant-time-analysis/skills/constant-time-analysis/references/:

LanguageFile ExtensionsGuide (upstream filename)
C, C++.c, .h, .cpp, .cc, .hppcompiled.md
Go.gocompiled.md
Rust.rscompiled.md
Swift.swiftswift.md
Java.javavm-compiled.md
Kotlin.kt, .ktskotlin.md
C#.csvm-compiled.md
PHP.phpphp.md
JavaScript.js, .mjs, .cjsjavascript.md
TypeScript.ts, .tsxjavascript.md
Python.pypython.md
Ruby.rbruby.md

Quick Start (paths relative to upstream constant-time-analysis plugin)

bash
uv run ct_analyzer/analyzer.py <source_file>
uv run ct_analyzer/analyzer.py --warnings <source_file>
uv run ct_analyzer/analyzer.py --func 'sign|verify' <source_file>
uv run ct_analyzer/analyzer.py --json <source_file>

Native compiled languages (C, C++, Go, Rust, Swift)

bash
uv run ct_analyzer/analyzer.py --arch x86_64 crypto.c
uv run ct_analyzer/analyzer.py --arch arm64 crypto.c
uv run ct_analyzer/analyzer.py --opt-level O0 crypto.c
uv run ct_analyzer/analyzer.py --opt-level O3 crypto.c

VM-compiled (Java, Kotlin, C#)

Bytecode/IL analysis; --arch / --opt-level do not apply.

Prerequisites (summary)

LanguageRequirements
C, C++, Go, RustCompiler in PATH (gcc/clang, go, rustc)
SwiftXcode or Swift toolchain (swiftc in PATH)
JavaJDK with javac and javap in PATH
KotlinKotlin compiler + JDK (javap) in PATH
C#.NET SDK + ilspycmd
PHPPHP with VLD extension or OPcache
JavaScript/TypeScriptNode.js in PATH
PythonPython 3.x in PATH
RubyRuby with --dump=insns support

macOS: Homebrew Java / .NET may be keg-only — add to PATH (see upstream vm-compiled.md).

Quick Reference

ProblemDetectionFix
Division on secretsDIV, IDIV, SDIV, UDIVBarrett reduction or multiply-by-inverse
Branch on secretsJE, JNE, BEQ, BNEConstant-time selection (cmov, bit masking)
Secret comparisonEarly-exit memcmpUse crypto/subtle or constant-time compare
Weak RNGrand(), mt_rand, Math.randomUse crypto-secure RNG
Table lookup by secretArray subscript on secret indexBit-sliced lookups

Interpreting Results

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

Verifying Results (Avoiding False Positives)

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?

  1. Identify the secret inputs to the function (private keys, plaintext, signatures, tokens)

  2. Trace data flow from the flagged instruction back to inputs

  3. Common false positive patterns:

    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
  4. Document your analysis for each flagged item

Quick Triage Questions

QuestionIf YesIf No
Is the operand a compile-time constant?Likely false positiveContinue
Is the operand a public parameter (length, count)?Likely false positiveContinue
Is the operand derived from key/plaintext/secret?TRUE POSITIVELikely false positive
Can an attacker influence the operand value?TRUE POSITIVELikely false positive

Limitations

  1. Static analysis only — not runtime; misses cache / microarchitectural channels.
  2. No data flow analysis — manual review required.
  3. Compiler/runtime variations — output may differ by toolchain.

Real-World Impact

  • KyberSlash (2023): Division in post-quantum ML-KEM implementations
  • Lucky Thirteen (2013): CBC padding validation timing
  • RSA timing attacks: Division timing leaked key bits

References

Frequently asked questions

What does the Constant Time Analysis AI skill do?

Detects timing side-channel vulnerabilities in cryptographic code. Use when implementing or reviewing crypto code, encountering division on secrets, secret-dependent branches, or constant-time programming questions in C, C++, Go, Rust, Swift, Java, Kotlin, C#, PHP, JavaScript, TypeScript, Python, or Ruby.

Why use Constant Time Analysis on TypingMind?

Because you install it once and use it with any model. Constant Time Analysis is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Constant Time Analysis in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/constant-time-analysis. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Constant Time Analysis?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Constant Time Analysis?

As many as you like. As long as a model supports skills, you can use Constant Time Analysis with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Constant Time Analysis AI skill free?

Yes. It is published on GitHub by RedHatProductSecurity under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇