diff --git a/CMakeLists.txt b/CMakeLists.txt index 47da9dd4c..ad2ee45b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,7 +99,7 @@ message(" ALLOC=STACK All memory is allocated from the stack.\n") message(STATUS "Supported operating systems (default = LINUX):\n") -message(" OPSYS=NONE Undefined/No operating system.") +message(" OPSYS=RELIC_NONE Undefined/No operating system.") message(" OPSYS=LINUX GNU/Linux operating system.") message(" OPSYS=FREEBSD FreeBSD operating system.") message(" OPSYS=MACOSX Mac OS X operating system.") @@ -107,15 +107,15 @@ message(" OPSYS=WINDOWS Windows operating system.") message(" OPSYS=DROID Android operating system.") message(" OPSYS=DUINO Arduino platform.\n") -message(STATUS "Supported multithreading APIs (default = NONE):\n") +message(STATUS "Supported multithreading APIs (default = RELIC_NONE):\n") -message(" MULTI=NONE NO multithreading support.") +message(" MULTI=RELIC_NONE NO multithreading support.") message(" MULTI=OPENMP Open Multi-Processing.") message(" MULTI=PTHREAD POSIX threads.\n") message(STATUS "Supported timers (default = HPROC):\n") -message(" TIMER=NONE No timer.") +message(" TIMER=RELIC_NONE No timer.") message(" TIMER=HREAL GNU/Linux realtime high-resolution timer.") message(" TIMER=HPROC GNU/Linux per-process high-resolution timer.") message(" TIMER=HTHRD GNU/Linux per-thread high-resolution timer.") @@ -312,7 +312,7 @@ else(CMAKE_SYSTEM_NAME STREQUAL Linux) if(CMAKE_SYSTEM_NAME STREQUAL Darwin) set(OPSYS "MACOSX" CACHE STRING "Operating system") else(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(OPSYS "NONE" CACHE STRING "Operating system") + set(OPSYS "RELIC_NONE" CACHE STRING "Operating system") endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) endif(CMAKE_SYSTEM_NAME STREQUAL Linux) @@ -347,7 +347,7 @@ else(MULTI STREQUAL OPENMP) set(CFLAGS "${CFLAGS} -pthread") set(MULTI "PTHREAD" CACHE STRING "Multithreading interface") else(MULTI STREQUAL PTHREAD) - set(MULTI "NONE" CACHE STRING "Operating system") + set(MULTI "RELIC_NONE" CACHE STRING "Operating system") endif(MULTI STREQUAL PTHREAD) endif(MULTI STREQUAL OPENMP) diff --git a/bench/bench_bn.c b/bench/bench_bn.c index bfa2abcdf..b323a38c6 100644 --- a/bench/bench_bn.c +++ b/bench/bench_bn.c @@ -93,8 +93,8 @@ static void memory(void) { static void util(void) { dig_t digit; - char str[BN_BYTES * 3 + 1]; - uint8_t bin[BN_BYTES]; + char str[RELIC_BN_BYTES * 3 + 1]; + uint8_t bin[RELIC_BN_BYTES]; dig_t raw[BN_DIGS]; bn_t a, b; @@ -104,173 +104,173 @@ static void util(void) { bn_new(a); bn_new(b); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_BEGIN("bn_copy") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_copy(b, a)); } BENCH_END; BENCH_BEGIN("bn_abs") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_abs(b, a)); } BENCH_END; BENCH_BEGIN("bn_neg") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_neg(b, a)); } BENCH_END; BENCH_BEGIN("bn_sign") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_sign(a)); } BENCH_END; BENCH_BEGIN("bn_zero") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_zero(b)); } BENCH_END; BENCH_BEGIN("bn_is_zero") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_is_zero(a)); } BENCH_END; BENCH_BEGIN("bn_is_even") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_is_even(a)); } BENCH_END; BENCH_BEGIN("bn_bits") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_bits(a)); } BENCH_END; BENCH_BEGIN("bn_get_bit") { - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD(bn_get_bit(a, BN_BITS / 2)); + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD(bn_get_bit(a, RELIC_BN_BITS / 2)); } BENCH_END; BENCH_BEGIN("bn_set_bit") { - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD(bn_set_bit(a, BN_BITS / 2, 1)); + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD(bn_set_bit(a, RELIC_BN_BITS / 2, 1)); } BENCH_END; BENCH_BEGIN("bn_ham") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_ham(a)); } BENCH_END; BENCH_BEGIN("bn_get_dig") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_get_dig(&digit, a)); } BENCH_END; BENCH_BEGIN("bn_set_dig") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_set_dig(a, 1)); } BENCH_END; BENCH_BEGIN("bn_set_2b") { - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD(bn_set_2b(a, BN_BITS / 2)); + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD(bn_set_2b(a, RELIC_BN_BITS / 2)); } BENCH_END; BENCH_BEGIN("bn_rand") { - BENCH_ADD(bn_rand(a, BN_POS, BN_BITS)); + BENCH_ADD(bn_rand(a, BN_POS, RELIC_BN_BITS)); } BENCH_END; BENCH_BEGIN("bn_rand_mod") { - bn_rand(b, BN_POS, BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_rand_mod(a, b)); } BENCH_END; BENCH_BEGIN("bn_size_str") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_size_str(a, 10)); } BENCH_END; BENCH_BEGIN("bn_write_str") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_write_str(str, sizeof(str), a, 10)); } BENCH_END; BENCH_BEGIN("bn_read_str") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_read_str(a, str, sizeof(str), 10)); } BENCH_END; BENCH_BEGIN("bn_size_bin") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_size_bin(a)); } BENCH_END; BENCH_BEGIN("bn_write_bin") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_write_bin(bin, bn_size_bin(a), a)); } BENCH_END; BENCH_BEGIN("bn_read_bin") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_read_bin(a, bin, bn_size_bin(a))); } BENCH_END; BENCH_BEGIN("bn_size_raw") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_size_raw(a)); } BENCH_END; BENCH_BEGIN("bn_write_raw") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_write_raw(raw, bn_size_raw(a), a)); } BENCH_END; BENCH_BEGIN("bn_read_raw") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_read_raw(a, raw, bn_size_raw(a))); } BENCH_END; BENCH_BEGIN("bn_cmp_abs") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_cmp_abs(b, a)); } BENCH_END; BENCH_BEGIN("bn_cmp_dig") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_cmp_dig(a, (dig_t)0)); } BENCH_END; BENCH_BEGIN("bn_cmp") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_cmp(b, a)); } BENCH_END; @@ -297,45 +297,45 @@ static void arith(void) { bn_new(e); BENCH_BEGIN("bn_add") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_add(c, a, b)); } BENCH_END; BENCH_BEGIN("bn_add_dig") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_get_dig(&f, b); BENCH_ADD(bn_add_dig(c, a, f)); } BENCH_END; BENCH_BEGIN("bn_sub") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_sub(c, a, b)); } BENCH_END; BENCH_BEGIN("bn_sub_dig") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_get_dig(&f, b); BENCH_ADD(bn_sub_dig(c, a, f)); } BENCH_END; BENCH_BEGIN("bn_mul") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_mul(c, a, b)); } BENCH_END; BENCH_BEGIN("bn_mul_dig") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_get_dig(&f, b); BENCH_ADD(bn_mul_dig(c, a, f)); } @@ -343,8 +343,8 @@ static void arith(void) { #if BN_MUL == BASIC || !defined(STRIP) BENCH_BEGIN("bn_mul_basic") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_mul_basic(c, a, b)); } BENCH_END; @@ -352,8 +352,8 @@ static void arith(void) { #if BN_MUL == COMBA || !defined(STRIP) BENCH_BEGIN("bn_mul_comba") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_mul_comba(c, a, b)); } BENCH_END; @@ -361,22 +361,22 @@ static void arith(void) { #if BN_KARAT > 0 || !defined(STRIP) BENCH_BEGIN("bn_mul_karat") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_mul_karat(c, a, b)); } BENCH_END; #endif BENCH_BEGIN("bn_sqr") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_sqr(c, a)); } BENCH_END; #if BN_SQR == BASIC || !defined(STRIP) BENCH_BEGIN("bn_sqr_basic") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_sqr_basic(c, a)); } BENCH_END; @@ -384,7 +384,7 @@ static void arith(void) { #if BN_SQR == COMBA || !defined(STRIP) BENCH_BEGIN("bn_sqr_comba") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_sqr_comba(c, a)); } BENCH_END; @@ -392,52 +392,52 @@ static void arith(void) { #if BN_KARAT > 0 || !defined(STRIP) BENCH_BEGIN("bn_sqr_karat") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_sqr_karat(c, a)); } BENCH_END; #endif BENCH_BEGIN("bn_dbl") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_dbl(c, a)); } BENCH_END; BENCH_BEGIN("bn_hlv") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_hlv(c, a)); } BENCH_END; BENCH_BEGIN("bn_lsh") { - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD(bn_lsh(c, a, BN_BITS / 2 + BN_DIGIT / 2)); + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD(bn_lsh(c, a, RELIC_BN_BITS / 2 + BN_DIGIT / 2)); } BENCH_END; BENCH_BEGIN("bn_rsh") { - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD(bn_rsh(c, a, BN_BITS / 2 + BN_DIGIT / 2)); + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD(bn_rsh(c, a, RELIC_BN_BITS / 2 + BN_DIGIT / 2)); } BENCH_END; BENCH_BEGIN("bn_div") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_div(c, a, b)); } BENCH_END; BENCH_BEGIN("bn_div_rem") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_div_rem(c, d, a, b)); } BENCH_END; BENCH_BEGIN("bn_div_dig") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); do { bn_rand(b, BN_POS, BN_DIGIT); } while (bn_is_zero(b)); @@ -446,7 +446,7 @@ static void arith(void) { BENCH_END; BENCH_BEGIN("bn_div_rem_dig") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); do { bn_rand(b, BN_POS, BN_DIGIT); } while (bn_is_zero(b)); @@ -455,13 +455,13 @@ static void arith(void) { BENCH_END; BENCH_BEGIN("bn_mod_2b") { - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD(bn_mod_2b(c, a, BN_BITS / 2)); + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD(bn_mod_2b(c, a, RELIC_BN_BITS / 2)); } BENCH_END; BENCH_BEGIN("bn_mod_dig") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); do { bn_rand(b, BN_POS, BN_DIGIT); } while (bn_is_zero(b)); @@ -471,14 +471,14 @@ static void arith(void) { BENCH_BEGIN("bn_mod") { #if BN_MOD == PMERS - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_set_2b(b, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_set_2b(b, RELIC_BN_BITS); bn_rand(c, BN_POS, BN_DIGIT); bn_sub(b, b, c); bn_mod_pre(d, b); #else - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -490,8 +490,8 @@ static void arith(void) { #if BN_MOD == BASIC || !defined(STRIP) BENCH_BEGIN("bn_mod_basic") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_mod_basic(c, a, b)); } BENCH_END; @@ -499,7 +499,7 @@ static void arith(void) { #if BN_MOD == BARRT || !defined(STRIP) BENCH_BEGIN("bn_mod_pre_barrt") { - bn_rand(b, BN_POS, BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_mod_pre_barrt(d, b)); } BENCH_END; @@ -507,8 +507,8 @@ static void arith(void) { #if BN_MOD == BARRT || !defined(STRIP) BENCH_BEGIN("bn_mod_barrt") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_mod_pre_barrt(d, b); BENCH_ADD(bn_mod_barrt(c, a, b, d)); } @@ -517,7 +517,7 @@ static void arith(void) { #if BN_MOD == MONTY || !defined(STRIP) BENCH_BEGIN("bn_mod_pre_monty") { - bn_rand(b, BN_POS, BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -526,8 +526,8 @@ static void arith(void) { BENCH_END; BENCH_BEGIN("bn_mod_monty_conv") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -537,8 +537,8 @@ static void arith(void) { BENCH_END; BENCH_BEGIN("bn_mod_monty") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -550,8 +550,8 @@ static void arith(void) { #if BN_MUL == BASIC || !defined(STRIP) BENCH_BEGIN("bn_mod_monty_basic") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -564,8 +564,8 @@ static void arith(void) { #if BN_MUL == COMBA || !defined(STRIP) BENCH_BEGIN("bn_mod_monty_comba") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -577,8 +577,8 @@ static void arith(void) { #endif BENCH_BEGIN("bn_mod_monty_back") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -591,8 +591,8 @@ static void arith(void) { #if BN_MOD == PMERS || !defined(STRIP) BENCH_BEGIN("bn_mod_pre_pmers") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_set_2b(b, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_set_2b(b, RELIC_BN_BITS); bn_rand(c, BN_POS, BN_DIGIT); bn_sub(b, b, c); BENCH_ADD(bn_mod_pre_pmers(d, b)); @@ -600,8 +600,8 @@ static void arith(void) { BENCH_END; BENCH_BEGIN("bn_mod_pmers") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_set_2b(b, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_set_2b(b, RELIC_BN_BITS); bn_rand(c, BN_POS, BN_DIGIT); bn_sub(b, b, c); bn_mod_pre_pmers(d, b); @@ -611,14 +611,14 @@ static void arith(void) { #endif BENCH_BEGIN("bn_mxp") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); #if BN_MOD != PMERS if (bn_is_even(b)) { bn_add_dig(b, b, 1); } #else - bn_set_2b(b, BN_BITS); + bn_set_2b(b, RELIC_BN_BITS); bn_rand(c, BN_POS, BN_DIGIT); bn_sub(b, b, c); #endif @@ -637,7 +637,7 @@ static void arith(void) { #if BN_MXP == SLIDE || !defined(STRIP) BENCH_BEGIN("bn_mxp_slide") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); bn_mod(a, a, b); BENCH_ADD(bn_mxp_slide(c, a, b, b)); } @@ -646,7 +646,7 @@ static void arith(void) { #if BN_MXP == CONST || !defined(STRIP) BENCH_BEGIN("bn_mxp_monty") { - bn_rand(a, BN_POS, 2 * BN_BITS - BN_DIGIT / 2); + bn_rand(a, BN_POS, 2 * RELIC_BN_BITS - BN_DIGIT / 2); bn_mod(a, a, b); BENCH_ADD(bn_mxp_monty(c, a, b, b)); } @@ -654,7 +654,7 @@ static void arith(void) { #endif BENCH_BEGIN("bn_mxp_dig") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(d, BN_POS, BN_DIGIT); bn_get_dig(&f, d); BENCH_ADD(bn_mxp_dig(c, a, f, b)); @@ -662,22 +662,22 @@ static void arith(void) { BENCH_END; BENCH_BEGIN("bn_srt") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_srt(b, a)); } BENCH_END; BENCH_BEGIN("bn_gcd") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd(c, a, b)); } BENCH_END; #if BN_GCD == BASIC || !defined(STRIP) BENCH_BEGIN("bn_gcd_basic") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_basic(c, a, b)); } BENCH_END; @@ -685,8 +685,8 @@ static void arith(void) { #if BN_GCD == LEHME || !defined(STRIP) BENCH_BEGIN("bn_gcd_lehme") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_lehme(c, a, b)); } BENCH_END; @@ -694,15 +694,15 @@ static void arith(void) { #if BN_GCD == STEIN || !defined(STRIP) BENCH_BEGIN("bn_gcd_stein") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_stein(c, a, b)); } BENCH_END; #endif BENCH_BEGIN("bn_gcd_dig") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); bn_get_dig(&f, b); BENCH_ADD(bn_gcd_dig(c, a, f)); @@ -710,16 +710,16 @@ static void arith(void) { BENCH_END; BENCH_BEGIN("bn_gcd_ext") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_ext(c, d, e, a, b)); } BENCH_END; #if BN_GCD == BASIC || !defined(STRIP) BENCH_BEGIN("bn_gcd_ext_basic") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_ext_basic(c, d, e, a, b)); } BENCH_END; @@ -727,8 +727,8 @@ static void arith(void) { #if BN_GCD == LEHME || !defined(STRIP) BENCH_BEGIN("bn_gcd_ext_lehme") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_ext_lehme(c, d, e, a, b)); } BENCH_END; @@ -736,45 +736,45 @@ static void arith(void) { #if BN_GCD == STEIN || !defined(STRIP) BENCH_BEGIN("bn_gcd_ext_stein") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_ext_stein(c, d, e, a, b)); } BENCH_END; #endif BENCH_BEGIN("bn_gcd_ext_mid") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_gcd_ext_mid(c, c, d, d, a, b)); } BENCH_END; BENCH_BEGIN("bn_gcd_ext_dig") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); BENCH_ADD(bn_gcd_ext_dig(c, d, e, a, b->dp[0])); } BENCH_END; BENCH_BEGIN("bn_lcm") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_lcm(c, a, b)); } BENCH_END; - bn_gen_prime(b, BN_BITS); + bn_gen_prime(b, RELIC_BN_BITS); BENCH_BEGIN("bn_smb_leg") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_smb_leg(c, a, b)); } BENCH_END; BENCH_BEGIN("bn_smb_jac") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -782,18 +782,18 @@ static void arith(void) { } BENCH_END; - BENCH_ONCE("bn_gen_prime", bn_gen_prime(a, BN_BITS)); + BENCH_ONCE("bn_gen_prime", bn_gen_prime(a, RELIC_BN_BITS)); #if BN_GEN == BASIC || !defined(STRIP) - BENCH_ONCE("bn_gen_prime_basic", bn_gen_prime_basic(a, BN_BITS)); + BENCH_ONCE("bn_gen_prime_basic", bn_gen_prime_basic(a, RELIC_BN_BITS)); #endif #if BN_GEN == SAFEP || !defined(STRIP) - BENCH_ONCE("bn_gen_prime_safep", bn_gen_prime_safep(a, BN_BITS)); + BENCH_ONCE("bn_gen_prime_safep", bn_gen_prime_safep(a, RELIC_BN_BITS)); #endif #if BN_GEN == STRON || !defined(STRIP) - BENCH_ONCE("bn_gen_prime_stron", bn_gen_prime_stron(a, BN_BITS)); + BENCH_ONCE("bn_gen_prime_stron", bn_gen_prime_stron(a, RELIC_BN_BITS)); #endif BENCH_ONCE("bn_is_prime", bn_is_prime(a)); @@ -804,36 +804,36 @@ static void arith(void) { BENCH_ONCE("bn_is_prime_solov", bn_is_prime_solov(a)); - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); BENCH_ONCE("bn_factor", bn_factor(c, a)); BENCH_BEGIN("bn_is_factor") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); BENCH_ADD(bn_is_factor(b, a)); } BENCH_END; BENCH_BEGIN("bn_rec_win") { - uint8_t win[BN_BITS + 1]; - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD((len = BN_BITS + 1, bn_rec_win(win, &len, a, 4))); + uint8_t win[RELIC_BN_BITS + 1]; + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD((len = RELIC_BN_BITS + 1, bn_rec_win(win, &len, a, 4))); } BENCH_END; BENCH_BEGIN("bn_rec_slw") { - uint8_t win[BN_BITS + 1]; - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD((len = BN_BITS + 1, bn_rec_slw(win, &len, a, 4))); + uint8_t win[RELIC_BN_BITS + 1]; + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD((len = RELIC_BN_BITS + 1, bn_rec_slw(win, &len, a, 4))); } BENCH_END; BENCH_BEGIN("bn_rec_naf") { - signed char naf[BN_BITS + 1]; + signed char naf[RELIC_BN_BITS + 1]; int len; - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD((len = BN_BITS + 1, bn_rec_naf(naf, &len, a, 4))); + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD((len = RELIC_BN_BITS + 1, bn_rec_naf(naf, &len, a, 4))); } BENCH_END; @@ -841,7 +841,7 @@ static void arith(void) { if (eb_param_set_any_kbltz() == STS_OK) { BENCH_BEGIN("bn_rec_tnaf") { signed char tnaf[FB_BITS + 8]; - int len = BN_BITS + 1; + int len = RELIC_BN_BITS + 1; eb_curve_get_ord(e); bn_rand_mod(a, e); if (eb_curve_opt_a() == OPT_ZERO) { @@ -867,18 +867,18 @@ static void arith(void) { #endif BENCH_BEGIN("bn_rec_reg") { - signed char naf[BN_BITS + 1]; - int len = BN_BITS + 1; - bn_rand(a, BN_POS, BN_BITS); - BENCH_ADD((len = BN_BITS + 1, bn_rec_reg(naf, &len, a, BN_BITS, 4))); + signed char naf[RELIC_BN_BITS + 1]; + int len = RELIC_BN_BITS + 1; + bn_rand(a, BN_POS, RELIC_BN_BITS); + BENCH_ADD((len = RELIC_BN_BITS + 1, bn_rec_reg(naf, &len, a, RELIC_BN_BITS, 4))); } BENCH_END; BENCH_BEGIN("bn_rec_jsf") { - signed char jsf[2 * (BN_BITS + 1)]; - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); - BENCH_ADD((len = 2 * (BN_BITS + 1), bn_rec_jsf(jsf, &len, a, b))); + signed char jsf[2 * (RELIC_BN_BITS + 1)]; + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); + BENCH_ADD((len = 2 * (RELIC_BN_BITS + 1), bn_rec_jsf(jsf, &len, a, b))); } BENCH_END; diff --git a/bench/bench_cp.c b/bench/bench_cp.c index c2e7d5f97..9549c8fba 100644 --- a/bench/bench_cp.c +++ b/bench/bench_cp.c @@ -38,7 +38,7 @@ static void rsa(void) { rsa_t pub, prv; - uint8_t in[10], new[10], h[MD_LEN], out[BN_BITS / 8 + 1]; + uint8_t in[10], new[10], h[MD_LEN], out[RELIC_BN_BITS / 8 + 1]; int out_len, new_len; rsa_null(pub); @@ -47,10 +47,10 @@ static void rsa(void) { rsa_new(pub); rsa_new(prv); - BENCH_ONCE("cp_rsa_gen", cp_rsa_gen(pub, prv, BN_BITS)); + BENCH_ONCE("cp_rsa_gen", cp_rsa_gen(pub, prv, RELIC_BN_BITS)); BENCH_BEGIN("cp_rsa_enc") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); BENCH_ADD(cp_rsa_enc(out, &out_len, in, sizeof(in), pub)); @@ -58,7 +58,7 @@ static void rsa(void) { } BENCH_END; BENCH_BEGIN("cp_rsa_dec") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); cp_rsa_enc(out, &out_len, in, sizeof(in), pub); @@ -66,10 +66,10 @@ static void rsa(void) { } BENCH_END; #if CP_RSA == BASIC || !defined(STRIP) - BENCH_ONCE("cp_rsa_gen_basic", cp_rsa_gen_basic(pub, prv, BN_BITS)); + BENCH_ONCE("cp_rsa_gen_basic", cp_rsa_gen_basic(pub, prv, RELIC_BN_BITS)); BENCH_BEGIN("cp_rsa_dec_basic") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len =out_len; rand_bytes(in, sizeof(in)); cp_rsa_enc(out, &out_len, in, sizeof(in), pub); @@ -78,10 +78,10 @@ static void rsa(void) { #endif #if CP_RSA == QUICK || !defined(STRIP) - BENCH_ONCE("cp_rsa_gen_quick", cp_rsa_gen_quick(pub, prv, BN_BITS)); + BENCH_ONCE("cp_rsa_gen_quick", cp_rsa_gen_quick(pub, prv, RELIC_BN_BITS)); BENCH_BEGIN("cp_rsa_dec_quick") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len =out_len; rand_bytes(in, sizeof(in)); cp_rsa_enc(out, &out_len, in, sizeof(in), pub); @@ -89,17 +89,17 @@ static void rsa(void) { } BENCH_END; #endif - BENCH_ONCE("cp_rsa_gen", cp_rsa_gen(pub, prv, BN_BITS)); + BENCH_ONCE("cp_rsa_gen", cp_rsa_gen(pub, prv, RELIC_BN_BITS)); BENCH_BEGIN("cp_rsa_sig (h = 0)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); BENCH_ADD(cp_rsa_sig(out, &out_len, in, sizeof(in), 0, prv)); } BENCH_END; BENCH_BEGIN("cp_rsa_sig (h = 1)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); md_map(h, in, sizeof(in)); @@ -107,7 +107,7 @@ static void rsa(void) { } BENCH_END; BENCH_BEGIN("cp_rsa_ver (h = 0)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); cp_rsa_sig(out, &out_len, in, sizeof(in), 0, prv); @@ -115,7 +115,7 @@ static void rsa(void) { } BENCH_END; BENCH_BEGIN("cp_rsa_ver (h = 1)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); md_map(h, in, sizeof(in)); @@ -124,17 +124,17 @@ static void rsa(void) { } BENCH_END; #if CP_RSA == BASIC || !defined(STRIP) - BENCH_ONCE("cp_rsa_gen_basic", cp_rsa_gen_basic(pub, prv, BN_BITS)); + BENCH_ONCE("cp_rsa_gen_basic", cp_rsa_gen_basic(pub, prv, RELIC_BN_BITS)); BENCH_BEGIN("cp_rsa_sig_basic (h = 0)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); BENCH_ADD(cp_rsa_sig_basic(out, &out_len, in, sizeof(in), 0, prv)); } BENCH_END; BENCH_BEGIN("cp_rsa_sig_basic (h = 1)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); md_map(h, in, sizeof(in)); @@ -143,17 +143,17 @@ static void rsa(void) { #endif #if CP_RSA == QUICK || !defined(STRIP) - BENCH_ONCE("cp_rsa_gen_quick", cp_rsa_gen_quick(pub, prv, BN_BITS)); + BENCH_ONCE("cp_rsa_gen_quick", cp_rsa_gen_quick(pub, prv, RELIC_BN_BITS)); BENCH_BEGIN("cp_rsa_sig_quick (h = 0)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); BENCH_ADD(cp_rsa_sig_quick(out, &out_len, in, sizeof(in), 0, prv)); } BENCH_END; BENCH_BEGIN("cp_rsa_sig_quick (h = 1)") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; new_len = out_len; rand_bytes(in, sizeof(in)); md_map(h, in, sizeof(in)); @@ -167,7 +167,7 @@ static void rsa(void) { static void rabin(void) { rabin_t pub, prv; - uint8_t in[1000], new[1000], out[BN_BITS / 8 + 1]; + uint8_t in[1000], new[1000], out[RELIC_BN_BITS / 8 + 1]; int in_len, out_len, new_len; rabin_null(pub); @@ -176,11 +176,11 @@ static void rabin(void) { rabin_new(pub); rabin_new(prv); - BENCH_ONCE("cp_rabin_gen", cp_rabin_gen(pub, prv, BN_BITS)); + BENCH_ONCE("cp_rabin_gen", cp_rabin_gen(pub, prv, RELIC_BN_BITS)); BENCH_BEGIN("cp_rabin_enc") { in_len = bn_size_bin(pub->n) - 9; - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; rand_bytes(in, in_len); BENCH_ADD(cp_rabin_enc(out, &out_len, in, in_len, pub)); cp_rabin_dec(new, &new_len, out, out_len, prv); @@ -189,7 +189,7 @@ static void rabin(void) { BENCH_BEGIN("cp_rabin_dec") { in_len = bn_size_bin(pub->n) - 9; new_len = in_len; - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; rand_bytes(in, in_len); cp_rabin_enc(out, &out_len, in, in_len, pub); BENCH_ADD(cp_rabin_dec(new, &new_len, out, out_len, prv)); @@ -202,7 +202,7 @@ static void rabin(void) { static void benaloh(void) { bdpe_t pub, prv; dig_t in, new; - uint8_t out[BN_BITS / 8 + 1]; + uint8_t out[RELIC_BN_BITS / 8 + 1]; int out_len; bdpe_null(pub); @@ -211,10 +211,10 @@ static void benaloh(void) { bdpe_new(pub); bdpe_new(prv); - BENCH_ONCE("cp_bdpe_gen", cp_bdpe_gen(pub, prv, bn_get_prime(47), BN_BITS)); + BENCH_ONCE("cp_bdpe_gen", cp_bdpe_gen(pub, prv, bn_get_prime(47), RELIC_BN_BITS)); BENCH_BEGIN("cp_bdpe_enc") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; rand_bytes(out, 1); in = out[0] % bn_get_prime(47); BENCH_ADD(cp_bdpe_enc(out, &out_len, in, pub)); @@ -222,7 +222,7 @@ static void benaloh(void) { } BENCH_END; BENCH_BEGIN("cp_bdpe_dec") { - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; rand_bytes(out, 1); in = out[0] % bn_get_prime(47); cp_bdpe_enc(out, &out_len, in, pub); @@ -235,7 +235,7 @@ static void benaloh(void) { static void paillier(void) { bn_t n, l; - uint8_t in[1000], new[1000], out[BN_BITS / 8 + 1]; + uint8_t in[1000], new[1000], out[RELIC_BN_BITS / 8 + 1]; int in_len, out_len; bn_null(n); @@ -244,11 +244,11 @@ static void paillier(void) { bn_new(n); bn_new(l); - BENCH_ONCE("cp_phpe_gen", cp_phpe_gen(n, l, BN_BITS / 2)); + BENCH_ONCE("cp_phpe_gen", cp_phpe_gen(n, l, RELIC_BN_BITS / 2)); BENCH_BEGIN("cp_phpe_enc") { in_len = bn_size_bin(n); - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; memset(in, 0, sizeof(in)); rand_bytes(in + 1, in_len - 1); BENCH_ADD(cp_phpe_enc(out, &out_len, in, in_len, n)); @@ -257,7 +257,7 @@ static void paillier(void) { BENCH_BEGIN("cp_bdpe_dec") { in_len = bn_size_bin(n); - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; memset(in, 0, sizeof(in)); rand_bytes(in + 1, in_len - 1); cp_phpe_enc(out, &out_len, in, in_len, n); diff --git a/bench/bench_eb.c b/bench/bench_eb.c index 1ff160be9..bbd0ad841 100644 --- a/bench/bench_eb.c +++ b/bench/bench_eb.c @@ -153,13 +153,13 @@ static void util(void) { } static void arith(void) { - eb_t p, q, r, t[EB_TABLE_MAX]; + eb_t p, q, r, t[RELIC_EB_TABLE_MAX]; bn_t k, l, n; eb_null(p); eb_null(q); eb_null(r); - for (int i = 0; i < EB_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EB_TABLE_MAX; i++) { eb_null(t[i]); } bn_null(k); bn_null(l); @@ -429,7 +429,7 @@ static void arith(void) { } BENCH_END; - for (int i = 0; i < EB_TABLE; i++) { + for (int i = 0; i < RELIC_EB_TABLE; i++) { eb_new(t[i]); } @@ -445,12 +445,12 @@ static void arith(void) { BENCH_ADD(eb_mul_fix(q, (const eb_t *)t, k)); } BENCH_END; - for (int i = 0; i < EB_TABLE; i++) { + for (int i = 0; i < RELIC_EB_TABLE; i++) { eb_free(t[i]); } #if EB_FIX == BASIC || !defined(STRIP) - for (int i = 0; i < EB_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EB_TABLE_BASIC; i++) { eb_new(t[i]); } BENCH_BEGIN("eb_mul_pre_basic") { @@ -464,13 +464,13 @@ static void arith(void) { eb_mul_pre_basic(t, p); BENCH_ADD(eb_mul_fix_basic(q, (const eb_t *)t, k)); } BENCH_END; - for (int i = 0; i < EB_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EB_TABLE_BASIC; i++) { eb_free(t[i]); } #endif #if EB_FIX == YAOWI || !defined(STRIP) - for (int i = 0; i < EB_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_YAOWI; i++) { eb_new(t[i]); } BENCH_BEGIN("eb_mul_pre_yaowi") { @@ -484,13 +484,13 @@ static void arith(void) { eb_mul_pre_yaowi(t, p); BENCH_ADD(eb_mul_fix_yaowi(q, (const eb_t *)t, k)); } BENCH_END; - for (int i = 0; i < EB_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_YAOWI; i++) { eb_free(t[i]); } #endif #if EB_FIX == NAFWI || !defined(STRIP) - for (int i = 0; i < EB_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_NAFWI; i++) { eb_new(t[i]); } BENCH_BEGIN("eb_mul_pre_nafwi") { @@ -504,13 +504,13 @@ static void arith(void) { eb_mul_pre_nafwi(t, p); BENCH_ADD(eb_mul_fix_nafwi(q, (const eb_t *)t, k)); } BENCH_END; - for (int i = 0; i < EB_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_NAFWI; i++) { eb_free(t[i]); } #endif #if EB_FIX == COMBS || !defined(STRIP) - for (int i = 0; i < EB_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBS; i++) { eb_new(t[i]); } BENCH_BEGIN("eb_mul_pre_combs") { @@ -524,13 +524,13 @@ static void arith(void) { eb_mul_pre_combs(t, p); BENCH_ADD(eb_mul_fix_combs(q, (const eb_t *)t, k)); } BENCH_END; - for (int i = 0; i < EB_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBS; i++) { eb_free(t[i]); } #endif #if EB_FIX == COMBD || !defined(STRIP) - for (int i = 0; i < EB_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBD; i++) { eb_new(t[i]); } BENCH_BEGIN("eb_mul_pre_combd") { @@ -544,13 +544,13 @@ static void arith(void) { eb_mul_pre_combd(t, p); BENCH_ADD(eb_mul_fix_combd(q, (const eb_t *)t, k)); } BENCH_END; - for (int i = 0; i < EB_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBD; i++) { eb_free(t[i]); } #endif #if EB_FIX == LWNAF || !defined(STRIP) - for (int i = 0; i < EB_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EB_TABLE_LWNAF; i++) { eb_new(t[i]); } BENCH_BEGIN("eb_mul_pre_lwnaf") { @@ -564,7 +564,7 @@ static void arith(void) { eb_mul_pre_lwnaf(t, p); BENCH_ADD(eb_mul_fix_lwnaf(q, (const eb_t *)t, k)); } BENCH_END; - for (int i = 0; i < EB_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EB_TABLE_LWNAF; i++) { eb_free(t[i]); } #endif diff --git a/bench/bench_ec.c b/bench/bench_ec.c index c6f9c005d..0c8cb1fa4 100644 --- a/bench/bench_ec.c +++ b/bench/bench_ec.c @@ -139,13 +139,13 @@ static void util(void) { } static void arith(void) { - ec_t p, q, r, t[EC_TABLE]; + ec_t p, q, r, t[RELIC_EC_TABLE]; bn_t k, l, n; ec_null(p); ec_null(q); ec_null(r); - for (int i = 0; i < EC_TABLE; i++) { + for (int i = 0; i < RELIC_EC_TABLE; i++) { ec_null(t[i]); } @@ -209,7 +209,7 @@ static void arith(void) { } BENCH_END; - for (int i = 0; i < EC_TABLE; i++) { + for (int i = 0; i < RELIC_EC_TABLE; i++) { ec_new(t[i]); } @@ -263,7 +263,7 @@ static void arith(void) { bn_free(k); bn_free(l); bn_free(n); - for (int i = 0; i < EC_TABLE; i++) { + for (int i = 0; i < RELIC_EC_TABLE; i++) { ec_free(t[i]); } } diff --git a/bench/bench_ed.c b/bench/bench_ed.c index 8625ce4f8..239d9abc4 100644 --- a/bench/bench_ed.c +++ b/bench/bench_ed.c @@ -148,13 +148,13 @@ static void util(void) { } static void arith(void) { - ed_t p, q, r, t[ED_TABLE_MAX]; + ed_t p, q, r, t[RELIC_ED_TABLE_MAX]; bn_t k, l, n; ed_null(p); ed_null(q); ed_null(r); - for (int i = 0; i < ED_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_ED_TABLE_MAX; i++) { ed_null(t[i]); } @@ -258,7 +258,7 @@ static void arith(void) { } BENCH_END; - for (int i = 0; i < ED_TABLE; i++) { + for (int i = 0; i < RELIC_ED_TABLE; i++) { ed_new(t[i]); } @@ -274,12 +274,12 @@ static void arith(void) { BENCH_ADD(ed_mul_fix(q, (const ed_t *)t, k)); } BENCH_END; - for (int i = 0; i < ED_TABLE; i++) { + for (int i = 0; i < RELIC_ED_TABLE; i++) { ed_free(t[i]); } #if ED_FIX == BASIC || !defined(STRIP) - for (int i = 0; i < ED_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_ED_TABLE_BASIC; i++) { ed_new(t[i]); } BENCH_BEGIN("ed_mul_pre_basic") { @@ -293,13 +293,13 @@ static void arith(void) { ed_mul_pre_basic(t, p); BENCH_ADD(ed_mul_fix_basic(q, (const ed_t *)t, k)); } BENCH_END; - for (int i = 0; i < ED_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_ED_TABLE_BASIC; i++) { ed_free(t[i]); } #endif #if ED_FIX == YAOWI || !defined(STRIP) - for (int i = 0; i < ED_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_ED_TABLE_YAOWI; i++) { ed_new(t[i]); } BENCH_BEGIN("ed_mul_pre_yaowi") { @@ -313,13 +313,13 @@ static void arith(void) { ed_mul_pre_yaowi(t, p); BENCH_ADD(ed_mul_fix_yaowi(q, (const ed_t *)t, k)); } BENCH_END; - for (int i = 0; i < ED_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_ED_TABLE_YAOWI; i++) { ed_free(t[i]); } #endif #if ED_FIX == NAFWI || !defined(STRIP) - for (int i = 0; i < ED_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_ED_TABLE_NAFWI; i++) { ed_new(t[i]); } BENCH_BEGIN("ed_mul_pre_nafwi") { @@ -333,13 +333,13 @@ static void arith(void) { ed_mul_pre_nafwi(t, p); BENCH_ADD(ed_mul_fix_nafwi(q, (const ed_t *)t, k)); } BENCH_END; - for (int i = 0; i < ED_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_ED_TABLE_NAFWI; i++) { ed_free(t[i]); } #endif #if ED_FIX == COMBS || !defined(STRIP) - for (int i = 0; i < ED_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_ED_TABLE_COMBS; i++) { ed_new(t[i]); } BENCH_BEGIN("ed_mul_pre_combs") { @@ -353,13 +353,13 @@ static void arith(void) { ed_mul_pre_combs(t, p); BENCH_ADD(ed_mul_fix_combs(q, (const ed_t *)t, k)); } BENCH_END; - for (int i = 0; i < ED_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_ED_TABLE_COMBS; i++) { ed_free(t[i]); } #endif #if ED_FIX == COMBD || !defined(STRIP) - for (int i = 0; i < ED_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_ED_TABLE_COMBD; i++) { ed_new(t[i]); } BENCH_BEGIN("ed_mul_pre_combd") { @@ -371,13 +371,13 @@ static void arith(void) { ed_mul_pre_combd(t, p); BENCH_ADD(ed_mul_fix_combd(q, (const ed_t *)t, k)); } BENCH_END; - for (int i = 0; i < ED_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_ED_TABLE_COMBD; i++) { ed_free(t[i]); } #endif #if ED_FIX == LWNAF || !defined(STRIP) - for (int i = 0; i < ED_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_ED_TABLE_LWNAF; i++) { ed_new(t[i]); } BENCH_BEGIN("ed_mul_pre_lwnaf") { @@ -391,7 +391,7 @@ static void arith(void) { ed_mul_pre_lwnaf(t, p); BENCH_ADD(ed_mul_fix_lwnaf(q, (const ed_t *)t, k)); } BENCH_END; - for (int i = 0; i < ED_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_ED_TABLE_LWNAF; i++) { ed_free(t[i]); } #endif diff --git a/bench/bench_ep.c b/bench/bench_ep.c index 81f2df1b2..865f6dc76 100644 --- a/bench/bench_ep.c +++ b/bench/bench_ep.c @@ -153,13 +153,13 @@ static void util(void) { } static void arith(void) { - ep_t p, q, r, t[EP_TABLE_MAX]; + ep_t p, q, r, t[RELIC_EP_TABLE_MAX]; bn_t k, l, n; ep_null(p); ep_null(q); ep_null(r); - for (int i = 0; i < EP_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EP_TABLE_MAX; i++) { ep_null(t[i]); } @@ -367,7 +367,7 @@ static void arith(void) { } BENCH_END; - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { ep_new(t[i]); } @@ -383,12 +383,12 @@ static void arith(void) { BENCH_ADD(ep_mul_fix(q, (const ep_t *)t, k)); } BENCH_END; - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { ep_free(t[i]); } #if EP_FIX == BASIC || !defined(STRIP) - for (int i = 0; i < EP_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EP_TABLE_BASIC; i++) { ep_new(t[i]); } BENCH_BEGIN("ep_mul_pre_basic") { @@ -402,13 +402,13 @@ static void arith(void) { ep_mul_pre_basic(t, p); BENCH_ADD(ep_mul_fix_basic(q, (const ep_t *)t, k)); } BENCH_END; - for (int i = 0; i < EP_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EP_TABLE_BASIC; i++) { ep_free(t[i]); } #endif #if EP_FIX == YAOWI || !defined(STRIP) - for (int i = 0; i < EP_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_YAOWI; i++) { ep_new(t[i]); } BENCH_BEGIN("ep_mul_pre_yaowi") { @@ -422,13 +422,13 @@ static void arith(void) { ep_mul_pre_yaowi(t, p); BENCH_ADD(ep_mul_fix_yaowi(q, (const ep_t *)t, k)); } BENCH_END; - for (int i = 0; i < EP_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_YAOWI; i++) { ep_free(t[i]); } #endif #if EP_FIX == NAFWI || !defined(STRIP) - for (int i = 0; i < EP_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_NAFWI; i++) { ep_new(t[i]); } BENCH_BEGIN("ep_mul_pre_nafwi") { @@ -442,13 +442,13 @@ static void arith(void) { ep_mul_pre_nafwi(t, p); BENCH_ADD(ep_mul_fix_nafwi(q, (const ep_t *)t, k)); } BENCH_END; - for (int i = 0; i < EP_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_NAFWI; i++) { ep_free(t[i]); } #endif #if EP_FIX == COMBS || !defined(STRIP) - for (int i = 0; i < EP_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBS; i++) { ep_new(t[i]); } BENCH_BEGIN("ep_mul_pre_combs") { @@ -462,13 +462,13 @@ static void arith(void) { ep_mul_pre_combs(t, p); BENCH_ADD(ep_mul_fix_combs(q, (const ep_t *)t, k)); } BENCH_END; - for (int i = 0; i < EP_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBS; i++) { ep_free(t[i]); } #endif #if EP_FIX == COMBD || !defined(STRIP) - for (int i = 0; i < EP_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBD; i++) { ep_new(t[i]); } BENCH_BEGIN("ep_mul_pre_combd") { @@ -480,13 +480,13 @@ static void arith(void) { ep_mul_pre_combd(t, p); BENCH_ADD(ep_mul_fix_combd(q, (const ep_t *)t, k)); } BENCH_END; - for (int i = 0; i < EP_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBD; i++) { ep_free(t[i]); } #endif #if EP_FIX == LWNAF || !defined(STRIP) - for (int i = 0; i < EP_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EP_TABLE_LWNAF; i++) { ep_new(t[i]); } BENCH_BEGIN("ep_mul_pre_lwnaf") { @@ -500,7 +500,7 @@ static void arith(void) { ep_mul_pre_lwnaf(t, p); BENCH_ADD(ep_mul_fix_lwnaf(q, (const ep_t *)t, k)); } BENCH_END; - for (int i = 0; i < EP_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EP_TABLE_LWNAF; i++) { ep_free(t[i]); } #endif diff --git a/bench/bench_epx.c b/bench/bench_epx.c index 33b571753..4fc77f29a 100644 --- a/bench/bench_epx.c +++ b/bench/bench_epx.c @@ -139,7 +139,7 @@ static void util(void) { } static void arith(void) { - ep2_t p, q, r, t[EPX_TABLE_MAX]; + ep2_t p, q, r, t[RELIC_EPX_TABLE_MAX]; bn_t k, n, l; fp2_t s; @@ -149,7 +149,7 @@ static void arith(void) { bn_null(k); bn_null(n); fp2_null(s); - for (int i = 0; i < EPX_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_MAX; i++) { ep2_null(t[i]); } @@ -357,7 +357,7 @@ static void arith(void) { } BENCH_END; - for (int i = 0; i < EPX_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_MAX; i++) { ep2_new(t[i]); } @@ -373,12 +373,12 @@ static void arith(void) { BENCH_ADD(ep2_mul_fix(q, t, k)); } BENCH_END; - for (int i = 0; i < EPX_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_MAX; i++) { ep2_free(t[i]); } #if EP_FIX == BASIC || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_BASIC; i++) { ep2_new(t[i]); } BENCH_BEGIN("ep2_mul_pre_basic") { @@ -392,13 +392,13 @@ static void arith(void) { ep2_mul_pre_basic(t, p); BENCH_ADD(ep2_mul_fix_basic(q, t, k)); } BENCH_END; - for (int i = 0; i < EPX_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_BASIC; i++) { ep2_free(t[i]); } #endif #if EP_FIX == YAOWI || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_YAOWI; i++) { ep2_new(t[i]); } BENCH_BEGIN("ep2_mul_pre_yaowi") { @@ -412,13 +412,13 @@ static void arith(void) { ep2_mul_pre_yaowi(t, p); BENCH_ADD(ep2_mul_fix_yaowi(q, t, k)); } BENCH_END; - for (int i = 0; i < EPX_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_YAOWI; i++) { ep2_free(t[i]); } #endif #if EP_FIX == NAFWI || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_NAFWI; i++) { ep2_new(t[i]); } BENCH_BEGIN("ep2_mul_pre_nafwi") { @@ -432,13 +432,13 @@ static void arith(void) { ep2_mul_pre_nafwi(t, p); BENCH_ADD(ep2_mul_fix_nafwi(q, t, k)); } BENCH_END; - for (int i = 0; i < EPX_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_NAFWI; i++) { ep2_free(t[i]); } #endif #if EP_FIX == COMBS || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBS; i++) { ep2_new(t[i]); } BENCH_BEGIN("ep2_mul_pre_combs") { @@ -452,13 +452,13 @@ static void arith(void) { ep2_mul_pre_combs(t, p); BENCH_ADD(ep2_mul_fix_combs(q, t, k)); } BENCH_END; - for (int i = 0; i < EPX_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBS; i++) { ep2_free(t[i]); } #endif #if EP_FIX == COMBD || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBD; i++) { ep2_new(t[i]); } BENCH_BEGIN("ep2_mul_pre_combd") { @@ -470,13 +470,13 @@ static void arith(void) { ep2_mul_pre_combd(t, p); BENCH_ADD(ep2_mul_fix_combd(q, t, k)); } BENCH_END; - for (int i = 0; i < EPX_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBD; i++) { ep2_free(t[i]); } #endif #if EP_FIX == LWNAF || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_LWNAF; i++) { ep2_new(t[i]); } BENCH_BEGIN("ep2_mul_pre_lwnaf") { @@ -490,7 +490,7 @@ static void arith(void) { ep2_mul_pre_lwnaf(t, p); BENCH_ADD(ep2_mul_fix_lwnaf(q, t, k)); } BENCH_END; - for (int i = 0; i < EPX_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_LWNAF; i++) { ep2_free(t[i]); } #endif diff --git a/bench/bench_fb.c b/bench/bench_fb.c index f52d68f1c..6262178a7 100644 --- a/bench/bench_fb.c +++ b/bench/bench_fb.c @@ -166,7 +166,7 @@ static void util(void) { } static void arith(void) { - fb_t a, b, c, d[2], t[FB_TABLE_MAX]; + fb_t a, b, c, d[2], t[RELIC_FB_TABLE_MAX]; dv_t e; bn_t f; int bits; @@ -176,7 +176,7 @@ static void arith(void) { fb_null(c); fb_null(d[0]); fb_null(d[1]); - for (int i = 0; i < FB_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_FB_TABLE_MAX; i++) { fb_null(t[i]); } dv_null(e); @@ -321,7 +321,7 @@ static void arith(void) { BENCH_END; #endif -#if FB_SQR == TABLE || !defined(STRIP) +#if FB_SQR == RELIC_TABLE || !defined(STRIP) BENCH_BEGIN("fb_sqr_table") { fb_rand(a); BENCH_ADD(fb_sqr_table(c, a)); @@ -548,7 +548,7 @@ static void arith(void) { BENCH_END; #endif - for (int i = 0; i < FB_TABLE; i++) { + for (int i = 0; i < RELIC_FB_TABLE; i++) { fb_new(t[i]); } @@ -560,7 +560,7 @@ static void arith(void) { } BENCH_END; - for (int i = 0; i < FB_TABLE; i++) { + for (int i = 0; i < RELIC_FB_TABLE; i++) { fb_free(t[i]); } @@ -574,7 +574,7 @@ static void arith(void) { #endif #if FB_ITR == QUICK || !defined(STRIP) - for (int i = 0; i < FB_TABLE_QUICK; i++) { + for (int i = 0; i < RELIC_FB_TABLE_QUICK; i++) { fb_new(t[i]); } BENCH_BEGIN("fb_itr_quick") { @@ -584,7 +584,7 @@ static void arith(void) { BENCH_ADD(fb_itr_quick(c, a, (const fb_t *)t)); } BENCH_END; - for (int i = 0; i < FB_TABLE_QUICK; i++) { + for (int i = 0; i < RELIC_FB_TABLE_QUICK; i++) { fb_new(t[i]); } #endif diff --git a/bench/bench_pc.c b/bench/bench_pc.c index 182a8ba84..d9e5d0d6c 100755 --- a/bench/bench_pc.c +++ b/bench/bench_pc.c @@ -136,13 +136,13 @@ static void util1(void) { } static void arith1(void) { - g1_t p, q, r, t[G1_TABLE]; + g1_t p, q, r, t[RELIC_G1_TABLE]; bn_t k, l, n; g1_null(p); g1_null(q); g1_null(r); - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g1_null(t[i]); } @@ -208,7 +208,7 @@ static void arith1(void) { } BENCH_END; - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g1_new(t[i]); } @@ -255,7 +255,7 @@ static void arith1(void) { bn_free(k); bn_free(l); bn_free(n); - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g1_free(t[i]); } } @@ -366,13 +366,13 @@ static void util2(void) { } static void arith2(void) { - g2_t p, q, r, t[G1_TABLE]; + g2_t p, q, r, t[RELIC_G1_TABLE]; bn_t k, l, n; g2_null(p); g2_null(q); g2_null(r); - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g2_null(t[i]); } @@ -438,7 +438,7 @@ static void arith2(void) { } BENCH_END; - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g2_new(t[i]); } @@ -485,7 +485,7 @@ static void arith2(void) { bn_free(k); bn_free(l); bn_free(n); - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g2_free(t[i]); } } diff --git a/cmake/arch.cmake b/cmake/arch.cmake index 313ec2062..fac55ec4a 100644 --- a/cmake/arch.cmake +++ b/cmake/arch.cmake @@ -5,7 +5,7 @@ message(" ARCH=MSP TI MSP430 16-bit architecture.") message(" ARCH=ARM ARM 32-bit architecture.") message(" ARCH=X86 Intel x86-compatible 32-bit architecture.") message(" ARCH=X64 AMD x86_64-compatible 64-bit architecture.") -message(" ARCH=NONE No specific architecture (disable some features).\n") +message(" ARCH=RELIC_NONE No specific architecture (disable some features).\n") message(STATUS "Available word sizes (default = 64):\n") diff --git a/cmake/fb.cmake b/cmake/fb.cmake index 6ba6a7f7b..a14cb6080 100644 --- a/cmake/fb.cmake +++ b/cmake/fb.cmake @@ -9,7 +9,7 @@ message(" FB_SQRTF=[off|on] Prefer square-root friendly polynomials.") message(" FB_PRECO=[off|on] Precompute multiplication table for sqrt(z).") message(" FB_WIDTH=w Width w in [2,6] of window processing for exponentiation methods.\n") -message(" ** Available binary field arithmetic methods (default = LODAH;TABLE;QUICK;BASIC;QUICK;QUICK;EXGCD;SLIDE;QUICK):\n") +message(" ** Available binary field arithmetic methods (default = LODAH;RELIC_TABLE;QUICK;BASIC;QUICK;QUICK;EXGCD;SLIDE;QUICK):\n") message(" Field multiplication:") message(" FB_METHD=BASIC Right-to-left shift-and-add multiplication.") @@ -21,7 +21,7 @@ message(" FB_METHD=LODAH L message(" Field squaring:") message(" FB_METHD=BASIC Bit manipulation squaring.") message(" FB_METHD=INTEG Integrated modular squaring.") -message(" FB_METHD=TABLE Table-based squaring.\n") +message(" FB_METHD=RELIC_TABLE Table-based squaring.\n") message(" Modular reduction:") message(" FB_METHD=BASIC Shift-and-add modular reduction.") @@ -80,7 +80,7 @@ option(FB_PRECO "Precompute multiplication table for sqrt(z)." on) # Choose the arithmetic methods. if (NOT FB_METHD) - set(FB_METHD "LODAH;TABLE;QUICK;QUICK;QUICK;QUICK;EXGCD;SLIDE;QUICK") + set(FB_METHD "LODAH;RELIC_TABLE;QUICK;QUICK;QUICK;QUICK;EXGCD;SLIDE;QUICK") endif(NOT FB_METHD) list(LENGTH FB_METHD FB_LEN) if (FB_LEN LESS 9) diff --git a/cmake/rand.cmake b/cmake/rand.cmake index bae5e0ac1..93f1cf507 100644 --- a/cmake/rand.cmake +++ b/cmake/rand.cmake @@ -1,7 +1,7 @@ message(STATUS "Available pseudo-random number generators (default = HASH):\n") message(" RAND=HASH Use the HASH-DRBG generator. (recommended)") -message(" RAND=HMAC Use the HMAC-DRBG generator. (recommended)") +message(" RAND=RELIC_HMAC Use the RELIC_HMAC-DRBG generator. (recommended)") message(" RAND=UDEV Use the operating system underlying generator.") message(" RAND=FIPS Use the FIPS 186-2 (CN1) SHA1-based generator.") message(" RAND=CALL Override the generator with a callback.\n") diff --git a/include/relic_bn.h b/include/relic_bn.h index 95ff0b1f3..950a6957a 100644 --- a/include/relic_bn.h +++ b/include/relic_bn.h @@ -51,7 +51,7 @@ * multiple precision integer must grow. Otherwise, it represents the fixed * fixed precision. */ -#define BN_BITS ((int)BN_PRECI) +#define RELIC_BN_BITS ((int)BN_PRECI) /** * Size in bits of a digit. @@ -66,12 +66,12 @@ /** * Size in digits of a block sufficient to store the required precision. */ -#define BN_DIGS ((int)((BN_BITS)/(BN_DIGIT) + (BN_BITS % BN_DIGIT > 0))) +#define BN_DIGS ((int)((RELIC_BN_BITS)/(BN_DIGIT) + (RELIC_BN_BITS % BN_DIGIT > 0))) /** * Size in bytes of a block sufficient to store the required precision. */ -#define BN_BYTES ((int)((BN_BITS)/8 + ((BN_BITS % 8) > 0))) +#define RELIC_BN_BYTES ((int)((RELIC_BN_BITS)/8 + ((RELIC_BN_BITS % 8) > 0))) /** * Size in digits of a block sufficient to store a multiple precision integer. diff --git a/include/relic_conf.h.in b/include/relic_conf.h.in index c78870c3f..1ae749cbf 100644 --- a/include/relic_conf.h.in +++ b/include/relic_conf.h.in @@ -33,7 +33,7 @@ #define RELIC_CONF_H /** Project version. */ -#define VERSION "@VERSION@" +#define RELIC_VERSION "@VERSION@" /** Debugging support. */ #cmakedefine DEBUG @@ -71,7 +71,7 @@ #define CORES @CORES@ /** Generic architecture. */ -#define NONE 1 +#define RELIC_NONE 1 /** Atmel AVR ATMega128 8-bit architecture. */ #define AVR 2 /** MSP430 16-bit architecture. */ @@ -322,7 +322,7 @@ /** Basic squaring. */ #define BASIC 1 /** Table-based squaring. */ -#define TABLE 2 +#define RELIC_TABLE 2 /** Integrated modular squaring. */ #define INTEG 3 /** Chosen binary field squaring method. */ @@ -663,7 +663,7 @@ /** NIST HASH-DRBG generator. */ #define HASH 1 /** NIST HMAC-DRBG generator. */ -#define HMAC 2 +#define RELIC_HMAC 2 /** Operating system underlying generator. */ #define UDEV 3 /** Intel RdRand instruction. */ @@ -691,7 +691,7 @@ #define SEED @SEED@ /** Undefined/No operating system. */ -#define NONE 1 +#define RELIC_NONE 1 /** GNU/Linux operating system. */ #define LINUX 2 /** FreeBSD operating system. */ @@ -708,7 +708,7 @@ #define OPSYS @OPSYS@ /** No multithreading. */ -#define NONE 1 +#define RELIC_NONE 1 /** OpenMP multithreading support. */ #define OPENMP 2 /** POSIX multithreading support. */ @@ -717,7 +717,7 @@ #define MULTI @MULTI@ /** No timer. */ -#define NONE 1 +#define RELIC_NONE 1 /** Per-process high-resolution timer. */ #define HREAL 2 /** Per-process high-resolution timer. */ diff --git a/include/relic_core.h b/include/relic_core.h index 2bb7ad3ec..41525e5d4 100644 --- a/include/relic_core.h +++ b/include/relic_core.h @@ -51,7 +51,7 @@ #include "relic_pool.h" #include "relic_label.h" -#if MULTI != NONE +#if MULTI != RELIC_NONE #include #if MULTI == OPENMP @@ -60,7 +60,7 @@ #include #endif /* OPENMP */ -#endif /* MULTI != NONE */ +#endif /* MULTI != RELIC_NONE */ /*============================================================================*/ /* Constant definitions */ @@ -127,7 +127,7 @@ /** * Optimization identifier for the case where the coefficient is random */ -#define OPT_NONE 5 +#define RELIC_OPT_NONE 5 /** * Maximum number of terms to describe a sparse object. @@ -201,9 +201,9 @@ typedef struct _ctx_t { /** Stores the length of the addition chain. */ int chain_len; /** Tables for repeated squarings. */ - fb_st fb_tab_sqr[MAX_TERMS][FB_TABLE]; + fb_st fb_tab_sqr[MAX_TERMS][RELIC_FB_TABLE]; /** Pointers to the elements in the tables of repeated squarings. */ - fb_st *fb_tab_ptr[MAX_TERMS][FB_TABLE]; + fb_st *fb_tab_ptr[MAX_TERMS][RELIC_FB_TABLE]; #endif /* FB_INV == ITOHT */ #endif /* WITH_FB */ @@ -228,9 +228,9 @@ typedef struct _ctx_t { int eb_is_kbltz; #ifdef EB_PRECO /** Precomputation table for generator multiplication. */ - eb_st eb_pre[EB_TABLE]; + eb_st eb_pre[RELIC_EB_TABLE]; /** Array of pointers to the precomputation table. */ - eb_st *eb_ptr[EB_TABLE]; + eb_st *eb_ptr[RELIC_EB_TABLE]; #endif /* EB_PRECO */ #endif /* WITH_EB */ @@ -293,9 +293,9 @@ typedef struct _ctx_t { int ep_is_super; #ifdef EP_PRECO /** Precomputation table for generator multiplication. */ - ep_st ep_pre[EP_TABLE]; + ep_st ep_pre[RELIC_EP_TABLE]; /** Array of pointers to the precomputation table. */ - ep_st *ep_ptr[EP_TABLE]; + ep_st *ep_ptr[RELIC_EP_TABLE]; #endif /* EP_PRECO */ #endif /* WITH_EP */ @@ -322,13 +322,13 @@ typedef struct _ctx_t { int ep2_is_twist; #ifdef EP_PRECO /** Precomputation table for generator multiplication.*/ - ep2_st ep2_pre[EP_TABLE]; + ep2_st ep2_pre[RELIC_EP_TABLE]; /** Array of pointers to the precomputation table. */ - ep2_st *ep2_ptr[EP_TABLE]; + ep2_st *ep2_ptr[RELIC_EP_TABLE]; #endif /* EP_PRECO */ #if ALLOC == STACK /** In case of stack allocation, we need to get global memory for the table. */ - fp2_st _ep2_pre[3 * EP_TABLE]; + fp2_st _ep2_pre[3 * RELIC_EP_TABLE]; #endif /* ALLOC == STACK */ #endif /* WITH_EPX */ @@ -348,9 +348,9 @@ typedef struct _ctx_t { #ifdef ED_PRECO /** Precomputation table for generator multiplication. */ - ed_st ed_pre[ED_TABLE]; + ed_st ed_pre[RELIC_ED_TABLE]; /** Array of pointers to the precomputation table. */ - ed_st *ed_ptr[ED_TABLE]; + ed_st *ed_ptr[RELIC_ED_TABLE]; #endif /* ED_PRECO */ #endif diff --git a/include/relic_cp.h b/include/relic_cp.h index f9072933b..6e32e465b 100644 --- a/include/relic_cp.h +++ b/include/relic_cp.h @@ -94,15 +94,15 @@ typedef struct _rsa_t { bn_t dq; /** The inverse of q modulo p. */ bn_t qi; -} rsa_st; +} relic_rsa_st; /** * Pointer to an RSA key pair. */ #if ALLOC == AUTO -typedef rsa_st rsa_t[1]; +typedef relic_rsa_st rsa_t[1]; #else -typedef rsa_st *rsa_t; +typedef relic_rsa_st *rsa_t; #endif /** @@ -265,7 +265,7 @@ typedef vbnn_ibs_user_st *vbnn_ibs_user_t; */ #if ALLOC == DYNAMIC #define rsa_new(A) \ - A = (rsa_t)calloc(1, sizeof(rsa_st)); \ + A = (rsa_t)calloc(1, sizeof(relic_rsa_st)); \ if (A == NULL) { \ THROW(ERR_NO_MEMORY); \ } \ @@ -288,7 +288,7 @@ typedef vbnn_ibs_user_st *vbnn_ibs_user_t; #elif ALLOC == STATIC #define rsa_new(A) \ - A = (rsa_t)alloca(sizeof(rsa_st)); \ + A = (rsa_t)alloca(sizeof(relic_rsa_st)); \ if (A == NULL) { \ THROW(ERR_NO_MEMORY); \ } \ @@ -322,7 +322,7 @@ typedef vbnn_ibs_user_st *vbnn_ibs_user_t; #elif ALLOC == STACK #define rsa_new(A) \ - A = (rsa_t)alloca(sizeof(rsa_st)); \ + A = (rsa_t)alloca(sizeof(relic_rsa_st)); \ bn_new((A)->e); \ bn_new((A)->n); \ bn_new((A)->d); \ diff --git a/include/relic_eb.h b/include/relic_eb.h index b2013ea9b..5a069f5cb 100644 --- a/include/relic_eb.h +++ b/include/relic_eb.h @@ -80,57 +80,57 @@ enum { /** * Size of a precomputation table using the binary method. */ -#define EB_TABLE_BASIC (FB_BITS) +#define RELIC_EB_TABLE_BASIC (FB_BITS) /** * Size of a precomputation table using Yao's windowing method. */ -#define EB_TABLE_YAOWI (FB_BITS / EB_DEPTH + 1) +#define RELIC_EB_TABLE_YAOWI (FB_BITS / EB_DEPTH + 1) /** * Size of a precomputation table using the NAF windowing method. */ -#define EB_TABLE_NAFWI (FB_BITS / EB_DEPTH + 1) +#define RELIC_EB_TABLE_NAFWI (FB_BITS / EB_DEPTH + 1) /** * Size of a precomputation table using the single-table comb method. */ -#define EB_TABLE_COMBS (1 << EB_DEPTH) +#define RELIC_EB_TABLE_COMBS (1 << EB_DEPTH) /** * Size of a precomputation table using the double-table comb method. */ -#define EB_TABLE_COMBD (1 << (EB_DEPTH + 1)) +#define RELIC_EB_TABLE_COMBD (1 << (EB_DEPTH + 1)) /** * Size of a precomputation table using the w-(T)NAF method. */ -#define EB_TABLE_LWNAF (1 << (EB_DEPTH - 2)) +#define RELIC_EB_TABLE_LWNAF (1 << (EB_DEPTH - 2)) /** * Size of a precomputation table using the chosen algorithm. */ #if EB_FIX == BASIC -#define EB_TABLE EB_TABLE_BASIC +#define RELIC_EB_TABLE RELIC_EB_TABLE_BASIC #elif EB_FIX == YAOWI -#define EB_TABLE EB_TABLE_YAOWI +#define RELIC_EB_TABLE RELIC_EB_TABLE_YAOWI #elif EB_FIX == NAFWI -#define EB_TABLE EB_TABLE_NAFWI +#define RELIC_EB_TABLE RELIC_EB_TABLE_NAFWI #elif EB_FIX == COMBS -#define EB_TABLE EB_TABLE_COMBS +#define RELIC_EB_TABLE RELIC_EB_TABLE_COMBS #elif EB_FIX == COMBD -#define EB_TABLE EB_TABLE_COMBD +#define RELIC_EB_TABLE RELIC_EB_TABLE_COMBD #elif EB_FIX == LWNAF -#define EB_TABLE EB_TABLE_LWNAF +#define RELIC_EB_TABLE RELIC_EB_TABLE_LWNAF #endif /** * Maximum size of a precomputation table. */ #ifdef STRIP -#define EB_TABLE_MAX EB_TABLE +#define RELIC_EB_TABLE_MAX RELIC_EB_TABLE #else -#define EB_TABLE_MAX MAX(EB_TABLE_BASIC, EB_TABLE_COMBD) +#define RELIC_EB_TABLE_MAX MAX(RELIC_EB_TABLE_BASIC, RELIC_EB_TABLE_COMBD) #endif /*============================================================================*/ diff --git a/include/relic_ec.h b/include/relic_ec.h index 8b792b79c..ddcd20c92 100644 --- a/include/relic_ec.h +++ b/include/relic_ec.h @@ -73,11 +73,11 @@ * Size of a precomputation table using the chosen algorithm. */ #if EC_CUR == PRIME -#define EC_TABLE EP_TABLE +#define RELIC_EC_TABLE RELIC_EP_TABLE #elif EC_CUR == CHAR2 -#define EC_TABLE EB_TABLE +#define RELIC_EC_TABLE RELIC_EB_TABLE #elif EC_CUR == EDWARD -#define EC_TABLE ED_TABLE +#define RELIC_EC_TABLE RELIC_ED_TABLE #endif /** diff --git a/include/relic_ed.h b/include/relic_ed.h index 2625a36d8..6426a95ef 100644 --- a/include/relic_ed.h +++ b/include/relic_ed.h @@ -58,59 +58,59 @@ enum { /** * Size of a precomputation table using the binary method. */ -#define ED_TABLE_BASIC (FP_BITS + 1) +#define RELIC_ED_TABLE_BASIC (FP_BITS + 1) /** * Size of a precomputation table using Yao's windowing method. */ -#define ED_TABLE_YAOWI (FP_BITS / ED_DEPTH + 1) +#define RELIC_ED_TABLE_YAOWI (FP_BITS / ED_DEPTH + 1) /** * Size of a precomputation table using the NAF windowing method. */ -#define ED_TABLE_NAFWI (FP_BITS / ED_DEPTH + 1) +#define RELIC_ED_TABLE_NAFWI (FP_BITS / ED_DEPTH + 1) /** * Size of a precomputation table using the single-table comb method. */ -#define ED_TABLE_COMBS (1 << ED_DEPTH) +#define RELIC_ED_TABLE_COMBS (1 << ED_DEPTH) /** * Size of a precomputation table using the double-table comb method. */ -#define ED_TABLE_COMBD (1 << (ED_DEPTH + 1)) +#define RELIC_ED_TABLE_COMBD (1 << (ED_DEPTH + 1)) /** * Size of a precomputation table using the w-(T)NAF method. */ -#define ED_TABLE_LWNAF (1 << (ED_DEPTH - 2)) +#define RELIC_ED_TABLE_LWNAF (1 << (ED_DEPTH - 2)) /** * Size of a precomputation table using the chosen algorithm. */ #if ED_FIX == BASIC -#define ED_TABLE ED_TABLE_BASIC +#define RELIC_ED__TABLE RELIC_ED_TABLE_BASIC #elif ED_FIX == YAOWI -#define ED_TABLE ED_TABLE_YAOWI +#define RELIC_ED_TABLE RELIC_ED_TABLE_YAOWI #elif ED_FIX == NAFWI -#define ED_TABLE ED_TABLE_NAFWI +#define RELIC_ED_TABLE RELIC_ED_TABLE_NAFWI #elif ED_FIX == COMBS -#define ED_TABLE ED_TABLE_COMBS +#define RELIC_ED_TABLE RELIC_ED_TABLE_COMBS #elif ED_FIX == COMBD -#define ED_TABLE ED_TABLE_COMBD +#define RELIC_ED_TABLE RELIC_ED_TABLE_COMBD #elif ED_FIX == LWNAF -#define ED_TABLE ED_TABLE_LWNAF +#define RELIC_ED_TABLE RELIC_ED_TABLE_LWNAF #elif ED_FIX == LWNAF_MIXED -#define ED_TABLE ED_TABLE_LWNAF +#define RELIC_ED_TABLE RELIC_ED_TABLE_LWNAF #endif /** * Maximum size of a precomputation table. */ #ifdef STRIP -#define ED_TABLE_MAX ED_TABLE +#define RELIC_ED_TABLE_MAX RELIC_ED_TABLE #else -#define ED_TABLE_MAX MAX(ED_TABLE_BASIC, ED_TABLE_COMBD) +#define RELIC_ED_TABLE_MAX MAX(RELIC_ED_TABLE_BASIC, RELIC_ED_TABLE_COMBD) #endif /*============================================================================*/ diff --git a/include/relic_ep.h b/include/relic_ep.h index 806b20b73..87de16d97 100644 --- a/include/relic_ep.h +++ b/include/relic_ep.h @@ -119,57 +119,57 @@ enum { /** * Size of a precomputation table using the binary method. */ -#define EP_TABLE_BASIC (FP_BITS + 1) +#define RELIC_EP_TABLE_BASIC (FP_BITS + 1) /** * Size of a precomputation table using Yao's windowing method. */ -#define EP_TABLE_YAOWI (FP_BITS / EP_DEPTH + 1) +#define RELIC_EP_TABLE_YAOWI (FP_BITS / EP_DEPTH + 1) /** * Size of a precomputation table using the NAF windowing method. */ -#define EP_TABLE_NAFWI (FP_BITS / EP_DEPTH + 1) +#define RELIC_EP_TABLE_NAFWI (FP_BITS / EP_DEPTH + 1) /** * Size of a precomputation table using the single-table comb method. */ -#define EP_TABLE_COMBS (1 << EP_DEPTH) +#define RELIC_EP_TABLE_COMBS (1 << EP_DEPTH) /** * Size of a precomputation table using the double-table comb method. */ -#define EP_TABLE_COMBD (1 << (EP_DEPTH + 1)) +#define RELIC_EP_TABLE_COMBD (1 << (EP_DEPTH + 1)) /** * Size of a precomputation table using the w-(T)NAF method. */ -#define EP_TABLE_LWNAF (1 << (EP_DEPTH - 2)) +#define RELIC_EP_TABLE_LWNAF (1 << (EP_DEPTH - 2)) /** * Size of a precomputation table using the chosen algorithm. */ #if EP_FIX == BASIC -#define EP_TABLE EP_TABLE_BASIC +#define RELIC_EP_TABLE RELIC_EP_TABLE_BASIC #elif EP_FIX == YAOWI -#define EP_TABLE EP_TABLE_YAOWI +#define RELIC_EP_TABLE RELIC_EP_TABLE_YAOWI #elif EP_FIX == NAFWI -#define EP_TABLE EP_TABLE_NAFWI +#define RELIC_EP_TABLE RELIC_EP_TABLE_NAFWI #elif EP_FIX == COMBS -#define EP_TABLE EP_TABLE_COMBS +#define RELIC_EP_TABLE RELIC_EP_TABLE_COMBS #elif EP_FIX == COMBD -#define EP_TABLE EP_TABLE_COMBD +#define RELIC_EP_TABLE RELIC_EP_TABLE_COMBD #elif EP_FIX == LWNAF -#define EP_TABLE EP_TABLE_LWNAF +#define RELIC_EP_TABLE RELIC_EP_TABLE_LWNAF #endif /** * Maximum size of a precomputation table. */ #ifdef STRIP -#define EP_TABLE_MAX EP_TABLE +#define RELIC_EP_TABLE_MAX RELIC_EP_TABLE #else -#define EP_TABLE_MAX MAX(EP_TABLE_BASIC, EP_TABLE_COMBD) +#define RELIC_EP_TABLE_MAX MAX(RELIC_EP_TABLE_BASIC, RELIC_EP_TABLE_COMBD) #endif /*============================================================================*/ diff --git a/include/relic_epx.h b/include/relic_epx.h index a1d92197c..3a8ab0f03 100644 --- a/include/relic_epx.h +++ b/include/relic_epx.h @@ -47,57 +47,57 @@ /** * Size of a precomputation table using the binary method. */ -#define EPX_TABLE_BASIC (2 * FP_BITS + 1) +#define RELIC_EPX_TABLE_BASIC (2 * FP_BITS + 1) /** * Size of a precomputation table using Yao's windowing method. */ -#define EPX_TABLE_YAOWI (2 * FP_BITS / EP_DEPTH + 1) +#define RELIC_EPX_TABLE_YAOWI (2 * FP_BITS / EP_DEPTH + 1) /** * Size of a precomputation table using the NAF windowing method. */ -#define EPX_TABLE_NAFWI (2 * FP_BITS / EP_DEPTH + 1) +#define RELIC_EPX_TABLE_NAFWI (2 * FP_BITS / EP_DEPTH + 1) /** * Size of a precomputation table using the single-table comb method. */ -#define EPX_TABLE_COMBS (1 << EP_DEPTH) +#define RELIC_EPX_TABLE_COMBS (1 << EP_DEPTH) /** * Size of a precomputation table using the double-table comb method. */ -#define EPX_TABLE_COMBD (1 << (EP_DEPTH + 1)) +#define RELIC_EPX_TABLE_COMBD (1 << (EP_DEPTH + 1)) /** * Size of a precomputation table using the w-(T)NAF method. */ -#define EPX_TABLE_LWNAF (1 << (EP_DEPTH - 2)) +#define RELIC_EPX_TABLE_LWNAF (1 << (EP_DEPTH - 2)) /** * Size of a precomputation table using the chosen algorithm. */ #if EP_FIX == BASIC -#define EPX_TABLE EPX_TABLE_BASIC +#define RELIC_EPX_TABLE RELIC_EPX_TABLE_BASIC #elif EP_FIX == YAOWI -#define EPX_TABLE EPX_TABLE_YAOWI +#define RELIC_EPX_TABLE RELIC_EPX_TABLE_YAOWI #elif EP_FIX == NAFWI -#define EPX_TABLE EPX_TABLE_NAFWI +#define RELIC_EPX_TABLE RELIC_EPX_TABLE_NAFWI #elif EP_FIX == COMBS -#define EPX_TABLE EPX_TABLE_COMBS +#define RELIC_EPX_TABLE RELIC_EPX_TABLE_COMBS #elif EP_FIX == COMBD -#define EPX_TABLE EPX_TABLE_COMBD +#define RELIC_EPX_TABLE RELIC_EPX_TABLE_COMBD #elif EP_FIX == LWNAF -#define EPX_TABLE EPX_TABLE_LWNAF +#define RELIC_EPX_TABLE RELIC_EPX_TABLE_LWNAF #endif /** * Maximum size of a precomputation table. */ #ifdef STRIP -#define EPX_TABLE_MAX EPX_TABLE +#define RELIC_EPX_TABLE_MAX RELIC_EPX_TABLE #else -#define EPX_TABLE_MAX MAX(EPX_TABLE_BASIC, EPX_TABLE_COMBD) +#define RELIC_EPX_TABLE_MAX MAX(RELIC_EPX_TABLE_BASIC, RELIC_EPX_TABLE_COMBD) #endif diff --git a/include/relic_fb.h b/include/relic_fb.h index 108f8a4eb..e1894d308 100644 --- a/include/relic_fb.h +++ b/include/relic_fb.h @@ -134,31 +134,31 @@ enum { * Size of a precomputation table for repeated squaring/square-root using the * trivial approach. */ -#define FB_TABLE_BASIC (1) +#define RELIC_FB_TABLE_BASIC (1) /** * Size of a precomputation table for repeated squaring/square-root using the * faster approach. */ -#define FB_TABLE_QUICK ((FB_DIGIT / 4) * FB_DIGS * 16) +#define RELIC_FB_TABLE_QUICK ((FB_DIGIT / 4) * FB_DIGS * 16) /** * Size of a precomputation table for repeated squaring/square-root using the * chosen algorithm. */ #if FB_ITR == BASIC -#define FB_TABLE FB_TABLE_BASIC +#define RELIC_FB_TABLE RELIC_FB_TABLE_BASIC #else -#define FB_TABLE FB_TABLE_QUICK +#define RELIC_FB_TABLE RELIC_FB_TABLE_QUICK #endif /** * Maximum size of a precomputation table. */ #ifdef STRIP -#define FB_TABLE_MAX FB_TABLE +#define RELIC_FB_TABLE_MAX RELIC_FB_TABLE #else -#define FB_TABLE_MAX FB_TABLE_QUICK +#define RELIC_FB_TABLE_MAX RELIC_FB_TABLE_QUICK #endif /*============================================================================*/ @@ -257,7 +257,7 @@ typedef align dig_t fb_st[FB_DIGS + PADDING(FB_BYTES)/(FB_DIGIT / 8)]; */ #if FB_SQR == BASIC #define fb_sqr(C, A) fb_sqr_basic(C, A) -#elif FB_SQR == TABLE +#elif FB_SQR == RELIC_TABLE #define fb_sqr(C, A) fb_sqr_table(C, A) #elif FB_SQR == INTEG #define fb_sqr(C, A) fb_sqr_integ(C, A) diff --git a/include/relic_md.h b/include/relic_md.h index f1bd18643..f59c3d564 100644 --- a/include/relic_md.h +++ b/include/relic_md.h @@ -216,7 +216,7 @@ void md_kdf2(uint8_t *key, int key_len, const uint8_t *in, int in_len); void md_mgf1(uint8_t *mask, int mask_len, const uint8_t *in, int in_len); /** - * Computes a Message Authentication Code through HMAC. + * Computes a Message Authentication Code through RELIC_HMAC. * * @param[out] mac - the authentication. * @param[in] in - the date to authenticate. diff --git a/include/relic_pc.h b/include/relic_pc.h index 9d0dceab7..973bda37d 100644 --- a/include/relic_pc.h +++ b/include/relic_pc.h @@ -82,12 +82,12 @@ /** * Represents a G_1 precomputable table. */ -#define G1_TABLE CAT(G1_UPPER, _TABLE_MAX) +#define RELIC_G1_TABLE CAT(G1_UPPER, _RELIC_TABLE_MAX) /** * Represents a G_2 precomputable table. */ -#define G2_TABLE CAT(G2_UPPER, _TABLE_MAX) +#define RELIC_G2_TABLE CAT(G2_UPPER, _RELIC_TABLE_MAX) /*============================================================================*/ /* Type definitions */ diff --git a/preset/avr-ecc-80k-sim.sh b/preset/avr-ecc-80k-sim.sh index e3ba08086..e46ea6fcd 100755 --- a/preset/avr-ecc-80k-sim.sh +++ b/preset/avr-ecc-80k-sim.sh @@ -1,2 +1,2 @@ #!/bin/bash -cmake -DWORD=8 -DOPSYS=NONE -DRAND=FIPS -DSEED=LIBC -DSHLIB=ON -DSTBIN=ON -DTIMER=NONE -DWITH="ALL" -DBENCH=20 -DTESTS=20 -DCHECK=off -DVERBS=off -DSTRIP=on -DQUIET=off -DARITH=easy -DFB_POLYN=163 -DFB_METHD="INTEG;INTEG;QUICK;QUICK;QUICK;QUICK;EXGCD;BASIC;BASIC" -DFB_PRECO=off -DFB_TRINO=off -DBN_PRECI=160 -DBN_MAGNI=DOUBLE -DEB_PRECO=on -DEB_METHD="PROJC;RWNAF;LWNAF;INTER" -DEB_MIXED=on -DEB_KBLTZ=on -DEB_PLAIN=off -DEC_METHD="CHAR2" -DEC_ENDOM=on -DMD_METHD=SHONE $1 +cmake -DWORD=8 -DOPSYS=RELIC_NONE -DRAND=FIPS -DSEED=LIBC -DSHLIB=ON -DSTBIN=ON -DTIMER=RELIC_NONE -DWITH="ALL" -DBENCH=20 -DTESTS=20 -DCHECK=off -DVERBS=off -DSTRIP=on -DQUIET=off -DARITH=easy -DFB_POLYN=163 -DFB_METHD="INTEG;INTEG;QUICK;QUICK;QUICK;QUICK;EXGCD;BASIC;BASIC" -DFB_PRECO=off -DFB_TRINO=off -DBN_PRECI=160 -DBN_MAGNI=DOUBLE -DEB_PRECO=on -DEB_METHD="PROJC;RWNAF;LWNAF;INTER" -DEB_MIXED=on -DEB_KBLTZ=on -DEB_PLAIN=off -DEC_METHD="CHAR2" -DEC_ENDOM=on -DMD_METHD=SHONE $1 diff --git a/preset/avr-ecc-80k.sh b/preset/avr-ecc-80k.sh index 2ad3ab7d8..49bb297b1 100755 --- a/preset/avr-ecc-80k.sh +++ b/preset/avr-ecc-80k.sh @@ -1,2 +1,2 @@ #!/bin/bash -CC=avr-gcc CXX=avr-c++ LINK="-mmcu=atmega128 -Wl,-gc-sections" COMP="-O2 -ggdb -Wa,-mmcu=atmega128 -mmcu=atmega128 -ffunction-sections -fdata-sections" cmake -DCMAKE_SYSTEM_NAME=Generic -DARCH=AVR -DWORD=8 -DOPSYS=NONE -DRAND=FIPS -DSEED=LIBC -DSHLIB=OFF -DSTBIN=ON -DTIMER=NONE -DWITH="DV;MD;BN;FB;EB;EC" -DBENCH=10 -DTESTS=10 -DCHECK=off -DVERBS=off -DSTRIP=on -DQUIET=off -DCOLOR=off -DARITH=avr-asm-163 -DFB_POLYN=163 -DBN_METHD="COMBA;COMBA;BASIC;BASIC;STEIN;BASIC" -DFB_METHD="INTEG;INTEG;QUICK;BASIC;BASIC;BASIC;EXGCD;BASIC;BASIC" -DFB_PRECO=off -DFB_TRINO=off -DBN_PRECI=160 -DBN_MAGNI=DOUBLE -DEB_PRECO=on -DEB_METHD="PROJC;RWNAF;LWNAF;INTER" -DEB_MIXED=on -DEB_KBLTZ=on -DEB_PLAIN=off -DEC_METHD="CHAR2" -DMD_METHD=SHONE $1 +CC=avr-gcc CXX=avr-c++ LINK="-mmcu=atmega128 -Wl,-gc-sections" COMP="-O2 -ggdb -Wa,-mmcu=atmega128 -mmcu=atmega128 -ffunction-sections -fdata-sections" cmake -DCMAKE_SYSTEM_NAME=Generic -DARCH=AVR -DWORD=8 -DOPSYS=RELIC_NONE -DRAND=FIPS -DSEED=LIBC -DSHLIB=OFF -DSTBIN=ON -DTIMER=RELIC_NONE -DWITH="DV;MD;BN;FB;EB;EC" -DBENCH=10 -DTESTS=10 -DCHECK=off -DVERBS=off -DSTRIP=on -DQUIET=off -DCOLOR=off -DARITH=avr-asm-163 -DFB_POLYN=163 -DBN_METHD="COMBA;COMBA;BASIC;BASIC;STEIN;BASIC" -DFB_METHD="INTEG;INTEG;QUICK;BASIC;BASIC;BASIC;EXGCD;BASIC;BASIC" -DFB_PRECO=off -DFB_TRINO=off -DBN_PRECI=160 -DBN_MAGNI=DOUBLE -DEB_PRECO=on -DEB_METHD="PROJC;RWNAF;LWNAF;INTER" -DEB_MIXED=on -DEB_KBLTZ=on -DEB_PLAIN=off -DEC_METHD="CHAR2" -DMD_METHD=SHONE $1 diff --git a/preset/avr-pbc-80.sh b/preset/avr-pbc-80.sh index d49701edb..879652aa1 100755 --- a/preset/avr-pbc-80.sh +++ b/preset/avr-pbc-80.sh @@ -1,2 +1,2 @@ #!/bin/bash -CC=avr-gcc CXX=c++ LINK="-mmcu=atmega128 -Wl,-gc-sections" COMP="-O2 -ggdb -Wa,-mmcu=atmega128 -mmcu=atmega128 -ffunction-sections -fdata-sections" cmake -DARCH=AVR -DWORD=8 -DOPSYS=NONE -DSEED=LIBC -DSHLIB=OFF -DSTBIN=ON -DTIMER=NONE -DWITH="DV;MD;BN;FP;FPX;EP;EC;PP;PC" -DBENCH=20 -DTESTS=20 -DCHECK=off -DVERBS=off -DSTRIP=on -DQUIET=on -DARITH=avr-asm-158 -DFP_PRIME=158 -DBN_METHD="COMBA;COMBA;MONTY;BASIC;STEIN;BASIC" -DFP_QNRES=off -DFP_METHD="INTEG;COMBA;COMBA;MONTY;MONTY;SLIDE" -DBN_PRECI=160 -DBN_MAGNI=DOUBLE -DEP_PRECO=off -DEP_METHD="PROJC;LWNAF;LWNAF;BASIC" -DEP_ENDOM=on -DEP_PLAIN=on -DEC_METHD="PRIME" -DFPX_METHD="INTEG;INTEG;BASIC" -DPP_METHD="BASIC;OATEP" -DRAND=FIPS -DSEED=LIBC -DMD_METHD=SHONE $1 +CC=avr-gcc CXX=c++ LINK="-mmcu=atmega128 -Wl,-gc-sections" COMP="-O2 -ggdb -Wa,-mmcu=atmega128 -mmcu=atmega128 -ffunction-sections -fdata-sections" cmake -DARCH=AVR -DWORD=8 -DOPSYS=RELIC_NONE -DSEED=LIBC -DSHLIB=OFF -DSTBIN=ON -DTIMER=RELIC_NONE -DWITH="DV;MD;BN;FP;FPX;EP;EC;PP;PC" -DBENCH=20 -DTESTS=20 -DCHECK=off -DVERBS=off -DSTRIP=on -DQUIET=on -DARITH=avr-asm-158 -DFP_PRIME=158 -DBN_METHD="COMBA;COMBA;MONTY;BASIC;STEIN;BASIC" -DFP_QNRES=off -DFP_METHD="INTEG;COMBA;COMBA;MONTY;MONTY;SLIDE" -DBN_PRECI=160 -DBN_MAGNI=DOUBLE -DEP_PRECO=off -DEP_METHD="PROJC;LWNAF;LWNAF;BASIC" -DEP_ENDOM=on -DEP_PLAIN=on -DEC_METHD="PRIME" -DFPX_METHD="INTEG;INTEG;BASIC" -DPP_METHD="BASIC;OATEP" -DRAND=FIPS -DSEED=LIBC -DMD_METHD=SHONE $1 diff --git a/preset/msp-ecc-128k.sh b/preset/msp-ecc-128k.sh index 696765b3c..5de872ae0 100755 --- a/preset/msp-ecc-128k.sh +++ b/preset/msp-ecc-128k.sh @@ -1,2 +1,2 @@ #!/bin/bash -CC="msp430-gcc -mmcu=msp430f1611" CXX="c++" cmake -DARITH=msp-asm -DCMAKE_SYSTEM_NAME=Generic -DALIGN=2 -DARCH=MSP -DBENCH=1 "-DBN_METHD=BASIC;MULTP;MONTY;BASIC;BASIC;BASIC" -DCHECK=OFF -DCOLOR=OFF "-DCOMP:STRING=-O2 -g -mmcu=msp430f1611 -ffunction-sections -fdata-sections -fno-inline -mdisable-watchdog" -DDOCUM=OFF -DEB_DEPTH=3 -DEB_PLAIN=OFF -DEP_DEPTH=3 -DEP_PLAIN=OFF "-DFB_METHD=LODAH;TABLE;QUICK;QUICK;BASIC;BASIC;EXGCD;BASIC;BASIC" -DFB_PRECO=OFF "-DFP_METHD=BASIC;COMBA;COMBA;QUICK;LOWER;BASIC" -DFP_PMERS=ON "-DLINK=-Wl,--gc-sections" -DSEED=ZERO -DSHLIB=OFF -DSTRIP=ON -DTESTS=1 -DTIMER=CYCLE -DVERBS=OFF -DWORD=16 -DFP_PRIME=256 -DFB_POLYN=283 -DBN_PRECI=284 -DMD_METHD=SH256 "-DWITH=FP;FB;EP;EB;EC;DV;CP;MD;BN" -DEC_METHD=PRIME -DRAND=FIPS $1 +CC="msp430-gcc -mmcu=msp430f1611" CXX="c++" cmake -DARITH=msp-asm -DCMAKE_SYSTEM_NAME=Generic -DALIGN=2 -DARCH=MSP -DBENCH=1 "-DBN_METHD=BASIC;MULTP;MONTY;BASIC;BASIC;BASIC" -DCHECK=OFF -DCOLOR=OFF "-DCOMP:STRING=-O2 -g -mmcu=msp430f1611 -ffunction-sections -fdata-sections -fno-inline -mdisable-watchdog" -DDOCUM=OFF -DEB_DEPTH=3 -DEB_PLAIN=OFF -DEP_DEPTH=3 -DEP_PLAIN=OFF "-DFB_METHD=LODAH;RELIC_TABLE;QUICK;QUICK;BASIC;BASIC;EXGCD;BASIC;BASIC" -DFB_PRECO=OFF "-DFP_METHD=BASIC;COMBA;COMBA;QUICK;LOWER;BASIC" -DFP_PMERS=ON "-DLINK=-Wl,--gc-sections" -DSEED=ZERO -DSHLIB=OFF -DSTRIP=ON -DTESTS=1 -DTIMER=CYCLE -DVERBS=OFF -DWORD=16 -DFP_PRIME=256 -DFB_POLYN=283 -DBN_PRECI=284 -DMD_METHD=SH256 "-DWITH=FP;FB;EP;EB;EC;DV;CP;MD;BN" -DEC_METHD=PRIME -DRAND=FIPS $1 diff --git a/preset/msp-ecc-80k.sh b/preset/msp-ecc-80k.sh index 430bf7bdf..df5b89dce 100755 --- a/preset/msp-ecc-80k.sh +++ b/preset/msp-ecc-80k.sh @@ -1,2 +1,2 @@ #!/bin/bash -CC="msp430-gcc -mmcu=msp430f1611" CXX="c++" cmake -DARITH=msp-asm -DCMAKE_SYSTEM_NAME=Generic -DALIGN=2 -DARCH=MSP -DBENCH=1 "-DBN_METHD=BASIC;MULTP;MONTY;BASIC;BASIC;BASIC" -DCHECK=OFF -DCOLOR=OFF "-DCOMP:STRING=-O2 -g -mmcu=msp430f1611 -ffunction-sections -fdata-sections -fno-inline -mdisable-watchdog" -DDOCUM=OFF -DEB_DEPTH=3 -DEB_PLAIN=OFF -DEP_DEPTH=3 -DEP_PLAIN=OFF "-DFB_METHD=LODAH;TABLE;QUICK;QUICK;BASIC;BASIC;EXGCD;BASIC;BASIC" -DFB_PRECO=OFF "-DFP_METHD=BASIC;COMBA;COMBA;QUICK;LOWER;BASIC" -DFP_PMERS=ON "-DLINK=-Wl,--gc-sections" -DSEED=ZERO -DSHLIB=OFF -DSTRIP=ON -DTESTS=1 -DTIMER=CYCLE -DVERBS=OFF -DWORD=16 -DFP_PRIME=160 -DFB_POLYN=163 -DBN_PRECI=164 -DMD_METHD=SHONE "-DWITH=FP;FB;EP;EB;EC;DV;CP;MD;BN" -DEC_METHD=PRIME -DRAND=FIPS $1 +CC="msp430-gcc -mmcu=msp430f1611" CXX="c++" cmake -DARITH=msp-asm -DCMAKE_SYSTEM_NAME=Generic -DALIGN=2 -DARCH=MSP -DBENCH=1 "-DBN_METHD=BASIC;MULTP;MONTY;BASIC;BASIC;BASIC" -DCHECK=OFF -DCOLOR=OFF "-DCOMP:STRING=-O2 -g -mmcu=msp430f1611 -ffunction-sections -fdata-sections -fno-inline -mdisable-watchdog" -DDOCUM=OFF -DEB_DEPTH=3 -DEB_PLAIN=OFF -DEP_DEPTH=3 -DEP_PLAIN=OFF "-DFB_METHD=LODAH;RELIC_TABLE;QUICK;QUICK;BASIC;BASIC;EXGCD;BASIC;BASIC" -DFB_PRECO=OFF "-DFP_METHD=BASIC;COMBA;COMBA;QUICK;LOWER;BASIC" -DFP_PMERS=ON "-DLINK=-Wl,--gc-sections" -DSEED=ZERO -DSHLIB=OFF -DSTRIP=ON -DTESTS=1 -DTIMER=CYCLE -DVERBS=OFF -DWORD=16 -DFP_PRIME=160 -DFB_POLYN=163 -DBN_PRECI=164 -DMD_METHD=SHONE "-DWITH=FP;FB;EP;EB;EC;DV;CP;MD;BN" -DEC_METHD=PRIME -DRAND=FIPS $1 diff --git a/src/bn/relic_bn_mxp.c b/src/bn/relic_bn_mxp.c index 506f691c5..21bda9e6b 100644 --- a/src/bn/relic_bn_mxp.c +++ b/src/bn/relic_bn_mxp.c @@ -37,7 +37,7 @@ /** * Size of precomputation table. */ -#define TABLE_SIZE 64 +#define RELIC_TABLE_SIZE 64 /*============================================================================*/ /* Public definitions */ @@ -105,15 +105,15 @@ void bn_mxp_basic(bn_t c, const bn_t a, const bn_t b, const bn_t m) { #if BN_MXP == SLIDE || !defined(STRIP) void bn_mxp_slide(bn_t c, const bn_t a, const bn_t b, const bn_t m) { - bn_t tab[TABLE_SIZE], t, u, r; + bn_t tab[RELIC_TABLE_SIZE], t, u, r; int i, j, l, w = 1; - uint8_t win[BN_BITS]; + uint8_t win[RELIC_BN_BITS]; bn_null(t); bn_null(u); bn_null(r); /* Initialize table. */ - for (i = 0; i < TABLE_SIZE; i++) { + for (i = 0; i < RELIC_TABLE_SIZE; i++) { bn_null(tab[i]); } @@ -160,7 +160,7 @@ void bn_mxp_slide(bn_t c, const bn_t a, const bn_t b, const bn_t m) { bn_mod(tab[2 * i + 1], tab[2 * i + 1], m, u); } - l = BN_BITS + 1; + l = RELIC_BN_BITS + 1; bn_rec_slw(win, &l, b, w); for (i = 0; i < l; i++) { if (win[i] == 0) { diff --git a/src/eb/relic_eb_curve.c b/src/eb/relic_eb_curve.c index fc5875a16..9e123e97b 100644 --- a/src/eb/relic_eb_curve.c +++ b/src/eb/relic_eb_curve.c @@ -52,7 +52,7 @@ static void detect_opt(int *opt, fb_t a) { if (fb_bits(a) <= FB_DIGIT) { *opt = OPT_DIGIT; } else { - *opt = OPT_NONE; + *opt = RELIC_OPT_NONE; } } } @@ -65,7 +65,7 @@ static void detect_opt(int *opt, fb_t a) { void eb_curve_init(void) { ctx_t *ctx = core_get(); #ifdef EB_PRECO - for (int i = 0; i < EB_TABLE; i++) { + for (int i = 0; i < RELIC_EB_TABLE; i++) { ctx->eb_ptr[i] = &(ctx->eb_pre[i]); } #endif @@ -73,7 +73,7 @@ void eb_curve_init(void) { fb_new(ctx->eb_g.x); fb_new(ctx->eb_g.y); fb_new(ctx->eb_g.z); - for (int i = 0; i < EB_TABLE; i++) { + for (int i = 0; i < RELIC_EB_TABLE; i++) { fb_new(ctx->eb_pre[i].x); fb_new(ctx->eb_pre[i].y); fb_new(ctx->eb_pre[i].z); @@ -92,7 +92,7 @@ void eb_curve_clean(void) { fb_free(ctx->eb_g.x); fb_free(ctx->eb_g.y); fb_free(ctx->eb_g.z); - for (int i = 0; i < EB_TABLE; i++) { + for (int i = 0; i < RELIC_EB_TABLE; i++) { fb_free(ctx->eb_pre[i].x); fb_free(ctx->eb_pre[i].y); fb_free(ctx->eb_pre[i].z); diff --git a/src/eb/relic_eb_mul_fix.c b/src/eb/relic_eb_mul_fix.c index dd3b46f42..623e1cd3b 100644 --- a/src/eb/relic_eb_mul_fix.c +++ b/src/eb/relic_eb_mul_fix.c @@ -398,7 +398,7 @@ void eb_mul_pre_combs(eb_t *t, const eb_t p) { } } - eb_norm_sim(t + 2, (const eb_t *)t + 2, EB_TABLE_COMBS - 2); + eb_norm_sim(t + 2, (const eb_t *)t + 2, RELIC_EB_TABLE_COMBS - 2); } CATCH_ANY { THROW(ERR_CAUGHT); diff --git a/src/ed/relic_ed_curve.c b/src/ed/relic_ed_curve.c index 5d46d1a42..4bf1fb393 100644 --- a/src/ed/relic_ed_curve.c +++ b/src/ed/relic_ed_curve.c @@ -34,7 +34,7 @@ void ed_curve_init(void) { ctx_t *ctx = core_get(); #ifdef ED_PRECO - for (int i = 0; i < ED_TABLE; i++) { + for (int i = 0; i < RELIC_ED_TABLE; i++) { ctx->ed_ptr[i] = &(ctx->ed_pre[i]); } #endif @@ -46,7 +46,7 @@ void ed_curve_init(void) { fp_new(ctx->ed_g.t); #endif #ifdef ED_PRECO - for (int i = 0; i < ED_TABLE; i++) { + for (int i = 0; i < RELIC_ED_TABLE; i++) { fp_new(ctx->ed_pre[i].x); fp_new(ctx->ed_pre[i].y); fp_new(ctx->ed_pre[i].z); @@ -77,7 +77,7 @@ void ed_curve_clean(void) { fp_free(ctx->ed_g.t); #endif #ifdef ED_PRECO - for (int i = 0; i < ED_TABLE; i++) { + for (int i = 0; i < RELIC_ED_TABLE; i++) { fp_free(ctx->ed_pre[i].x); fp_free(ctx->ed_pre[i].y); fp_free(ctx->ed_pre[i].z); diff --git a/src/ed/relic_ed_mul_fix.c b/src/ed/relic_ed_mul_fix.c index c6a3c0c75..f146f11f2 100644 --- a/src/ed/relic_ed_mul_fix.c +++ b/src/ed/relic_ed_mul_fix.c @@ -638,7 +638,7 @@ void ed_mul_pre_combs(ed_t *t, const ed_t p) { } } - ed_norm_sim(t + 2, (const ed_t *)t + 2, ED_TABLE_COMBS - 2); + ed_norm_sim(t + 2, (const ed_t *)t + 2, RELIC_ED_TABLE_COMBS - 2); } CATCH_ANY { THROW(ERR_CAUGHT); diff --git a/src/ed/relic_ed_param.c b/src/ed/relic_ed_param.c index 9dca0a841..837510dad 100644 --- a/src/ed/relic_ed_param.c +++ b/src/ed/relic_ed_param.c @@ -140,7 +140,7 @@ void ed_param_set(int param) { #endif #ifdef ED_PRECO - for (int i = 0; i < ED_TABLE; i++) { + for (int i = 0; i < RELIC_ED_TABLE; i++) { ctx->ed_ptr[i] = &(ctx->ed_pre[i]); } #endif @@ -152,7 +152,7 @@ void ed_param_set(int param) { fp_new(ctx->ed_g.t); #endif #ifdef ED_PRECO - for (int i = 0; i < ED_TABLE; i++) { + for (int i = 0; i < RELIC_ED_TABLE; i++) { fp_new(ctx->ed_pre[i].x); fp_new(ctx->ed_pre[i].y); fp_new(ctx->ed_pre[i].z); diff --git a/src/ep/relic_ep_curve.c b/src/ep/relic_ep_curve.c index 7f0ed3c42..e750ab8b7 100644 --- a/src/ep/relic_ep_curve.c +++ b/src/ep/relic_ep_curve.c @@ -66,7 +66,7 @@ static void detect_opt(int *opt, fp_t a) { if (fp_bits(a) <= FP_DIGIT) { *opt = OPT_DIGIT; } else { - *opt = OPT_NONE; + *opt = RELIC_OPT_NONE; } } } @@ -88,7 +88,7 @@ static void detect_opt(int *opt, fp_t a) { void ep_curve_init(void) { ctx_t *ctx = core_get(); #ifdef EP_PRECO - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { ctx->ep_ptr[i] = &(ctx->ep_pre[i]); } #endif @@ -97,7 +97,7 @@ void ep_curve_init(void) { fp_new(ctx->ep_g.y); fp_new(ctx->ep_g.z); #ifdef EP_PRECO - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { fp_new(ctx->ep_pre[i].x); fp_new(ctx->ep_pre[i].y); fp_new(ctx->ep_pre[i].z); @@ -122,7 +122,7 @@ void ep_curve_clean(void) { fp_free(ctx->ep_g.y); fp_free(ctx->ep_g.z); #ifdef EP_PRECO - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { fp_free(ctx->ep_pre[i].x); fp_free(ctx->ep_pre[i].y); fp_free(ctx->ep_pre[i].z); diff --git a/src/ep/relic_ep_mul_fix.c b/src/ep/relic_ep_mul_fix.c index 04d9c778f..6bfcec2f2 100644 --- a/src/ep/relic_ep_mul_fix.c +++ b/src/ep/relic_ep_mul_fix.c @@ -520,7 +520,7 @@ void ep_mul_pre_combs(ep_t *t, const ep_t p) { } } - ep_norm_sim(t + 2, (const ep_t *)t + 2, EP_TABLE_COMBS - 2); + ep_norm_sim(t + 2, (const ep_t *)t + 2, RELIC_EP_TABLE_COMBS - 2); } CATCH_ANY { THROW(ERR_CAUGHT); diff --git a/src/epx/relic_ep2_curve.c b/src/epx/relic_ep2_curve.c index b7303ed5d..303b6ce06 100644 --- a/src/epx/relic_ep2_curve.c +++ b/src/epx/relic_ep2_curve.c @@ -153,7 +153,7 @@ void ep2_curve_init(void) { ctx_t *ctx = core_get(); #ifdef EP_PRECO - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { ctx->ep2_ptr[i] = &(ctx->ep2_pre[i]); } #endif @@ -169,13 +169,13 @@ void ep2_curve_init(void) { #ifdef EP_PRECO #if ALLOC == STATIC || ALLOC == DYNAMIC - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { fp2_new(ctx->ep2_pre[i].x); fp2_new(ctx->ep2_pre[i].y); fp2_new(ctx->ep2_pre[i].z); } #elif ALLOC == STACK - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { ctx->ep2_pre[i].x[0] = ctx->_ep2_pre[3 * i][0]; ctx->ep2_pre[i].x[1] = ctx->_ep2_pre[3 * i][1]; ctx->ep2_pre[i].y[0] = ctx->_ep2_pre[3 * i + 1][0]; @@ -193,7 +193,7 @@ void ep2_curve_init(void) { void ep2_curve_clean(void) { ctx_t *ctx = core_get(); #ifdef EP_PRECO - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { fp2_free(ctx->ep2_pre[i].x); fp2_free(ctx->ep2_pre[i].y); fp2_free(ctx->ep2_pre[i].z); diff --git a/src/epx/relic_ep2_mul_fix.c b/src/epx/relic_ep2_mul_fix.c index ccdce9f77..f0a43a0a2 100755 --- a/src/epx/relic_ep2_mul_fix.c +++ b/src/epx/relic_ep2_mul_fix.c @@ -334,7 +334,7 @@ void ep2_mul_pre_combs(ep2_t *t, ep2_t p) { } } #if defined(EP_MIXED) - for (i = 1; i < EP_TABLE_COMBS; i++) { + for (i = 1; i < RELIC_EP_TABLE_COMBS; i++) { ep2_norm(t[i], t[i]); } #endif @@ -439,7 +439,7 @@ void ep2_mul_pre_combd(ep2_t *t, ep2_t p) { } } #if defined(EP_MIXED) - for (i = 1; i < EP_TABLE_COMBD; i++) { + for (i = 1; i < RELIC_EP_TABLE_COMBD; i++) { ep2_norm(t[i], t[i]); } #endif diff --git a/src/fb/relic_fb_poly.c b/src/fb/relic_fb_poly.c index c94b74cd2..ade6ca7ba 100644 --- a/src/fb/relic_fb_poly.c +++ b/src/fb/relic_fb_poly.c @@ -269,7 +269,7 @@ static void find_chain() { int x, y, u[ctx->chain_len + 1]; for (i = 0; i < MAX_TERMS; i++) { - for (j = 0; j < FB_TABLE; j++) { + for (j = 0; j < RELIC_FB_TABLE; j++) { ctx->fb_tab_ptr[i][j] = &(ctx->fb_tab_sqr[i][j]); } } diff --git a/src/fb/relic_fb_sqr.c b/src/fb/relic_fb_sqr.c index c87baa4c4..40aa182ce 100644 --- a/src/fb/relic_fb_sqr.c +++ b/src/fb/relic_fb_sqr.c @@ -63,7 +63,7 @@ void fb_sqr_basic(fb_t c, const fb_t a) { #endif -#if FB_SQR == TABLE || !defined(STRIP) +#if FB_SQR == RELIC_TABLE || !defined(STRIP) void fb_sqr_table(fb_t c, const fb_t a) { dv_t t; diff --git a/src/low/avr-asm-163/relic_fb_mul_low.s b/src/low/avr-asm-163/relic_fb_mul_low.s index b2c02667c..7d400a83f 100755 --- a/src/low/avr-asm-163/relic_fb_mul_low.s +++ b/src/low/avr-asm-163/relic_fb_mul_low.s @@ -236,7 +236,7 @@ fb_sqrm_table2: std y + 32, RT ; tab[15][i] = r6^r9 .endm -.macro FILL_TABLE i, j +.macro RELIC_FILL_TABLE i, j /* * We do not need to initialize the first row with zeroes, as the .data * section is already initialized with null bytes. @@ -257,7 +257,7 @@ fb_sqrm_table2: .endif .endif .if \i < \j - FILL_TABLE \i + 1, \j + RELIC_FILL_TABLE \i + 1, \j .endif .endm @@ -382,12 +382,12 @@ fb_sqrm_table2: #if FB_POLYN == 163 -.macro MULN_TABLE +.macro RELIC_MULN_TABLE ldi RC, 0x40 ldi r29, hi8(fb_muln_table0) - FILL_TABLE 0, 15 + RELIC_FILL_TABLE 0, 15 ldi r29, hi8(fb_muln_table1) - FILL_TABLE 16, 20 + RELIC_FILL_TABLE 16, 20 .endm .macro MULN_DO @@ -431,7 +431,7 @@ fb_muln_low: movw r26, r22 ; copy a to x movw r30, r20 ; copy b to z - MULN_TABLE + RELIC_MULN_TABLE movw r30, r24 ; z = &c MULN_DO @@ -527,7 +527,7 @@ fb_muli_low: movw r26, r20 ; copy a to x movw r30, r18 ; copy b to z - MULN_TABLE + RELIC_MULN_TABLE movw r30, r14 ; z = &t MULN_DO diff --git a/src/low/msp-asm/relic_fb_mul_low_163.s b/src/low/msp-asm/relic_fb_mul_low_163.s index e496a4901..9b334141f 100644 --- a/src/low/msp-asm/relic_fb_mul_low_163.s +++ b/src/low/msp-asm/relic_fb_mul_low_163.s @@ -56,21 +56,21 @@ push r11 .endm -.macro MULN_TABLE +.macro RELIC_MULN_TABLE mov r1, T_PTR - FILL_TABLE 0, 10 /* fill 11 columns */ + RELIC_FILL_TABLE 0, 10 /* fill 11 columns */ .endm -.macro MULN_TABLE_KARATSUBA +.macro RELIC_MULN_TABLE_KARATSUBA mov r1, T_PTR - FILL_TABLE 0, 8 /* fill 9 columns */ + RELIC_FILL_TABLE 0, 8 /* fill 9 columns */ PREP_LAST r6, r7, r8, r9 /* fill last column */ FILL_COLUMN r6, r7, r8, r9 sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro FILL_TABLE i, j +.macro RELIC_FILL_TABLE i, j .if \i == 0 PREP_FIRST r6, r7, r8, r9 FILL_COLUMN r6, r7, r8, r9 @@ -80,7 +80,7 @@ .endif incd T_PTR .if \i < \j - FILL_TABLE \i + 1, \j + RELIC_FILL_TABLE \i + 1, \j .endif .endm @@ -222,7 +222,7 @@ fb_muln_low: sub #512,r1 - MULN_TABLE + RELIC_MULN_TABLE #include "fb_mul_163_ld.inc" @@ -234,7 +234,7 @@ fb_muln_low: #else #define TEMP_SIZE 72 -#define TABLE_SIZE 512 +#define RELIC_TABLE_SIZE 512 fb_muln_low: /* r15: c @@ -328,13 +328,13 @@ fb_muln_low: fb_muln_low_karatsuba: - sub #TABLE_SIZE,r1 + sub #RELIC_TABLE_SIZE,r1 - MULN_TABLE_KARATSUBA + RELIC_MULN_TABLE_KARATSUBA #include "ld_mult_271_karatsuba.inc" - add #TABLE_SIZE,r1 + add #RELIC_TABLE_SIZE,r1 ret diff --git a/src/low/msp-asm/relic_fb_mul_low_271.s b/src/low/msp-asm/relic_fb_mul_low_271.s index 7fc3bc2ae..6b9ebd20c 100644 --- a/src/low/msp-asm/relic_fb_mul_low_271.s +++ b/src/low/msp-asm/relic_fb_mul_low_271.s @@ -60,25 +60,25 @@ push r11 .endm -.macro MULN_TABLE +.macro RELIC_MULN_TABLE mov r1, T_PTR - FILL_TABLE 0, 16 /* fill 17 columns */ + RELIC_FILL_TABLE 0, 16 /* fill 17 columns */ PREP_LAST r6, r7, r8, r9 /* fill last column */ FILL_COLUMN r6, r7, r8, r9 sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro MULN_TABLE_KARATSUBA +.macro RELIC_MULN_TABLE_KARATSUBA mov r1, T_PTR - FILL_TABLE 0, 8 /* fill 9 columns */ + RELIC_FILL_TABLE 0, 8 /* fill 9 columns */ PREP_LAST r6, r7, r8, r9 /* fill last column */ FILL_COLUMN r6, r7, r8, r9 sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro FILL_TABLE i, j +.macro RELIC_FILL_TABLE i, j .if \i == 0 PREP_FIRST r6, r7, r8, r9 FILL_COLUMN r6, r7, r8, r9 @@ -88,7 +88,7 @@ .endif incd T_PTR .if \i < \j - FILL_TABLE \i + 1, \j + RELIC_FILL_TABLE \i + 1, \j .endif .endm @@ -230,7 +230,7 @@ fb_muln_low: sub #576,r1 - MULN_TABLE + RELIC_MULN_TABLE #include "fb_mul_271_ld.inc" @@ -242,7 +242,7 @@ fb_muln_low: #else #define TEMP_SIZE 72 -#define TABLE_SIZE 512 +#define RELIC_TABLE_SIZE 512 fb_muln_low: /* r15: c @@ -336,13 +336,13 @@ fb_muln_low: fb_muln_low_karatsuba: - sub #TABLE_SIZE,r1 + sub #RELIC_TABLE_SIZE,r1 - MULN_TABLE_KARATSUBA + RELIC_MULN_TABLE_KARATSUBA #include "fb_mul_271_ld_k2.inc" - add #TABLE_SIZE,r1 + add #RELIC_TABLE_SIZE,r1 ret diff --git a/src/low/msp-asm/relic_fb_mul_low_283.s b/src/low/msp-asm/relic_fb_mul_low_283.s index a35c55347..6565a1d73 100644 --- a/src/low/msp-asm/relic_fb_mul_low_283.s +++ b/src/low/msp-asm/relic_fb_mul_low_283.s @@ -92,23 +92,23 @@ push r11 .endm -.macro MULN_TABLE +.macro RELIC_MULN_TABLE mov r1, T_PTR - FILL_TABLE 0, 17 /* fill 18 columns */ + RELIC_FILL_TABLE 0, 17 /* fill 18 columns */ sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro MULN_TABLE_KARATSUBA +.macro RELIC_MULN_TABLE_KARATSUBA mov r1, T_PTR - FILL_TABLE 0, 8 /* fill 9 columns */ + RELIC_FILL_TABLE 0, 8 /* fill 9 columns */ PREP_LAST r6, r7, r8, r9 /* fill last column */ FILL_COLUMN r6, r7, r8, r9 sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro FILL_TABLE i, j +.macro RELIC_FILL_TABLE i, j .if \i == 0 PREP_FIRST r6, r7, r8, r9 FILL_COLUMN r6, r7, r8, r9 @@ -118,7 +118,7 @@ .endif incd T_PTR .if \i < \j - FILL_TABLE \i + 1, \j + RELIC_FILL_TABLE \i + 1, \j .endif .endm @@ -260,7 +260,7 @@ fb_muln_low: sub #576,r1 - MULN_TABLE + RELIC_MULN_TABLE #include "fb_mul_283_ld.inc" @@ -272,7 +272,7 @@ fb_muln_low: #else #define TEMP_SIZE 72 -#define TABLE_SIZE 512 +#define RELIC_TABLE_SIZE 512 fb_muln_low: /* r15: c @@ -366,13 +366,13 @@ fb_muln_low: fb_muln_low_karatsuba: - sub #TABLE_SIZE,r1 + sub #RELIC_TABLE_SIZE,r1 - MULN_TABLE_KARATSUBA + RELIC_MULN_TABLE_KARATSUBA #include "ld_mult_271_karatsuba.inc" - add #TABLE_SIZE,r1 + add #RELIC_TABLE_SIZE,r1 ret diff --git a/src/low/msp-asm/relic_fb_mul_low_353.s b/src/low/msp-asm/relic_fb_mul_low_353.s index 4cb7b3aa3..bc332e9fb 100644 --- a/src/low/msp-asm/relic_fb_mul_low_353.s +++ b/src/low/msp-asm/relic_fb_mul_low_353.s @@ -92,23 +92,23 @@ push r11 .endm -.macro MULN_TABLE +.macro RELIC_MULN_TABLE mov r1, T_PTR - FILL_TABLE 0, 16 /* fill 17 columns */ + RELIC_FILL_TABLE 0, 16 /* fill 17 columns */ PREP_LAST r6, r7, r8, r9 /* fill last column */ FILL_COLUMN r6, r7, r8, r9 sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro MULN_TABLE_KARATSUBA +.macro RELIC_MULN_TABLE_KARATSUBA mov r1, T_PTR - FILL_TABLE 0, 11 /* fill 12 columns */ + RELIC_FILL_TABLE 0, 11 /* fill 12 columns */ sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro FILL_TABLE i, j +.macro RELIC_FILL_TABLE i, j .if \i == 0 PREP_FIRST r6, r7, r8, r9 FILL_COLUMN r6, r7, r8, r9 @@ -118,7 +118,7 @@ .endif incd T_PTR .if \i < \j - FILL_TABLE \i + 1, \j + RELIC_FILL_TABLE \i + 1, \j .endif .endm @@ -260,7 +260,7 @@ fb_muln_low: sub #576,r1 - MULN_TABLE + RELIC_MULN_TABLE #include "ld_mult_271.inc" @@ -272,7 +272,7 @@ fb_muln_low: #else #define TEMP_SIZE 96 -#define TABLE_SIZE 512 +#define RELIC_TABLE_SIZE 512 fb_muln_low: /* r15: c @@ -490,13 +490,13 @@ fb_muln_low: fb_muln_low_karatsuba: - sub #TABLE_SIZE,r1 + sub #RELIC_TABLE_SIZE,r1 - MULN_TABLE_KARATSUBA + RELIC_MULN_TABLE_KARATSUBA #include "fb_mul_353_ld_k2.inc" - add #TABLE_SIZE,r1 + add #RELIC_TABLE_SIZE,r1 ret diff --git a/src/low/msp-asm/relic_fb_mul_low_353_k3.s b/src/low/msp-asm/relic_fb_mul_low_353_k3.s index d94ecf20e..1cf799ef2 100644 --- a/src/low/msp-asm/relic_fb_mul_low_353_k3.s +++ b/src/low/msp-asm/relic_fb_mul_low_353_k3.s @@ -88,16 +88,16 @@ .endr .endm -.macro MULN_TABLE +.macro RELIC_MULN_TABLE mov r1, T_PTR - FILL_TABLE 0, 7 /* fill 8 columns */ + RELIC_FILL_TABLE 0, 7 /* fill 8 columns */ PREP_LAST r6, r7, r8, r9 /* fill last column */ FILL_COLUMN r6, r7, r8, r9 sub #2*T_LINE, T_PTR /* restore T_PTR */ sub #2*T_LINE, B_PTR /* restore B_PTR */ .endm -.macro FILL_TABLE i, j +.macro RELIC_FILL_TABLE i, j .if \i == 0 PREP_FIRST r6, r7, r8, r9 FILL_COLUMN r6, r7, r8, r9 @@ -107,7 +107,7 @@ .endif incd T_PTR .if \i < \j - FILL_TABLE \i + 1, \j + RELIC_FILL_TABLE \i + 1, \j .endif .endm @@ -237,7 +237,7 @@ .global fb_muln_low #define TEMP_SIZE 192 -#define TABLE_SIZE 512 +#define RELIC_TABLE_SIZE 512 fb_muln_low: /* r15: c @@ -475,13 +475,13 @@ fb_muln_low: fb_muln_low_karatsuba: - sub #TABLE_SIZE,r1 + sub #RELIC_TABLE_SIZE,r1 - MULN_TABLE + RELIC_MULN_TABLE #include "fb_mul_353_ld_k3.inc" - add #TABLE_SIZE,r1 + add #RELIC_TABLE_SIZE,r1 ret diff --git a/src/md/sha.h b/src/md/sha.h index 393ac5e5a..9998c74e0 100644 --- a/src/md/sha.h +++ b/src/md/sha.h @@ -189,17 +189,17 @@ typedef struct USHAContext { } USHAContext; /* - * This structure will hold context information for the HMAC + * This structure will hold context information for the RELIC_HMAC * keyed hashing operation. */ -typedef struct HMACContext { +typedef struct RELIC_HMACContext { int whichSha; /* which SHA is being used */ int hashSize; /* hash size of SHA being used */ int blockSize; /* block size of SHA being used */ USHAContext shaContext; /* SHA context */ uint8_t k_opad[USHA_Max_Message_Block_Size]; /* outer padding - key XORd with opad */ -} HMACContext; +} RELIC_HMACContext; /* * Function Prototypes diff --git a/src/relic_bench.c b/src/relic_bench.c index e4168f1dd..a86fcf78e 100644 --- a/src/relic_bench.c +++ b/src/relic_bench.c @@ -47,7 +47,7 @@ uint32_t micros(); /* Private definitions */ /*============================================================================*/ -#if defined(OVERH) && TIMER != NONE && BENCH > 1 +#if defined(OVERH) && TIMER != RELIC_NONE && BENCH > 1 /** * Dummy function for measuring benchmarking overhead. @@ -58,13 +58,13 @@ static void empty(int *a) { (*a)++; } -#endif /* OVER && TIMER != NONE && BENCH > 1 */ +#endif /* OVER && TIMER != RELIC_NONE && BENCH > 1 */ /*============================================================================*/ /* Public definitions */ /*============================================================================*/ -#if defined(OVERH) && TIMER != NONE && BENCH > 1 +#if defined(OVERH) && TIMER != RELIC_NONE && BENCH > 1 void bench_overhead(void) { ctx_t *ctx = core_get(); @@ -112,10 +112,10 @@ void bench_overhead(void) { bench_print(); } -#endif /* OVER && TIMER != NONE && BENCH > 1 */ +#endif /* OVER && TIMER != RELIC_NONE && BENCH > 1 */ void bench_reset() { -#if TIMER != NONE +#if TIMER != RELIC_NONE core_get()->total = 0; #endif } @@ -157,7 +157,7 @@ void bench_after() { result = (ctx->after - ctx->before); #endif -#if TIMER != NONE +#if TIMER != RELIC_NONE ctx->total += result; #else (void)result; @@ -167,7 +167,7 @@ void bench_after() { void bench_compute(int benches) { ctx_t *ctx = core_get(); -#if TIMER != NONE +#if TIMER != RELIC_NONE ctx->total = ctx->total / benches; #ifdef OVERH ctx->total = ctx->total - ctx->over; @@ -175,7 +175,7 @@ void bench_compute(int benches) { #else (void)benches; (void)ctx; -#endif /* TIMER != NONE */ +#endif /* TIMER != RELIC_NONE */ } void bench_print() { diff --git a/src/relic_conf.c b/src/relic_conf.c index fb28f4b35..3cd7d0c59 100644 --- a/src/relic_conf.c +++ b/src/relic_conf.c @@ -48,7 +48,7 @@ void conf_print(void) { #ifndef QUIET - util_print("-- RELIC " VERSION " configuration:\n\n"); + util_print("-- RELIC " RELIC_VERSION " configuration:\n\n"); #if ALLOC == STATIC util_print("** Allocation mode: STATIC\n\n"); #elif ALLOC == DYNAMIC @@ -83,7 +83,7 @@ void conf_print(void) { #ifdef WITH_BN util_print("** Multiple precision module options:\n"); - util_print(" Precision: %d bits, %d words\n", BN_BITS, BN_DIGS); + util_print(" Precision: %d bits, %d words\n", RELIC_BN_BITS, BN_DIGS); util_print(" Arithmetic method: " BN_METHD "\n\n"); #endif diff --git a/src/relic_util.c b/src/relic_util.c index 6d8ae6bc7..9861a7ebc 100644 --- a/src/relic_util.c +++ b/src/relic_util.c @@ -182,7 +182,7 @@ int util_cmp_const(const void * a, const void *b, int size) { void util_printf(const char *format, ...) { #ifndef QUIET -#if ARCH == AVR && OPSYS == NONE +#if ARCH == AVR && OPSYS == RELIC_NONE util_print_ptr = print_buf + 1; va_list list; va_start(list, format); @@ -196,7 +196,7 @@ void util_printf(const char *format, ...) { vsnprintf_P((char *)print_buf, sizeof(print_buf), format, list); printf("%s", (char *)print_buf); va_end(list); -#elif ARCH == MSP && OPSYS == NONE +#elif ARCH == MSP && OPSYS == RELIC_NONE va_list list; va_start(list, format); vprintf(format, list); diff --git a/test/test_bn.c b/test/test_bn.c index 0eb7058f5..939daa540 100644 --- a/test/test_bn.c +++ b/test/test_bn.c @@ -63,9 +63,9 @@ static int memory(void) { static int util(void) { int bits, code = STS_ERR; - char str[BN_BITS + 2]; + char str[RELIC_BN_BITS + 2]; dig_t digit, raw[BN_DIGS]; - uint8_t bin[BN_BYTES]; + uint8_t bin[RELIC_BN_BYTES]; bn_t a, b, c; bn_null(a); @@ -78,8 +78,8 @@ static int util(void) { bn_new(c); TEST_BEGIN("comparison is consistent") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); if (bn_cmp(a, b) != CMP_EQ) { if (bn_cmp(a, b) == CMP_GT) { TEST_ASSERT(bn_cmp(b, a) == CMP_LT, end); @@ -91,9 +91,9 @@ static int util(void) { TEST_END; TEST_BEGIN("copy and comparison are consistent") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); - bn_rand(c, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); + bn_rand(c, BN_POS, RELIC_BN_BITS); if (bn_cmp(a, c) != CMP_EQ) { bn_copy(c, a); TEST_ASSERT(bn_cmp(c, a) == CMP_EQ, end); @@ -106,7 +106,7 @@ static int util(void) { TEST_END; TEST_BEGIN("absolute, negation and comparison are consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_neg(b, a); bn_abs(a, b); TEST_ASSERT(bn_cmp(a, b) == CMP_GT, end); @@ -117,15 +117,15 @@ static int util(void) { } TEST_END; TEST_BEGIN("signal test is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_NEG, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_NEG, RELIC_BN_BITS); TEST_ASSERT(bn_sign(a) == BN_POS, end); TEST_ASSERT(bn_sign(b) == BN_NEG, end); } TEST_END; TEST_BEGIN("assignment to zero and comparison are consistent") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_NEG, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_NEG, RELIC_BN_BITS); bn_zero(c); TEST_ASSERT(bn_cmp(a, c) == CMP_GT, end); TEST_ASSERT(bn_cmp(c, a) == CMP_LT, end); @@ -153,7 +153,7 @@ static int util(void) { TEST_BEGIN("assignment and bit counting are consistent") { bn_set_2b(a, bits); TEST_ASSERT(bits + 1 == bn_bits(a), end); - bits = (bits + 1) % BN_BITS; + bits = (bits + 1) % RELIC_BN_BITS; } TEST_END; bits = 0; @@ -163,7 +163,7 @@ static int util(void) { TEST_ASSERT(bn_get_bit(a, bits) == 1, end); bn_set_bit(a, bits, 0); TEST_ASSERT(bn_get_bit(a, bits) == 0, end); - bits = (bits + 1) % BN_BITS; + bits = (bits + 1) % RELIC_BN_BITS; } TEST_END; @@ -174,12 +174,12 @@ static int util(void) { bn_set_bit(a, j, 1); } TEST_ASSERT(bn_ham(a) == bits, end); - bits = (bits + 1) % BN_BITS; + bits = (bits + 1) % RELIC_BN_BITS; } TEST_END; TEST_BEGIN("generating a random integer is consistent") { - bn_rand(b, BN_POS, BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_rand_mod(a, b); TEST_ASSERT(bn_sign(a) == bn_sign(b), end); TEST_ASSERT(bn_is_zero(a) == 0, end); @@ -210,8 +210,8 @@ static int util(void) { } TEST_END; TEST_BEGIN("assignment to random and comparison are consistent") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_NEG, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_NEG, RELIC_BN_BITS); bn_zero(c); TEST_ASSERT(bn_cmp(a, c) == CMP_GT, end); TEST_ASSERT(bn_cmp(b, c) == CMP_LT, end); @@ -229,8 +229,8 @@ static int util(void) { } TEST_END; TEST_BEGIN("reading and writing a positive number are consistent") { - int len = BN_BYTES; - bn_rand(a, BN_POS, BN_BITS); + int len = RELIC_BN_BYTES; + bn_rand(a, BN_POS, RELIC_BN_BITS); for (int j = 2; j <= 64; j++) { bits = bn_size_str(a, j); bn_write_str(str, bits, a, j); @@ -248,7 +248,7 @@ static int util(void) { TEST_END; TEST_BEGIN("getting the size of a positive number is correct") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); TEST_ASSERT((bn_size_str(a, 2) - 1) == bn_bits(a), end); bits = (bn_bits(a) % 8 == 0 ? bn_bits(a) / 8 : bn_bits(a) / 8 + 1); TEST_ASSERT(bn_size_bin(a) == bits, end); @@ -257,8 +257,8 @@ static int util(void) { TEST_END; TEST_BEGIN("reading and writing a negative number are consistent") { - int len = BN_BYTES; - bn_rand(a, BN_NEG, BN_BITS); + int len = RELIC_BN_BYTES; + bn_rand(a, BN_NEG, RELIC_BN_BITS); for (int j = 2; j <= 64; j++) { bits = bn_size_str(a, j); bn_write_str(str, bits, a, j); @@ -278,7 +278,7 @@ static int util(void) { TEST_END; TEST_BEGIN("getting the size of a negative number is correct") { - bn_rand(a, BN_NEG, BN_BITS); + bn_rand(a, BN_NEG, RELIC_BN_BITS); TEST_ASSERT((bn_size_str(a, 2) - 2) == bn_bits(a), end); bits = (bn_bits(a) % 8 == 0 ? bn_bits(a) / 8 : bn_bits(a) / 8 + 1); TEST_ASSERT(bn_size_bin(a) == bits, end); @@ -315,17 +315,17 @@ static int addition(void) { bn_new(e); TEST_BEGIN("addition is commutative") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_add(d, a, b); bn_add(e, b, a); TEST_ASSERT(bn_cmp(d, e) == CMP_EQ, end); } TEST_END; TEST_BEGIN("addition is associative") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); - bn_rand(c, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); + bn_rand(c, BN_POS, RELIC_BN_BITS); bn_add(d, a, b); bn_add(d, d, c); bn_add(e, b, c); @@ -334,7 +334,7 @@ static int addition(void) { } TEST_END; TEST_BEGIN("addition has identity") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_zero(d); bn_add(e, a, d); TEST_ASSERT(bn_cmp(e, a) == CMP_EQ, end); @@ -343,7 +343,7 @@ static int addition(void) { } TEST_END; TEST_BEGIN("addition has inverse") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_neg(d, a); bn_add(e, a, d); TEST_ASSERT(bn_is_zero(e), end); @@ -379,8 +379,8 @@ static int subtraction(void) { bn_new(d); TEST_BEGIN("subtraction is anti-commutative") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_sub(c, a, b); bn_sub(d, b, a); TEST_ASSERT(bn_cmp_abs(c, d) == CMP_EQ, end); @@ -392,7 +392,7 @@ static int subtraction(void) { TEST_END; TEST_BEGIN("subtraction has identity") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_zero(c); bn_sub(d, a, c); TEST_ASSERT(bn_cmp(d, a) == CMP_EQ, end); @@ -400,7 +400,7 @@ static int subtraction(void) { TEST_END; TEST_BEGIN("subtraction has inverse") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_sub(c, a, a); TEST_ASSERT(bn_is_zero(c), end); } @@ -438,17 +438,17 @@ static int multiplication(void) { bn_new(f); TEST_BEGIN("multiplication is commutative") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_mul(d, a, b); bn_mul(e, b, a); TEST_ASSERT(bn_cmp(d, e) == CMP_EQ, end); } TEST_END; TEST_BEGIN("multiplication is associative") { - bn_rand(a, BN_POS, BN_BITS / 3); - bn_rand(b, BN_POS, BN_BITS / 3); - bn_rand(c, BN_POS, BN_BITS / 3); + bn_rand(a, BN_POS, RELIC_BN_BITS / 3); + bn_rand(b, BN_POS, RELIC_BN_BITS / 3); + bn_rand(c, BN_POS, RELIC_BN_BITS / 3); bn_mul(d, a, b); bn_mul(d, d, c); bn_mul(e, b, c); @@ -457,9 +457,9 @@ static int multiplication(void) { } TEST_END; TEST_BEGIN("multiplication is distributive") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); - bn_rand(c, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); + bn_rand(c, BN_POS, RELIC_BN_BITS / 2); bn_add(d, a, b); bn_mul(d, c, d); bn_mul(e, c, a); @@ -469,21 +469,21 @@ static int multiplication(void) { } TEST_END; TEST_BEGIN("multiplication has identity") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_set_dig(d, (dig_t)1); bn_mul(e, a, d); TEST_ASSERT(bn_cmp(e, a) == CMP_EQ, end); } TEST_END; TEST_BEGIN("multiplication has zero property") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_zero(d); bn_mul(e, a, d); TEST_ASSERT(bn_is_zero(e), end); } TEST_END; TEST_BEGIN("multiplication has negation property") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_set_dig(d, 1); bn_neg(d, d); bn_mul(e, a, d); @@ -492,9 +492,9 @@ static int multiplication(void) { } TEST_END; TEST_BEGIN("multiplication by a positive number preserves order") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); - bn_rand(c, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); + bn_rand(c, BN_POS, RELIC_BN_BITS / 2); int t = bn_cmp(a, b); bn_mul(d, c, a); bn_mul(e, c, b); @@ -502,9 +502,9 @@ static int multiplication(void) { } TEST_END; TEST_BEGIN("multiplication by a negative number reverses order") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); - bn_rand(c, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); + bn_rand(c, BN_POS, RELIC_BN_BITS / 2); int t = bn_cmp(a, b); bn_neg(d, c); bn_mul(e, d, a); @@ -517,8 +517,8 @@ static int multiplication(void) { #if BN_MUL == BASIC || !defined(STRIP) TEST_BEGIN("basic multiplication is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_mul(c, a, b); bn_mul_basic(d, a, b); TEST_ASSERT(bn_cmp(c, d) == CMP_EQ, end); @@ -528,8 +528,8 @@ static int multiplication(void) { #if BN_MUL == COMBA || !defined(STRIP) TEST_BEGIN("comba multiplication is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_mul(c, a, b); bn_mul_comba(d, a, b); TEST_ASSERT(bn_cmp(c, d) == CMP_EQ, end); @@ -539,8 +539,8 @@ static int multiplication(void) { #if BN_KARAT > 0 || !defined(STRIP) TEST_BEGIN("karatsuba multiplication is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_mul(c, a, b); bn_mul_karat(d, a, b); TEST_ASSERT(bn_cmp(c, d) == CMP_EQ, end); @@ -577,7 +577,7 @@ static int squaring(void) { bn_new(c); TEST_BEGIN("squaring is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); bn_mul(b, a, a); bn_sqr(c, a); TEST_ASSERT(bn_cmp(b, c) == CMP_EQ, end); @@ -585,7 +585,7 @@ static int squaring(void) { #if BN_SQR == BASIC || !defined(STRIP) TEST_BEGIN("basic squaring is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); bn_sqr(b, a); bn_sqr_basic(c, a); TEST_ASSERT(bn_cmp(b, c) == CMP_EQ, end); @@ -594,7 +594,7 @@ static int squaring(void) { #if BN_SQR == COMBA || !defined(STRIP) TEST_BEGIN("comba squaring is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); bn_sqr(b, a); bn_sqr_comba(c, a); TEST_ASSERT(bn_cmp(b, c) == CMP_EQ, end); @@ -603,7 +603,7 @@ static int squaring(void) { #if BN_KARAT > 0 || !defined(STRIP) TEST_BEGIN("karatsuba squaring is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); bn_sqr(b, a); bn_sqr_karat(c, a); TEST_ASSERT(bn_cmp(b, c) == CMP_EQ, end); @@ -636,14 +636,14 @@ static int doubling_halving(void) { bn_new(c); TEST_BEGIN("doubling is consistent") { - bn_rand(a, BN_POS, BN_BITS - 1); + bn_rand(a, BN_POS, RELIC_BN_BITS - 1); bn_add(b, a, a); bn_dbl(c, a); TEST_ASSERT(bn_cmp(b, c) == CMP_EQ, end); } TEST_END; TEST_BEGIN("halving is consistent") { - bn_rand(a, BN_POS, BN_BITS - 1); + bn_rand(a, BN_POS, RELIC_BN_BITS - 1); bn_dbl(b, a); bn_hlv(c, b); TEST_ASSERT(bn_cmp(c, a) == CMP_EQ, end); @@ -674,7 +674,7 @@ static int shifting(void) { bn_new(c); TEST_BEGIN("shifting by 1 bit is consistent") { - bn_rand(a, BN_POS, BN_BITS - 1); + bn_rand(a, BN_POS, RELIC_BN_BITS - 1); bn_lsh(b, a, 1); bn_dbl(c, a); TEST_ASSERT(bn_cmp(b, c) == CMP_EQ, end); @@ -687,14 +687,14 @@ static int shifting(void) { } TEST_END; TEST_BEGIN("shifting by 2 bits is consistent") { - bn_rand(a, BN_POS, BN_BITS - 2); + bn_rand(a, BN_POS, RELIC_BN_BITS - 2); bn_lsh(b, a, 2); bn_rsh(c, b, 2); TEST_ASSERT(bn_cmp(a, c) == CMP_EQ, end); } TEST_END; TEST_BEGIN("shifting by half digit is consistent") { - bn_rand(a, BN_POS, BN_BITS - BN_DIGIT / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS - BN_DIGIT / 2); bn_lsh(b, a, BN_DIGIT / 2); bn_rsh(c, b, BN_DIGIT / 2); TEST_ASSERT(bn_cmp(a, c) == CMP_EQ, end); @@ -708,7 +708,7 @@ static int shifting(void) { } TEST_END; TEST_BEGIN("shifting by 2 digits is consistent") { - bn_rand(a, BN_POS, BN_BITS - 2 * BN_DIGIT); + bn_rand(a, BN_POS, RELIC_BN_BITS - 2 * BN_DIGIT); bn_lsh(b, a, 2 * BN_DIGIT); bn_rsh(c, b, 2 * BN_DIGIT); TEST_ASSERT(bn_cmp(a, c) == CMP_EQ, end); @@ -716,7 +716,7 @@ static int shifting(void) { TEST_END; TEST_BEGIN("shifting by 1 digit and half is consistent") { - bn_rand(a, BN_POS, BN_BITS - BN_DIGIT - BN_DIGIT / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS - BN_DIGIT - BN_DIGIT / 2); bn_lsh(b, a, BN_DIGIT + BN_DIGIT / 2); bn_copy(c, a); for (int j = 0; j < (int)(BN_DIGIT + BN_DIGIT / 2); j++) @@ -758,8 +758,8 @@ static int division(void) { bn_new(e); TEST_BEGIN("trivial division is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_div(e, a, b); bn_div_rem(c, d, a, b); TEST_ASSERT(bn_cmp(e, c) == CMP_EQ, end); @@ -771,8 +771,8 @@ static int division(void) { } TEST_END; TEST_BEGIN("trivial negative division is correct") { - bn_rand(a, BN_NEG, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_NEG, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_div(e, a, b); bn_div_rem(c, d, a, b); TEST_ASSERT(bn_cmp(e, c) == CMP_EQ, end); @@ -784,8 +784,8 @@ static int division(void) { } TEST_END; TEST_BEGIN("trivial division by negative is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_NEG, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_NEG, RELIC_BN_BITS); bn_div(e, a, b); bn_div_rem(c, d, a, b); TEST_ASSERT(bn_cmp(e, c) == CMP_EQ, end); @@ -797,8 +797,8 @@ static int division(void) { } TEST_END; TEST_BEGIN("division is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_div(e, a, b); bn_div_rem(c, d, a, b); TEST_ASSERT(bn_cmp(e, c) == CMP_EQ, end); @@ -810,8 +810,8 @@ static int division(void) { } TEST_END; TEST_BEGIN("negative division is correct") { - bn_rand(a, BN_NEG, BN_BITS); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_NEG, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_div(e, a, b); bn_div_rem(c, d, a, b); TEST_ASSERT(bn_cmp(e, c) == CMP_EQ, end); @@ -823,8 +823,8 @@ static int division(void) { } TEST_END; TEST_BEGIN("division by negative is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_NEG, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_NEG, RELIC_BN_BITS / 2); bn_div(e, a, b); bn_div_rem(c, d, a, b); TEST_ASSERT(bn_cmp(e, c) == CMP_EQ, end); @@ -867,8 +867,8 @@ static int reduction(void) { #if BN_MOD == BARRT || !defined(STRIP) TEST_BEGIN("barrett reduction is correct") { - bn_rand(a, BN_POS, BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_div_rem(c, d, a, b); bn_sqr(c, b); if (bn_cmp(a, c) == CMP_LT) { @@ -882,8 +882,8 @@ static int reduction(void) { #if (BN_MOD == MONTY && BN_MUL == BASIC) || !defined(STRIP) TEST_BEGIN("basic montgomery reduction is correct") { - bn_rand(a, BN_POS, BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -898,8 +898,8 @@ static int reduction(void) { #if (BN_MOD == MONTY && BN_MUL == COMBA) || !defined(STRIP) TEST_BEGIN("comba montgomery reduction is correct") { - bn_rand(a, BN_POS, BN_BITS - BN_DIGIT / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS - BN_DIGIT / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); if (bn_is_even(b)) { bn_add_dig(b, b, 1); } @@ -914,12 +914,12 @@ static int reduction(void) { #if BN_MOD == PMERS || !defined(STRIP) TEST_BEGIN("pseudo-mersenne reduction is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS / 2); - bn_rand(c, BN_POS, BN_BITS / 4); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); + bn_rand(c, BN_POS, RELIC_BN_BITS / 4); if (bn_is_zero(c)) bn_set_dig(c, 1); - bn_set_2b(b, BN_BITS / 2); + bn_set_2b(b, RELIC_BN_BITS / 2); bn_sub(b, b, c); bn_mod(c, a, b); bn_mod_pre_pmers(e, b); @@ -957,7 +957,7 @@ static int exponentiation(void) { bn_new(p); #if BN_MOD != PMERS - bn_gen_prime(p, BN_BITS); + bn_gen_prime(p, RELIC_BN_BITS); #elif BN_PRECI >= 128 /* Let's try a Mersenne prime. */ bn_zero(p); @@ -966,7 +966,7 @@ static int exponentiation(void) { #endif TEST_BEGIN("modular exponentiation is correct") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_mod(a, a, p); bn_mxp(b, a, p, p); TEST_ASSERT(bn_cmp(a, b) == CMP_EQ, end); @@ -974,7 +974,7 @@ static int exponentiation(void) { TEST_END; TEST_BEGIN("modular exponentiation with zero power is correct") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_zero(b); bn_mxp(a, a, b, p); TEST_ASSERT(bn_cmp_dig(a, 1) == CMP_EQ, end); @@ -983,7 +983,7 @@ static int exponentiation(void) { #if BN_MXP == BASIC || !defined(STRIP) TEST_BEGIN("basic modular exponentiation is correct") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_mod(a, a, p); bn_copy(b, a); bn_mxp_basic(b, a, p, p); @@ -994,7 +994,7 @@ static int exponentiation(void) { #if BN_MXP == SLIDE || !defined(STRIP) TEST_BEGIN("sliding window modular exponentiation is correct") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_mod(a, a, p); bn_copy(b, a); bn_mxp_slide(b, b, p, p); @@ -1005,7 +1005,7 @@ static int exponentiation(void) { #if BN_MXP == CONST || !defined(STRIP) TEST_BEGIN("powering ladder modular exponentiation is correct") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_mod(a, a, p); bn_copy(b, a); bn_mxp_monty(b, b, p, p); @@ -1040,7 +1040,7 @@ static int square_root(void) { bn_new(c); TEST_BEGIN("square root extraction is correct") { - bn_rand(a, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); bn_sqr(c, a); bn_srt(b, c); TEST_ASSERT(bn_cmp(a, b) == CMP_EQ, end); @@ -1078,8 +1078,8 @@ static int gcd(void) { bn_new(f); TEST_BEGIN("greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd(c, a, b); bn_mod(d, a, c); bn_mod(e, b, c); @@ -1088,19 +1088,19 @@ static int gcd(void) { bn_div(b, b, c); bn_gcd(c, a, b); TEST_ASSERT(bn_cmp_dig(c, 1) == CMP_EQ, end); - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_zero(b); bn_gcd(c, a, b); TEST_ASSERT(bn_cmp_abs(c, a) == CMP_EQ, end); - bn_rand(a, BN_NEG, BN_BITS); + bn_rand(a, BN_NEG, RELIC_BN_BITS); bn_zero(b); bn_gcd(c, a, b); TEST_ASSERT(bn_cmp_abs(c, a) == CMP_EQ, end); } TEST_END; TEST_BEGIN("extended greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd_ext(c, d, e, a, b); bn_mul(d, d, a); bn_mul(e, e, b); @@ -1111,16 +1111,16 @@ static int gcd(void) { #if BN_GCD == BASIC || !defined(STRIP) TEST_BEGIN("basic greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd(c, a, b); bn_gcd_basic(d, a, b); TEST_ASSERT(bn_cmp(c, d) == CMP_EQ, end); } TEST_END; TEST_BEGIN("basic extended greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd_ext_basic(c, d, e, a, b); bn_mul(d, d, a); bn_mul(e, e, b); @@ -1132,16 +1132,16 @@ static int gcd(void) { #if BN_GCD == LEHME || !defined(STRIP) TEST_BEGIN("lehmer greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd(c, a, b); bn_gcd_lehme(d, a, b); TEST_ASSERT(bn_cmp(c, d) == CMP_EQ, end); } TEST_END; TEST_BEGIN("lehmer extended greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd_ext_lehme(c, d, e, a, b); bn_mul(d, d, a); bn_mul(e, e, b); @@ -1153,16 +1153,16 @@ static int gcd(void) { #if BN_GCD == STEIN || !defined(STRIP) TEST_BEGIN("stein greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd(c, a, b); bn_gcd_stein(d, a, b); TEST_ASSERT(bn_cmp(c, d) == CMP_EQ, end); } TEST_END; TEST_BEGIN("stein extended greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd_ext_stein(c, d, e, a, b); bn_mul(d, d, a); bn_mul(e, e, b); @@ -1172,8 +1172,8 @@ static int gcd(void) { #endif TEST_BEGIN("midway extended greatest common divisor is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_gcd_ext_mid(c, d, e, f, a, b); bn_abs(d, d); bn_abs(f, f); @@ -1211,8 +1211,8 @@ static int lcm(void) { bn_new(c); TEST_BEGIN("least common multiple is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); bn_lcm(c, a, b); bn_mod(a, c, a); bn_mod(b, c, b); @@ -1248,27 +1248,27 @@ static int symbol(void) { bn_new(q); do { - bn_gen_prime(p, BN_BITS); - bn_gen_prime(q, BN_BITS); + bn_gen_prime(p, RELIC_BN_BITS); + bn_gen_prime(q, RELIC_BN_BITS); } while (bn_is_even(p) || bn_is_even(q)); TEST_BEGIN("legendre symbol is correct") { bn_smb_leg(c, p, p); TEST_ASSERT(bn_is_zero(c) == 1, end); - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_sqr(a, a); bn_mod(a, a, p); bn_smb_leg(c, a, p); TEST_ASSERT(bn_cmp_dig(c, 1) == CMP_EQ, end); - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_smb_leg(c, a, p); bn_set_dig(a, 1); TEST_ASSERT(bn_cmp_abs(c, a) == CMP_EQ, end); } TEST_END; TEST_BEGIN("legendre symbol is a homomorphism") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); bn_mul(c, a, b); bn_smb_leg(a, a, p); bn_smb_leg(b, b, p); @@ -1315,16 +1315,16 @@ static int symbol(void) { } TEST_END; TEST_BEGIN("jacobi symbol is correct") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_smb_leg(c, a, p); bn_smb_jac(b, a, p); TEST_ASSERT(bn_cmp_abs(c, b) == CMP_EQ, end); } TEST_END; TEST_BEGIN("jacobi symbol is a homomorphism") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(b, BN_POS, BN_BITS / 2); - bn_rand(p, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(b, BN_POS, RELIC_BN_BITS / 2); + bn_rand(p, BN_POS, RELIC_BN_BITS / 2); if (bn_is_even(p)) { bn_add_dig(p, p, 1); } @@ -1337,8 +1337,8 @@ static int symbol(void) { } TEST_END; TEST_BEGIN("jacobi symbol is consistent with gcd") { - bn_rand(a, BN_POS, BN_BITS / 2); - bn_rand(p, BN_POS, BN_BITS / 2); + bn_rand(a, BN_POS, RELIC_BN_BITS / 2); + bn_rand(p, BN_POS, RELIC_BN_BITS / 2); if (bn_is_even(p)) { bn_add_dig(p, p, 1); } @@ -1353,11 +1353,11 @@ static int symbol(void) { } TEST_END; TEST_BEGIN("jacobi symbol respects quadratic reciprocity") { - bn_rand(p, BN_POS, BN_BITS / 2); + bn_rand(p, BN_POS, RELIC_BN_BITS / 2); if (bn_is_even(p)) { bn_add_dig(p, p, 1); } - bn_rand(q, BN_POS, BN_BITS / 2); + bn_rand(q, BN_POS, RELIC_BN_BITS / 2); if (bn_is_even(q)) { bn_add_dig(q, q, 1); } @@ -1431,7 +1431,7 @@ static int digit(void) { bn_new(f); TEST_BEGIN("addition of a single digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); bn_get_dig(&g, b); bn_add(c, a, b); @@ -1440,7 +1440,7 @@ static int digit(void) { } TEST_END; TEST_BEGIN("subtraction of a single digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); bn_get_dig(&g, b); bn_sub(c, a, b); @@ -1449,7 +1449,7 @@ static int digit(void) { } TEST_END; TEST_BEGIN("multiplication by a single digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); bn_get_dig(&g, b); bn_mul(c, a, b); @@ -1458,7 +1458,7 @@ static int digit(void) { } TEST_END; TEST_BEGIN("division by a single digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); if (b->dp[0] == 0) continue; @@ -1473,7 +1473,7 @@ static int digit(void) { TEST_END; TEST_BEGIN("modular reduction modulo a digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); if (b->dp[0] == 0) continue; @@ -1484,7 +1484,7 @@ static int digit(void) { TEST_END; TEST_BEGIN("greatest common divisor with a digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); bn_get_dig(&g, b); bn_gcd(c, a, b); @@ -1496,7 +1496,7 @@ static int digit(void) { TEST_BEGIN ("extended greatest common divisor with a digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); bn_get_dig(&g, b); bn_gcd_ext_dig(c, d, e, a, g); @@ -1508,7 +1508,7 @@ static int digit(void) { TEST_END; #if BN_MOD != PMERS - bn_gen_prime(d, BN_BITS); + bn_gen_prime(d, RELIC_BN_BITS); #elif BN_PRECI >= 128 /* Let's try a Mersenne prime. */ bn_zero(d); @@ -1517,7 +1517,7 @@ static int digit(void) { #endif TEST_BEGIN("modular exponentiation with a digit is consistent") { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); bn_rand(b, BN_POS, BN_DIGIT); bn_get_dig(&g, b); bn_mxp(c, a, b, d); @@ -1550,20 +1550,20 @@ static int prime(void) { bn_new(p); TEST_ONCE("prime generation is consistent") { - bn_gen_prime(p, BN_BITS); + bn_gen_prime(p, RELIC_BN_BITS); TEST_ASSERT(bn_is_prime(p) == 1, end); } TEST_END; #if BN_GEN == BASIC || !defined(STRIP) TEST_ONCE("basic prime generation is consistent") { - bn_gen_prime_basic(p, BN_BITS); + bn_gen_prime_basic(p, RELIC_BN_BITS); TEST_ASSERT(bn_is_prime(p) == 1, end); } TEST_END; #endif #if BN_GEN == SAFEP || !defined(STRIP) TEST_ONCE("safe prime generation is consistent") { - bn_gen_prime_safep(p, BN_BITS); + bn_gen_prime_safep(p, RELIC_BN_BITS); TEST_ASSERT(bn_is_prime(p) == 1, end); bn_sub_dig(p, p, 1); bn_hlv(p, p); @@ -1573,12 +1573,12 @@ static int prime(void) { #if BN_GEN == STRON || !defined(STRIP) TEST_ONCE("strong prime generation is consistent") { - bn_gen_prime_stron(p, BN_BITS); + bn_gen_prime_stron(p, RELIC_BN_BITS); TEST_ASSERT(bn_is_prime(p) == 1, end); } TEST_END; #endif - bn_gen_prime(p, BN_BITS); + bn_gen_prime(p, RELIC_BN_BITS); TEST_ONCE("basic prime testing is correct") { TEST_ASSERT(bn_is_prime_basic(p) == 1, end); @@ -1616,7 +1616,7 @@ static int factor(void) { TEST_ONCE("integer factorization is consistent") { bn_gen_prime(p, 16); - bn_rand(n, BN_POS, BN_BITS - 16); + bn_rand(n, BN_POS, RELIC_BN_BITS - 16); bn_mul(n, n, p); if (bn_factor(q, n) == 1) { TEST_ASSERT(bn_is_factor(q, n) == 1, end); @@ -1640,8 +1640,8 @@ static int recoding(void) { int code = STS_ERR; bn_t a, b, c, v1[3], v2[3]; int w, k, l; - uint8_t d[BN_BITS + 1]; - signed char e[2 * (BN_BITS + 1)]; + uint8_t d[RELIC_BN_BITS + 1]; + signed char e[2 * (RELIC_BN_BITS + 1)]; bn_null(a); bn_null(b); @@ -1662,8 +1662,8 @@ static int recoding(void) { TEST_BEGIN("window recoding is correct") { for (w = 2; w <= 8; w++) { - bn_rand(a, BN_POS, BN_BITS); - l = BN_BITS + 1; + bn_rand(a, BN_POS, RELIC_BN_BITS); + l = RELIC_BN_BITS + 1; bn_rec_win(d, &l, a, w); bn_zero(b); for (k = l - 1; k >= 0; k--) { @@ -1676,8 +1676,8 @@ static int recoding(void) { TEST_BEGIN("sliding window recoding is correct") { for (w = 2; w <= 8; w++) { - bn_rand(a, BN_POS, BN_BITS); - l = BN_BITS + 1; + bn_rand(a, BN_POS, RELIC_BN_BITS); + l = RELIC_BN_BITS + 1; bn_rec_slw(d, &l, a, w); bn_zero(b); for (k = 0; k < l; k++) { @@ -1694,8 +1694,8 @@ static int recoding(void) { TEST_BEGIN("naf recoding is correct") { for (w = 2; w <= 8; w++) { - bn_rand(a, BN_POS, BN_BITS); - l = BN_BITS + 1; + bn_rand(a, BN_POS, RELIC_BN_BITS); + l = RELIC_BN_BITS + 1; bn_rec_naf(e, &l, a, w); bn_zero(b); for (k = l - 1; k >= 0; k--) { @@ -1847,12 +1847,12 @@ static int recoding(void) { TEST_BEGIN("regular recoding is correct") { for (w = 2; w <= 8; w++) { - bn_rand(a, BN_POS, BN_BITS); + bn_rand(a, BN_POS, RELIC_BN_BITS); if (bn_is_even(a)) { bn_add_dig(a, a, 1); } - l = BN_BITS + 1; - bn_rec_reg(e, &l, a, BN_BITS, w); + l = RELIC_BN_BITS + 1; + bn_rec_reg(e, &l, a, RELIC_BN_BITS, w); bn_zero(b); for (k = l - 1; k >= 0; k--) { bn_lsh(b, b, w - 1); @@ -1867,9 +1867,9 @@ static int recoding(void) { } TEST_END; TEST_BEGIN("jsf recoding is correct") { - bn_rand(a, BN_POS, BN_BITS); - bn_rand(b, BN_POS, BN_BITS); - l = 2 * (BN_BITS + 1); + bn_rand(a, BN_POS, RELIC_BN_BITS); + bn_rand(b, BN_POS, RELIC_BN_BITS); + l = 2 * (RELIC_BN_BITS + 1); bn_rec_jsf(e, &l, a, b); w = MAX(bn_bits(a), bn_bits(b)) + 1; bn_add(a, a, b); diff --git a/test/test_cp.c b/test/test_cp.c index c10ca75a1..3e643a2c4 100644 --- a/test/test_cp.c +++ b/test/test_cp.c @@ -37,7 +37,7 @@ static int rsa(void) { int code = STS_ERR; rsa_t pub, prv; - uint8_t in[10], out[BN_BITS / 8 + 1], h[MD_LEN]; + uint8_t in[10], out[RELIC_BN_BITS / 8 + 1], h[MD_LEN]; int il, ol; int result; @@ -48,12 +48,12 @@ static int rsa(void) { rsa_new(pub); rsa_new(prv); - result = cp_rsa_gen(pub, prv, BN_BITS); + result = cp_rsa_gen(pub, prv, RELIC_BN_BITS); TEST_BEGIN("rsa encryption/decryption is correct") { TEST_ASSERT(result == STS_OK, end); il = 10; - ol = BN_BITS / 8 + 1; + ol = RELIC_BN_BITS / 8 + 1; rand_bytes(in, il); TEST_ASSERT(cp_rsa_enc(out, &ol, in, il, pub) == STS_OK, end); TEST_ASSERT(cp_rsa_dec(out, &ol, out, ol, prv) == STS_OK, end); @@ -61,12 +61,12 @@ static int rsa(void) { } TEST_END; #if CP_RSA == BASIC || !defined(STRIP) - result = cp_rsa_gen_basic(pub, prv, BN_BITS); + result = cp_rsa_gen_basic(pub, prv, RELIC_BN_BITS); TEST_BEGIN("basic rsa encryption/decryption is correct") { TEST_ASSERT(result == STS_OK, end); il = 10; - ol = BN_BITS / 8 + 1; + ol = RELIC_BN_BITS / 8 + 1; rand_bytes(in, il); TEST_ASSERT(cp_rsa_enc(out, &ol, in, il, pub) == STS_OK, end); TEST_ASSERT(cp_rsa_dec_basic(out, &ol, out, ol, prv) == STS_OK, @@ -76,12 +76,12 @@ static int rsa(void) { #endif #if CP_RSA == QUICK || !defined(STRIP) - result = cp_rsa_gen_quick(pub, prv, BN_BITS); + result = cp_rsa_gen_quick(pub, prv, RELIC_BN_BITS); TEST_BEGIN("fast rsa encryption/decryption is correct") { TEST_ASSERT(result == STS_OK, end); il = 10; - ol = BN_BITS / 8 + 1; + ol = RELIC_BN_BITS / 8 + 1; rand_bytes(in, il); TEST_ASSERT(cp_rsa_enc(out, &ol, in, il, pub) == STS_OK, end); TEST_ASSERT(cp_rsa_dec_quick(out, &ol, out, ol, prv) == STS_OK, @@ -90,12 +90,12 @@ static int rsa(void) { } TEST_END; #endif - result = cp_rsa_gen(pub, prv, BN_BITS); + result = cp_rsa_gen(pub, prv, RELIC_BN_BITS); TEST_BEGIN("rsa signature/verification is correct") { TEST_ASSERT(result == STS_OK, end); il = 10; - ol = BN_BITS / 8 + 1; + ol = RELIC_BN_BITS / 8 + 1; rand_bytes(in, il); TEST_ASSERT(cp_rsa_sig(out, &ol, in, il, 0, prv) == STS_OK, end); TEST_ASSERT(cp_rsa_ver(out, ol, in, il, 0, pub) == 1, end); @@ -105,12 +105,12 @@ static int rsa(void) { } TEST_END; #if CP_RSA == BASIC || !defined(STRIP) - result = cp_rsa_gen_basic(pub, prv, BN_BITS); + result = cp_rsa_gen_basic(pub, prv, RELIC_BN_BITS); TEST_BEGIN("basic rsa signature/verification is correct") { TEST_ASSERT(result == STS_OK, end); il = 10; - ol = BN_BITS / 8 + 1; + ol = RELIC_BN_BITS / 8 + 1; rand_bytes(in, il); TEST_ASSERT(cp_rsa_sig_basic(out, &ol, in, il, 0, prv) == STS_OK, end); @@ -123,12 +123,12 @@ static int rsa(void) { #endif #if CP_RSA == QUICK || !defined(STRIP) - result = cp_rsa_gen_quick(pub, prv, BN_BITS); + result = cp_rsa_gen_quick(pub, prv, RELIC_BN_BITS); TEST_BEGIN("fast rsa signature/verification is correct") { TEST_ASSERT(result == STS_OK, end); il = 10; - ol = BN_BITS / 8 + 1; + ol = RELIC_BN_BITS / 8 + 1; rand_bytes(in, il); TEST_ASSERT(cp_rsa_sig_quick(out, &ol, in, il, 0, prv) == STS_OK, end); @@ -154,7 +154,7 @@ static int rabin(void) { int code = STS_ERR; rabin_t pub, prv; uint8_t in[10]; - uint8_t out[BN_BITS / 8 + 1]; + uint8_t out[RELIC_BN_BITS / 8 + 1]; int in_len, out_len; int result; @@ -165,12 +165,12 @@ static int rabin(void) { rabin_new(pub); rabin_new(prv); - result = cp_rabin_gen(pub, prv, BN_BITS); + result = cp_rabin_gen(pub, prv, RELIC_BN_BITS); TEST_BEGIN("rabin encryption/decryption is correct") { TEST_ASSERT(result == STS_OK, end); in_len = 10; - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; rand_bytes(in, in_len); TEST_ASSERT(cp_rabin_enc(out, &out_len, in, in_len, pub) == STS_OK, end); @@ -194,7 +194,7 @@ static int benaloh(void) { bdpe_t pub, prv; bn_t a, b; dig_t in, out; - uint8_t buf[BN_BITS / 8 + 1]; + uint8_t buf[RELIC_BN_BITS / 8 + 1]; int len; int result; @@ -209,11 +209,11 @@ static int benaloh(void) { bdpe_new(pub); bdpe_new(prv); - result = cp_bdpe_gen(pub, prv, bn_get_prime(47), BN_BITS); + result = cp_bdpe_gen(pub, prv, bn_get_prime(47), RELIC_BN_BITS); TEST_BEGIN("benaloh encryption/decryption is correct") { TEST_ASSERT(result == STS_OK, end); - len = BN_BITS / 8 + 1; + len = RELIC_BN_BITS / 8 + 1; rand_bytes(buf, 1); in = buf[0] % bn_get_prime(47); TEST_ASSERT(cp_bdpe_enc(buf, &len, in, pub) == STS_OK, end); @@ -223,7 +223,7 @@ static int benaloh(void) { TEST_BEGIN("benaloh encryption/decryption is homomorphic") { TEST_ASSERT(result == STS_OK, end); - len = BN_BITS / 8 + 1; + len = RELIC_BN_BITS / 8 + 1; rand_bytes(buf, 1); in = buf[0] % bn_get_prime(47); TEST_ASSERT(cp_bdpe_enc(buf, &len, in, pub) == STS_OK, end); @@ -256,7 +256,7 @@ static int benaloh(void) { static int paillier(void) { int code = STS_ERR; bn_t a, b, c, d, n, l, s; - uint8_t in[BN_BITS / 8 + 1], out[BN_BITS / 8 + 1]; + uint8_t in[RELIC_BN_BITS / 8 + 1], out[RELIC_BN_BITS / 8 + 1]; int in_len, out_len; int result; @@ -277,12 +277,12 @@ static int paillier(void) { bn_new(l); bn_new(s); - result = cp_phpe_gen(n, l, BN_BITS / 2); + result = cp_phpe_gen(n, l, RELIC_BN_BITS / 2); TEST_BEGIN("paillier encryption/decryption is correct") { TEST_ASSERT(result == STS_OK, end); in_len = bn_size_bin(n); - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; memset(in, 0, sizeof(in)); rand_bytes(in + (in_len - 10), 10); TEST_ASSERT(cp_phpe_enc(out, &out_len, in, in_len, n) == STS_OK, @@ -296,7 +296,7 @@ static int paillier(void) { TEST_BEGIN("paillier encryption/decryption is homomorphic") { TEST_ASSERT(result == STS_OK, end); in_len = bn_size_bin(n); - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; memset(in, 0, sizeof(in)); rand_bytes(in + (in_len - 10), 10); bn_read_bin(a, in, in_len); @@ -306,7 +306,7 @@ static int paillier(void) { memset(in, 0, sizeof(in)); rand_bytes(in + (in_len - 10), 10); bn_read_bin(c, in, in_len); - out_len = BN_BITS / 8 + 1; + out_len = RELIC_BN_BITS / 8 + 1; TEST_ASSERT(cp_phpe_enc(out, &out_len, in, in_len, n) == STS_OK, end); bn_read_bin(d, out, out_len); diff --git a/test/test_eb.c b/test/test_eb.c index ea9fc0267..18da7281f 100644 --- a/test/test_eb.c +++ b/test/test_eb.c @@ -761,7 +761,7 @@ static int multiplication(void) { static int fixed(void) { int code = STS_ERR; bn_t n, k; - eb_t p, q, r, t[EB_TABLE_MAX]; + eb_t p, q, r, t[RELIC_EB_TABLE_MAX]; bn_null(n); bn_null(k); @@ -769,7 +769,7 @@ static int fixed(void) { eb_null(q); eb_null(r); - for (int i = 0; i < EB_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EB_TABLE_MAX; i++) { eb_null(t[i]); } @@ -782,7 +782,7 @@ static int fixed(void) { eb_curve_get_ord(n); - for (int i = 0; i < EB_TABLE; i++) { + for (int i = 0; i < RELIC_EB_TABLE; i++) { eb_new(t[i]); } TEST_BEGIN("fixed point multiplication is correct") { @@ -794,12 +794,12 @@ static int fixed(void) { eb_mul(r, p, k); TEST_ASSERT(eb_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EB_TABLE; i++) { + for (int i = 0; i < RELIC_EB_TABLE; i++) { eb_free(t[i]); } #if EB_FIX == BASIC || !defined(STRIP) - for (int i = 0; i < EB_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EB_TABLE_BASIC; i++) { eb_new(t[i]); } TEST_BEGIN("binary fixed point multiplication is correct") { @@ -811,13 +811,13 @@ static int fixed(void) { eb_mul(r, p, k); TEST_ASSERT(eb_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EB_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EB_TABLE_BASIC; i++) { eb_free(t[i]); } #endif #if EB_FIX == YAOWI || !defined(STRIP) - for (int i = 0; i < EB_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_YAOWI; i++) { eb_new(t[i]); } TEST_BEGIN("yao windowing fixed point multiplication is correct") { @@ -829,13 +829,13 @@ static int fixed(void) { eb_mul(r, p, k); TEST_ASSERT(eb_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EB_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_YAOWI; i++) { eb_free(t[i]); } #endif #if EB_FIX == NAFWI || !defined(STRIP) - for (int i = 0; i < EB_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_NAFWI; i++) { eb_new(t[i]); } TEST_BEGIN("naf windowing fixed point multiplication is correct") { @@ -847,13 +847,13 @@ static int fixed(void) { eb_mul(r, p, k); TEST_ASSERT(eb_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EB_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EB_TABLE_NAFWI; i++) { eb_free(t[i]); } #endif #if EB_FIX == COMBS || !defined(STRIP) - for (int i = 0; i < EB_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBS; i++) { eb_new(t[i]); } TEST_BEGIN("single-table comb fixed point multiplication is correct") { @@ -865,13 +865,13 @@ static int fixed(void) { eb_mul(r, p, k); TEST_ASSERT(eb_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EB_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBS; i++) { eb_free(t[i]); } #endif #if EB_FIX == COMBD || !defined(STRIP) - for (int i = 0; i < EB_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBD; i++) { eb_new(t[i]); } TEST_BEGIN("double-table comb fixed point multiplication is correct") { @@ -884,13 +884,13 @@ static int fixed(void) { eb_mul(r, p, k); TEST_ASSERT(eb_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EB_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EB_TABLE_COMBD; i++) { eb_free(t[i]); } #endif #if EB_FIX == LWNAF || !defined(STRIP) - for (int i = 0; i < EB_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EB_TABLE_LWNAF; i++) { eb_new(t[i]); } TEST_BEGIN("w(t)naf fixed point multiplication is correct") { @@ -902,7 +902,7 @@ static int fixed(void) { eb_mul(r, p, k); TEST_ASSERT(eb_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EB_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EB_TABLE_LWNAF; i++) { eb_free(t[i]); } #endif diff --git a/test/test_ec.c b/test/test_ec.c index 71f05b1cf..f955cbbdd 100644 --- a/test/test_ec.c +++ b/test/test_ec.c @@ -370,7 +370,7 @@ static int multiplication(void) { static int fixed(void) { int code = STS_ERR; bn_t n, k; - ec_t p, q, r, t[EC_TABLE]; + ec_t p, q, r, t[RELIC_EC_TABLE]; bn_null(n); bn_null(k); @@ -378,7 +378,7 @@ static int fixed(void) { ec_null(q); ec_null(r); - for (int i = 0; i < EC_TABLE; i++) { + for (int i = 0; i < RELIC_EC_TABLE; i++) { ec_null(t[i]); } @@ -392,7 +392,7 @@ static int fixed(void) { ec_curve_get_gen(p); ec_curve_get_ord(n); - for (int i = 0; i < EC_TABLE; i++) { + for (int i = 0; i < RELIC_EC_TABLE; i++) { ec_new(t[i]); } TEST_BEGIN("fixed point multiplication is correct") { @@ -403,7 +403,7 @@ static int fixed(void) { ec_mul(r, p, k); TEST_ASSERT(ec_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EC_TABLE; i++) { + for (int i = 0; i < RELIC_EC_TABLE; i++) { ec_free(t[i]); } } diff --git a/test/test_ep.c b/test/test_ep.c index ce60351fa..91546d23f 100644 --- a/test/test_ep.c +++ b/test/test_ep.c @@ -563,7 +563,7 @@ static int multiplication(void) { static int fixed(void) { int code = STS_ERR; bn_t n, k; - ep_t p, q, r, t[EP_TABLE_MAX]; + ep_t p, q, r, t[RELIC_EP_TABLE_MAX]; bn_null(n); bn_null(k); @@ -571,7 +571,7 @@ static int fixed(void) { ep_null(q); ep_null(r); - for (int i = 0; i < EP_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EP_TABLE_MAX; i++) { ep_null(t[i]); } @@ -585,7 +585,7 @@ static int fixed(void) { ep_curve_get_gen(p); ep_curve_get_ord(n); - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { ep_new(t[i]); } TEST_BEGIN("fixed point multiplication is correct") { @@ -596,12 +596,12 @@ static int fixed(void) { ep_mul(r, p, k); TEST_ASSERT(ep_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EP_TABLE; i++) { + for (int i = 0; i < RELIC_EP_TABLE; i++) { ep_free(t[i]); } #if EP_FIX == BASIC || !defined(STRIP) - for (int i = 0; i < EP_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EP_TABLE_BASIC; i++) { ep_new(t[i]); } TEST_BEGIN("binary fixed point multiplication is correct") { @@ -612,13 +612,13 @@ static int fixed(void) { ep_mul(r, p, k); TEST_ASSERT(ep_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EP_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EP_TABLE_BASIC; i++) { ep_free(t[i]); } #endif #if EP_FIX == YAOWI || !defined(STRIP) - for (int i = 0; i < EP_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_YAOWI; i++) { ep_new(t[i]); } TEST_BEGIN("yao windowing fixed point multiplication is correct") { @@ -629,13 +629,13 @@ static int fixed(void) { ep_mul(r, p, k); TEST_ASSERT(ep_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EP_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_YAOWI; i++) { ep_free(t[i]); } #endif #if EP_FIX == NAFWI || !defined(STRIP) - for (int i = 0; i < EP_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_NAFWI; i++) { ep_new(t[i]); } TEST_BEGIN("naf windowing fixed point multiplication is correct") { @@ -646,13 +646,13 @@ static int fixed(void) { ep_mul(r, p, k); TEST_ASSERT(ep_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EP_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EP_TABLE_NAFWI; i++) { ep_free(t[i]); } #endif #if EP_FIX == COMBS || !defined(STRIP) - for (int i = 0; i < EP_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBS; i++) { ep_new(t[i]); } TEST_BEGIN("single-table comb fixed point multiplication is correct") { @@ -663,13 +663,13 @@ static int fixed(void) { ep_mul(r, p, k); TEST_ASSERT(ep_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EP_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBS; i++) { ep_free(t[i]); } #endif #if EP_FIX == COMBD || !defined(STRIP) - for (int i = 0; i < EP_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBD; i++) { ep_new(t[i]); } TEST_BEGIN("double-table comb fixed point multiplication is correct") { @@ -680,13 +680,13 @@ static int fixed(void) { ep_mul(r, p, k); TEST_ASSERT(ep_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EP_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EP_TABLE_COMBD; i++) { ep_free(t[i]); } #endif #if EP_FIX == LWNAF || !defined(STRIP) - for (int i = 0; i < EP_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EP_TABLE_LWNAF; i++) { ep_new(t[i]); } TEST_BEGIN("left-to-right w-naf fixed point multiplication is correct") { @@ -697,7 +697,7 @@ static int fixed(void) { ep_mul(r, p, k); TEST_ASSERT(ep_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EP_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EP_TABLE_LWNAF; i++) { ep_free(t[i]); } #endif diff --git a/test/test_epx.c b/test/test_epx.c index ae11955f5..c338c5f6b 100644 --- a/test/test_epx.c +++ b/test/test_epx.c @@ -540,7 +540,7 @@ static int multiplication(void) { static int fixed(void) { int code = STS_ERR; bn_t n, k; - ep2_t p, q, r, t[EPX_TABLE_MAX]; + ep2_t p, q, r, t[RELIC_EPX_TABLE_MAX]; bn_null(n); bn_null(k); @@ -548,7 +548,7 @@ static int fixed(void) { ep2_null(q); ep2_null(r); - for (int i = 0; i < EPX_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_MAX; i++) { ep2_null(t[i]); } @@ -562,7 +562,7 @@ static int fixed(void) { ep2_curve_get_gen(p); ep2_curve_get_ord(n); - for (int i = 0; i < EPX_TABLE; i++) { + for (int i = 0; i < RELIC_EPX_TABLE; i++) { ep2_new(t[i]); } TEST_BEGIN("fixed point multiplication is correct") { @@ -573,12 +573,12 @@ static int fixed(void) { ep2_mul(r, p, k); TEST_ASSERT(ep2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EPX_TABLE; i++) { + for (int i = 0; i < RELIC_EPX_TABLE; i++) { ep2_free(t[i]); } #if EP_FIX == BASIC || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_BASIC; i++) { ep2_new(t[i]); } TEST_BEGIN("binary fixed point multiplication is correct") { @@ -589,13 +589,13 @@ static int fixed(void) { ep2_mul(r, p, k); TEST_ASSERT(ep2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EPX_TABLE_BASIC; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_BASIC; i++) { ep2_free(t[i]); } #endif #if EP_FIX == YAOWI || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_YAOWI; i++) { ep2_new(t[i]); } TEST_BEGIN("yao windowing fixed point multiplication is correct") { @@ -606,13 +606,13 @@ static int fixed(void) { ep2_mul(r, p, k); TEST_ASSERT(ep2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EPX_TABLE_YAOWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_YAOWI; i++) { ep2_free(t[i]); } #endif #if EP_FIX == NAFWI || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_NAFWI; i++) { ep2_new(t[i]); } TEST_BEGIN("naf windowing fixed point multiplication is correct") { @@ -623,13 +623,13 @@ static int fixed(void) { ep2_mul(r, p, k); TEST_ASSERT(ep2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EPX_TABLE_NAFWI; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_NAFWI; i++) { ep2_free(t[i]); } #endif #if EP_FIX == COMBS || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBS; i++) { ep2_new(t[i]); } TEST_BEGIN("single-table comb fixed point multiplication is correct") { @@ -640,13 +640,13 @@ static int fixed(void) { ep2_mul(r, p, k); TEST_ASSERT(ep2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EPX_TABLE_COMBS; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBS; i++) { ep2_free(t[i]); } #endif #if EP_FIX == COMBD || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBD; i++) { ep2_new(t[i]); } TEST_BEGIN("double-table comb fixed point multiplication is correct") { @@ -657,13 +657,13 @@ static int fixed(void) { ep2_mul(r, p, k); TEST_ASSERT(ep2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EPX_TABLE_COMBD; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_COMBD; i++) { ep2_free(t[i]); } #endif #if EP_FIX == LWNAF || !defined(STRIP) - for (int i = 0; i < EPX_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_LWNAF; i++) { ep2_new(t[i]); } TEST_BEGIN("left-to-right w-naf fixed point multiplication is correct") { @@ -674,7 +674,7 @@ static int fixed(void) { ep2_mul(r, p, k); TEST_ASSERT(ep2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < EPX_TABLE_LWNAF; i++) { + for (int i = 0; i < RELIC_EPX_TABLE_LWNAF; i++) { ep2_free(t[i]); } #endif diff --git a/test/test_fb.c b/test/test_fb.c index 6b78e48aa..a536e31d7 100644 --- a/test/test_fb.c +++ b/test/test_fb.c @@ -517,7 +517,7 @@ static int squaring(void) { } TEST_END; #endif -#if FB_SQR == TABLE || !defined(STRIP) +#if FB_SQR == RELIC_TABLE || !defined(STRIP) TEST_BEGIN("table squaring is correct") { fb_rand(a); fb_sqr(b, a); @@ -970,13 +970,13 @@ static int inversion(void) { static int exponentiation(void) { int code = STS_ERR; - fb_t a, b, c, t[FB_TABLE_MAX]; + fb_t a, b, c, t[RELIC_FB_TABLE_MAX]; bn_t d; fb_null(a); fb_null(b); fb_null(c); - for (int i = 0; i < FB_TABLE_MAX; i++) { + for (int i = 0; i < RELIC_FB_TABLE_MAX; i++) { fb_null(t[i]); } bn_null(d); @@ -1036,7 +1036,7 @@ static int exponentiation(void) { } TEST_END; #endif - for (int i = 0; i < FB_TABLE; i++) { + for (int i = 0; i < RELIC_FB_TABLE; i++) { fb_new(t[i]); } @@ -1062,7 +1062,7 @@ static int exponentiation(void) { TEST_ASSERT(fb_cmp(a, b) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < FB_TABLE; i++) { + for (int i = 0; i < RELIC_FB_TABLE; i++) { fb_free(t[i]); } @@ -1089,7 +1089,7 @@ static int exponentiation(void) { #endif #if FB_ITR == QUICK || !defined(STRIP) - for (int i = 0; i < FB_TABLE_QUICK; i++) { + for (int i = 0; i < RELIC_FB_TABLE_QUICK; i++) { fb_new(t[i]); fb_zero(t[i]); } @@ -1115,7 +1115,7 @@ static int exponentiation(void) { TEST_ASSERT(fb_cmp(a, b) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < FB_TABLE_QUICK; i++) { + for (int i = 0; i < RELIC_FB_TABLE_QUICK; i++) { fb_free(t[i]); } #endif diff --git a/test/test_fp.c b/test/test_fp.c index 4e314abfe..277938aaa 100644 --- a/test/test_fp.c +++ b/test/test_fp.c @@ -170,7 +170,7 @@ static int util(void) { TEST_ASSERT(fp_get_bit(a, bits) == 1, end); fp_set_bit(a, bits, 0); TEST_ASSERT(fp_get_bit(a, bits) == 0, end); - bits = (bits + 1) % BN_BITS; + bits = (bits + 1) % RELIC_BN_BITS; } TEST_END; diff --git a/test/test_md.c b/test/test_md.c index adc297151..10dc12b32 100644 --- a/test/test_md.c +++ b/test/test_md.c @@ -360,7 +360,7 @@ static int hmac(void) { "Test Using Larger Than Block-Size Key - Hash Key First", "This is a test using a larger than block-size key and a larger " "than block-size data. The key needs to be hashed before being " - "used by the HMAC algorithm." + "used by the RELIC_HMAC algorithm." }; #define FUNCTION "sha256" diff --git a/test/test_pc.c b/test/test_pc.c index d46475af1..1e3bfcf5c 100755 --- a/test/test_pc.c +++ b/test/test_pc.c @@ -368,7 +368,7 @@ static int multiplication1(void) { static int fixed1(void) { int code = STS_ERR; g1_t p, q, r; - g1_t t[G1_TABLE]; + g1_t t[RELIC_G1_TABLE]; bn_t n, k; bn_null(n); @@ -377,7 +377,7 @@ static int fixed1(void) { g1_null(q); g1_null(r); - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g1_null(t[i]); } @@ -391,7 +391,7 @@ static int fixed1(void) { g1_get_gen(p); g1_get_ord(n); - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g1_new(t[i]); } TEST_BEGIN("fixed point multiplication is correct") { @@ -402,7 +402,7 @@ static int fixed1(void) { g1_mul(r, p, k); TEST_ASSERT(g1_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < G1_TABLE; i++) { + for (int i = 0; i < RELIC_G1_TABLE; i++) { g1_free(t[i]); } } @@ -850,7 +850,7 @@ static int multiplication2(void) { static int fixed2(void) { int code = STS_ERR; g2_t p, q, r; - g2_t t[G2_TABLE]; + g2_t t[RELIC_G2_TABLE]; bn_t n, k; bn_null(n); @@ -859,7 +859,7 @@ static int fixed2(void) { g2_null(q); g2_null(r); - for (int i = 0; i < G2_TABLE; i++) { + for (int i = 0; i < RELIC_G2_TABLE; i++) { g2_null(t[i]); } @@ -873,7 +873,7 @@ static int fixed2(void) { g2_get_gen(p); g2_get_ord(n); - for (int i = 0; i < G2_TABLE; i++) { + for (int i = 0; i < RELIC_G2_TABLE; i++) { g2_new(t[i]); } TEST_BEGIN("fixed point multiplication is correct") { @@ -884,7 +884,7 @@ static int fixed2(void) { g2_mul(r, p, k); TEST_ASSERT(g2_cmp(q, r) == CMP_EQ, end); } TEST_END; - for (int i = 0; i < G2_TABLE; i++) { + for (int i = 0; i < RELIC_G2_TABLE; i++) { g2_free(t[i]); } }