diff --git a/Makefile.am b/Makefile.am index f51fb54db..af9a452c3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,7 @@ CLANGFORMAT ?= clang-format SUBDIRS = ${SRCDIR} -BUILT_SOURCES = links +BUILT_SOURCES = links ntru lib_LTLIBRARIES = liboqs.la liboqs_la_SOURCES = liboqs_la_LIBADD = src/common/libcommon.la src/kex/libkex.la src/crypto/rand/librand.la src/crypto/aes/libaes.la @@ -75,6 +75,9 @@ endif test: clean-tests +if USE_NTRU + make -C external/NTRUEncrypt-master/ +endif make if USE_NTRU if ON_DARWIN @@ -87,7 +90,12 @@ endif ./test_rand ./test_aes -links: +ntru: +if USE_NTRU + make -C external/NTRUEncrypt-master/ +endif + +links: $(MKDIR_P) include/oqs $(LN_S) -f ../../src/common/common.h include/oqs $(LN_S) -f ../../src/crypto/aes/aes.h include/oqs @@ -116,6 +124,13 @@ endif clean-local: rm -f liboqs.a + rm -rf include +if USE_SIDH_IQC + rm -f sample_params +endif +if USE_NTRU + make -C external/NTRUEncrypt-master/ clean +endif clean-tests: rm -f test_kex test_rand test_aes diff --git a/configure.ac b/configure.ac index 22465c0e0..82e54329d 100644 --- a/configure.ac +++ b/configure.ac @@ -76,7 +76,7 @@ AM_CONDITIONAL([USE_SIDH_IQC], [test "x$sidhiqc" = xtrue]) -AM_CPPFLAGS="-g -std=gnu11 -Wpedantic -Wall -Wextra -DCONSTANT_TIME" +AM_CPPFLAGS="-g -std=gnu11 -Werror -Wpedantic -Wall -Wextra -DCONSTANT_TIME" AC_CANONICAL_HOST # Check for which host we are on and setup a few things # specifically based on the host diff --git a/src/kex_rlwe_newhope/newhope.c b/src/kex_rlwe_newhope/newhope.c index 8b5ea4fbc..804599bce 100644 --- a/src/kex_rlwe_newhope/newhope.c +++ b/src/kex_rlwe_newhope/newhope.c @@ -49,7 +49,7 @@ static void gen_a(poly *a, const unsigned char *seed) { // API FUNCTIONS -static void keygen(unsigned char *send, poly *sk, OQS_RAND *rand) { +void keygen(unsigned char *send, poly *sk, OQS_RAND *rand) { poly a, e, r, pk; unsigned char seed[NEWHOPE_SEEDBYTES]; @@ -69,7 +69,7 @@ static void keygen(unsigned char *send, poly *sk, OQS_RAND *rand) { encode_a(send, &pk, seed); } -static void sharedb(unsigned char *sharedkey, unsigned char *send, const unsigned char *received, OQS_RAND *rand) { +void sharedb(unsigned char *sharedkey, unsigned char *send, const unsigned char *received, OQS_RAND *rand) { poly sp, ep, v, a, pka, c, epp, bp; unsigned char seed[NEWHOPE_SEEDBYTES]; @@ -101,7 +101,7 @@ static void sharedb(unsigned char *sharedkey, unsigned char *send, const unsigne #endif } -static void shareda(unsigned char *sharedkey, const poly *sk, const unsigned char *received) { +void shareda(unsigned char *sharedkey, const poly *sk, const unsigned char *received) { poly v, bp, c; decode_b(&bp, &c, received); @@ -115,3 +115,4 @@ static void shareda(unsigned char *sharedkey, const poly *sk, const unsigned cha OQS_SHA3_sha3256(sharedkey, sharedkey, 32); #endif } + diff --git a/src/kex_rlwe_newhope/poly.c b/src/kex_rlwe_newhope/poly.c index 162d93592..e2c48d162 100644 --- a/src/kex_rlwe_newhope/poly.c +++ b/src/kex_rlwe_newhope/poly.c @@ -86,7 +86,7 @@ static void ntt(uint16_t *a, const uint16_t *omega) { } } -static void poly_frombytes(poly *r, const unsigned char *a) { +void poly_frombytes(poly *r, const unsigned char *a) { int i; for (i = 0; i < PARAM_N / 4; i++) { r->coeffs[4 * i + 0] = a[7 * i + 0] | (((uint16_t) a[7 * i + 1] & 0x3f) << 8); @@ -96,7 +96,7 @@ static void poly_frombytes(poly *r, const unsigned char *a) { } } -static void poly_tobytes(unsigned char *r, const poly *p) { +void poly_tobytes(unsigned char *r, const poly *p) { int i; uint16_t t0, t1, t2, t3, m; int16_t c; @@ -136,7 +136,7 @@ static void poly_tobytes(unsigned char *r, const poly *p) { } } -static void poly_uniform(poly *a, const unsigned char *seed) { +void poly_uniform(poly *a, const unsigned char *seed) { unsigned int pos = 0, ctr = 0; uint16_t val; uint64_t state[OQS_SHA3_STATESIZE]; @@ -161,7 +161,7 @@ static void poly_uniform(poly *a, const unsigned char *seed) { } } -static void poly_getnoise(poly *r, OQS_RAND *rand) { +void poly_getnoise(poly *r, OQS_RAND *rand) { #if PARAM_K != 16 #error "poly_getnoise in poly.c only supports k=16" #endif @@ -186,7 +186,7 @@ static void poly_getnoise(poly *r, OQS_RAND *rand) { } } -static void poly_pointwise(poly *r, const poly *a, const poly *b) { +void poly_pointwise(poly *r, const poly *a, const poly *b) { int i; uint16_t t; for (i = 0; i < PARAM_N; i++) { @@ -195,19 +195,19 @@ static void poly_pointwise(poly *r, const poly *a, const poly *b) { } } -static void poly_add(poly *r, const poly *a, const poly *b) { +void poly_add(poly *r, const poly *a, const poly *b) { int i; for (i = 0; i < PARAM_N; i++) { r->coeffs[i] = barrett_reduce(a->coeffs[i] + b->coeffs[i]); } } -static void poly_ntt(poly *r) { +void poly_ntt(poly *r) { mul_coefficients(r->coeffs, psis_bitrev_montgomery); ntt((uint16_t *) r->coeffs, omegas_montgomery); } -static void poly_invntt(poly *r) { +void poly_invntt(poly *r) { bitrev_vector(r->coeffs); ntt((uint16_t *) r->coeffs, omegas_inv_montgomery); mul_coefficients(r->coeffs, psis_inv_montgomery); @@ -274,7 +274,7 @@ static int16_t LDDecode(int32_t xi0, int32_t xi1, int32_t xi2, int32_t xi3) { return t & 1; } -static void helprec(poly *c, const poly *v, OQS_RAND *oqs_rand) { +void helprec(poly *c, const poly *v, OQS_RAND *oqs_rand) { int32_t v0[4], v1[4], v_tmp[4], k; unsigned char rbit; unsigned char rand[32]; @@ -304,7 +304,7 @@ static void helprec(poly *c, const poly *v, OQS_RAND *oqs_rand) { } } -static void rec(unsigned char *key, const poly *v, const poly *c) { +void rec(unsigned char *key, const poly *v, const poly *c) { int i; int32_t tmp[4]; diff --git a/src/kex_sidh_iqc_ref/sidh_public_key_encryption.c b/src/kex_sidh_iqc_ref/sidh_public_key_encryption.c index ca1921be3..ff43ea94c 100644 --- a/src/kex_sidh_iqc_ref/sidh_public_key_encryption.c +++ b/src/kex_sidh_iqc_ref/sidh_public_key_encryption.c @@ -123,8 +123,8 @@ const mp_limb_t *mpz_limbs_read(const mpz_t x); char *oqs_sidh_iqc_ref_public_key_encryption_hash(const fp2_element_t value, long size) { // compute the size of value in chars - long size_a = labs(mpz_size(value->a)) * sizeof(mp_limb_t); - long size_b = labs(mpz_size(value->b)) * sizeof(mp_limb_t); + long size_a = mpz_size(value->a) * sizeof(mp_limb_t); + long size_b = mpz_size(value->b) * sizeof(mp_limb_t); char *hash = (char *) malloc(size); @@ -136,6 +136,6 @@ char *oqs_sidh_iqc_ref_public_key_encryption_hash(const fp2_element_t value, long oqs_sidh_iqc_ref_public_key_get_key_size() { // the key size is twice as large as the base prime. - long key_size = 2 * labs(mpz_size(characteristic)) * sizeof(mp_limb_t); + long key_size = 2 * mpz_size(characteristic) * sizeof(mp_limb_t); return key_size; }