7 releases (4 breaking)
Uses new Rust 2021
0.5.0  Aug 26, 2022 

0.4.1  Sep 8, 2019 
0.4.0  Apr 14, 2019 
0.3.1 

0.1.0  Jul 7, 2017 
#455 in Cryptography
67 downloads per month
30KB
476 lines
dudectbencher
This crate implements the DudeCT statistical methods for
testing constanttime functions. It is based loosely off of the
bencher
crate.
Usage
Example use is as follows. Since this requires the current crate as a dependency, it is easiest to
put the benchmarks in examples/
. Take a look at examples/ctbenchfoo.rs
for sample source code.
To run all the benchmarks in examples/ctbenchfoo.rs
, you can simply run cargo run release example ctbenchfoo
.
To run a subset of the benchmarks in the above file that have a the substring ar
in it, run
cargo run release example ctbenchfoo  filter ar
.
To run the vec_eq
benchmark continuously, collecting more samples as it goes along, run cargo run release example ctbenchfoo  continuous vec_eq
.
To run the benchmarks in ctbenchfoo
and get the raw runtimes in CSV format, run cargo run release example ctbenchfoo  out data.csv
.
Interpreting Output
The benchmark output looks like
bench array_eq ... : n == +0.046M, max t = +61.61472, max tau = +0.28863, (5/tau)^2 = 300
It is interpreted as follows. Firstly note that the runtime distributions are cropped at different
percentiles and about 100 ttests are performed. Of these ttests, the one that produces the largest
absolute tvalue is printed as max_t
. The other values printed are
n
, indicating the number of samples used in computing this tvaluemax_tau
, which is the tvalue scaled for the samples size (formally,max_tau = max_t / sqrt(n)
)(5/tau)^2
, which indicates the number of measurements that would be needed to distinguish the two distributions with t > 5
tvalues greater than 5 are generally considered a good indication that the function is not constant time. tvalues less than 5 does not necessarily imply that the function is constanttime, since there may be other input distributions under which the function behaves significantly differently.
License
Licensed under either of
 Apache License, Version 2.0, (LICENSEAPACHE)
 MIT license (LICENSEMIT)
at your option.
Dependencies
~1.3–1.8MB
~30K SLoC