diff --git a/.gitignore b/.gitignore index a826ffce50..c98ec5d108 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,14 @@ +.cache/ .vscode/ _attic/ *.o *.d *.exe *~ -test_openssl -test_speed -test_check -aes/aestst +tests/aestst +tests/test_openssl +tests/test_speed +tests/test_check +tests/libtrezor-crypto.so *.os -*.so *.pyc diff --git a/.travis.yml b/.travis.yml index 8f2c902d32..f3e10e1ddc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,12 +21,11 @@ install: script: - make - - ./aes/aestst - - ./test_check - - CK_TIMEOUT_MULTIPLIER=20 valgrind -q --error-exitcode=1 ./test_check - - ./test_openssl 1000 - - ITERS=10 py.test - - mkdir _build && cd _build && cmake .. && make && cd .. + - ./tests/aestst + - ./tests/test_check + - CK_TIMEOUT_MULTIPLIER=20 valgrind -q --error-exitcode=1 ./tests/test_check + - ./tests/test_openssl 1000 + - cd ./tests ; ITERS=10 pytest ; cd .. notifications: webhooks: diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 81e51f9061..0000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -set(SOURCES - bignum.c ecdsa.c curves.c secp256k1.c nist256p1.c rand.c hmac.c bip32.c bip39.c pbkdf2.c base58.c base32.c - address.c - script.c - ripemd160.c - sha2.c - sha3.c - hasher.c - aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c - ed25519-donna/curve25519-donna-32bit.c ed25519-donna/curve25519-donna-helpers.c ed25519-donna/modm-donna-32bit.c - ed25519-donna/ed25519-donna-basepoint-table.c ed25519-donna/ed25519-donna-32bit-tables.c ed25519-donna/ed25519-donna-impl-base.c - ed25519-donna/ed25519.c ed25519-donna/curve25519-donna-scalarmult-base.c ed25519-donna/ed25519-sha3.c ed25519-donna/ed25519-keccak.c - blake256.c - blake2b.c blake2s.c - chacha20poly1305/chacha20poly1305.c chacha20poly1305/chacha_merged.c chacha20poly1305/poly1305-donna.c chacha20poly1305/rfc7539.c - rc4.c - nem.c -) - -add_library(TrezorCrypto STATIC ${SOURCES}) - -target_include_directories(TrezorCrypto PUBLIC .) -target_include_directories(TrezorCrypto PUBLIC aes) -target_include_directories(TrezorCrypto PUBLIC chacha20poly1305) -target_include_directories(TrezorCrypto PUBLIC ed25519-donna) - -target_compile_options(TrezorCrypto PRIVATE "-std=c99") - -if(MSVC) - set_source_files_properties(${SOURCES} PROPERTIES LANGUAGE CXX) -endif(MSVC) - -# Build trezor-crypto tests (requires OpenSSL) -if (TREZOR_CRYPTO_TESTS) - add_executable(test_check test_check.c) - target_link_libraries(test_check TrezorCrypto check rt pthread m crypto) - add_test(NAME trezor-crypto COMMAND test_check) - - add_executable(test_openssl test_openssl.c) - target_link_libraries(test_openssl TrezorCrypto check rt pthread m crypto) - add_test(NAME trezor-crypto-openssl COMMAND test_openssl 100) -endif() diff --git a/Makefile b/Makefile index 88d3146ce5..ccbc3c7c7b 100644 --- a/Makefile +++ b/Makefile @@ -58,27 +58,29 @@ OBJS = $(SRCS:.c=.o) TESTLIBS = $(shell pkg-config --libs check) -lpthread -lm TESTSSLLIBS = $(shell pkg-config --libs openssl) -all: test_check test_openssl test_speed aes/aestst tools libtrezor-crypto.so +all: tools tests %.o: %.c %.h options.h $(CC) $(CFLAGS) -o $@ -c $< -test_check.o: test_check_segwit.h test_check_cashaddr.h +tests: tests/test_check tests/test_openssl tests/test_speed tests/libtrezor-crypto.so tests/aestst -aes/aestst: aes/aestst.o aes/aescrypt.o aes/aeskey.o aes/aestab.o +tests/aestst: aes/aestst.o aes/aescrypt.o aes/aeskey.o aes/aestab.o $(CC) $^ -o $@ -test_check: test_check.o $(OBJS) - $(CC) test_check.o $(OBJS) $(TESTLIBS) -o test_check +tests/test_check.o: tests/test_check_segwit.h tests/test_check_cashaddr.h -test_speed: test_speed.o $(OBJS) - $(CC) test_speed.o $(OBJS) -o test_speed +tests/test_check: tests/test_check.o $(OBJS) + $(CC) tests/test_check.o $(OBJS) $(TESTLIBS) -o tests/test_check -test_openssl: test_openssl.o $(OBJS) - $(CC) test_openssl.o $(OBJS) $(TESTSSLLIBS) -o test_openssl +tests/test_speed: tests/test_speed.o $(OBJS) + $(CC) tests/test_speed.o $(OBJS) -o tests/test_speed -libtrezor-crypto.so: $(SRCS) - $(CC) $(CFLAGS) -fPIC -shared $(SRCS) -o libtrezor-crypto.so +tests/test_openssl: tests/test_openssl.o $(OBJS) + $(CC) tests/test_openssl.o $(OBJS) $(TESTSSLLIBS) -o tests/test_openssl + +tests/libtrezor-crypto.so: $(SRCS) + $(CC) $(CFLAGS) -fPIC -shared $(SRCS) -o tests/libtrezor-crypto.so tools: tools/xpubaddrgen tools/mktable tools/bip39bruteforce @@ -93,5 +95,5 @@ tools/bip39bruteforce: tools/bip39bruteforce.o $(OBJS) clean: rm -f *.o aes/*.o chacha20poly1305/*.o ed25519-donna/*.o - rm -f test_check test_speed test_openssl libtrezor-crypto.so + rm -f tests/test_check tests/test_speed tests/test_openssl tests/libtrezor-crypto.so tests/aestst rm -f tools/*.o tools/xpubaddrgen tools/mktable tools/bip39bruteforce diff --git a/test_check.c b/tests/test_check.c similarity index 100% rename from test_check.c rename to tests/test_check.c diff --git a/test_check_cashaddr.h b/tests/test_check_cashaddr.h similarity index 100% rename from test_check_cashaddr.h rename to tests/test_check_cashaddr.h diff --git a/test_check_segwit.h b/tests/test_check_segwit.h similarity index 100% rename from test_check_segwit.h rename to tests/test_check_segwit.h diff --git a/test_curves.py b/tests/test_curves.py similarity index 100% rename from test_curves.py rename to tests/test_curves.py diff --git a/test_openssl.c b/tests/test_openssl.c similarity index 100% rename from test_openssl.c rename to tests/test_openssl.c diff --git a/test_speed.c b/tests/test_speed.c similarity index 100% rename from test_speed.c rename to tests/test_speed.c