Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed May 9, 2024
2 parents bba57ce + 8bb67fa commit 57b01bb
Show file tree
Hide file tree
Showing 34 changed files with 171 additions and 231 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ else()
set(CFLAGS "$ENV{CFLAGS}" CACHE STRING "User-chosen compiler flags.")
endif()

# Remove annoying flags when compiler cannot compute buffer sizes.
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CFLAGS "${CFLAGS} -Wno-stringop-overflow -Wno-stringop-overread")
endif()

if(AUSAN)
set(DFLAGS "${DFLAGS} -ggdb -fsanitize=address -fsanitize=undefined")
endif()
Expand Down
7 changes: 6 additions & 1 deletion cmake/gmp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ endif()
if(GMP_FOUND)
message(STATUS "Configured GMP: -I${GMP_INCLUDE_DIR} -L${GMP_LIBRARIES}")
else(GMP_FOUND)
message(STATUS "Could NOT find GMP")
if(NOT GMP_INCLUDE_DIR)
message(STATUS "Could NOT find GMP headers")
endif()
if(NOT GMP_LIBRARIES)
message(STATUS "Could NOT find GMP library")
endif()
endif(GMP_FOUND)

mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES)
12 changes: 7 additions & 5 deletions include/low/relic_bn_low.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#ifdef ASM

#include "relic_conf.h"
#include "relic_label.h"

#if (BN_PRECI % WSIZE) > 0
#define RLC_BN_DIGS (BN_PRECI/WSIZE + 1)
Expand Down Expand Up @@ -112,12 +113,13 @@ dig_t bn_subn_low(dig_t *c, const dig_t *a, const dig_t *b, size_t size);
/**
* Conditionally negate a digit vector using two's complement representation.
*
* @param[out] c - the result.
* @param[in] a - the digit vector to conditionally negate.
* @param[in] sa - the sign of the digit vector.
* @param[in] n - the number of digits to conditionally negate.
* @param[out] c - the result.
* @param[in] a - the digit vector to conditionally negate.
* @param[in] sa - the sign of the digit vector.
* @param[in] n - the number of digits to conditionally negate.
* @return the carry of the last digit negation.
*/
void bn_negs_low(dig_t *c, const dig_t *a, dig_t sa, size_t size);
dig_t bn_negs_low(dig_t *c, const dig_t *a, dig_t sa, size_t size);

/**
* Compares two digits.
Expand Down
10 changes: 10 additions & 0 deletions include/relic_fpx.h
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,16 @@ void fp8_mul_art(fp8_t c, const fp8_t a);
*/
void fp8_mul_frb(fp8_t c, const fp8_t a, int i, int j);

/**
* Multiplies an octic extension field element by a digit.
* Computes c = a * b.
*
* @param[out] c - the result.
* @param[in] a - the octic extension field element.
* @param[in] b - the digit to multiply.
*/
void fp8_mul_dig(fp8_t c, const fp8_t a, dig_t b);

