Valgrind does bit-level tracking of the “uninitialized” status of memory, property tracks memory which is tainted by any uninitialized memory, and warns if any branch or array access depends on an uninitialized bit.
That is exactly the verification we need on secret data to test for constant-time behaviour. All we need to do is tell valgrind our secret key is actually uninitialized memory.
This adds a valgrind_ctime_test which is compiled if valgrind is installed:
Run it with libtool –mode=execute: $ libtool –mode=execute valgrind ./valgrind_ctime_test