Skip to content

Commit e25f221

Browse files
Add valgrind constant-time test to make check
1 parent e9fccd4 commit e25f221

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ libtool
3131
*.lo
3232
*.o
3333
*~
34+
*.log
35+
*.trs
3436
src/libsecp256k1-config.h
3537
src/libsecp256k1-config.h.in
3638
src/ecmult_static_context.h

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ script:
9595
travis_wait 30 valgrind --error-exitcode=42 ./exhaustive_tests;
9696
fi
9797
- if [ -n "$CTIMETEST" ]; then
98-
libtool --mode=execute valgrind ./valgrind_ctime_test &> valgrind_ctime_test.log;
98+
./valgrind_ctime_test.sh &> valgrind_ctime_test.log;
9999
fi
100100

101101
after_script:

Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ tests_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/src -I$(top_srcdir)/include $
9696
if VALGRIND_ENABLED
9797
tests_CPPFLAGS += -DVALGRIND
9898
noinst_PROGRAMS += valgrind_ctime_test
99+
TESTS += valgrind_ctime_test.sh
99100
valgrind_ctime_test_SOURCES = src/valgrind_ctime_test.c
100101
valgrind_ctime_test_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
101102
endif
@@ -141,7 +142,7 @@ src/ecmult_static_context.h: $(gen_context_BIN)
141142
CLEANFILES = $(gen_context_BIN) src/ecmult_static_context.h
142143
endif
143144

144-
EXTRA_DIST = autogen.sh src/gen_context.c src/basic-config.h
145+
EXTRA_DIST = autogen.sh valgrind_ctime_test.sh src/gen_context.c src/basic-config.h
145146

146147
if ENABLE_MODULE_ECDH
147148
include src/modules/ecdh/Makefile.am.include

src/valgrind_ctime_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int main(void) {
2828
if (!RUNNING_ON_VALGRIND) {
2929
fprintf(stderr, "This test can only usefully be run inside valgrind.\n");
3030
fprintf(stderr, "Usage: libtool --mode=execute valgrind ./valgrind_ctime_test\n");
31-
exit(1);
31+
exit(99); /* indicates "ERROR" in make check */
3232
}
3333

3434
/** In theory, testing with a single secret input should be sufficient:

valgrind_ctime_test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
3+
libtool --mode=execute valgrind --error-exitcode=1 ./valgrind_ctime_test "$@"
4+
5+
case $? in
6+
127) # "command not found", i.e., either libtool or valgrind not installed
7+
exit 77 # map this to "SKIP" (=77) for make check
8+
;;
9+
*)
10+
exit $?
11+
;;
12+
esac

0 commit comments

Comments
 (0)