From 4d0082fa43d3741faaf1f01f3e7a7c822f016c58 Mon Sep 17 00:00:00 2001 From: Thom Wiggers Date: Wed, 16 Jan 2019 13:02:57 +0100 Subject: [PATCH] Add travis config Also fixes some tidy issues Not sure why my local clang-tidy doesn't complain --- .clang-tidy | 2 +- .travis.yml | 33 ++++++++++++++++++----- Makefile | 19 +++++++------ common/sha2.h | 4 +-- crypto_kem/kyber768/clean/ntt.h | 2 +- crypto_sign/dilithium-iii/clean/polyvec.h | 4 +-- crypto_sign/dilithium-iii/clean/sign.h | 2 +- 7 files changed, 45 insertions(+), 21 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 281d9e58..9ec04c26 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,clang-diagnostic-*,clang-analyzer-*,*,-hicpp-signed-bitwise,-llvm-header-guard,-hicpp-function-*,-readability-function-size' +Checks: '*,-llvm-header-guard,-hicpp-*,-readability-function-size' WarningsAsErrors: '*' HeaderFilterRegex: '.*' AnalyzeTemporaryDtors: false diff --git a/.travis.yml b/.travis.yml index 4f0f56c8..024867da 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,32 @@ language: c -compiler: - - clang - - gcc +dist: xenial + +matrix: + include: + - os: linux + compiler: gcc + env: + - MAKETARGET="test-all tidy-all check-format" + - os: linux + compiler: clang + env: + - MAKETARGET=test-all + - os: osx + compiler: clang + env: + - MAKETARGET=test-all + - os: osx + osx_image: xcode9 + env: + - MATRIX_EVAL="brew upgrade && brew install gcc && CC=gcc-8 && CXX=g++-8" + - MAKETARGET=test-all + +before_install: + - eval "${MATRIX_EVAL}" script: - - make test-all - - make tidy-all - - make check-format + - make ${MAKETARGET} + + # vim: set ft=yaml ts=2 sw=2 tw=0 et : diff --git a/Makefile b/Makefile index ec029152..88253e4b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # This -Wall was supported by the European Commission through the ERC Starting Grant 805031 (EPOQUE) CFLAGS=-Wall -Wextra -Wpedantic -Werror -std=c99 $(EXTRAFLAGS) -ALL_SCHEMES=$(filter-out crypto_%/test.c, $(wildcard crypto_*/*)) +ALL_SCHEMES=$(filter-out crypto_%.c, $(wildcard crypto_*/*)) default: help @@ -63,7 +63,6 @@ check-format: .PHONY: tidy tidy: - $(eval undefine .TIDY_FIX) $(MAKE) do-tidy do-tidy: require_scheme @@ -81,10 +80,11 @@ apply-tidy: # The below should be outlined with ts=8 .PHONY: help help: + @echo "make test-all Run all tests" @echo "make functest SCHEME=scheme Build functional tests for SCHEME" + @echo "make functest-all Build functional tests for all schemes" @echo "make run-functest SCHEME=scheme Run functional tests for SCHEME" @echo "make run-functest-all Run all functests" - @echo "make testvectors SCHEME=scheme Build testvector generator for SCHEME" @echo "make clean Clean up the bin/ folder" @echo "make format Automatically formats all the source code" @echo "make tidy SCHEME=scheme Runs the clang-tidy linter against SCHEME" @@ -94,23 +94,26 @@ help: @echo "make help Displays this message" .PHONY: functest-all -build-functests: $(foreach skeme,$(ALL_SCHEMES),bin/functest_$(subst /,_,$(skeme))) +functest-all: + @for scheme in $(ALL_SCHEMES); do \ + $(MAKE) functest SCHEME=$$scheme || exit 1; \ + done .PHONY: run-functest-all -run-functest-all: build-functests +run-functest-all: functest-all @for functest in bin/functest_* ; do \ echo ./$$functest ; \ - ./$$functest ; \ + ./$$functest || exit 1 ;\ done @echo Tests completed .PHONY: test-all -test-all: run-functests +test-all: run-functest-all .PHONY: tidy-all tidy-all: @for scheme in $(ALL_SCHEMES); do \ - $(MAKE) tidy SCHEME=$$scheme; \ + $(MAKE) tidy SCHEME=$$scheme || exit 1 ; \ done .PHONY: apply-tidy-all diff --git a/common/sha2.h b/common/sha2.h index b47927ef..fdd4ab1e 100644 --- a/common/sha2.h +++ b/common/sha2.h @@ -1,9 +1,9 @@ #ifndef SHA2_H #define SHA2_H -int sha384(unsigned char *output, const unsigned char *input, +int sha384(unsigned char *out, const unsigned char *in, unsigned long long inlen); -int sha512(unsigned char *output, const unsigned char *input, +int sha512(unsigned char *out, const unsigned char *in, unsigned long long inlen); #endif diff --git a/crypto_kem/kyber768/clean/ntt.h b/crypto_kem/kyber768/clean/ntt.h index 139cffed..68b86735 100644 --- a/crypto_kem/kyber768/clean/ntt.h +++ b/crypto_kem/kyber768/clean/ntt.h @@ -3,7 +3,7 @@ #include -void ntt(uint16_t *poly); +void ntt(uint16_t *p); void invntt(uint16_t *a); #endif diff --git a/crypto_sign/dilithium-iii/clean/polyvec.h b/crypto_sign/dilithium-iii/clean/polyvec.h index 45f2987d..9f593cd8 100644 --- a/crypto_sign/dilithium-iii/clean/polyvec.h +++ b/crypto_sign/dilithium-iii/clean/polyvec.h @@ -18,7 +18,7 @@ void polyvecl_ntt(polyvecl *v); void polyvecl_pointwise_acc_invmontgomery(poly *w, const polyvecl *u, const polyvecl *v); -int polyvecl_chknorm(const polyvecl *v, uint32_t B); +int polyvecl_chknorm(const polyvecl *v, uint32_t bound); /* Vectors of polynomials of length K */ typedef struct { @@ -36,7 +36,7 @@ void polyveck_shiftl(polyveck *v, unsigned int k); void polyveck_ntt(polyveck *v); void polyveck_invntt_montgomery(polyveck *v); -int polyveck_chknorm(const polyveck *v, uint32_t B); +int polyveck_chknorm(const polyveck *v, uint32_t bound); void polyveck_power2round(polyveck *v1, polyveck *v0, const polyveck *v); void polyveck_decompose(polyveck *v1, polyveck *v0, const polyveck *v); diff --git a/crypto_sign/dilithium-iii/clean/sign.h b/crypto_sign/dilithium-iii/clean/sign.h index 82020227..7f52b7b3 100644 --- a/crypto_sign/dilithium-iii/clean/sign.h +++ b/crypto_sign/dilithium-iii/clean/sign.h @@ -11,7 +11,7 @@ void challenge(poly *c, const unsigned char mu[CRHBYTES], const polyveck *w1); int crypto_sign_keypair(unsigned char *pk, unsigned char *sk); int crypto_sign(unsigned char *sm, unsigned long long *smlen, - const unsigned char *msg, unsigned long long len, + const unsigned char *m, unsigned long long mlen, const unsigned char *sk); int crypto_sign_open(unsigned char *m, unsigned long long *mlen,