diff --git a/build.sh b/.ci/build.sh similarity index 96% rename from build.sh rename to .ci/build.sh index 62d09c5..fa35694 100755 --- a/build.sh +++ b/.ci/build.sh @@ -45,7 +45,7 @@ fi if [ -a testok.txt ] && [ -f testok.txt ]; then if [ "$LTC_COVERAGE" != "" ]; then - ./coverage_more.sh > test_coverage_more.txt || exit 1 + bash .ci/coverage_more.sh > test_coverage_more.txt || exit 1 lcov_opts="--capture --no-external --directory src -q" lcov_out=$(echo coverage_$1_$2_$3 | tr ' -=+' '_')".info" lcov $lcov_opts --output-file $lcov_out diff --git a/check_source.sh b/.ci/check_source.sh similarity index 91% rename from check_source.sh rename to .ci/check_source.sh index 731377b..1e04546 100755 --- a/check_source.sh +++ b/.ci/check_source.sh @@ -1,7 +1,7 @@ #!/bin/bash # output version -bash printinfo.sh +bash .ci/printinfo.sh make clean > /dev/null diff --git a/coverage.sh b/.ci/coverage.sh similarity index 77% rename from coverage.sh rename to .ci/coverage.sh index edf145c..1fd4296 100755 --- a/coverage.sh +++ b/.ci/coverage.sh @@ -23,9 +23,9 @@ if [ "$(echo $3 | grep -v 'makefile[.]')" == "" ]; then fi # output version -bash printinfo.sh +bash .ci/printinfo.sh -bash build.sh " $1" " $2" " $3 COVERAGE=1" "$4" "$5" +bash .ci/build.sh " $1" " $2" " $3 COVERAGE=1" "$4" "$5" if [ -a testok.txt ] && [ -f testok.txt ]; then echo else @@ -34,11 +34,11 @@ else exit 1 fi -./coverage_more.sh > test_coverage_more.txt || { rm -f testok.txt && exit 1 ; } +bash .ci/coverage_more.sh "$5" > test_coverage_more.txt || { rm -f testok.txt && exit 1 ; } make lcov-single -# if this was executed as './coverage.sh ...' create coverage locally -if [[ "${0%% *}" == "./${0##*/}" ]]; then +# if this isn't run on Travis CI create coverage locally +if [ "$TRAVIS" == "" ]; then make lcov-html else coveralls-lcov coverage.info diff --git a/coverage_more.sh b/.ci/coverage_more.sh similarity index 88% rename from coverage_more.sh rename to .ci/coverage_more.sh index 562afcf..37c73f7 100755 --- a/coverage_more.sh +++ b/.ci/coverage_more.sh @@ -2,6 +2,10 @@ set -e +if [ "$#" = "1" -a "$(echo $1 | grep 'gmp')" != "" ]; then + ./test t gmp +fi + ./sizes ./constants diff --git a/.ci/meta_builds.sh b/.ci/meta_builds.sh new file mode 100755 index 0000000..87f0402 --- /dev/null +++ b/.ci/meta_builds.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# +# This builds different stuff depending on the compiler: +# gcc - valgrind, coverage +# clang - asan, ubsan, scan-build +# both - the two testbuild's NOTEST and NOFILE + +set -e + +if [ "$#" = "5" -a "$(echo $3 | grep -v 'makefile[.]')" = "" ]; then + echo "only run $0 for the regular makefile, early exit success" + exit 0 +fi + +if [ -f /proc/cpuinfo ] +then + MAKE_JOBS=$(( ($(cat /proc/cpuinfo | grep -E '^processor[[:space:]]*:' | tail -n -1 | cut -d':' -f2) + 1) * 2 + 1 )) +else + MAKE_JOBS=8 +fi + +function run_gcc() { + bash .ci/check_source.sh "CHECK_SOURCES" "$2" "$3" "$4" "$5" + + make clean &>/dev/null + + echo + echo "Build for ASAN..." + + make -j$MAKE_JOBS CFLAGS="-fsanitize=address -fno-omit-frame-pointer -static-libasan $2 $CFLAGS $4" EXTRALIBS="-lasan $5" test LTC_DEBUG=1 1>gcc_1.txt 2>gcc_2.txt + + echo + echo "Run ASAN tests with LTM..." + + ASAN_OPTIONS=verbosity=1 ./test t ltm 1>test_std.txt 2> test_err.txt || exit 1 + + if echo $2 | grep -q GMP ; then + echo + echo "Run ASAN tests with GMP..." + + ASAN_OPTIONS=verbosity=1 ./test t gmp 1>test_std.txt 2> test_err.txt || exit 1 + fi + + make clean &>/dev/null + + echo + echo "Create code coverage" + + bash .ci/coverage.sh "COVERAGE" "$2" "$3" "$4" "$5" +} + +function run_clang() { + # output version + bash .ci/printinfo.sh + + scan_build=$(which scan-build) + [ -z "$scan_build" ] && scan_build=$(find /usr/bin/ -name 'scan-build-*' | sort -nr | head -n1) || true + [ -z "$scan_build" ] && { echo "couldn't find clang scan-build"; exit 1; } || echo "run $scan_build" + $scan_build --status-bugs make -j$MAKE_JOBS all CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" + + make clean &>/dev/null + + echo + echo "Build for UBSAN..." + + make -j$MAKE_JOBS LDFLAGS="-fsanitize=undefined" CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" all LTC_DEBUG=1 1>gcc_1.txt 2>gcc_2.txt + + echo "Run UBSAN tests with LTM..." + UBSAN_OPTIONS=verbosity=1 ./test t ltm 1>test_std.txt 2> test_err.txt || exit 1 + + if echo $2 | grep -q GMP ; then + echo + echo "Run UBSAN tests with GMP..." + + UBSAN_OPTIONS=verbosity=1 ./test t gmp 1>test_std.txt 2> test_err.txt || exit 1 + fi +} + +make clean &>/dev/null + +EXTRALIBS="$5" + +echo $2 | grep -q GMP && EXTRALIBS="$EXTRALIBS -lgmp" + +if [ -z "$(echo $CC | grep "clang")" ]; then + run_gcc "$1" "$2" "$3" "$4" "$EXTRALIBS" +else + run_clang "$1" "$2" "$3" "$4" "$EXTRALIBS" +fi + +make clean &>/dev/null + +bash .ci/testbuild.sh "NOTEST" "-DLTC_NO_TEST" "$3" "$4" "$5" + +make clean &>/dev/null + +bash .ci/testbuild.sh "NOFILE" "-DLTC_NO_FILE" "$3" "$4" "$5" + +# ref: $Format:%D$ +# git commit: $Format:%H$ +# commit time: $Format:%ai$ diff --git a/printinfo.sh b/.ci/printinfo.sh similarity index 83% rename from printinfo.sh rename to .ci/printinfo.sh index 213af5b..21e1fec 100644 --- a/printinfo.sh +++ b/.ci/printinfo.sh @@ -18,3 +18,7 @@ then fi echo "${CC}="`${CC} -dumpversion` echo + +# ref: $Format:%D$ +# git commit: $Format:%H$ +# commit time: $Format:%ai$ diff --git a/run.sh b/.ci/run.sh similarity index 69% rename from run.sh rename to .ci/run.sh index 94043c7..224dbc2 100755 --- a/run.sh +++ b/.ci/run.sh @@ -1,9 +1,9 @@ #!/bin/bash # output version -bash printinfo.sh +bash .ci/printinfo.sh -bash build.sh " $1" "$2 -O2" "$3 IGNORE_SPEED=1" "$4" "$5" +bash .ci/build.sh " $1" "$2 -O2" "$3 IGNORE_SPEED=1" "$4" "$5" if [ -a testok.txt ] && [ -f testok.txt ]; then echo else @@ -13,7 +13,7 @@ else fi rm -f testok.txt -bash build.sh " $1" "$2 -Os" "$3 IGNORE_SPEED=1 LTC_SMALL=1" "$4" "$5" +bash .ci/build.sh " $1" "$2 -Os" "$3 IGNORE_SPEED=1 LTC_SMALL=1" "$4" "$5" if [ -a testok.txt ] && [ -f testok.txt ]; then echo else @@ -23,7 +23,7 @@ else fi rm -f testok.txt -bash build.sh " $1" "$2" "$3 LTC_DEBUG=1" "$4" "$5" +bash .ci/build.sh " $1" "$2" "$3 LTC_DEBUG=1" "$4" "$5" if [ -a testok.txt ] && [ -f testok.txt ]; then echo else @@ -33,7 +33,7 @@ else fi rm -f testok.txt -bash build.sh " $1" "$2" "$3" "$4" "$5" +bash .ci/build.sh " $1" "$2" "$3" "$4" "$5" if [ -a testok.txt ] && [ -f testok.txt ]; then echo else diff --git a/.ci/testbuild.sh b/.ci/testbuild.sh new file mode 100755 index 0000000..96810f9 --- /dev/null +++ b/.ci/testbuild.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# output version +bash .ci/printinfo.sh + +if [ -f /proc/cpuinfo ] +then + MAKE_JOBS=$(( ($(cat /proc/cpuinfo | grep -E '^processor[[:space:]]*:' | tail -n -1 | cut -d':' -f2) + 1) * 2 + 1 )) +else + MAKE_JOBS=8 +fi + +echo "$1 (Build Only, $2, $3)..." +make clean 1>/dev/null 2>/dev/null +echo -n "building..." +touch testok.txt +CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" make -j$MAKE_JOBS -f $3 test tv_gen 1>gcc_1.txt 2>gcc_2.txt || (echo "build $1 failed see gcc_2.txt for more information" && cat gcc_2.txt && rm -f testok.txt && exit 1) +if find testok.txt -type f 1>/dev/null 2>/dev/null ; then + echo "successful" + exit 0 +fi +exit 1 + +# ref: $Format:%D$ +# git commit: $Format:%H$ +# commit time: $Format:%ai$ diff --git a/.ci/valgrind.sh b/.ci/valgrind.sh new file mode 100755 index 0000000..87ad884 --- /dev/null +++ b/.ci/valgrind.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +if [ "$#" = "5" -a "$(echo $3 | grep -v 'makefile[.]')" = "" ]; then + echo "only run $0 for the regular makefile, early exit success" + exit 0 +fi + +if [ -f /proc/cpuinfo ] +then + MAKE_JOBS=$(( ($(cat /proc/cpuinfo | grep -E '^processor[[:space:]]*:' | tail -n -1 | cut -d':' -f2) + 1) * 2 + 1 )) +else + MAKE_JOBS=8 +fi + +# output version +bash .ci/printinfo.sh + +make clean &>/dev/null + +echo "Build for valgrind..." + +make -j$MAKE_JOBS CFLAGS="$2 $CFLAGS $4" EXTRALIBS="$5" test LTC_DEBUG=1 1>gcc_1.txt 2>gcc_2.txt + +echo "Run tests with valgrind..." + +for i in `seq 1 10` ; do sleep 300 && echo "Valgrind tests in Progress..."; done & +alive_pid=$! + +valgrind --error-exitcode=666 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all ./test >test_std.txt 2> >(tee -a test_err.txt >&2) || { kill $alive_pid; echo "Valgrind failed"; exit 1; } + +kill $alive_pid + +# ref: $Format:%D$ +# git commit: $Format:%H$ +# commit time: $Format:%ai$ diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..bf632fd --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,29 @@ + + +### Prerequisites + +* [ ] Checked the developer manual +* [ ] Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=repo%3Alibtom%2Flibtomcrypt +* [ ] Checked that your issue isn't related to TomsFastMath's limitation that PK operations can by default only be done with max. 2048bit keys + +### Description + +[Description of the issue] + +### Steps to Reproduce + + +### Version + +You can get this information from the define `SCRYPT` in `src/include/tomcrypt.h` or your local git repository by running `git describe --always --tags --dirty`. +Also, please include the compiler, the compiler version, the architecture and (if applicable) the MPI provider, the OS and what version of the OS you're experiencing the issue. + +### Additional Information + +Any additional information, configuration or data that might be necessary to reproduce the issue. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..8cd4614 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,13 @@ + + +### Checklist + + +* [ ] documentation is added or updated +* [ ] tests are added or updated diff --git a/.gitignore b/.gitignore index be6d759..e44243e 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,12 @@ timing.exe .cproject .settings/ +# macOS special files +.DS_Store + +# other special files +showlibs # symlink to .libs + # oops ;) but we don't want them to appear in the repository... *.stackdump *.core @@ -94,3 +100,7 @@ coverage*.info cov-int/ .coverity_* libtomcrypt.lzma +.build_linux_amd64.txt +build/ +cmake-build-*/ +out/*_*/ diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..ec9a396 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,441 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + LTC_DER + link + LTM + oid_st + #include + WIN32 + LTM_DESC + ltc_mp + -fPIC + LTC_SOURCE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +