mirror of
https://github.com/open-quantum-safe/liboqs.git
synced 2025-10-09 00:04:26 -04:00
Flag warning as error and fix warnings
This commit is contained in:
parent
d0ec688e33
commit
b91c93098f
17
Makefile.am
17
Makefile.am
@ -11,7 +11,7 @@ CLANGFORMAT ?= clang-format
|
|||||||
|
|
||||||
SUBDIRS = ${SRCDIR}
|
SUBDIRS = ${SRCDIR}
|
||||||
|
|
||||||
BUILT_SOURCES = links
|
BUILT_SOURCES = links ntru
|
||||||
lib_LTLIBRARIES = liboqs.la
|
lib_LTLIBRARIES = liboqs.la
|
||||||
liboqs_la_SOURCES =
|
liboqs_la_SOURCES =
|
||||||
liboqs_la_LIBADD = src/common/libcommon.la src/kex/libkex.la src/crypto/rand/librand.la src/crypto/aes/libaes.la
|
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
|
test: clean-tests
|
||||||
|
if USE_NTRU
|
||||||
|
make -C external/NTRUEncrypt-master/
|
||||||
|
endif
|
||||||
make
|
make
|
||||||
if USE_NTRU
|
if USE_NTRU
|
||||||
if ON_DARWIN
|
if ON_DARWIN
|
||||||
@ -87,6 +90,11 @@ endif
|
|||||||
./test_rand
|
./test_rand
|
||||||
./test_aes
|
./test_aes
|
||||||
|
|
||||||
|
ntru:
|
||||||
|
if USE_NTRU
|
||||||
|
make -C external/NTRUEncrypt-master/
|
||||||
|
endif
|
||||||
|
|
||||||
links:
|
links:
|
||||||
$(MKDIR_P) include/oqs
|
$(MKDIR_P) include/oqs
|
||||||
$(LN_S) -f ../../src/common/common.h include/oqs
|
$(LN_S) -f ../../src/common/common.h include/oqs
|
||||||
@ -116,6 +124,13 @@ endif
|
|||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -f liboqs.a
|
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:
|
clean-tests:
|
||||||
rm -f test_kex test_rand test_aes
|
rm -f test_kex test_rand test_aes
|
||||||
|
@ -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
|
AC_CANONICAL_HOST
|
||||||
# Check for which host we are on and setup a few things
|
# Check for which host we are on and setup a few things
|
||||||
# specifically based on the host
|
# specifically based on the host
|
||||||
|
@ -49,7 +49,7 @@ static void gen_a(poly *a, const unsigned char *seed) {
|
|||||||
|
|
||||||
// API FUNCTIONS
|
// 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;
|
poly a, e, r, pk;
|
||||||
unsigned char seed[NEWHOPE_SEEDBYTES];
|
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);
|
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;
|
poly sp, ep, v, a, pka, c, epp, bp;
|
||||||
unsigned char seed[NEWHOPE_SEEDBYTES];
|
unsigned char seed[NEWHOPE_SEEDBYTES];
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ static void sharedb(unsigned char *sharedkey, unsigned char *send, const unsigne
|
|||||||
#endif
|
#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;
|
poly v, bp, c;
|
||||||
|
|
||||||
decode_b(&bp, &c, received);
|
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);
|
OQS_SHA3_sha3256(sharedkey, sharedkey, 32);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
int i;
|
||||||
for (i = 0; i < PARAM_N / 4; 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);
|
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;
|
int i;
|
||||||
uint16_t t0, t1, t2, t3, m;
|
uint16_t t0, t1, t2, t3, m;
|
||||||
int16_t c;
|
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;
|
unsigned int pos = 0, ctr = 0;
|
||||||
uint16_t val;
|
uint16_t val;
|
||||||
uint64_t state[OQS_SHA3_STATESIZE];
|
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
|
#if PARAM_K != 16
|
||||||
#error "poly_getnoise in poly.c only supports k=16"
|
#error "poly_getnoise in poly.c only supports k=16"
|
||||||
#endif
|
#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;
|
int i;
|
||||||
uint16_t t;
|
uint16_t t;
|
||||||
for (i = 0; i < PARAM_N; i++) {
|
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;
|
int i;
|
||||||
for (i = 0; i < PARAM_N; i++) {
|
for (i = 0; i < PARAM_N; i++) {
|
||||||
r->coeffs[i] = barrett_reduce(a->coeffs[i] + b->coeffs[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);
|
mul_coefficients(r->coeffs, psis_bitrev_montgomery);
|
||||||
ntt((uint16_t *) r->coeffs, omegas_montgomery);
|
ntt((uint16_t *) r->coeffs, omegas_montgomery);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void poly_invntt(poly *r) {
|
void poly_invntt(poly *r) {
|
||||||
bitrev_vector(r->coeffs);
|
bitrev_vector(r->coeffs);
|
||||||
ntt((uint16_t *) r->coeffs, omegas_inv_montgomery);
|
ntt((uint16_t *) r->coeffs, omegas_inv_montgomery);
|
||||||
mul_coefficients(r->coeffs, psis_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;
|
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;
|
int32_t v0[4], v1[4], v_tmp[4], k;
|
||||||
unsigned char rbit;
|
unsigned char rbit;
|
||||||
unsigned char rand[32];
|
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;
|
int i;
|
||||||
int32_t tmp[4];
|
int32_t tmp[4];
|
||||||
|
|
||||||
|
@ -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,
|
char *oqs_sidh_iqc_ref_public_key_encryption_hash(const fp2_element_t value,
|
||||||
long size) {
|
long size) {
|
||||||
// compute the size of value in chars
|
// compute the size of value in chars
|
||||||
long size_a = labs(mpz_size(value->a)) * sizeof(mp_limb_t);
|
long size_a = mpz_size(value->a) * sizeof(mp_limb_t);
|
||||||
long size_b = labs(mpz_size(value->b)) * sizeof(mp_limb_t);
|
long size_b = mpz_size(value->b) * sizeof(mp_limb_t);
|
||||||
|
|
||||||
char *hash = (char *) malloc(size);
|
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() {
|
long oqs_sidh_iqc_ref_public_key_get_key_size() {
|
||||||
// the key size is twice as large as the base prime.
|
// 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;
|
return key_size;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user