From 1fca5ec0681634311c44489d69c42e4a212734ac Mon Sep 17 00:00:00 2001 From: "Matthias J. Kannwischer" Date: Wed, 24 Jul 2019 10:41:42 +0200 Subject: [PATCH] unsigned -> unsigned int --- .../rainbowIIIc-classic/clean/blas_comm.c | 60 +++++------ .../rainbowIIIc-classic/clean/blas_comm.h | 18 ++-- .../rainbowIIIc-classic/clean/blas_u32.c | 44 ++++---- .../rainbowIIIc-classic/clean/blas_u32.h | 8 +- crypto_sign/rainbowIIIc-classic/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 100 ++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- .../rainbowIIIc-classic/clean/rainbow.c | 12 +-- .../clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../clean/blas_comm.c | 60 +++++------ .../clean/blas_comm.h | 18 ++-- .../clean/blas_u32.c | 44 ++++---- .../clean/blas_u32.h | 8 +- .../rainbowIIIc-cyclic-compressed/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 100 ++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- .../clean/rainbow.c | 12 +-- .../clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../rainbowIIIc-cyclic/clean/blas_comm.c | 60 +++++------ .../rainbowIIIc-cyclic/clean/blas_comm.h | 18 ++-- .../rainbowIIIc-cyclic/clean/blas_u32.c | 44 ++++---- .../rainbowIIIc-cyclic/clean/blas_u32.h | 8 +- crypto_sign/rainbowIIIc-cyclic/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 100 ++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- .../rainbowIIIc-cyclic/clean/rainbow.c | 12 +-- .../clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../rainbowIa-classic/clean/blas_comm.c | 68 ++++++------ .../rainbowIa-classic/clean/blas_comm.h | 14 +-- .../rainbowIa-classic/clean/blas_u32.c | 56 +++++----- .../rainbowIa-classic/clean/blas_u32.h | 10 +- crypto_sign/rainbowIa-classic/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 102 +++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- crypto_sign/rainbowIa-classic/clean/rainbow.c | 12 +-- .../rainbowIa-classic/clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../clean/blas_comm.c | 68 ++++++------ .../clean/blas_comm.h | 14 +-- .../clean/blas_u32.c | 56 +++++----- .../clean/blas_u32.h | 10 +- .../rainbowIa-cyclic-compressed/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 102 +++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- .../clean/rainbow.c | 12 +-- .../clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../rainbowIa-cyclic/clean/blas_comm.c | 68 ++++++------ .../rainbowIa-cyclic/clean/blas_comm.h | 14 +-- crypto_sign/rainbowIa-cyclic/clean/blas_u32.c | 56 +++++----- crypto_sign/rainbowIa-cyclic/clean/blas_u32.h | 10 +- crypto_sign/rainbowIa-cyclic/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 102 +++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- crypto_sign/rainbowIa-cyclic/clean/rainbow.c | 12 +-- .../rainbowIa-cyclic/clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../rainbowVc-classic/clean/blas_comm.c | 60 +++++------ .../rainbowVc-classic/clean/blas_comm.h | 18 ++-- .../rainbowVc-classic/clean/blas_u32.c | 44 ++++---- .../rainbowVc-classic/clean/blas_u32.h | 8 +- crypto_sign/rainbowVc-classic/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 100 ++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- crypto_sign/rainbowVc-classic/clean/rainbow.c | 12 +-- .../rainbowVc-classic/clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../clean/blas_comm.c | 60 +++++------ .../clean/blas_comm.h | 18 ++-- .../clean/blas_u32.c | 44 ++++---- .../clean/blas_u32.h | 8 +- .../rainbowVc-cyclic-compressed/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 100 ++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- .../clean/rainbow.c | 12 +-- .../clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- .../rainbowVc-cyclic/clean/blas_comm.c | 60 +++++------ .../rainbowVc-cyclic/clean/blas_comm.h | 18 ++-- crypto_sign/rainbowVc-cyclic/clean/blas_u32.c | 44 ++++---- crypto_sign/rainbowVc-cyclic/clean/blas_u32.h | 8 +- crypto_sign/rainbowVc-cyclic/clean/gf.c | 4 +- .../clean/parallel_matrix_op.c | 100 ++++++++--------- .../clean/parallel_matrix_op.h | 52 ++++----- crypto_sign/rainbowVc-cyclic/clean/rainbow.c | 12 +-- .../rainbowVc-cyclic/clean/rainbow_keypair.c | 12 +-- .../clean/rainbow_keypair_computation.c | 36 +++---- 90 files changed, 1587 insertions(+), 1587 deletions(-) diff --git a/crypto_sign/rainbowIIIc-classic/clean/blas_comm.c b/crypto_sign/rainbowIIIc-classic/clean/blas_comm.c index caff3bbf..03db4d45 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/blas_comm.c +++ b/crypto_sign/rainbowIIIc-classic/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } /// @brief get an element from GF(256) vector . @@ -19,11 +19,11 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_ /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i) { return a[i]; } -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte) { +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte) { uint8_t r = 0; while (_num_byte--) { r |= a[0]; @@ -34,41 +34,41 @@ unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsig /// polynomial multplication /// School boook -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num) { PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(c, _num * 2 - 1); - for (unsigned i = 0; i < _num; i++) { + for (unsigned int i = 0; i < _num; i++) { gf256v_madd(c + i, a, b[i], _num); } } -static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { gf256v_madd(c, matA, b[i], n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = len_vec; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = len_vec; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { gf256v_madd(c, a + n_vec_byte * i, bk[i], n_vec_byte); } c += n_vec_byte; } } -static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned r8 = 1; +static unsigned int gf256mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int r8 = 1; - for (unsigned i = 0; i < h; i++) { + for (unsigned int i = 0; i < h; i++) { uint8_t *ai = mat + w * i; - unsigned skip_len_align4 = i & ((unsigned)~0x3); + unsigned int skip_len_align4 = i & ((unsigned int)~0x3); - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + w * j; gf256v_predicated_add(ai + skip_len_align4, !PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256_is_nonzero(ai[i]), aj + skip_len_align4, w - skip_len_align4); } @@ -76,7 +76,7 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { uint8_t pivot = ai[i]; pivot = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256_inv(pivot); gf256v_mul_scalar(ai + skip_len_align4, pivot, w - skip_len_align4); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -88,36 +88,36 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 64]; - for (unsigned i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n + 1), inp_mat + i * n, n); mat[i * (n + 1) + n] = c_terms[i]; } - unsigned r8 = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); + for (unsigned int i = 0; i < n; i++) { sol[i] = mat[i * (n + 1) + n]; } return r8; } -static inline void gf256mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < w2; j++) { +static inline void gf256mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < w2; j++) { mat2[i * w2 + j] = mat[i * w + st + j]; } } } -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * H; PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(ai, 2 * H); gf256v_add(ai, a + i * H, H); ai[H + i] = 1; } - unsigned r8 = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); gf256mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -128,15 +128,15 @@ unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uin #define gf256mat_prod_impl gf256mat_prod_ref #define gf256mat_gauss_elim_impl gf256mat_gauss_elim_ref #define gf256mat_solve_linear_eq_impl gf256mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf256mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf256mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf256mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowIIIc-classic/clean/blas_comm.h b/crypto_sign/rainbowIIIc-classic/clean/blas_comm.h index c88853b4..6357c0ab 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/blas_comm.h +++ b/crypto_sign/rainbowIIIc-classic/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(256) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_ /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i); /// @brief check if a vector is 0. /// @@ -28,7 +28,7 @@ uint8_t PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsign /// @param[in] _num_byte - number of bytes for the vector a. /// @return 1(true) if a is 0. 0(false) else. /// -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte); +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte); /// @brief polynomial multiplication: c = a*b /// @@ -37,7 +37,7 @@ unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsig /// @param[in] b - the vector b. /// @param[in] _num - number of elements for the polynomials a and b. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num); /// @brief matrix-vector multiplication: c = matA * b , in GF(256) /// @@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t * /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); /// @brief matrix-matrix multiplication: c = a * b , in GF(256) /// @@ -56,7 +56,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *m /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(256) /// @@ -65,7 +65,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(256) /// @@ -75,7 +75,7 @@ unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsi /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(256) /// @@ -85,6 +85,6 @@ unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowIIIc-classic/clean/blas_u32.c b/crypto_sign/rainbowIIIc-classic/clean/blas_u32.c index 52f83776..7e1bcba6 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/blas_u32.c +++ b/crypto_sign/rainbowIIIc-classic/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_u32(a_u32[i], b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_u32(t.u32, b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_u32(a_u32[i], gf256_b); } @@ -75,12 +75,12 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uin t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_u32(t.u32, gf256_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } diff --git a/crypto_sign/rainbowIIIc-classic/clean/blas_u32.h b/crypto_sign/rainbowIIIc-classic/clean/blas_u32.h index ba38066f..1675a602 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/blas_u32.h +++ b/crypto_sign/rainbowIIIc-classic/clean/blas_u32.h @@ -7,12 +7,12 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte); -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowIIIc-classic/clean/gf.c b/crypto_sign/rainbowIIIc-classic/clean/gf.c index 02df8e1f..e70613d2 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/gf.c +++ b/crypto_sign/rainbowIIIc-classic/clean/gf.c @@ -61,8 +61,8 @@ uint32_t PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf16v_mul_u32(uint32_t a, uint8_t b) { } uint8_t PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256_is_nonzero(uint8_t a) { - unsigned a8 = a; - unsigned r = ((unsigned)0) - a8; + unsigned int a8 = a; + unsigned int r = ((unsigned int)0) - a8; r >>= 8; return r & 1; } diff --git a/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.c b/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.c index d13c97ea..74285568 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, cons } void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, } void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *b } void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf256v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,18 +138,18 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, co } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(x, i); } PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf256v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } @@ -157,23 +157,23 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char } } -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_get_ele(y, i); } PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf256v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } diff --git a/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.h b/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.h index 260a6a23..78c1e83f 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowIIIc-classic/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, cons /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *b /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, con /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, co /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowIIIc-classic/clean/rainbow.c b/crypto_sign/rainbowIIIc-classic/clean/rainbow.c index 54449133..dc68af43 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/rainbow.c +++ b/crypto_sign/rainbowIIIc-classic/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair.c b/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair.c index d90108bd..b0cc6617 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair_computation.c index ce0f1592..796b7de2 100644 --- a/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowIIIc-classic/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cp } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cp } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cp } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cp } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cp } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.c index 475df36c..e0e550a5 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } /// @brief get an element from GF(256) vector . @@ -19,11 +19,11 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsig /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i) { return a[i]; } -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte) { +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte) { uint8_t r = 0; while (_num_byte--) { r |= a[0]; @@ -34,41 +34,41 @@ unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t /// polynomial multplication /// School boook -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num) { PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, _num * 2 - 1); - for (unsigned i = 0; i < _num; i++) { + for (unsigned int i = 0; i < _num; i++) { gf256v_madd(c + i, a, b[i], _num); } } -static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { gf256v_madd(c, matA, b[i], n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = len_vec; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = len_vec; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { gf256v_madd(c, a + n_vec_byte * i, bk[i], n_vec_byte); } c += n_vec_byte; } } -static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned r8 = 1; +static unsigned int gf256mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int r8 = 1; - for (unsigned i = 0; i < h; i++) { + for (unsigned int i = 0; i < h; i++) { uint8_t *ai = mat + w * i; - unsigned skip_len_align4 = i & ((unsigned)~0x3); + unsigned int skip_len_align4 = i & ((unsigned int)~0x3); - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + w * j; gf256v_predicated_add(ai + skip_len_align4, !PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256_is_nonzero(ai[i]), aj + skip_len_align4, w - skip_len_align4); } @@ -76,7 +76,7 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { uint8_t pivot = ai[i]; pivot = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256_inv(pivot); gf256v_mul_scalar(ai + skip_len_align4, pivot, w - skip_len_align4); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -88,36 +88,36 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 64]; - for (unsigned i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n + 1), inp_mat + i * n, n); mat[i * (n + 1) + n] = c_terms[i]; } - unsigned r8 = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); + for (unsigned int i = 0; i < n; i++) { sol[i] = mat[i * (n + 1) + n]; } return r8; } -static inline void gf256mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < w2; j++) { +static inline void gf256mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < w2; j++) { mat2[i * w2 + j] = mat[i * w + st + j]; } } } -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * H; PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(ai, 2 * H); gf256v_add(ai, a + i * H, H); ai[H + i] = 1; } - unsigned r8 = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); gf256mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -128,15 +128,15 @@ unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, #define gf256mat_prod_impl gf256mat_prod_ref #define gf256mat_gauss_elim_impl gf256mat_gauss_elim_ref #define gf256mat_solve_linear_eq_impl gf256mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf256mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf256mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf256mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.h b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.h index 4eb71dbf..e86298fe 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.h +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(256) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsig /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i); /// @brief check if a vector is 0. /// @@ -28,7 +28,7 @@ uint8_t PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t * /// @param[in] _num_byte - number of bytes for the vector a. /// @return 1(true) if a is 0. 0(false) else. /// -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte); +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte); /// @brief polynomial multiplication: c = a*b /// @@ -37,7 +37,7 @@ unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t /// @param[in] b - the vector b. /// @param[in] _num - number of elements for the polynomials a and b. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num); /// @brief matrix-vector multiplication: c = matA * b , in GF(256) /// @@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); /// @brief matrix-matrix multiplication: c = a * b , in GF(256) /// @@ -56,7 +56,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const u /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(256) /// @@ -65,7 +65,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const ui /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(256) /// @@ -75,7 +75,7 @@ unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t * /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(256) /// @@ -85,6 +85,6 @@ unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.c index 9d07f8ec..81f1afca 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(a_u32[i], b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(t.u32, b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(a_u32[i], gf256_b); } @@ -75,12 +75,12 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(t.u32, gf256_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.h b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.h index a309a5a9..d94c03ed 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.h +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/blas_u32.h @@ -7,12 +7,12 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte); -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/gf.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/gf.c index dd39e2ae..98cf167c 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/gf.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/gf.c @@ -61,8 +61,8 @@ uint32_t PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf16v_mul_u32(uint32_t a, uin } uint8_t PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256_is_nonzero(uint8_t a) { - unsigned a8 = a; - unsigned r = ((unsigned)0) - a8; + unsigned int a8 = a; + unsigned int r = ((unsigned int)0) - a8; r >>= 8; return r & 1; } diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.c index a750a014..18962545 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *bt } void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned } void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigne } void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf256v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,18 +138,18 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned cha } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(x, i); } PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf256v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } @@ -157,23 +157,23 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsi } } -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(y, i); } PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf256v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.h b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.h index 65c30466..63d82311 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *bt /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigne /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned ch /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned c /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned c /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned cha /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsig /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsi /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsig /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow.c index fcd33739..9da0c4e3 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, c uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, c uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_rainbow_verify(const uint8_t *dige // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair.c index c3ed6104..648dc106 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair_computation.c index 82630143..2e577e03 100644 --- a/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowIIIc-cyclic-compressed/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_ } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_ } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_ } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_ } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_ } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.c b/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.c index 936a4c98..d5363105 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } /// @brief get an element from GF(256) vector . @@ -19,11 +19,11 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_b /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i) { return a[i]; } -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte) { +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte) { uint8_t r = 0; while (_num_byte--) { r |= a[0]; @@ -34,41 +34,41 @@ unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsign /// polynomial multplication /// School boook -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num) { PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(c, _num * 2 - 1); - for (unsigned i = 0; i < _num; i++) { + for (unsigned int i = 0; i < _num; i++) { gf256v_madd(c + i, a, b[i], _num); } } -static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { gf256v_madd(c, matA, b[i], n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = len_vec; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = len_vec; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { gf256v_madd(c, a + n_vec_byte * i, bk[i], n_vec_byte); } c += n_vec_byte; } } -static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned r8 = 1; +static unsigned int gf256mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int r8 = 1; - for (unsigned i = 0; i < h; i++) { + for (unsigned int i = 0; i < h; i++) { uint8_t *ai = mat + w * i; - unsigned skip_len_align4 = i & ((unsigned)~0x3); + unsigned int skip_len_align4 = i & ((unsigned int)~0x3); - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + w * j; gf256v_predicated_add(ai + skip_len_align4, !PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256_is_nonzero(ai[i]), aj + skip_len_align4, w - skip_len_align4); } @@ -76,7 +76,7 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { uint8_t pivot = ai[i]; pivot = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256_inv(pivot); gf256v_mul_scalar(ai + skip_len_align4, pivot, w - skip_len_align4); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -88,36 +88,36 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 64]; - for (unsigned i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n + 1), inp_mat + i * n, n); mat[i * (n + 1) + n] = c_terms[i]; } - unsigned r8 = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); + for (unsigned int i = 0; i < n; i++) { sol[i] = mat[i * (n + 1) + n]; } return r8; } -static inline void gf256mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < w2; j++) { +static inline void gf256mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < w2; j++) { mat2[i * w2 + j] = mat[i * w + st + j]; } } } -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * H; PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(ai, 2 * H); gf256v_add(ai, a + i * H, H); ai[H + i] = 1; } - unsigned r8 = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); gf256mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -128,15 +128,15 @@ unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint #define gf256mat_prod_impl gf256mat_prod_ref #define gf256mat_gauss_elim_impl gf256mat_gauss_elim_ref #define gf256mat_solve_linear_eq_impl gf256mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf256mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf256mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf256mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.h b/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.h index 2d2474dc..96ac02d7 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.h +++ b/crypto_sign/rainbowIIIc-cyclic/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(256) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_b /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i); /// @brief check if a vector is 0. /// @@ -28,7 +28,7 @@ uint8_t PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigne /// @param[in] _num_byte - number of bytes for the vector a. /// @return 1(true) if a is 0. 0(false) else. /// -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte); +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte); /// @brief polynomial multiplication: c = a*b /// @@ -37,7 +37,7 @@ unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsign /// @param[in] b - the vector b. /// @param[in] _num - number of elements for the polynomials a and b. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num); /// @brief matrix-vector multiplication: c = matA * b , in GF(256) /// @@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); /// @brief matrix-matrix multiplication: c = a * b , in GF(256) /// @@ -56,7 +56,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *ma /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(256) /// @@ -65,7 +65,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(256) /// @@ -75,7 +75,7 @@ unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsig /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(256) /// @@ -85,6 +85,6 @@ unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.c b/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.c index 9e013ff2..b8965553 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_u32(a_u32[i], b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_u32(t.u32, b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_u32(a_u32[i], gf256_b); } @@ -75,12 +75,12 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_u32(t.u32, gf256_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.h b/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.h index 028c2cd6..9779dd9c 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.h +++ b/crypto_sign/rainbowIIIc-cyclic/clean/blas_u32.h @@ -7,12 +7,12 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte); -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/gf.c b/crypto_sign/rainbowIIIc-cyclic/clean/gf.c index f480af63..c5cece1d 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/gf.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/gf.c @@ -61,8 +61,8 @@ uint32_t PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf16v_mul_u32(uint32_t a, uint8_t b) { } uint8_t PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256_is_nonzero(uint8_t a) { - unsigned a8 = a; - unsigned r = ((unsigned)0) - a8; + unsigned int a8 = a; + unsigned int r = ((unsigned int)0) - a8; r >>= 8; return r & 1; } diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.c b/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.c index b4d06330..7cb5244e 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const } void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, } void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC } void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf256v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,18 +138,18 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, con } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(x, i); } PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf256v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } @@ -157,23 +157,23 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char } } -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_get_ele(y, i); } PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf256v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.h b/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.h index 59a00470..62dd1404 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowIIIc-cyclic/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, c /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, cons /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, con /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char * /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char * /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/rainbow.c b/crypto_sign/rainbowIIIc-cyclic/clean/rainbow.c index ee19dd32..3379c7fe 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/rainbow.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair.c b/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair.c index 1a368a37..e7ee2b3c 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair_computation.c index d3f3ae13..ab38bca7 100644 --- a/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowIIIc-cyclic/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIIICCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowIa-classic/clean/blas_comm.c b/crypto_sign/rainbowIa-classic/clean/blas_comm.c index 938478c5..3c67c694 100644 --- a/crypto_sign/rainbowIa-classic/clean/blas_comm.c +++ b/crypto_sign/rainbowIa-classic/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_by /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) { uint8_t r = a[i >> 1]; uint8_t r0 = r & 0xf; uint8_t r1 = r >> 4; @@ -35,28 +35,28 @@ uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned /// @param[in] v - the value for the i-th element in vector a. /// @return the value of the element. /// -static uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned i, uint8_t v) { +static uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) { uint8_t m = (uint8_t)(0xf ^ (-((int8_t)i & 1))); /// 1--> 0xf0 , 0--> 0x0f uint8_t ai_remaining = (uint8_t)(a[i >> 1] & (~m)); /// erase a[i >> 1] = (uint8_t)(ai_remaining | (m & (v << 4)) | (m & v & 0xf)); /// set return v; } -static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { uint8_t bb = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(b, i); gf16v_madd(c, matA, bb, n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = (len_vec + 1) / 2; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = (len_vec + 1) / 2; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { uint8_t bb = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(bk, i); gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte); } @@ -64,13 +64,13 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, co } } -static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned n_w_byte = (w + 1) / 2; - unsigned r8 = 1; - for (unsigned i = 0; i < h; i++) { - unsigned offset_byte = i >> 1; +static unsigned int gf16mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int n_w_byte = (w + 1) / 2; + unsigned int r8 = 1; + for (unsigned int i = 0; i < h; i++) { + unsigned int offset_byte = i >> 1; uint8_t *ai = mat + n_w_byte * i; - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + n_w_byte * j; gf256v_predicated_add(ai + offset_byte, !PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte); } @@ -79,7 +79,7 @@ static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { pivot = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_inv(pivot); offset_byte = (i + 1) >> 1; gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -90,42 +90,42 @@ static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 33]; - unsigned n_byte = (n + 1) >> 1; - for (unsigned i = 0; i < n; i++) { + unsigned int n_byte = (n + 1) >> 1; + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n_byte + 1), inp_mat + i * n_byte, n_byte); mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(c_terms, i); } - unsigned r8 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(mat, n, n + 2); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(mat, n, n + 2); + for (unsigned int i = 0; i < n; i++) { PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]); } return r8; } -static inline void gf16mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - unsigned n_byte_w1 = (w + 1) / 2; - unsigned n_byte_w2 = (w2 + 1) / 2; - unsigned st_2 = st / 2; - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < n_byte_w2; j++) { +static inline void gf16mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + unsigned int n_byte_w1 = (w + 1) / 2; + unsigned int n_byte_w2 = (w2 + 1) / 2; + unsigned int st_2 = st / 2; + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < n_byte_w2; j++) { mat2[i * n_byte_w2 + j] = mat[i * n_byte_w1 + st_2 + j]; } } } -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { - unsigned n_w_byte = (H + 1) / 2; +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { + unsigned int n_w_byte = (H + 1) / 2; uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * n_w_byte; PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte); gf256v_add(ai, a + i * n_w_byte, n_w_byte); PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1); } - unsigned r8 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H); gf16mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -136,15 +136,15 @@ unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_ #define gf16mat_gauss_elim_impl gf16mat_gauss_elim_ref #define gf16mat_solve_linear_eq_impl gf16mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf16mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf16mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf16mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowIa-classic/clean/blas_comm.h b/crypto_sign/rainbowIa-classic/clean/blas_comm.h index 5c8e3938..9cbe8ff1 100644 --- a/crypto_sign/rainbowIa-classic/clean/blas_comm.h +++ b/crypto_sign/rainbowIa-classic/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(16) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_by /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i); /// @brief matrix-matrix multiplication: c = a * b , in GF(16) /// @@ -29,7 +29,7 @@ uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(16) /// @@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, co /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(16) /// @@ -48,7 +48,7 @@ unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigne /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(16) /// @@ -58,7 +58,7 @@ unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, co /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); /// @brief matrix-vector multiplication: c = matA * b , in GF(16) /// @@ -68,7 +68,7 @@ unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_ /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowIa-classic/clean/blas_u32.c b/crypto_sign/rainbowIa-classic/clean/blas_u32.c index 00d35968..312eef5f 100644 --- a/crypto_sign/rainbowIa-classic/clean/blas_u32.c +++ b/crypto_sign/rainbowIa-classic/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_u32(a_u32[i], gf16_b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf1 } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_u32(t.u32, gf16_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_u32(a_u32[i], gf16_b); } @@ -75,26 +75,26 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_ t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_u32(t.u32, gf16_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } -uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; const uint32_t *a_u32 = (const uint32_t *)a; const uint32_t *b_u32 = (const uint32_t *)b; uint32_t r = 0; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { r ^= PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_u32_u32(a_u32[i], b_u32[i]); } - unsigned rem = _num_byte & 3; + unsigned int rem = _num_byte & 3; if (rem) { union tmp_32 { uint8_t u8[4]; @@ -102,10 +102,10 @@ uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uin } ta, tb; ta.u32 = 0; tb.u32 = 0; - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { ta.u8[i] = a[(n_u32 << 2) + i]; } - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { tb.u8[i] = b[(n_u32 << 2) + i]; } r ^= PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_u32_u32(ta.u32, tb.u32); diff --git a/crypto_sign/rainbowIa-classic/clean/blas_u32.h b/crypto_sign/rainbowIa-classic/clean/blas_u32.h index 0bbfd015..25005e14 100644 --- a/crypto_sign/rainbowIa-classic/clean/blas_u32.h +++ b/crypto_sign/rainbowIa-classic/clean/blas_u32.h @@ -7,13 +7,13 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned _num_byte); -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned _num_byte); -uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned int _num_byte); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned int _num_byte); +uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowIa-classic/clean/gf.c b/crypto_sign/rainbowIa-classic/clean/gf.c index c9563dbe..cdad4492 100644 --- a/crypto_sign/rainbowIa-classic/clean/gf.c +++ b/crypto_sign/rainbowIa-classic/clean/gf.c @@ -69,8 +69,8 @@ static inline uint32_t _gf4v_mul_u32_u32(uint32_t a0, uint32_t a1, uint32_t b0, } uint8_t PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16_is_nonzero(uint8_t a) { - unsigned a4 = a & 0xf; - unsigned r = ((unsigned)0) - a4; + unsigned int a4 = a & 0xf; + unsigned int r = ((unsigned int)0) - a4; r >>= 4; return r & 1; } diff --git a/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.c b/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.c index c116f05a..8d1f0a95 100644 --- a/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const } void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, co } void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, } void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, c } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, co } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,23 +138,23 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, - const unsigned char *x, unsigned dim_x, unsigned size_batch) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, + const unsigned char *x, unsigned int dim_x, unsigned int size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(y, i); } PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf16v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } @@ -162,18 +162,18 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z } } -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf16v_get_ele(x, i); } PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWIACLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf16v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } diff --git a/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.h b/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.h index 214507e8..b9f8b8c5 100644 --- a/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowIa-classic/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, co /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, co /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, c /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, cons /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char * /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIACLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowIa-classic/clean/rainbow.c b/crypto_sign/rainbowIa-classic/clean/rainbow.c index 18ba4e33..e51d867c 100644 --- a/crypto_sign/rainbowIa-classic/clean/rainbow.c +++ b/crypto_sign/rainbowIa-classic/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t * uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWIACLASSIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWIACLASSIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t * uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWIACLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const u // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowIa-classic/clean/rainbow_keypair.c b/crypto_sign/rainbowIa-classic/clean/rainbow_keypair.c index 4da6ca44..5abe1159 100644 --- a/crypto_sign/rainbowIa-classic/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowIa-classic/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWIACLASSIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIACLASSIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIACLASSIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowIa-classic/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowIa-classic/clean/rainbow_keypair_computation.c index 9730a0e8..88ad49bd 100644 --- a/crypto_sign/rainbowIa-classic/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowIa-classic/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWIACLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.c index 5022089d..3ab27446 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigne /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) { uint8_t r = a[i >> 1]; uint8_t r0 = r & 0xf; uint8_t r1 = r >> 4; @@ -35,28 +35,28 @@ uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, /// @param[in] v - the value for the i-th element in vector a. /// @return the value of the element. /// -static uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(uint8_t *a, unsigned i, uint8_t v) { +static uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) { uint8_t m = (uint8_t)(0xf ^ (-((int8_t)i & 1))); /// 1--> 0xf0 , 0--> 0x0f uint8_t ai_remaining = (uint8_t)(a[i >> 1] & (~m)); /// erase a[i >> 1] = (uint8_t)(ai_remaining | (m & (v << 4)) | (m & v & 0xf)); /// set return v; } -static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { uint8_t bb = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(b, i); gf16v_madd(c, matA, bb, n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = (len_vec + 1) / 2; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = (len_vec + 1) / 2; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { uint8_t bb = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(bk, i); gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte); } @@ -64,13 +64,13 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8 } } -static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned n_w_byte = (w + 1) / 2; - unsigned r8 = 1; - for (unsigned i = 0; i < h; i++) { - unsigned offset_byte = i >> 1; +static unsigned int gf16mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int n_w_byte = (w + 1) / 2; + unsigned int r8 = 1; + for (unsigned int i = 0; i < h; i++) { + unsigned int offset_byte = i >> 1; uint8_t *ai = mat + n_w_byte * i; - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + n_w_byte * j; gf256v_predicated_add(ai + offset_byte, !PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte); } @@ -79,7 +79,7 @@ static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { pivot = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_inv(pivot); offset_byte = (i + 1) >> 1; gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -90,42 +90,42 @@ static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 33]; - unsigned n_byte = (n + 1) >> 1; - for (unsigned i = 0; i < n; i++) { + unsigned int n_byte = (n + 1) >> 1; + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n_byte + 1), inp_mat + i * n_byte, n_byte); mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(c_terms, i); } - unsigned r8 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(mat, n, n + 2); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(mat, n, n + 2); + for (unsigned int i = 0; i < n; i++) { PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]); } return r8; } -static inline void gf16mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - unsigned n_byte_w1 = (w + 1) / 2; - unsigned n_byte_w2 = (w2 + 1) / 2; - unsigned st_2 = st / 2; - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < n_byte_w2; j++) { +static inline void gf16mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + unsigned int n_byte_w1 = (w + 1) / 2; + unsigned int n_byte_w2 = (w2 + 1) / 2; + unsigned int st_2 = st / 2; + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < n_byte_w2; j++) { mat2[i * n_byte_w2 + j] = mat[i * n_byte_w1 + st_2 + j]; } } } -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { - unsigned n_w_byte = (H + 1) / 2; +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { + unsigned int n_w_byte = (H + 1) / 2; uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * n_w_byte; PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte); gf256v_add(ai, a + i * n_w_byte, n_w_byte); PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1); } - unsigned r8 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H); gf16mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -136,15 +136,15 @@ unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, con #define gf16mat_gauss_elim_impl gf16mat_gauss_elim_ref #define gf16mat_solve_linear_eq_impl gf16mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf16mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf16mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf16mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.h b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.h index 4b8ec358..bf0131b7 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.h +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(16) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigne /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i); /// @brief matrix-matrix multiplication: c = a * b , in GF(16) /// @@ -29,7 +29,7 @@ uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(const uint8_t *a, /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(16) /// @@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_mul(uint8_t *c, const uint8 /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(16) /// @@ -48,7 +48,7 @@ unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_gauss_elim(uint8_t *mat /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(16) /// @@ -58,7 +58,7 @@ unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_solve_linear_eq(uint8_t /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); /// @brief matrix-vector multiplication: c = matA * b , in GF(16) /// @@ -68,7 +68,7 @@ unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_inv(uint8_t *inv_a, con /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.c index 9ccd0d72..76044e16 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_u32(a_u32[i], gf16_b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, ui } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_u32(t.u32, gf16_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_u32(a_u32[i], gf16_b); } @@ -75,26 +75,26 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd_u32(uint8_t *accu_c, con t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_u32(t.u32, gf16_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } -uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; const uint32_t *a_u32 = (const uint32_t *)a; const uint32_t *b_u32 = (const uint32_t *)b; uint32_t r = 0; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { r ^= PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_u32_u32(a_u32[i], b_u32[i]); } - unsigned rem = _num_byte & 3; + unsigned int rem = _num_byte & 3; if (rem) { union tmp_32 { uint8_t u8[4]; @@ -102,10 +102,10 @@ uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_dot_u32(const uint8_t *a, } ta, tb; ta.u32 = 0; tb.u32 = 0; - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { ta.u8[i] = a[(n_u32 << 2) + i]; } - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { tb.u8[i] = b[(n_u32 << 2) + i]; } r ^= PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_u32_u32(ta.u32, tb.u32); diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.h b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.h index def05094..992d447f 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.h +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/blas_u32.h @@ -7,13 +7,13 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned _num_byte); -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned _num_byte); -uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned int _num_byte); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned int _num_byte); +uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/gf.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/gf.c index cbf59609..55d9fd6a 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/gf.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/gf.c @@ -69,8 +69,8 @@ static inline uint32_t _gf4v_mul_u32_u32(uint32_t a0, uint32_t a1, uint32_t b0, } uint8_t PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16_is_nonzero(uint8_t a) { - unsigned a4 = a & 0xf; - unsigned r = ((unsigned)0) - a4; + unsigned int a4 = a & 0xf; + unsigned int r = ((unsigned int)0) - a4; r >>= 4; return r & 1; } diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.c index c764ff72..97e3265c 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, u /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btri } void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned cha } void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned c } void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned ch } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned cha } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,23 +138,23 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char * } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, - const unsigned char *x, unsigned dim_x, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, + const unsigned char *x, unsigned int dim_x, unsigned int size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(y, i); } PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf16v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } @@ -162,18 +162,18 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigne } } -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf16v_get_ele(x, i); } PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf16v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.h b/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.h index e85424c3..00c40ed7 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, u /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btri /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned cha /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned ch /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned ch /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned cha /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned cha /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned ch /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char * /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigne /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsign /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigne /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow.c index edc8a2e8..949b04bd 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, con uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, con uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_rainbow_verify(const uint8_t *digest // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair.c index a91f523d..d57039c6 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair_computation.c index 16698d31..ab7756b3 100644 --- a/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowIa-cyclic-compressed/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowIa-cyclic/clean/blas_comm.c b/crypto_sign/rainbowIa-cyclic/clean/blas_comm.c index d58a1cba..45f062cf 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/blas_comm.c +++ b/crypto_sign/rainbowIa-cyclic/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byt /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i) { uint8_t r = a[i >> 1]; uint8_t r0 = r & 0xf; uint8_t r1 = r >> 4; @@ -35,28 +35,28 @@ uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i /// @param[in] v - the value for the i-th element in vector a. /// @return the value of the element. /// -static uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned i, uint8_t v) { +static uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(uint8_t *a, unsigned int i, uint8_t v) { uint8_t m = (uint8_t)(0xf ^ (-((int8_t)i & 1))); /// 1--> 0xf0 , 0--> 0x0f uint8_t ai_remaining = (uint8_t)(a[i >> 1] & (~m)); /// erase a[i >> 1] = (uint8_t)(ai_remaining | (m & (v << 4)) | (m & v & 0xf)); /// set return v; } -static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf16mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { uint8_t bb = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(b, i); gf16v_madd(c, matA, bb, n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = (len_vec + 1) / 2; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = (len_vec + 1) / 2; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { uint8_t bb = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(bk, i); gf16v_madd(c, a + n_vec_byte * i, bb, n_vec_byte); } @@ -64,13 +64,13 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, con } } -static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned n_w_byte = (w + 1) / 2; - unsigned r8 = 1; - for (unsigned i = 0; i < h; i++) { - unsigned offset_byte = i >> 1; +static unsigned int gf16mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int n_w_byte = (w + 1) / 2; + unsigned int r8 = 1; + for (unsigned int i = 0; i < h; i++) { + unsigned int offset_byte = i >> 1; uint8_t *ai = mat + n_w_byte * i; - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + n_w_byte * j; gf256v_predicated_add(ai + offset_byte, !PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_is_nonzero(PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(ai, i)), aj + offset_byte, n_w_byte - offset_byte); } @@ -79,7 +79,7 @@ static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { pivot = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_inv(pivot); offset_byte = (i + 1) >> 1; gf16v_mul_scalar(ai + offset_byte, pivot, n_w_byte - offset_byte); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -90,42 +90,42 @@ static unsigned gf16mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf16mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 33]; - unsigned n_byte = (n + 1) >> 1; - for (unsigned i = 0; i < n; i++) { + unsigned int n_byte = (n + 1) >> 1; + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n_byte + 1), inp_mat + i * n_byte, n_byte); mat[i * (n_byte + 1) + n_byte] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(c_terms, i); } - unsigned r8 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(mat, n, n + 2); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(mat, n, n + 2); + for (unsigned int i = 0; i < n; i++) { PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(sol, i, mat[i * (n_byte + 1) + n_byte]); } return r8; } -static inline void gf16mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - unsigned n_byte_w1 = (w + 1) / 2; - unsigned n_byte_w2 = (w2 + 1) / 2; - unsigned st_2 = st / 2; - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < n_byte_w2; j++) { +static inline void gf16mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + unsigned int n_byte_w1 = (w + 1) / 2; + unsigned int n_byte_w2 = (w2 + 1) / 2; + unsigned int st_2 = st / 2; + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < n_byte_w2; j++) { mat2[i * n_byte_w2 + j] = mat[i * n_byte_w1 + st_2 + j]; } } } -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { - unsigned n_w_byte = (H + 1) / 2; +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { + unsigned int n_w_byte = (H + 1) / 2; uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * n_w_byte; PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(ai, 2 * n_w_byte); gf256v_add(ai, a + i * n_w_byte, n_w_byte); PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_set_ele(ai + n_w_byte, i, 1); } - unsigned r8 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(aa, H, 2 * H); gf16mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -136,15 +136,15 @@ unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t #define gf16mat_gauss_elim_impl gf16mat_gauss_elim_ref #define gf16mat_solve_linear_eq_impl gf16mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf16mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf16mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf16mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowIa-cyclic/clean/blas_comm.h b/crypto_sign/rainbowIa-cyclic/clean/blas_comm.h index 10fed039..570e5ede 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/blas_comm.h +++ b/crypto_sign/rainbowIa-cyclic/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(16) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byt /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned int i); /// @brief matrix-matrix multiplication: c = a * b , in GF(16) /// @@ -29,7 +29,7 @@ uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(const uint8_t *a, unsigned i /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(16) /// @@ -38,7 +38,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_mul(uint8_t *c, const uint8_t *a, con /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(16) /// @@ -48,7 +48,7 @@ unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_gauss_elim(uint8_t *mat, unsigned /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(16) /// @@ -58,7 +58,7 @@ unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_solve_linear_eq(uint8_t *sol, con /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); /// @brief matrix-vector multiplication: c = matA * b , in GF(16) /// @@ -68,7 +68,7 @@ unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_inv(uint8_t *inv_a, const uint8_t /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowIa-cyclic/clean/blas_u32.c b/crypto_sign/rainbowIa-cyclic/clean/blas_u32.c index e8a3444a..518f6489 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/blas_u32.c +++ b/crypto_sign/rainbowIa-cyclic/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_u32(a_u32[i], gf16_b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16 } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_u32(t.u32, gf16_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_u32(a_u32[i], gf16_b); } @@ -75,26 +75,26 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_u32(t.u32, gf16_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } -uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; const uint32_t *a_u32 = (const uint32_t *)a; const uint32_t *b_u32 = (const uint32_t *)b; uint32_t r = 0; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { r ^= PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_u32_u32(a_u32[i], b_u32[i]); } - unsigned rem = _num_byte & 3; + unsigned int rem = _num_byte & 3; if (rem) { union tmp_32 { uint8_t u8[4]; @@ -102,10 +102,10 @@ uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint } ta, tb; ta.u32 = 0; tb.u32 = 0; - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { ta.u8[i] = a[(n_u32 << 2) + i]; } - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { tb.u8[i] = b[(n_u32 << 2) + i]; } r ^= PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_u32_u32(ta.u32, tb.u32); diff --git a/crypto_sign/rainbowIa-cyclic/clean/blas_u32.h b/crypto_sign/rainbowIa-cyclic/clean/blas_u32.h index d149674a..cd3ea9e4 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/blas_u32.h +++ b/crypto_sign/rainbowIa-cyclic/clean/blas_u32.h @@ -7,13 +7,13 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned _num_byte); -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned _num_byte); -uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf16_b, unsigned int _num_byte); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_mul_scalar_u32(uint8_t *a, uint8_t gf16_b, unsigned int _num_byte); +uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_dot_u32(const uint8_t *a, const uint8_t *b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowIa-cyclic/clean/gf.c b/crypto_sign/rainbowIa-cyclic/clean/gf.c index 2bed34aa..29c75c68 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/gf.c +++ b/crypto_sign/rainbowIa-cyclic/clean/gf.c @@ -69,8 +69,8 @@ static inline uint32_t _gf4v_mul_u32_u32(uint32_t a0, uint32_t a1, uint32_t b0, } uint8_t PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16_is_nonzero(uint8_t a) { - unsigned a4 = a & 0xf; - unsigned r = ((unsigned)0) - a4; + unsigned int a4 = a & 0xf; + unsigned int r = ((unsigned int)0) - a4; r >>= 4; return r & 1; } diff --git a/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.c b/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.c index 1b4eb254..6fa60381 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_ /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const u } void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, con } void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, c } void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, co } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf16v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf16v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, con } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf16v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,23 +138,23 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, - const unsigned char *x, unsigned dim_x, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, + const unsigned char *x, unsigned int dim_x, unsigned int size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(y, i); } PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf16v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } @@ -162,18 +162,18 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, } } -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf16v_get_ele(x, i); } PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWIACYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf16v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } diff --git a/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.h b/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.h index f97f6406..223fbeea 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowIa-cyclic/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_ /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const u /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, con /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, co /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, co /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, con /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, co /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWIACYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowIa-cyclic/clean/rainbow.c b/crypto_sign/rainbowIa-cyclic/clean/rainbow.c index 4e9cdef4..7fc7e5b7 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/rainbow.c +++ b/crypto_sign/rainbowIa-cyclic/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWIACYCLIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWIACYCLIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWIACYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const ui // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair.c b/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair.c index 5152a5c7..92d08634 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWIACYCLIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIACYCLIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWIACYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair_computation.c index 2cd3c2c2..982d13b1 100644 --- a/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowIa-cyclic/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWIACYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWIACYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowVc-classic/clean/blas_comm.c b/crypto_sign/rainbowVc-classic/clean/blas_comm.c index 4900b713..594f5f30 100644 --- a/crypto_sign/rainbowVc-classic/clean/blas_comm.c +++ b/crypto_sign/rainbowVc-classic/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } /// @brief get an element from GF(256) vector . @@ -19,11 +19,11 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_by /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i) { return a[i]; } -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte) { +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte) { uint8_t r = 0; while (_num_byte--) { r |= a[0]; @@ -34,41 +34,41 @@ unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigne /// polynomial multplication /// School boook -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num) { PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(c, _num * 2 - 1); - for (unsigned i = 0; i < _num; i++) { + for (unsigned int i = 0; i < _num; i++) { gf256v_madd(c + i, a, b[i], _num); } } -static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { gf256v_madd(c, matA, b[i], n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = len_vec; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = len_vec; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { gf256v_madd(c, a + n_vec_byte * i, bk[i], n_vec_byte); } c += n_vec_byte; } } -static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned r8 = 1; +static unsigned int gf256mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int r8 = 1; - for (unsigned i = 0; i < h; i++) { + for (unsigned int i = 0; i < h; i++) { uint8_t *ai = mat + w * i; - unsigned skip_len_align4 = i & ((unsigned)~0x3); + unsigned int skip_len_align4 = i & ((unsigned int)~0x3); - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + w * j; gf256v_predicated_add(ai + skip_len_align4, !PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256_is_nonzero(ai[i]), aj + skip_len_align4, w - skip_len_align4); } @@ -76,7 +76,7 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { uint8_t pivot = ai[i]; pivot = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256_inv(pivot); gf256v_mul_scalar(ai + skip_len_align4, pivot, w - skip_len_align4); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -88,36 +88,36 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 64]; - for (unsigned i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n + 1), inp_mat + i * n, n); mat[i * (n + 1) + n] = c_terms[i]; } - unsigned r8 = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); + for (unsigned int i = 0; i < n; i++) { sol[i] = mat[i * (n + 1) + n]; } return r8; } -static inline void gf256mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < w2; j++) { +static inline void gf256mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < w2; j++) { mat2[i * w2 + j] = mat[i * w + st + j]; } } } -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * H; PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(ai, 2 * H); gf256v_add(ai, a + i * H, H); ai[H + i] = 1; } - unsigned r8 = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); gf256mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -128,15 +128,15 @@ unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8 #define gf256mat_prod_impl gf256mat_prod_ref #define gf256mat_gauss_elim_impl gf256mat_gauss_elim_ref #define gf256mat_solve_linear_eq_impl gf256mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf256mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf256mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf256mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowVc-classic/clean/blas_comm.h b/crypto_sign/rainbowVc-classic/clean/blas_comm.h index 0c290952..55be9b5e 100644 --- a/crypto_sign/rainbowVc-classic/clean/blas_comm.h +++ b/crypto_sign/rainbowVc-classic/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(256) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_by /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i); /// @brief check if a vector is 0. /// @@ -28,7 +28,7 @@ uint8_t PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned /// @param[in] _num_byte - number of bytes for the vector a. /// @return 1(true) if a is 0. 0(false) else. /// -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte); +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte); /// @brief polynomial multiplication: c = a*b /// @@ -37,7 +37,7 @@ unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigne /// @param[in] b - the vector b. /// @param[in] _num - number of elements for the polynomials a and b. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num); /// @brief matrix-vector multiplication: c = matA * b , in GF(256) /// @@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); /// @brief matrix-matrix multiplication: c = a * b , in GF(256) /// @@ -56,7 +56,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *mat /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(256) /// @@ -65,7 +65,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, c /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(256) /// @@ -75,7 +75,7 @@ unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsign /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(256) /// @@ -85,6 +85,6 @@ unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, c /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowVc-classic/clean/blas_u32.c b/crypto_sign/rainbowVc-classic/clean/blas_u32.c index f82efae7..65be162d 100644 --- a/crypto_sign/rainbowVc-classic/clean/blas_u32.c +++ b/crypto_sign/rainbowVc-classic/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_u32(a_u32[i], b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_u32(t.u32, b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_u32(a_u32[i], gf256_b); } @@ -75,12 +75,12 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8 t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_u32(t.u32, gf256_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } diff --git a/crypto_sign/rainbowVc-classic/clean/blas_u32.h b/crypto_sign/rainbowVc-classic/clean/blas_u32.h index 8f063d89..eba39b9c 100644 --- a/crypto_sign/rainbowVc-classic/clean/blas_u32.h +++ b/crypto_sign/rainbowVc-classic/clean/blas_u32.h @@ -7,12 +7,12 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte); -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowVc-classic/clean/gf.c b/crypto_sign/rainbowVc-classic/clean/gf.c index 7aa3dd5d..81437d26 100644 --- a/crypto_sign/rainbowVc-classic/clean/gf.c +++ b/crypto_sign/rainbowVc-classic/clean/gf.c @@ -61,8 +61,8 @@ uint32_t PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf16v_mul_u32(uint32_t a, uint8_t b) { } uint8_t PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256_is_nonzero(uint8_t a) { - unsigned a8 = a; - unsigned r = ((unsigned)0) - a8; + unsigned int a8 = a; + unsigned int r = ((unsigned int)0) - a8; r >>= 8; return r & 1; } diff --git a/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.c b/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.c index 85d1e495..764b3a48 100644 --- a/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const } void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, c } void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, } void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf256v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, c } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,18 +138,18 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, cons } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(x, i); } PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf256v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } @@ -157,23 +157,23 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char * } } -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_get_ele(y, i); } PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWVCCLASSIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf256v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } diff --git a/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.h b/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.h index e9072bf1..2af16a7e 100644 --- a/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowVc-classic/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_UpperTrianglize(unsigned char *btriC, const /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, co /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, co /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, c /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, cons /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char * /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowVc-classic/clean/rainbow.c b/crypto_sign/rainbowVc-classic/clean/rainbow.c index 14f52346..e1527f60 100644 --- a/crypto_sign/rainbowVc-classic/clean/rainbow.c +++ b/crypto_sign/rainbowVc-classic/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t * uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWVCCLASSIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWVCCLASSIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t * uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWVCCLASSIC_CLEAN_rainbow_verify(const uint8_t *digest, const u // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowVc-classic/clean/rainbow_keypair.c b/crypto_sign/rainbowVc-classic/clean/rainbow_keypair.c index 33549ebc..14632136 100644 --- a/crypto_sign/rainbowVc-classic/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowVc-classic/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWVCCLASSIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWVCCLASSIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWVCCLASSIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowVc-classic/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowVc-classic/clean/rainbow_keypair_computation.c index f9a70478..da7851f4 100644 --- a/crypto_sign/rainbowVc-classic/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowVc-classic/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWVCCLASSIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCLASSIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.c index 6587be95..1a59ae7c 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } /// @brief get an element from GF(256) vector . @@ -19,11 +19,11 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigne /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i) { return a[i]; } -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte) { +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte) { uint8_t r = 0; while (_num_byte--) { r |= a[0]; @@ -34,41 +34,41 @@ unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a /// polynomial multplication /// School boook -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num) { PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, _num * 2 - 1); - for (unsigned i = 0; i < _num; i++) { + for (unsigned int i = 0; i < _num; i++) { gf256v_madd(c + i, a, b[i], _num); } } -static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { gf256v_madd(c, matA, b[i], n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = len_vec; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = len_vec; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { gf256v_madd(c, a + n_vec_byte * i, bk[i], n_vec_byte); } c += n_vec_byte; } } -static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned r8 = 1; +static unsigned int gf256mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int r8 = 1; - for (unsigned i = 0; i < h; i++) { + for (unsigned int i = 0; i < h; i++) { uint8_t *ai = mat + w * i; - unsigned skip_len_align4 = i & ((unsigned)~0x3); + unsigned int skip_len_align4 = i & ((unsigned int)~0x3); - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + w * j; gf256v_predicated_add(ai + skip_len_align4, !PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256_is_nonzero(ai[i]), aj + skip_len_align4, w - skip_len_align4); } @@ -76,7 +76,7 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { uint8_t pivot = ai[i]; pivot = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256_inv(pivot); gf256v_mul_scalar(ai + skip_len_align4, pivot, w - skip_len_align4); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -88,36 +88,36 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 64]; - for (unsigned i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n + 1), inp_mat + i * n, n); mat[i * (n + 1) + n] = c_terms[i]; } - unsigned r8 = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); + for (unsigned int i = 0; i < n; i++) { sol[i] = mat[i * (n + 1) + n]; } return r8; } -static inline void gf256mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < w2; j++) { +static inline void gf256mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < w2; j++) { mat2[i * w2 + j] = mat[i * w + st + j]; } } } -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * H; PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(ai, 2 * H); gf256v_add(ai, a + i * H, H); ai[H + i] = 1; } - unsigned r8 = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); gf256mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -128,15 +128,15 @@ unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, co #define gf256mat_prod_impl gf256mat_prod_ref #define gf256mat_gauss_elim_impl gf256mat_gauss_elim_ref #define gf256mat_solve_linear_eq_impl gf256mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf256mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf256mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf256mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.h b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.h index 1ba8a5db..af5715c6 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.h +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(256) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(uint8_t *b, unsigne /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i); /// @brief check if a vector is 0. /// @@ -28,7 +28,7 @@ uint8_t PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(const uint8_t *a, /// @param[in] _num_byte - number of bytes for the vector a. /// @return 1(true) if a is 0. 0(false) else. /// -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte); +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte); /// @brief polynomial multiplication: c = a*b /// @@ -37,7 +37,7 @@ unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_is_zero(const uint8_t *a /// @param[in] b - the vector b. /// @param[in] _num - number of elements for the polynomials a and b. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num); /// @brief matrix-vector multiplication: c = matA * b , in GF(256) /// @@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_polymul(uint8_t *c, const ui /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); /// @brief matrix-matrix multiplication: c = a * b , in GF(256) /// @@ -56,7 +56,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_prod(uint8_t *c, const uin /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(256) /// @@ -65,7 +65,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_mul(uint8_t *c, const uint /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(256) /// @@ -75,7 +75,7 @@ unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_gauss_elim(uint8_t *ma /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(256) /// @@ -85,6 +85,6 @@ unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_solve_linear_eq(uint8_ /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.c index 959badb1..c37d4687 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(a_u32[i], b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, u } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(t.u32, b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(a_u32[i], gf256_b); } @@ -75,12 +75,12 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, co t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_u32(t.u32, gf256_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.h b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.h index 99c69d7b..6777dafc 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.h +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/blas_u32.h @@ -7,12 +7,12 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte); -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/gf.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/gf.c index 2863a138..b5a4d604 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/gf.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/gf.c @@ -61,8 +61,8 @@ uint32_t PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf16v_mul_u32(uint32_t a, uint8 } uint8_t PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256_is_nonzero(uint8_t a) { - unsigned a8 = a; - unsigned r = ((unsigned)0) - a8; + unsigned int a8 = a; + unsigned int r = ((unsigned int)0) - a8; r >>= 8; return r & 1; } diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.c index dfad8351..8e04fabe 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, u /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btri } void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned ch } void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned } void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned c } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf256v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned ch } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,18 +138,18 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(x, i); } PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf256v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } @@ -157,23 +157,23 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsign } } -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_get_ele(y, i); } PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf256v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.h b/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.h index 32edd826..6ce3d8c6 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(unsigned i_row, u /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_UpperTrianglize(unsigned char *btri /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf16(unsigned cha /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimat_madd_gf256(unsigned ch /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf16(unsigned c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_trimatTr_madd_gf256(unsigned /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf16(unsigned ch /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_2trimat_madd_gf256(unsigned c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf16(unsigned char /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_matTr_madd_gf256(unsigned cha /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf16(unsigned cha /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_bmatTr_madd_gf256(unsigned ch /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf16(unsigned char * /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_mat_madd_gf256(unsigned char /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf16(unsigne /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_trimat_eval_gf256(unsign /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf16(unsigne /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow.c index 4cdf6e6c..e78bc524 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, con uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_rainbow_sign(uint8_t *signature, con uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_rainbow_verify(const uint8_t *digest // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair.c index ed660ebf..d90a2ecb 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair_computation.c index 665d46ee..3661f6c8 100644 --- a/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowVc-cyclic-compressed/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cp } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLICCOMPRESSED_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; diff --git a/crypto_sign/rainbowVc-cyclic/clean/blas_comm.c b/crypto_sign/rainbowVc-cyclic/clean/blas_comm.c index 5d544b0d..0ff48c2a 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/blas_comm.c +++ b/crypto_sign/rainbowVc-cyclic/clean/blas_comm.c @@ -10,7 +10,7 @@ #include #include -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte) { gf256v_add(b, b, _num_byte); } /// @brief get an element from GF(256) vector . @@ -19,11 +19,11 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byt /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i) { +uint8_t PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i) { return a[i]; } -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte) { +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte) { uint8_t r = 0; while (_num_byte--) { r |= a[0]; @@ -34,41 +34,41 @@ unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned /// polynomial multplication /// School boook -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num) { PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(c, _num * 2 - 1); - for (unsigned i = 0; i < _num; i++) { + for (unsigned int i = 0; i < _num; i++) { gf256v_madd(c + i, a, b[i], _num); } } -static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +static void gf256mat_prod_ref(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(c, n_A_vec_byte); - for (unsigned i = 0; i < n_A_width; i++) { + for (unsigned int i = 0; i < n_A_width; i++) { gf256v_madd(c, matA, b[i], n_A_vec_byte); matA += n_A_vec_byte; } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec) { - unsigned n_vec_byte = len_vec; - for (unsigned k = 0; k < len_vec; k++) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec) { + unsigned int n_vec_byte = len_vec; + for (unsigned int k = 0; k < len_vec; k++) { PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(c, n_vec_byte); const uint8_t *bk = b + n_vec_byte * k; - for (unsigned i = 0; i < len_vec; i++) { + for (unsigned int i = 0; i < len_vec; i++) { gf256v_madd(c, a + n_vec_byte * i, bk[i], n_vec_byte); } c += n_vec_byte; } } -static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { - unsigned r8 = 1; +static unsigned int gf256mat_gauss_elim_ref(uint8_t *mat, unsigned int h, unsigned int w) { + unsigned int r8 = 1; - for (unsigned i = 0; i < h; i++) { + for (unsigned int i = 0; i < h; i++) { uint8_t *ai = mat + w * i; - unsigned skip_len_align4 = i & ((unsigned)~0x3); + unsigned int skip_len_align4 = i & ((unsigned int)~0x3); - for (unsigned j = i + 1; j < h; j++) { + for (unsigned int j = i + 1; j < h; j++) { uint8_t *aj = mat + w * j; gf256v_predicated_add(ai + skip_len_align4, !PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256_is_nonzero(ai[i]), aj + skip_len_align4, w - skip_len_align4); } @@ -76,7 +76,7 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { uint8_t pivot = ai[i]; pivot = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256_inv(pivot); gf256v_mul_scalar(ai + skip_len_align4, pivot, w - skip_len_align4); - for (unsigned j = 0; j < h; j++) { + for (unsigned int j = 0; j < h; j++) { if (i == j) { continue; } @@ -88,36 +88,36 @@ static unsigned gf256mat_gauss_elim_ref(uint8_t *mat, unsigned h, unsigned w) { return r8; } -static unsigned gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +static unsigned int gf256mat_solve_linear_eq_ref(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { uint8_t mat[64 * 64]; - for (unsigned i = 0; i < n; i++) { + for (unsigned int i = 0; i < n; i++) { memcpy(mat + i * (n + 1), inp_mat + i * n, n); mat[i * (n + 1) + n] = c_terms[i]; } - unsigned r8 = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); - for (unsigned i = 0; i < n; i++) { + unsigned int r8 = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(mat, n, n + 1); + for (unsigned int i = 0; i < n; i++) { sol[i] = mat[i * (n + 1) + n]; } return r8; } -static inline void gf256mat_submat(uint8_t *mat2, unsigned w2, unsigned st, const uint8_t *mat, unsigned w, unsigned h) { - for (unsigned i = 0; i < h; i++) { - for (unsigned j = 0; j < w2; j++) { +static inline void gf256mat_submat(uint8_t *mat2, unsigned int w2, unsigned int st, const uint8_t *mat, unsigned int w, unsigned int h) { + for (unsigned int i = 0; i < h; i++) { + for (unsigned int j = 0; j < w2; j++) { mat2[i * w2 + j] = mat[i * w + st + j]; } } } -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer) { +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer) { uint8_t *aa = buffer; - for (unsigned i = 0; i < H; i++) { + for (unsigned int i = 0; i < H; i++) { uint8_t *ai = aa + i * 2 * H; PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(ai, 2 * H); gf256v_add(ai, a + i * H, H); ai[H + i] = 1; } - unsigned r8 = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); + unsigned int r8 = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(aa, H, 2 * H); gf256mat_submat(inv_a, H, H, aa, 2 * H, H); return r8; } @@ -128,15 +128,15 @@ unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_ #define gf256mat_prod_impl gf256mat_prod_ref #define gf256mat_gauss_elim_impl gf256mat_gauss_elim_ref #define gf256mat_solve_linear_eq_impl gf256mat_solve_linear_eq_ref -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b) { gf256mat_prod_impl(c, matA, n_A_vec_byte, n_A_width, b); } -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w) { +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w) { return gf256mat_gauss_elim_impl(mat, h, w); } -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n) { +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n) { return gf256mat_solve_linear_eq_impl(sol, inp_mat, c_terms, n); } diff --git a/crypto_sign/rainbowVc-cyclic/clean/blas_comm.h b/crypto_sign/rainbowVc-cyclic/clean/blas_comm.h index cecc310c..08ae23c0 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/blas_comm.h +++ b/crypto_sign/rainbowVc-cyclic/clean/blas_comm.h @@ -12,7 +12,7 @@ /// @param[in,out] b - the vector b. /// @param[in] _num_byte - number of bytes for the vector b. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned int _num_byte); /// @brief get an element from GF(256) vector . /// @@ -20,7 +20,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(uint8_t *b, unsigned _num_byt /// @param[in] i - the index in the vector a. /// @return the value of the element. /// -uint8_t PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned i); +uint8_t PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned int i); /// @brief check if a vector is 0. /// @@ -28,7 +28,7 @@ uint8_t PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(const uint8_t *a, unsigned /// @param[in] _num_byte - number of bytes for the vector a. /// @return 1(true) if a is 0. 0(false) else. /// -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned _num_byte); +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned int _num_byte); /// @brief polynomial multiplication: c = a*b /// @@ -37,7 +37,7 @@ unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_is_zero(const uint8_t *a, unsigned /// @param[in] b - the vector b. /// @param[in] _num - number of elements for the polynomials a and b. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned _num); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int _num); /// @brief matrix-vector multiplication: c = matA * b , in GF(256) /// @@ -47,7 +47,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_polymul(uint8_t *c, const uint8_t *a, /// @param[in] n_A_width - the width of matrix A. /// @param[in] b - the vector b. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned n_A_vec_byte, unsigned n_A_width, const uint8_t *b); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA, unsigned int n_A_vec_byte, unsigned int n_A_width, const uint8_t *b); /// @brief matrix-matrix multiplication: c = a * b , in GF(256) /// @@ -56,7 +56,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_prod(uint8_t *c, const uint8_t *matA /// @param[in] b - a matrix b. /// @param[in] len_vec - the length of column vectors. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned len_vec); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, const uint8_t *b, unsigned int len_vec); /// @brief Gauss elimination for a matrix, in GF(256) /// @@ -65,7 +65,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_mul(uint8_t *c, const uint8_t *a, co /// @param[in] w - the width of the matrix. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned h, unsigned w); +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigned int h, unsigned int w); /// @brief Solving linear equations, in GF(256) /// @@ -75,7 +75,7 @@ unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_gauss_elim(uint8_t *mat, unsigne /// @param[in] n - the number of equations. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned n); +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, const uint8_t *inp_mat, const uint8_t *c_terms, unsigned int n); /// @brief Computing the inverse matrix, in GF(256) /// @@ -85,6 +85,6 @@ unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_solve_linear_eq(uint8_t *sol, co /// @param[in] buffer - The buffer for computations. it has to be as large as 2 input matrixes. /// @return 1(true) if success. 0(false) if the matrix is singular. /// -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned H, uint8_t *buffer); +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256mat_inv(uint8_t *inv_a, const uint8_t *a, unsigned int H, uint8_t *buffer); #endif // _BLAS_COMM_H_ diff --git a/crypto_sign/rainbowVc-cyclic/clean/blas_u32.c b/crypto_sign/rainbowVc-cyclic/clean/blas_u32.c index bbe63b2a..d8d5b65d 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/blas_u32.c +++ b/crypto_sign/rainbowVc-cyclic/clean/blas_u32.c @@ -1,46 +1,46 @@ #include "blas_u32.h" #include "gf.h" -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte) { uint32_t pr_u32 = ((uint32_t)0) - ((uint32_t)predicate); uint8_t pr_u8 = pr_u32 & 0xff; - unsigned n_u32 = _num_byte >> 2; + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= (a_u32[i] & pr_u32); } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= (a[i] & pr_u8); } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *b_u32 = (uint32_t *)accu_b; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { b_u32[i] ^= a_u32[i]; } a += (n_u32 << 2); accu_b += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { accu_b[i] ^= a[i]; } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *a_u32 = (uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { a_u32[i] = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_u32(a_u32[i], b); } @@ -50,21 +50,21 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, } t; t.u32 = 0; a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_u32(t.u32, b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { a[i] = t.u8[i]; } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte) { - unsigned n_u32 = _num_byte >> 2; +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte) { + unsigned int n_u32 = _num_byte >> 2; uint32_t *c_u32 = (uint32_t *)accu_c; const uint32_t *a_u32 = (const uint32_t *)a; - for (unsigned i = 0; i < n_u32; i++) { + for (unsigned int i = 0; i < n_u32; i++) { c_u32[i] ^= PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_u32(a_u32[i], gf256_b); } @@ -75,12 +75,12 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_ t.u32 = 0; accu_c += (n_u32 << 2); a += (n_u32 << 2); - unsigned rem = _num_byte & 3; - for (unsigned i = 0; i < rem; i++) { + unsigned int rem = _num_byte & 3; + for (unsigned int i = 0; i < rem; i++) { t.u8[i] = a[i]; } t.u32 = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_u32(t.u32, gf256_b); - for (unsigned i = 0; i < rem; i++) { + for (unsigned int i = 0; i < rem; i++) { accu_c[i] ^= t.u8[i]; } } diff --git a/crypto_sign/rainbowVc-cyclic/clean/blas_u32.h b/crypto_sign/rainbowVc-cyclic/clean/blas_u32.h index ea0679c0..4ca03d6b 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/blas_u32.h +++ b/crypto_sign/rainbowVc-cyclic/clean/blas_u32.h @@ -7,12 +7,12 @@ #include "rainbow_config.h" #include -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned _num_byte); -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_predicated_add_u32(uint8_t *accu_b, uint8_t predicate, const uint8_t *a, unsigned int _num_byte); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_add_u32(uint8_t *accu_b, const uint8_t *a, unsigned int _num_byte); -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned _num_byte); -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned _num_byte); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_mul_scalar_u32(uint8_t *a, uint8_t b, unsigned int _num_byte); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_madd_u32(uint8_t *accu_c, const uint8_t *a, uint8_t gf256_b, unsigned int _num_byte); #endif // _BLAS_U32_H_ diff --git a/crypto_sign/rainbowVc-cyclic/clean/gf.c b/crypto_sign/rainbowVc-cyclic/clean/gf.c index 1fb5237c..17074555 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/gf.c +++ b/crypto_sign/rainbowVc-cyclic/clean/gf.c @@ -61,8 +61,8 @@ uint32_t PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf16v_mul_u32(uint32_t a, uint8_t b) { } uint8_t PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256_is_nonzero(uint8_t a) { - unsigned a8 = a; - unsigned r = ((unsigned)0) - a8; + unsigned int a8 = a; + unsigned int r = ((unsigned int)0) - a8; r >>= 8; return r & 1; } diff --git a/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.c b/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.c index 2d64cbd6..22a68c6c 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.c +++ b/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.c @@ -16,7 +16,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim) { +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim) { return (dim + dim - i_row + 1) * i_row / 2 + j_col - i_row; } @@ -28,19 +28,19 @@ unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_ /// @param[in] dim - the dimension of the triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -static inline unsigned idx_of_2trimat(unsigned i_row, unsigned j_col, unsigned n_var) { +static inline unsigned int idx_of_2trimat(unsigned int i_row, unsigned int j_col, unsigned int n_var) { if (i_row > j_col) { return PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(j_col, i_row, n_var); } return PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i_row, j_col, n_var); } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch) { unsigned char *runningC = btriC; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < i; j++) { - unsigned idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(j, i, Aheight); + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < i; j++) { + unsigned int idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(j, i, Aheight); gf256v_add(btriC + idx * size_batch, bA + size_batch * (i * Awidth + j), size_batch); } gf256v_add(runningC, bA + size_batch * (i * Awidth + i), size_batch * (Aheight - i)); @@ -49,12 +49,12 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const u } void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - unsigned Aheight = Awidth; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + unsigned int Aheight = Awidth; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (k < i) { continue; } @@ -67,11 +67,11 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, co } void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i < k) { continue; } @@ -83,11 +83,11 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, } void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Aheight = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Aheight = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { if (i == k) { continue; } @@ -98,25 +98,25 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, c } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch) { - unsigned Atr_height = Awidth; - unsigned Atr_width = Aheight; - for (unsigned i = 0; i < Atr_height; i++) { - for (unsigned j = 0; j < Atr_width; j++) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Atr_height = Awidth; + unsigned int Atr_width = Aheight; + for (unsigned int i = 0; i < Atr_height; i++) { + for (unsigned int j = 0; j < Atr_width; j++) { gf256v_madd(bC, &bB[j * Bwidth * size_batch], PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(&A_to_tr[size_Acolvec * i], j), size_batch * Bwidth); } bC += size_batch * Bwidth; } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { const unsigned char *bA = bA_to_tr; - unsigned Aheight = Awidth_before_tr; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { + unsigned int Aheight = Awidth_before_tr; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[size_batch * (i + k * Aheight)], PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -124,12 +124,12 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, co } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch) { - unsigned Awidth = Bheight; - for (unsigned i = 0; i < Aheight; i++) { - for (unsigned j = 0; j < Bwidth; j++) { - for (unsigned k = 0; k < Bheight; k++) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch) { + unsigned int Awidth = Bheight; + for (unsigned int i = 0; i < Aheight; i++) { + for (unsigned int j = 0; j < Bwidth; j++) { + for (unsigned int k = 0; k < Bheight; k++) { gf256v_madd(bC, &bA[k * size_batch], PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(&B[j * size_Bcolvec], k), size_batch); } bC += size_batch; @@ -138,18 +138,18 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch) { +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch) { unsigned char tmp[256]; unsigned char _x[256]; - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { _x[i] = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(x, i); } PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(y, size_batch); - for (unsigned i = 0; i < dim; i++) { + for (unsigned int i = 0; i < dim; i++) { PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = i; j < dim; j++) { + for (unsigned int j = i; j < dim; j++) { gf256v_madd(tmp, trimat, _x[j], size_batch); trimat += size_batch; } @@ -157,23 +157,23 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y } } -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, const unsigned char *mat, +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch) { unsigned char tmp[128]; unsigned char _x[128]; - for (unsigned i = 0; i < dim_x; i++) { + for (unsigned int i = 0; i < dim_x; i++) { _x[i] = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(x, i); } unsigned char _y[128]; - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { _y[i] = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_get_ele(y, i); } PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(z, size_batch); - for (unsigned i = 0; i < dim_y; i++) { + for (unsigned int i = 0; i < dim_y; i++) { PQCLEAN_RAINBOWVCCYCLIC_CLEAN_gf256v_set_zero(tmp, size_batch); - for (unsigned j = 0; j < dim_x; j++) { + for (unsigned int j = 0; j < dim_x; j++) { gf256v_madd(tmp, mat, _x[j], size_batch); mat += size_batch; } diff --git a/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.h b/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.h index b6c3528a..2a3308de 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.h +++ b/crypto_sign/rainbowVc-cyclic/clean/parallel_matrix_op.h @@ -15,7 +15,7 @@ /// @param[in] dim - the dimension of the upper-triangle matrix, i.e., an dim x dim matrix. /// @return the corresponding index in an array storage. /// -unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_col, unsigned dim); +unsigned int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(unsigned int i_row, unsigned int j_col, unsigned int dim); /// /// @brief Upper trianglize a rectangle matrix to the corresponding upper-trangle matrix. @@ -25,7 +25,7 @@ unsigned PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(unsigned i_row, unsigned j_ /// @param[in] bwidth - the width of the batched matrix A, i.e., A is a Awidth x Awidth matrix. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned Awidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const unsigned char *bA, unsigned int Awidth, unsigned int size_batch); //////////////////// Section: matrix multiplications /////////////////////////////// @@ -41,7 +41,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_UpperTrianglize(unsigned char *btriC, const u /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA * B , in GF(256) @@ -55,7 +55,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimat_madd_gf16(unsigned char *bC, con /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(16) @@ -69,7 +69,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimat_madd_gf256(unsigned char *bC, co /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += btriA^Tr * B , in GF(256) @@ -83,7 +83,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimatTr_madd_gf16(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(16) @@ -97,7 +97,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_trimatTr_madd_gf256(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += (btriA + btriA^Tr) *B , in GF(256) @@ -111,7 +111,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_2trimat_madd_gf16(unsigned char *bC, co /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, const unsigned char *btriA, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(16) @@ -126,8 +126,8 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_2trimat_madd_gf256(unsigned char *bC, c /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += A^Tr * bB , in GF(256) @@ -142,8 +142,8 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_matTr_madd_gf16(unsigned char *bC, /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, - const unsigned char *A_to_tr, unsigned Aheight, unsigned size_Acolvec, unsigned Awidth, - const unsigned char *bB, unsigned Bwidth, unsigned size_batch); + const unsigned char *A_to_tr, unsigned int Aheight, unsigned int size_Acolvec, unsigned int Awidth, + const unsigned char *bB, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(16) @@ -157,8 +157,8 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_matTr_madd_gf256(unsigned char *bC, /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA^Tr * B , in GF(256) @@ -172,8 +172,8 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf16(unsigned char *bC, con /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned Awidth_before_tr, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, const unsigned char *bA_to_tr, unsigned int Awidth_before_tr, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(16) @@ -187,8 +187,8 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_bmatTr_madd_gf256(unsigned char *bC, co /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); /// /// @brief bC += bA * B , in GF(256) @@ -202,8 +202,8 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf16(unsigned char *bC, const /// @param[in] Bwidth - the width of B. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned Aheight, - const unsigned char *B, unsigned Bheight, unsigned size_Bcolvec, unsigned Bwidth, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const unsigned char *bA, unsigned int Aheight, + const unsigned char *B, unsigned int Bheight, unsigned int size_Bcolvec, unsigned int Bwidth, unsigned int size_batch); //////////////////// Section: "quadratric" matrix evaluation /////////////////////////////// @@ -216,7 +216,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_mat_madd_gf256(unsigned char *bC, const /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief y = x^Tr * trimat * x , in GF(256) @@ -227,7 +227,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf16(unsigned char *y, /// @param[in] dim - the dimension of matrix trimat (and x). /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned dim, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y, const unsigned char *trimat, const unsigned char *x, unsigned int dim, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(16) @@ -240,8 +240,8 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_trimat_eval_gf256(unsigned char *y /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); /// /// @brief z = y^Tr * mat * x , in GF(256) @@ -254,7 +254,7 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_recmat_eval_gf16(unsigned char *z, /// @param[in] dim_x - the length of x. /// @param[in] size_batch - number of the batched elements in the corresponding position of the matrix. /// -void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned dim_y, - const unsigned char *mat, const unsigned char *x, unsigned dim_x, unsigned size_batch); +void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_batch_quad_recmat_eval_gf256(unsigned char *z, const unsigned char *y, unsigned int dim_y, + const unsigned char *mat, const unsigned char *x, unsigned int dim_x, unsigned int size_batch); #endif // _P_MATRIX_OP_H_ diff --git a/crypto_sign/rainbowVc-cyclic/clean/rainbow.c b/crypto_sign/rainbowVc-cyclic/clean/rainbow.c index 97409632..ee75d39a 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/rainbow.c +++ b/crypto_sign/rainbowVc-cyclic/clean/rainbow.c @@ -30,17 +30,17 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s uint8_t prng_seed[_HASH_LEN]; PQCLEAN_RAINBOWVCCYCLIC_CLEAN_hash_msg(prng_seed, _HASH_LEN, prng_preseed, _HASH_LEN + LEN_SKSEED); PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_set(&prng_sign, prng_seed, _HASH_LEN); // seed = H( sk_seed || digest ) - for (unsigned i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { + for (unsigned int i = 0; i < LEN_SKSEED + _HASH_LEN; i++) { prng_preseed[i] ^= prng_preseed[i]; // clean } - for (unsigned i = 0; i < _HASH_LEN; i++) { + for (unsigned int i = 0; i < _HASH_LEN; i++) { prng_seed[i] ^= prng_seed[i]; // clean } // roll vinegars. uint8_t vinegar[_V1_BYTE]; - unsigned n_attempt = 0; - unsigned l1_succ = 0; + unsigned int n_attempt = 0; + unsigned int l1_succ = 0; while (!l1_succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -73,7 +73,7 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_sign(uint8_t *signature, const sk_t *s uint8_t *salt = digest_salt + _HASH_LEN; uint8_t temp_o[_MAX_O_BYTE + 32] = {0}; - unsigned succ = 0; + unsigned int succ = 0; while (!succ) { if (MAX_ATTEMPT_FRMAT <= n_attempt) { break; @@ -160,7 +160,7 @@ int PQCLEAN_RAINBOWVCCYCLIC_CLEAN_rainbow_verify(const uint8_t *digest, const ui // check consistancy. unsigned char cc = 0; - for (unsigned i = 0; i < _PUB_M_BYTE; i++) { + for (unsigned int i = 0; i < _PUB_M_BYTE; i++) { cc |= (digest_ck[i] ^ correct[i]); } return (0 == cc) ? 0 : -1; diff --git a/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair.c b/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair.c index 9a5e137c..3480d2f0 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair.c +++ b/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair.c @@ -22,8 +22,8 @@ static void generate_S_T(unsigned char *s_and_t, prng_t *prng0) { PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, s_and_t, _O1_BYTE * _O2); // T3 } -static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l1_F12(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O1_BYTE * N_TRIANGLE_TERMS(_V1)); // l1_F1 sk += _O1_BYTE * N_TRIANGLE_TERMS(_V1); n_byte_generated += _O1_BYTE * N_TRIANGLE_TERMS(_V1); @@ -33,8 +33,8 @@ static unsigned generate_l1_F12(unsigned char *sk, prng_t *prng0) { return n_byte_generated; } -static unsigned generate_l2_F12356(unsigned char *sk, prng_t *prng0) { - unsigned n_byte_generated = 0; +static unsigned int generate_l2_F12356(unsigned char *sk, prng_t *prng0) { + unsigned int n_byte_generated = 0; PQCLEAN_RAINBOWVCCYCLIC_CLEAN_prng_gen(prng0, sk, _O2_BYTE * N_TRIANGLE_TERMS(_V1)); // l2_F1 sk += _O2_BYTE * N_TRIANGLE_TERMS(_V1); @@ -67,7 +67,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const // t4 = T_sk.t1 * T_sk.t3 - T_sk.t2 unsigned char temp[_V1_BYTE + 32]; unsigned char *t4 = t2_to_t4; - for (unsigned i = 0; i < _O2; i++) { /// t3 width + for (unsigned int i = 0; i < _O2; i++) { /// t3 width gfmat_prod(temp, t1, _V1_BYTE, _O1, t3); gf256v_add(t4, temp, _V1_BYTE); t4 += _V1_BYTE; @@ -75,7 +75,7 @@ static void calculate_t4(unsigned char *t2_to_t4, const unsigned char *t1, const } } -static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned n_terms, const unsigned char *s1) { +static void obsfucate_l1_polys(unsigned char *l1_polys, const unsigned char *l2_polys, unsigned int n_terms, const unsigned char *s1) { unsigned char temp[_O1_BYTE + 32]; while (n_terms--) { gfmat_prod(temp, s1, _O1_BYTE, _O2, l2_polys); diff --git a/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair_computation.c b/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair_computation.c index 8a662fcc..db23a907 100644 --- a/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair_computation.c +++ b/crypto_sign/rainbowVc-cyclic/clean/rainbow_keypair_computation.c @@ -14,9 +14,9 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) { const unsigned char *idx_l1 = cpk->l1_Q1; const unsigned char *idx_l2 = cpk->l2_Q1; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = i; j < _V1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = i; j < _V1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -25,9 +25,9 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q2; idx_l2 = cpk->l2_Q2; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -36,9 +36,9 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q3; idx_l2 = cpk->l2_Q3; - for (unsigned i = 0; i < _V1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = 0; i < _V1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -47,9 +47,9 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q5; idx_l2 = cpk->l2_Q5; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = i; j < _V1 + _O1; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = i; j < _V1 + _O1; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -58,9 +58,9 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q6; idx_l2 = cpk->l2_Q6; - for (unsigned i = _V1; i < _V1 + _O1; i++) { - for (unsigned j = _V1 + _O1; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1; i < _V1 + _O1; i++) { + for (unsigned int j = _V1 + _O1; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE; @@ -69,9 +69,9 @@ void PQCLEAN_RAINBOWVCCYCLIC_CLEAN_extcpk_to_pk(pk_t *pk, const ext_cpk_t *cpk) } idx_l1 = cpk->l1_Q9; idx_l2 = cpk->l2_Q9; - for (unsigned i = _V1 + _O1; i < _PUB_N; i++) { - for (unsigned j = i; j < _PUB_N; j++) { - unsigned pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); + for (unsigned int i = _V1 + _O1; i < _PUB_N; i++) { + for (unsigned int j = i; j < _PUB_N; j++) { + unsigned int pub_idx = PQCLEAN_RAINBOWVCCYCLIC_CLEAN_idx_of_trimat(i, j, _PUB_N); memcpy(&pk->pk[_PUB_M_BYTE * pub_idx], idx_l1, _O1_BYTE); memcpy((&pk->pk[_PUB_M_BYTE * pub_idx]) + _O1_BYTE, idx_l2, _O2_BYTE); idx_l1 += _O1_BYTE;