dudect Timing Leakage Detection Tool

repository·master·Indexed 42 days ago

https://github.com/oreparaz/dudect

A lightweight C/C++ library for detecting timing leakages in code using statistical analysis (t-tests). It helps developers verify constant-time implementations, particularly in cryptography, by measuring execution time across different inputs.

Tokens
547
Snippets
2
Records
4
Agent score
3%

What's inside dudect

  1. Interpret dudect output and t-statistics

    master

    The tool uses a t-statistic to determine if code is constant time based on execution time measurements.

    • t > 5: Likely timing leakage (not constant time).
    • t > 10: Strong evidence of timing leakage.
    • t < 10: The implementation is considered "maybe constant time."

    If the code is truly constant time, the tool will continue running indefinitely as it accumulates measurements. You must manually interrupt the process (e.g., using Ctrl-C) once you are satisfied with the number of measurements.

  2. Integrate dudect into your C/C++ project

    master

    dudect is distributed as a single-file library. To use it in your own codebase, follow these steps:

    1. Copy dudect.h to your include directories.
    2. Add #include "dudect.h" to your source files.
    3. Implement the following three required functions:
      • do_one_computation(): Performs a single execution of the code you want to test.
      • prepare_inputs(): Sets up the input data for the computations.
      • Call dudect_main() from your main() function to start the testing process.

    For a complete implementation reference, see examples/simple/example.c in the repository.

    #include "dudect.h"
    
    // You must implement these:
    void do_one_computation();
    void prepare_inputs();
    
    int main() {
        // Call the dudect entry point
        dudect_main();
        return 0;
    }
  3. Reference: dudect example binaries

    master

    The repository includes several pre-built binaries used for demonstration purposes:

    • dudect_aes32: A variable-time T-tables AES implementation.
    • dudect_aesbitsliced: A constant-time bitsliced AES implementation.
    • dudect_donna: Langley's curve25519-donna (intended to be constant-time).
    • dudect_donnabad: A variant of curve25519 with an intentional timing leak.
    • dudect_cmpmemcmp: A comparison using memcmp() (demonstrates easy leakage detection).
    • dudect_cmpct: A constant-time comparison implementation.