diff --git a/crypto_kem/ledakemlt12/leaktime/bf_decoding.c b/crypto_kem/ledakemlt12/leaktime/bf_decoding.c index 6d27d761..3faa117c 100644 --- a/crypto_kem/ledakemlt12/leaktime/bf_decoding.c +++ b/crypto_kem/ledakemlt12/leaktime/bf_decoding.c @@ -13,7 +13,7 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_bf_decoding(DIGIT err[], uint8_t unsatParityChecks[N0 * P]; POSITION_T currQBlkPos[M], currQBitPos[M]; POSITION_T syndromePosToFlip, tmp; - unsigned int correlation, corrt_syndrome_based; + uint32_t correlation, corrt_syndrome_based; size_t currQoneIdx, endQblockIdx, currblockoffset; int check; int iteration = 0; @@ -22,7 +22,7 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_bf_decoding(DIGIT err[], PQCLEAN_LEDAKEMLT12_LEAKTIME_gf2x_copy(currSyndrome, privateSyndrome); memset(unsatParityChecks, 0x00, N0 * P * sizeof(uint8_t)); for (size_t i = 0; i < N0; i++) { - for (size_t valueIdx = 0; valueIdx < P; valueIdx++) { + for (POSITION_T valueIdx = 0; valueIdx < P; valueIdx++) { for (size_t HtrOneIdx = 0; HtrOneIdx < DV; HtrOneIdx++) { tmp = (HtrPosOnes[i][HtrOneIdx] + valueIdx) >= P ? (HtrPosOnes[i][HtrOneIdx] + valueIdx) - P : @@ -39,7 +39,7 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_bf_decoding(DIGIT err[], // Computation of correlation with a full Q matrix for (size_t i = 0; i < N0; i++) { - for (size_t j = 0; j < P; j++) { + for (POSITION_T j = 0; j < P; j++) { currQoneIdx = endQblockIdx = 0; correlation = 0; @@ -50,7 +50,7 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_bf_decoding(DIGIT err[], tmp = QtrPosOnes[i][currQoneIdx] + j; tmp = tmp >= P ? tmp - P : tmp; currQBitPos[currQoneIdx] = tmp; - currQBlkPos[currQoneIdx] = blockIdx; + currQBlkPos[currQoneIdx] = (POSITION_T)blockIdx; correlation += unsatParityChecks[tmp + currblockoffset]; } } diff --git a/crypto_kem/ledakemlt12/leaktime/dfr_test.c b/crypto_kem/ledakemlt12/leaktime/dfr_test.c index dea8b6f3..5669c288 100644 --- a/crypto_kem/ledakemlt12/leaktime/dfr_test.c +++ b/crypto_kem/ledakemlt12/leaktime/dfr_test.c @@ -10,12 +10,11 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_DFR_test(POSITION_T LSparse[N0][DV * M], uint8_t *secondIterThreshold) { POSITION_T LSparse_loc[N0][DV * M]; /* vector of N_0 sparse blocks */ - unsigned int gamma[N0][N0][P] = {{{0}}}; - unsigned int maxMut[N0], maxMutMinusOne[N0]; - unsigned int allBlockMaxSumst, allBlockMaxSumstMinusOne; - unsigned int gammaHist[N0][DV * M + 1] = {{0}}; - unsigned int toAdd; - size_t histIdx; + uint8_t gamma[N0][N0][P] = {{{0}}}; + uint32_t gammaHist[N0][DV * M + 1] = {{0}}; + size_t maxMut[N0], maxMutMinusOne[N0]; + size_t allBlockMaxSumst, allBlockMaxSumstMinusOne; + size_t histIdx, toAdd; for (size_t i = 0; i < N0; i++) { for (size_t j = 0; j < DV * M; j++) { @@ -73,7 +72,7 @@ int PQCLEAN_LEDAKEMLT12_LEAKTIME_DFR_test(POSITION_T LSparse[N0][DV * M], uint8_ /*seek max values across all gamma blocks */ allBlockMaxSumst = maxMut[0]; allBlockMaxSumstMinusOne = maxMutMinusOne[0]; - for (size_t gammaBlockRowIdx = 0; gammaBlockRowIdx < N0 ; gammaBlockRowIdx++) { + for (size_t gammaBlockRowIdx = 0; gammaBlockRowIdx < N0; gammaBlockRowIdx++) { allBlockMaxSumst = allBlockMaxSumst < maxMut[gammaBlockRowIdx] ? maxMut[gammaBlockRowIdx] : allBlockMaxSumst; diff --git a/crypto_kem/ledakemlt12/leaktime/gf2x_arith_mod_xPplusOne.c b/crypto_kem/ledakemlt12/leaktime/gf2x_arith_mod_xPplusOne.c index 0753efa2..70de3d80 100644 --- a/crypto_kem/ledakemlt12/leaktime/gf2x_arith_mod_xPplusOne.c +++ b/crypto_kem/ledakemlt12/leaktime/gf2x_arith_mod_xPplusOne.c @@ -134,9 +134,7 @@ void PQCLEAN_LEDAKEMLT12_LEAKTIME_gf2x_transpose_in_place(DIGIT A[]) { A[NUM_DIGITS_GF2X_ELEMENT - 1 - i] = rev1; } - if (NUM_DIGITS_GF2X_ELEMENT % 2 == 1) { - A[NUM_DIGITS_GF2X_ELEMENT / 2] = reverse_digit(A[NUM_DIGITS_GF2X_ELEMENT / 2]); - } + A[NUM_DIGITS_GF2X_ELEMENT / 2] = reverse_digit(A[NUM_DIGITS_GF2X_ELEMENT / 2]); if (slack_bits_amount) { PQCLEAN_LEDAKEMLT12_LEAKTIME_right_bit_shift_n(NUM_DIGITS_GF2X_ELEMENT, A, slack_bits_amount); diff --git a/crypto_kem/ledakemlt32/leaktime/bf_decoding.c b/crypto_kem/ledakemlt32/leaktime/bf_decoding.c index 02f528e7..fc6aab04 100644 --- a/crypto_kem/ledakemlt32/leaktime/bf_decoding.c +++ b/crypto_kem/ledakemlt32/leaktime/bf_decoding.c @@ -13,7 +13,7 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_bf_decoding(DIGIT err[], uint8_t unsatParityChecks[N0 * P]; POSITION_T currQBlkPos[M], currQBitPos[M]; POSITION_T syndromePosToFlip, tmp; - unsigned int correlation, corrt_syndrome_based; + uint32_t correlation, corrt_syndrome_based; size_t currQoneIdx, endQblockIdx, currblockoffset; int check; int iteration = 0; @@ -22,7 +22,7 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_bf_decoding(DIGIT err[], PQCLEAN_LEDAKEMLT32_LEAKTIME_gf2x_copy(currSyndrome, privateSyndrome); memset(unsatParityChecks, 0x00, N0 * P * sizeof(uint8_t)); for (size_t i = 0; i < N0; i++) { - for (size_t valueIdx = 0; valueIdx < P; valueIdx++) { + for (POSITION_T valueIdx = 0; valueIdx < P; valueIdx++) { for (size_t HtrOneIdx = 0; HtrOneIdx < DV; HtrOneIdx++) { tmp = (HtrPosOnes[i][HtrOneIdx] + valueIdx) >= P ? (HtrPosOnes[i][HtrOneIdx] + valueIdx) - P : @@ -39,7 +39,7 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_bf_decoding(DIGIT err[], // Computation of correlation with a full Q matrix for (size_t i = 0; i < N0; i++) { - for (size_t j = 0; j < P; j++) { + for (POSITION_T j = 0; j < P; j++) { currQoneIdx = endQblockIdx = 0; correlation = 0; @@ -50,7 +50,7 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_bf_decoding(DIGIT err[], tmp = QtrPosOnes[i][currQoneIdx] + j; tmp = tmp >= P ? tmp - P : tmp; currQBitPos[currQoneIdx] = tmp; - currQBlkPos[currQoneIdx] = blockIdx; + currQBlkPos[currQoneIdx] = (POSITION_T)blockIdx; correlation += unsatParityChecks[tmp + currblockoffset]; } } diff --git a/crypto_kem/ledakemlt32/leaktime/dfr_test.c b/crypto_kem/ledakemlt32/leaktime/dfr_test.c index 1235852d..bacbb9c4 100644 --- a/crypto_kem/ledakemlt32/leaktime/dfr_test.c +++ b/crypto_kem/ledakemlt32/leaktime/dfr_test.c @@ -10,12 +10,11 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_DFR_test(POSITION_T LSparse[N0][DV * M], uint8_t *secondIterThreshold) { POSITION_T LSparse_loc[N0][DV * M]; /* vector of N_0 sparse blocks */ - unsigned int gamma[N0][N0][P] = {{{0}}}; - unsigned int maxMut[N0], maxMutMinusOne[N0]; - unsigned int allBlockMaxSumst, allBlockMaxSumstMinusOne; - unsigned int gammaHist[N0][DV * M + 1] = {{0}}; - unsigned int toAdd; - size_t histIdx; + uint8_t gamma[N0][N0][P] = {{{0}}}; + uint32_t gammaHist[N0][DV * M + 1] = {{0}}; + size_t maxMut[N0], maxMutMinusOne[N0]; + size_t allBlockMaxSumst, allBlockMaxSumstMinusOne; + size_t histIdx, toAdd; for (size_t i = 0; i < N0; i++) { for (size_t j = 0; j < DV * M; j++) { @@ -73,7 +72,7 @@ int PQCLEAN_LEDAKEMLT32_LEAKTIME_DFR_test(POSITION_T LSparse[N0][DV * M], uint8_ /*seek max values across all gamma blocks */ allBlockMaxSumst = maxMut[0]; allBlockMaxSumstMinusOne = maxMutMinusOne[0]; - for (size_t gammaBlockRowIdx = 0; gammaBlockRowIdx < N0 ; gammaBlockRowIdx++) { + for (size_t gammaBlockRowIdx = 0; gammaBlockRowIdx < N0; gammaBlockRowIdx++) { allBlockMaxSumst = allBlockMaxSumst < maxMut[gammaBlockRowIdx] ? maxMut[gammaBlockRowIdx] : allBlockMaxSumst; diff --git a/crypto_kem/ledakemlt32/leaktime/gf2x_arith_mod_xPplusOne.c b/crypto_kem/ledakemlt32/leaktime/gf2x_arith_mod_xPplusOne.c index bfe9c6b3..9206dfb0 100644 --- a/crypto_kem/ledakemlt32/leaktime/gf2x_arith_mod_xPplusOne.c +++ b/crypto_kem/ledakemlt32/leaktime/gf2x_arith_mod_xPplusOne.c @@ -134,10 +134,6 @@ void PQCLEAN_LEDAKEMLT32_LEAKTIME_gf2x_transpose_in_place(DIGIT A[]) { A[NUM_DIGITS_GF2X_ELEMENT - 1 - i] = rev1; } - if (NUM_DIGITS_GF2X_ELEMENT % 2 == 1) { - A[NUM_DIGITS_GF2X_ELEMENT / 2] = reverse_digit(A[NUM_DIGITS_GF2X_ELEMENT / 2]); - } - if (slack_bits_amount) { PQCLEAN_LEDAKEMLT32_LEAKTIME_right_bit_shift_n(NUM_DIGITS_GF2X_ELEMENT, A, slack_bits_amount); } diff --git a/crypto_kem/ledakemlt52/leaktime/bf_decoding.c b/crypto_kem/ledakemlt52/leaktime/bf_decoding.c index 7c76fb67..3b6878d0 100644 --- a/crypto_kem/ledakemlt52/leaktime/bf_decoding.c +++ b/crypto_kem/ledakemlt52/leaktime/bf_decoding.c @@ -13,7 +13,7 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_bf_decoding(DIGIT err[], uint8_t unsatParityChecks[N0 * P]; POSITION_T currQBlkPos[M], currQBitPos[M]; POSITION_T syndromePosToFlip, tmp; - unsigned int correlation, corrt_syndrome_based; + uint32_t correlation, corrt_syndrome_based; size_t currQoneIdx, endQblockIdx, currblockoffset; int check; int iteration = 0; @@ -22,7 +22,7 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_bf_decoding(DIGIT err[], PQCLEAN_LEDAKEMLT52_LEAKTIME_gf2x_copy(currSyndrome, privateSyndrome); memset(unsatParityChecks, 0x00, N0 * P * sizeof(uint8_t)); for (size_t i = 0; i < N0; i++) { - for (size_t valueIdx = 0; valueIdx < P; valueIdx++) { + for (POSITION_T valueIdx = 0; valueIdx < P; valueIdx++) { for (size_t HtrOneIdx = 0; HtrOneIdx < DV; HtrOneIdx++) { tmp = (HtrPosOnes[i][HtrOneIdx] + valueIdx) >= P ? (HtrPosOnes[i][HtrOneIdx] + valueIdx) - P : @@ -39,7 +39,7 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_bf_decoding(DIGIT err[], // Computation of correlation with a full Q matrix for (size_t i = 0; i < N0; i++) { - for (size_t j = 0; j < P; j++) { + for (POSITION_T j = 0; j < P; j++) { currQoneIdx = endQblockIdx = 0; correlation = 0; @@ -50,7 +50,7 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_bf_decoding(DIGIT err[], tmp = QtrPosOnes[i][currQoneIdx] + j; tmp = tmp >= P ? tmp - P : tmp; currQBitPos[currQoneIdx] = tmp; - currQBlkPos[currQoneIdx] = blockIdx; + currQBlkPos[currQoneIdx] = (POSITION_T)blockIdx; correlation += unsatParityChecks[tmp + currblockoffset]; } } diff --git a/crypto_kem/ledakemlt52/leaktime/dfr_test.c b/crypto_kem/ledakemlt52/leaktime/dfr_test.c index 31a4f93e..abb80238 100644 --- a/crypto_kem/ledakemlt52/leaktime/dfr_test.c +++ b/crypto_kem/ledakemlt52/leaktime/dfr_test.c @@ -10,12 +10,11 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_DFR_test(POSITION_T LSparse[N0][DV * M], uint8_t *secondIterThreshold) { POSITION_T LSparse_loc[N0][DV * M]; /* vector of N_0 sparse blocks */ - unsigned int gamma[N0][N0][P] = {{{0}}}; - unsigned int maxMut[N0], maxMutMinusOne[N0]; - unsigned int allBlockMaxSumst, allBlockMaxSumstMinusOne; - unsigned int gammaHist[N0][DV * M + 1] = {{0}}; - unsigned int toAdd; - size_t histIdx; + uint8_t gamma[N0][N0][P] = {{{0}}}; + uint32_t gammaHist[N0][DV * M + 1] = {{0}}; + size_t maxMut[N0], maxMutMinusOne[N0]; + size_t allBlockMaxSumst, allBlockMaxSumstMinusOne; + size_t histIdx, toAdd; for (size_t i = 0; i < N0; i++) { for (size_t j = 0; j < DV * M; j++) { @@ -73,7 +72,7 @@ int PQCLEAN_LEDAKEMLT52_LEAKTIME_DFR_test(POSITION_T LSparse[N0][DV * M], uint8_ /*seek max values across all gamma blocks */ allBlockMaxSumst = maxMut[0]; allBlockMaxSumstMinusOne = maxMutMinusOne[0]; - for (size_t gammaBlockRowIdx = 0; gammaBlockRowIdx < N0 ; gammaBlockRowIdx++) { + for (size_t gammaBlockRowIdx = 0; gammaBlockRowIdx < N0; gammaBlockRowIdx++) { allBlockMaxSumst = allBlockMaxSumst < maxMut[gammaBlockRowIdx] ? maxMut[gammaBlockRowIdx] : allBlockMaxSumst; diff --git a/crypto_kem/ledakemlt52/leaktime/gf2x_arith_mod_xPplusOne.c b/crypto_kem/ledakemlt52/leaktime/gf2x_arith_mod_xPplusOne.c index 56584fc8..f19b6648 100644 --- a/crypto_kem/ledakemlt52/leaktime/gf2x_arith_mod_xPplusOne.c +++ b/crypto_kem/ledakemlt52/leaktime/gf2x_arith_mod_xPplusOne.c @@ -134,10 +134,6 @@ void PQCLEAN_LEDAKEMLT52_LEAKTIME_gf2x_transpose_in_place(DIGIT A[]) { A[NUM_DIGITS_GF2X_ELEMENT - 1 - i] = rev1; } - if (NUM_DIGITS_GF2X_ELEMENT % 2 == 1) { - A[NUM_DIGITS_GF2X_ELEMENT / 2] = reverse_digit(A[NUM_DIGITS_GF2X_ELEMENT / 2]); - } - if (slack_bits_amount) { PQCLEAN_LEDAKEMLT52_LEAKTIME_right_bit_shift_n(NUM_DIGITS_GF2X_ELEMENT, A, slack_bits_amount); }