From c00cb2dd20de80db71cb2bd98966932373e9efc1 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Fri, 27 Nov 2020 08:32:56 -0500 Subject: [PATCH] explicit casts --- crypto_kem/kyber1024-90s/clean/indcpa.c | 4 ++-- crypto_kem/kyber1024-90s/clean/poly.c | 6 +++--- crypto_kem/kyber1024/clean/indcpa.c | 4 ++-- crypto_kem/kyber1024/clean/poly.c | 6 +++--- crypto_kem/kyber512-90s/clean/indcpa.c | 4 ++-- crypto_kem/kyber512-90s/clean/poly.c | 6 +++--- crypto_kem/kyber512/clean/indcpa.c | 4 ++-- crypto_kem/kyber512/clean/poly.c | 6 +++--- crypto_kem/kyber768-90s/clean/indcpa.c | 4 ++-- crypto_kem/kyber768-90s/clean/poly.c | 6 +++--- crypto_kem/kyber768/clean/indcpa.c | 4 ++-- crypto_kem/kyber768/clean/poly.c | 6 +++--- 12 files changed, 30 insertions(+), 30 deletions(-) diff --git a/crypto_kem/kyber1024-90s/clean/indcpa.c b/crypto_kem/kyber1024-90s/clean/indcpa.c index 03d5557c..607b6487 100644 --- a/crypto_kem/kyber1024-90s/clean/indcpa.c +++ b/crypto_kem/kyber1024-90s/clean/indcpa.c @@ -167,9 +167,9 @@ void PQCLEAN_KYBER102490S_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_ for (i = 0; i < KYBER_K; i++) { for (j = 0; j < KYBER_K; j++) { if (transposed) { - xof_absorb(&state, seed, i, j); + xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j); } else { - xof_absorb(&state, seed, j, i); + xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i); } xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state); diff --git a/crypto_kem/kyber1024-90s/clean/poly.c b/crypto_kem/kyber1024-90s/clean/poly.c index 515453ac..36b16249 100644 --- a/crypto_kem/kyber1024-90s/clean/poly.c +++ b/crypto_kem/kyber1024-90s/clean/poly.c @@ -88,9 +88,9 @@ void PQCLEAN_KYBER102490S_CLEAN_poly_tobytes(uint8_t r[KYBER_POLYBYTES], const p t0 += ((int16_t)t0 >> 15) & KYBER_Q; t1 = a->coeffs[2 * i + 1]; t1 += ((int16_t)t1 >> 15) & KYBER_Q; - r[3 * i + 0] = (t0 >> 0); - r[3 * i + 1] = (t0 >> 8) | (t1 << 4); - r[3 * i + 2] = (t1 >> 4); + r[3 * i + 0] = (uint8_t)(t0 >> 0); + r[3 * i + 1] = (uint8_t)((t0 >> 8) | (t1 << 4)); + r[3 * i + 2] = (uint8_t)(t1 >> 4); } } diff --git a/crypto_kem/kyber1024/clean/indcpa.c b/crypto_kem/kyber1024/clean/indcpa.c index a78f9139..9e9d6052 100644 --- a/crypto_kem/kyber1024/clean/indcpa.c +++ b/crypto_kem/kyber1024/clean/indcpa.c @@ -167,9 +167,9 @@ void PQCLEAN_KYBER1024_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_SYM for (i = 0; i < KYBER_K; i++) { for (j = 0; j < KYBER_K; j++) { if (transposed) { - xof_absorb(&state, seed, i, j); + xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j); } else { - xof_absorb(&state, seed, j, i); + xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i); } xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state); diff --git a/crypto_kem/kyber1024/clean/poly.c b/crypto_kem/kyber1024/clean/poly.c index 8eb73f74..c5414f25 100644 --- a/crypto_kem/kyber1024/clean/poly.c +++ b/crypto_kem/kyber1024/clean/poly.c @@ -88,9 +88,9 @@ void PQCLEAN_KYBER1024_CLEAN_poly_tobytes(uint8_t r[KYBER_POLYBYTES], const poly t0 += ((int16_t)t0 >> 15) & KYBER_Q; t1 = a->coeffs[2 * i + 1]; t1 += ((int16_t)t1 >> 15) & KYBER_Q; - r[3 * i + 0] = (t0 >> 0); - r[3 * i + 1] = (t0 >> 8) | (t1 << 4); - r[3 * i + 2] = (t1 >> 4); + r[3 * i + 0] = (uint8_t)(t0 >> 0); + r[3 * i + 1] = (uint8_t)((t0 >> 8) | (t1 << 4)); + r[3 * i + 2] = (uint8_t)(t1 >> 4); } } diff --git a/crypto_kem/kyber512-90s/clean/indcpa.c b/crypto_kem/kyber512-90s/clean/indcpa.c index 927307fc..7dd2457f 100644 --- a/crypto_kem/kyber512-90s/clean/indcpa.c +++ b/crypto_kem/kyber512-90s/clean/indcpa.c @@ -167,9 +167,9 @@ void PQCLEAN_KYBER51290S_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_S for (i = 0; i < KYBER_K; i++) { for (j = 0; j < KYBER_K; j++) { if (transposed) { - xof_absorb(&state, seed, i, j); + xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j); } else { - xof_absorb(&state, seed, j, i); + xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i); } xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state); diff --git a/crypto_kem/kyber512-90s/clean/poly.c b/crypto_kem/kyber512-90s/clean/poly.c index 737e102b..c2fbf557 100644 --- a/crypto_kem/kyber512-90s/clean/poly.c +++ b/crypto_kem/kyber512-90s/clean/poly.c @@ -75,9 +75,9 @@ void PQCLEAN_KYBER51290S_CLEAN_poly_tobytes(uint8_t r[KYBER_POLYBYTES], const po t0 += ((int16_t)t0 >> 15) & KYBER_Q; t1 = a->coeffs[2 * i + 1]; t1 += ((int16_t)t1 >> 15) & KYBER_Q; - r[3 * i + 0] = (t0 >> 0); - r[3 * i + 1] = (t0 >> 8) | (t1 << 4); - r[3 * i + 2] = (t1 >> 4); + r[3 * i + 0] = (uint8_t)(t0 >> 0); + r[3 * i + 1] = (uint8_t)((t0 >> 8) | (t1 << 4)); + r[3 * i + 2] = (uint8_t)(t1 >> 4); } } diff --git a/crypto_kem/kyber512/clean/indcpa.c b/crypto_kem/kyber512/clean/indcpa.c index a413614d..e90dccd8 100644 --- a/crypto_kem/kyber512/clean/indcpa.c +++ b/crypto_kem/kyber512/clean/indcpa.c @@ -167,9 +167,9 @@ void PQCLEAN_KYBER512_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_SYMB for (i = 0; i < KYBER_K; i++) { for (j = 0; j < KYBER_K; j++) { if (transposed) { - xof_absorb(&state, seed, i, j); + xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j); } else { - xof_absorb(&state, seed, j, i); + xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i); } xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state); diff --git a/crypto_kem/kyber512/clean/poly.c b/crypto_kem/kyber512/clean/poly.c index 14cac577..f10afd7d 100644 --- a/crypto_kem/kyber512/clean/poly.c +++ b/crypto_kem/kyber512/clean/poly.c @@ -75,9 +75,9 @@ void PQCLEAN_KYBER512_CLEAN_poly_tobytes(uint8_t r[KYBER_POLYBYTES], const poly t0 += ((int16_t)t0 >> 15) & KYBER_Q; t1 = a->coeffs[2 * i + 1]; t1 += ((int16_t)t1 >> 15) & KYBER_Q; - r[3 * i + 0] = (t0 >> 0); - r[3 * i + 1] = (t0 >> 8) | (t1 << 4); - r[3 * i + 2] = (t1 >> 4); + r[3 * i + 0] = (uint8_t)(t0 >> 0); + r[3 * i + 1] = (uint8_t)((t0 >> 8) | (t1 << 4)); + r[3 * i + 2] = (uint8_t)(t1 >> 4); } } diff --git a/crypto_kem/kyber768-90s/clean/indcpa.c b/crypto_kem/kyber768-90s/clean/indcpa.c index b68871d9..835abb8a 100644 --- a/crypto_kem/kyber768-90s/clean/indcpa.c +++ b/crypto_kem/kyber768-90s/clean/indcpa.c @@ -167,9 +167,9 @@ void PQCLEAN_KYBER76890S_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_S for (i = 0; i < KYBER_K; i++) { for (j = 0; j < KYBER_K; j++) { if (transposed) { - xof_absorb(&state, seed, i, j); + xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j); } else { - xof_absorb(&state, seed, j, i); + xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i); } xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state); diff --git a/crypto_kem/kyber768-90s/clean/poly.c b/crypto_kem/kyber768-90s/clean/poly.c index 746fff57..b67f124a 100644 --- a/crypto_kem/kyber768-90s/clean/poly.c +++ b/crypto_kem/kyber768-90s/clean/poly.c @@ -75,9 +75,9 @@ void PQCLEAN_KYBER76890S_CLEAN_poly_tobytes(uint8_t r[KYBER_POLYBYTES], const po t0 += ((int16_t)t0 >> 15) & KYBER_Q; t1 = a->coeffs[2 * i + 1]; t1 += ((int16_t)t1 >> 15) & KYBER_Q; - r[3 * i + 0] = (t0 >> 0); - r[3 * i + 1] = (t0 >> 8) | (t1 << 4); - r[3 * i + 2] = (t1 >> 4); + r[3 * i + 0] = (uint8_t)(t0 >> 0); + r[3 * i + 1] = (uint8_t)((t0 >> 8) | (t1 << 4)); + r[3 * i + 2] = (uint8_t)(t1 >> 4); } } diff --git a/crypto_kem/kyber768/clean/indcpa.c b/crypto_kem/kyber768/clean/indcpa.c index d45118e9..b36fc537 100644 --- a/crypto_kem/kyber768/clean/indcpa.c +++ b/crypto_kem/kyber768/clean/indcpa.c @@ -167,9 +167,9 @@ void PQCLEAN_KYBER768_CLEAN_gen_matrix(polyvec *a, const uint8_t seed[KYBER_SYMB for (i = 0; i < KYBER_K; i++) { for (j = 0; j < KYBER_K; j++) { if (transposed) { - xof_absorb(&state, seed, i, j); + xof_absorb(&state, seed, (uint8_t)i, (uint8_t)j); } else { - xof_absorb(&state, seed, j, i); + xof_absorb(&state, seed, (uint8_t)j, (uint8_t)i); } xof_squeezeblocks(buf, GEN_MATRIX_NBLOCKS, &state); diff --git a/crypto_kem/kyber768/clean/poly.c b/crypto_kem/kyber768/clean/poly.c index 7307f5ee..477e462e 100644 --- a/crypto_kem/kyber768/clean/poly.c +++ b/crypto_kem/kyber768/clean/poly.c @@ -75,9 +75,9 @@ void PQCLEAN_KYBER768_CLEAN_poly_tobytes(uint8_t r[KYBER_POLYBYTES], const poly t0 += ((int16_t)t0 >> 15) & KYBER_Q; t1 = a->coeffs[2 * i + 1]; t1 += ((int16_t)t1 >> 15) & KYBER_Q; - r[3 * i + 0] = (t0 >> 0); - r[3 * i + 1] = (t0 >> 8) | (t1 << 4); - r[3 * i + 2] = (t1 >> 4); + r[3 * i + 0] = (uint8_t)(t0 >> 0); + r[3 * i + 1] = (uint8_t)((t0 >> 8) | (t1 << 4)); + r[3 * i + 2] = (uint8_t)(t1 >> 4); } }