/**
* Multiples a dense octic extension field element by a sparse element.
*
Expand Down
38 changes: 36 additions & 2 deletions include/relic_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@
#undef bn_addn_low
#undef bn_sub1_low
#undef bn_subn_low
#undef bn_negs_low
#undef bn_cmp1_low
#undef bn_cmpn_low
#undef bn_lsh1_low
Expand All @@ -434,6 +435,7 @@
#define bn_addn_low RLC_PREFIX(bn_addn_low)
#define bn_sub1_low RLC_PREFIX(bn_sub1_low)
#define bn_subn_low RLC_PREFIX(bn_subn_low)
#define bn_negs_low RLC_PREFIX(bn_negs_low)
#define bn_cmp1_low RLC_PREFIX(bn_cmp1_low)
#define bn_cmpn_low RLC_PREFIX(bn_cmpn_low)
#define bn_lsh1_low RLC_PREFIX(bn_lsh1_low)
Expand Down Expand Up @@ -937,6 +939,8 @@
#undef ep_curve_set_plain
#undef ep_curve_set_super
#undef ep_curve_set_endom
#undef ep_curve_embed
#undef ep_curve_frdim
#undef ep_param_set
#undef ep_param_set_any
#undef ep_param_set_any_plain
Expand All @@ -946,7 +950,6 @@
#undef ep_param_get
#undef ep_param_print
#undef ep_param_level
#undef ep_curve_embed
#undef ep_is_infty
#undef ep_set_infty
#undef ep_copy
Expand Down Expand Up @@ -1030,6 +1033,8 @@
#define ep_curve_set_plain RLC_PREFIX(ep_curve_set_plain)
#define ep_curve_set_super RLC_PREFIX(ep_curve_set_super)
#define ep_curve_set_endom RLC_PREFIX(ep_curve_set_endom)
#define ep_curve_embed RLC_PREFIX(ep_curve_embed)
#define ep_curve_frdim RLC_PREFIX(ep_curve_frdim)
#define ep_param_set RLC_PREFIX(ep_param_set)
#define ep_param_set_any RLC_PREFIX(ep_param_set_any)
#define ep_param_set_any_plain RLC_PREFIX(ep_param_set_any_plain)
Expand All @@ -1039,7 +1044,6 @@
#define ep_param_get RLC_PREFIX(ep_param_get)
#define ep_param_print RLC_PREFIX(ep_param_print)
#define ep_param_level RLC_PREFIX(ep_param_level)
#define ep_curve_embed RLC_PREFIX(ep_curve_embed)
#define ep_is_infty RLC_PREFIX(ep_is_infty)
#define ep_set_infty RLC_PREFIX(ep_set_infty)
#define ep_copy RLC_PREFIX(ep_copy)
Expand Down Expand Up @@ -1559,6 +1563,8 @@
#undef ep3_curve_get_b
#undef ep3_curve_opt_a
#undef ep3_curve_opt_b
#undef ep3_curve_mul_a
#undef ep3_curve_mul_b
#undef ep3_curve_is_twist
#undef ep3_curve_get_gen
#undef ep3_curve_get_tab
Expand All @@ -1583,10 +1589,12 @@
#undef ep3_add_basic
#undef ep3_add_slp_basic
#undef ep3_add_projc
#undef ep3_add_jacob
#undef ep3_sub
#undef ep3_dbl_basic
#undef ep3_dbl_slp_basic
#undef ep3_dbl_projc
#undef ep3_dbl_jacob
#undef ep3_mul_basic
#undef ep3_mul_slide
#undef ep3_mul_monty
Expand Down Expand Up @@ -1627,6 +1635,8 @@
#define ep3_curve_get_b RLC_PREFIX(ep3_curve_get_b)
#define ep3_curve_opt_a RLC_PREFIX(ep3_curve_opt_a)
#define ep3_curve_opt_b RLC_PREFIX(ep3_curve_opt_b)
#define ep3_curve_mul_a RLC_PREFIX(ep3_curve_mul_a)
#define ep3_curve_mul_b RLC_PREFIX(ep3_curve_mul_b)
#define ep3_curve_is_twist RLC_PREFIX(ep3_curve_is_twist)
#define ep3_curve_get_gen RLC_PREFIX(ep3_curve_get_gen)
#define ep3_curve_get_tab RLC_PREFIX(ep3_curve_get_tab)
Expand All @@ -1651,10 +1661,12 @@
#define ep3_add_basic RLC_PREFIX(ep3_add_basic)
#define ep3_add_slp_basic RLC_PREFIX(ep3_add_slp_basic)
#define ep3_add_projc RLC_PREFIX(ep3_add_projc)
#define ep3_add_jacob RLC_PREFIX(ep3_add_jacob)
#define ep3_sub RLC_PREFIX(ep3_sub)
#define ep3_dbl_basic RLC_PREFIX(ep3_dbl_basic)
#define ep3_dbl_slp_basic RLC_PREFIX(ep3_dbl_slp_basic)
#define ep3_dbl_projc RLC_PREFIX(ep3_dbl_projc)
#define ep3_dbl_jacob RLC_PREFIX(ep3_dbl_jacob)
#define ep3_mul_basic RLC_PREFIX(ep3_mul_basic)
#define ep3_mul_slide RLC_PREFIX(ep3_mul_slide)
#define ep3_mul_monty RLC_PREFIX(ep3_mul_monty)
Expand Down Expand Up @@ -1700,6 +1712,8 @@
#undef ep4_curve_get_b
#undef ep4_curve_opt_a
#undef ep4_curve_opt_b
#undef ep4_curve_mul_a
#undef ep4_curve_mul_b
#undef ep4_curve_is_twist
#undef ep4_curve_get_gen
#undef ep4_curve_get_tab
Expand All @@ -1724,10 +1738,12 @@
#undef ep4_add_basic
#undef ep4_add_slp_basic
#undef ep4_add_projc
#undef ep4_add_jacob
#undef ep4_sub
#undef ep4_dbl_basic
#undef ep4_dbl_slp_basic
#undef ep4_dbl_projc
#undef ep4_dbl_jacob
#undef ep4_mul_basic
#undef ep4_mul_slide
#undef ep4_mul_monty
Expand Down Expand Up @@ -1768,6 +1784,8 @@
#define ep4_curve_get_b RLC_PREFIX(ep4_curve_get_b)
#define ep4_curve_opt_a RLC_PREFIX(ep4_curve_opt_a)
#define ep4_curve_opt_b RLC_PREFIX(ep4_curve_opt_b)
#define ep4_curve_mul_a RLC_PREFIX(ep4_curve_mul_a)
#define ep4_curve_mul_b RLC_PREFIX(ep4_curve_mul_b)
#define ep4_curve_is_twist RLC_PREFIX(ep4_curve_is_twist)
#define ep4_curve_get_gen RLC_PREFIX(ep4_curve_get_gen)
#define ep4_curve_get_tab RLC_PREFIX(ep4_curve_get_tab)
Expand All @@ -1792,10 +1810,12 @@
#define ep4_add_basic RLC_PREFIX(ep4_add_basic)
#define ep4_add_slp_basic RLC_PREFIX(ep4_add_slp_basic)
#define ep4_add_projc RLC_PREFIX(ep4_add_projc)
#define ep4_add_jacob RLC_PREFIX(ep4_add_jacob)
#define ep4_sub RLC_PREFIX(ep4_sub)
#define ep4_dbl_basic RLC_PREFIX(ep4_dbl_basic)
#define ep4_dbl_slp_basic RLC_PREFIX(ep4_dbl_slp_basic)
#define ep4_dbl_projc RLC_PREFIX(ep4_dbl_projc)
#define ep4_dbl_jacob RLC_PREFIX(ep4_dbl_jacob)
#define ep4_mul_basic RLC_PREFIX(ep4_mul_basic)
#define ep4_mul_slide RLC_PREFIX(ep4_mul_slide)
#define ep4_mul_monty RLC_PREFIX(ep4_mul_monty)
Expand Down Expand Up @@ -1841,6 +1861,8 @@
#undef ep8_curve_get_b
#undef ep8_curve_opt_a
#undef ep8_curve_opt_b
#undef ep8_curve_mul_a
#undef ep8_curve_mul_b
#undef ep8_curve_is_twist
#undef ep8_curve_get_gen
#undef ep8_curve_get_tab
Expand All @@ -1865,10 +1887,12 @@
#undef ep8_add_basic
#undef ep8_add_slp_basic
#undef ep8_add_projc
#undef ep8_add_jacob
#undef ep8_sub
#undef ep8_dbl_basic
#undef ep8_dbl_slp_basic
#undef ep8_dbl_projc
#undef ep8_dbl_jacob
#undef ep8_mul_basic
#undef ep8_mul_slide
#undef ep8_mul_monty
Expand Down Expand Up @@ -1909,6 +1933,8 @@
#define ep8_curve_get_b RLC_PREFIX(ep8_curve_get_b)
#define ep8_curve_opt_a RLC_PREFIX(ep8_curve_opt_a)
#define ep8_curve_opt_b RLC_PREFIX(ep8_curve_opt_b)
#define ep8_curve_mul_a RLC_PREFIX(ep8_curve_mul_a)
#define ep8_curve_mul_b RLC_PREFIX(ep8_curve_mul_b)
#define ep8_curve_is_twist RLC_PREFIX(ep8_curve_is_twist)
#define ep8_curve_get_gen RLC_PREFIX(ep8_curve_get_gen)
#define ep8_curve_get_tab RLC_PREFIX(ep8_curve_get_tab)
Expand All @@ -1933,10 +1959,12 @@
#define ep8_add_basic RLC_PREFIX(ep8_add_basic)
#define ep8_add_slp_basic RLC_PREFIX(ep8_add_slp_basic)
#define ep8_add_projc RLC_PREFIX(ep8_add_projc)
#define ep8_add_jacob RLC_PREFIX(ep8_add_jacob)
#define ep8_sub RLC_PREFIX(ep8_sub)
#define ep8_dbl_basic RLC_PREFIX(ep8_dbl_basic)
#define ep8_dbl_slp_basic RLC_PREFIX(ep8_dbl_slp_basic)
#define ep8_dbl_projc RLC_PREFIX(ep8_dbl_projc)
#define ep8_dbl_jacob RLC_PREFIX(ep8_dbl_jacob)
#define ep8_mul_basic RLC_PREFIX(ep8_mul_basic)
#define ep8_mul_slide RLC_PREFIX(ep8_mul_slide)
#define ep8_mul_monty RLC_PREFIX(ep8_mul_monty)
Expand Down Expand Up @@ -2428,6 +2456,7 @@
#undef fp8_mul_lazyr
#undef fp8_mul_art
#undef fp8_mul_frb
#undef fp8_mul_dig
#undef fp8_mul_dxs
#undef fp8_sqr_unr
#undef fp8_sqr_basic
Expand All @@ -2441,6 +2470,7 @@
#undef fp8_exp
#undef fp8_exp_dig
#undef fp8_exp_cyc
#undef fp8_exp_cyc_sim
#undef fp8_frb
#undef fp8_is_sqr
#undef fp8_srt
Expand All @@ -2467,6 +2497,7 @@
#define fp8_mul_lazyr RLC_PREFIX(fp8_mul_lazyr)
#define fp8_mul_art RLC_PREFIX(fp8_mul_art)
#define fp8_mul_frb RLC_PREFIX(fp8_mul_frb)
#define fp8_mul_dig RLC_PREFIX(fp8_mul_dig)
#define fp8_mul_dxs RLC_PREFIX(fp8_mul_dxs)
#define fp8_sqr_unr RLC_PREFIX(fp8_sqr_unr)
#define fp8_sqr_basic RLC_PREFIX(fp8_sqr_basic)
Expand All @@ -2480,6 +2511,7 @@
#define fp8_exp RLC_PREFIX(fp8_exp)
#define fp8_exp_dig RLC_PREFIX(fp8_exp_dig)
#define fp8_exp_cyc RLC_PREFIX(fp8_exp_cyc)
#define fp8_exp_cyc_sim RLC_PREFIX(fp8_exp_cyc_sim)
#define fp8_frb RLC_PREFIX(fp8_frb)
#define fp8_is_sqr RLC_PREFIX(fp8_is_sqr)
#define fp8_srt RLC_PREFIX(fp8_srt)
Expand Down Expand Up @@ -3076,6 +3108,7 @@
#undef pp_map_weilp_k2
#undef pp_map_sim_weilp_k2
#undef pp_map_oatep_k8
#undef pp_map_sim_oatep_k8
#undef pp_map_tatep_k12
#undef pp_map_sim_tatep_k12
#undef pp_map_weilp_k12
Expand Down Expand Up @@ -3180,6 +3213,7 @@
#define pp_map_weilp_k2 RLC_PREFIX(pp_map_weilp_k2)
#define pp_map_sim_weilp_k2 RLC_PREFIX(pp_map_sim_weilp_k2)
#define pp_map_oatep_k8 RLC_PREFIX(pp_map_oatep_k8)
#define pp_map_sim_oatep_k8 RLC_PREFIX(pp_map_sim_oatep_k8)
#define pp_map_tatep_k12 RLC_PREFIX(pp_map_tatep_k12)
#define pp_map_sim_tatep_k12 RLC_PREFIX(pp_map_sim_tatep_k12)
#define pp_map_weilp_k12 RLC_PREFIX(pp_map_weilp_k12)
Expand Down
2 changes: 1 addition & 1 deletion src/bn/relic_bn_mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* @param[in] b - the second multiple precision integer.
* @param[in] level - the number of Karatsuba steps to apply.
*/
static void bn_mul_karat_imp(bn_t c, const bn_t a, const bn_t b, int level) {
static void bn_mul_karat_imp(bn_t c, const bn_t a, const bn_t b, uint_t level) {
bn_t a0, a1, b0, b1, a0b0, a1b1, t;

/* Compute half the digits of a or b. */
Expand Down
2 changes: 1 addition & 1 deletion src/bn/relic_bn_sqr.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
* @param[in] a - the multiple precision integer to square.
* @param[in] level - the number of Karatsuba steps to apply.
*/
static void bn_sqr_karat_imp(bn_t c, const bn_t a, int level) {
static void bn_sqr_karat_imp(bn_t c, const bn_t a, uint_t level) {
bn_t a0, a1, a0a0, a1a1, t;
int h = a->used >> 1;

Expand Down
2 changes: 1 addition & 1 deletion src/bn/relic_bn_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int bn_is_even(const bn_t a) {
}

size_t bn_bits(const bn_t a) {
size_t bits;
uint_t bits;

if (bn_is_zero(a)) {
return 0;
Expand Down
11 changes: 5 additions & 6 deletions src/cp/relic_cp_rsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,10 @@
* @param[out] p_len - the number of added pad bytes.
* @param[in] m_len - the message length in bytes.
* @param[in] k_len - the key length in bytes.
* @param[in] operation - flag to indicate the operation type.
* @param[in] op - flag to indicate the operation type.
* @return RLC_ERR if errors occurred, RLC_OK otherwise.
*/
static int pad_basic(bn_t m, size_t *p_len, size_t m_len, size_t k_len,
int operation) {
static int pad_basic(bn_t m, size_t *p_len, size_t m_len, size_t k_len, int op) {
uint8_t pad = 0;
int result = RLC_ERR;
bn_t t;
Expand All @@ -128,7 +127,7 @@ static int pad_basic(bn_t m, size_t *p_len, size_t m_len, size_t k_len,
bn_null(t);
bn_new(t);

switch (operation) {
switch (op) {
case RSA_ENC:
case RSA_SIG:
case RSA_SIG_HASH:
Expand Down Expand Up @@ -215,7 +214,7 @@ static const uint8_t sh512_id[] = {
* @param[in, out] len - the length of the identifier.
* @return The pointer to the hash function identifier.
*/
static uint8_t *hash_id(int md, int *len) {
static uint8_t *hash_id(int md, size_t *len) {
switch (md) {
case SH224:
*len = sizeof(sh224_id);
Expand All @@ -242,7 +241,7 @@ static uint8_t *hash_id(int md, int *len) {
* @param[out] p_len - the number of added pad bytes.
* @param[in] m_len - the message length in bytes.
* @param[in] k_len - the key length in bytes.
* @param[in] operation - flag to indicate the operation type.
* @param[in] op - flag to indicate the operation type.
* @return RLC_ERR if errors occurred, RLC_OK otherwise.
*/
static int pad_pkcs1(bn_t m, size_t *p_len, size_t m_len, size_t k_len,
Expand Down
4 changes: 2 additions & 2 deletions src/ep/relic_ep_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ TMPL_MAP_SVDW(ep, fp, dig_t);
* @param[in] map_fn - the mapping function.
*/
static void ep_map_from_field(ep_t p, const uint8_t *uniform_bytes, size_t len,
const void (*const map_fn)(ep_t, const fp_t)) {
void (*const map_fn)(ep_t, const fp_t)) {
bn_t k;
fp_t t;
ep_t q;
Expand Down Expand Up @@ -219,7 +219,7 @@ void ep_map_sswum(ep_t p, const uint8_t *msg, size_t len) {
/* figure out which hash function to use */
const int abNeq0 = (ep_curve_opt_a() != RLC_ZERO) &&
(ep_curve_opt_b() != RLC_ZERO);
const void (*const map_fn)(ep_t, const fp_t) = (void (*const))
void (*const map_fn)(ep_t, const fp_t) =
(ep_curve_is_ctmap() || abNeq0 ? ep_map_sswu : ep_map_svdw);
ep_map_from_field(p, r, 2 * elm, map_fn);
}
Expand Down
Loading

0 comments on commit 57b01bb

Please sign in to comment.