explicit casts

This commit is contained in:
John M. Schanck 2020-10-28 23:42:28 -04:00 committed by Kris Kwiatkowski
parent 4406f00784
commit 8263a9d0cb
9 changed files with 128 additions and 128 deletions

View File

@ -14,9 +14,9 @@ principal-submitters:
- Frederik Vercauteren - Frederik Vercauteren
implementations: implementations:
- name: clean - name: clean
version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/90d072e4/saber version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/3a63008f/saber
- name: avx2 - name: avx2
version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/90d072e4/saber version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/3a63008f/saber
supported_platforms: supported_platforms:
- architecture: x86_64 - architecture: x86_64
operating_systems: operating_systems:

View File

@ -8,9 +8,9 @@ void PQCLEAN_FIRESABER_AVX2_POLT2BS(uint8_t bytes[SABER_SCALEBYTES_KEM], const p
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = (in[0] & 0x3f) | (in[1] << 6); out[0] = (uint8_t) ((in[0] & 0x3f) | (in[1] << 6));
out[1] = ((in[1] >> 2) & 0x0f) | (in[2] << 4); out[1] = (uint8_t) (((in[1] >> 2) & 0x0f) | (in[2] << 4));
out[2] = ((in[2] >> 4) & 0x03) | (in[3] << 2); out[2] = (uint8_t) (((in[2] >> 4) & 0x03) | (in[3] << 2));
in += 4; in += 4;
out += 3; out += 3;
} }
@ -36,19 +36,19 @@ static void POLq2BS(uint8_t bytes[SABER_POLYBYTES], const poly *data) {
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x1f) | (in[1] << 5); out[1] = (uint8_t) (((in[0] >> 8) & 0x1f) | (in[1] << 5));
out[2] = in[1] >> 3; out[2] = (uint8_t) (in[1] >> 3);
out[3] = ((in[1] >> 11) & 0x03) | (in[2] << 2); out[3] = (uint8_t) (((in[1] >> 11) & 0x03) | (in[2] << 2));
out[4] = ((in[2] >> 6) & 0x7f) | (in[3] << 7); out[4] = (uint8_t) (((in[2] >> 6) & 0x7f) | (in[3] << 7));
out[5] = in[3] >> 1; out[5] = (uint8_t) (in[3] >> 1);
out[6] = ((in[3] >> 9) & 0x0f) | (in[4] << 4); out[6] = (uint8_t) (((in[3] >> 9) & 0x0f) | (in[4] << 4));
out[7] = in[4] >> 4; out[7] = (uint8_t) (in[4] >> 4);
out[8] = ((in[4] >> 12) & 0x01) | (in[5] << 1); out[8] = (uint8_t) (((in[4] >> 12) & 0x01) | (in[5] << 1));
out[9] = ((in[5] >> 7) & 0x3f) | (in[6] << 6); out[9] = (uint8_t) (((in[5] >> 7) & 0x3f) | (in[6] << 6));
out[10] = in[6] >> 2; out[10] = (uint8_t) (in[6] >> 2);
out[11] = ((in[6] >> 10) & 0x07) | (in[7] << 3); out[11] = (uint8_t) (((in[6] >> 10) & 0x07) | (in[7] << 3));
out[12] = in[7] >> 5; out[12] = (uint8_t) (in[7] >> 5);
in += 8; in += 8;
out += 13; out += 13;
} }
@ -78,11 +78,11 @@ static void POLp2BS(uint8_t bytes[SABER_POLYCOMPRESSEDBYTES], const poly *data)
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x03) | (in[1] << 2); out[1] = (uint8_t) (((in[0] >> 8) & 0x03) | (in[1] << 2));
out[2] = ((in[1] >> 6) & 0x0f) | (in[2] << 4); out[2] = (uint8_t) (((in[1] >> 6) & 0x0f) | (in[2] << 4));
out[3] = ((in[2] >> 4) & 0x3f) | (in[3] << 6); out[3] = (uint8_t) (((in[2] >> 4) & 0x3f) | (in[3] << 6));
out[4] = in[3] >> 2; out[4] = (uint8_t) (in[3] >> 2);
in += 4; in += 4;
out += 5; out += 5;
} }

View File

@ -8,9 +8,9 @@ void PQCLEAN_FIRESABER_CLEAN_POLT2BS(uint8_t bytes[SABER_SCALEBYTES_KEM], const
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = (in[0] & 0x3f) | (in[1] << 6); out[0] = (uint8_t) ((in[0] & 0x3f) | (in[1] << 6));
out[1] = ((in[1] >> 2) & 0x0f) | (in[2] << 4); out[1] = (uint8_t) (((in[1] >> 2) & 0x0f) | (in[2] << 4));
out[2] = ((in[2] >> 4) & 0x03) | (in[3] << 2); out[2] = (uint8_t) (((in[2] >> 4) & 0x03) | (in[3] << 2));
in += 4; in += 4;
out += 3; out += 3;
} }
@ -36,19 +36,19 @@ static void POLq2BS(uint8_t bytes[SABER_POLYBYTES], const poly *data) {
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x1f) | (in[1] << 5); out[1] = (uint8_t) (((in[0] >> 8) & 0x1f) | (in[1] << 5));
out[2] = in[1] >> 3; out[2] = (uint8_t) (in[1] >> 3);
out[3] = ((in[1] >> 11) & 0x03) | (in[2] << 2); out[3] = (uint8_t) (((in[1] >> 11) & 0x03) | (in[2] << 2));
out[4] = ((in[2] >> 6) & 0x7f) | (in[3] << 7); out[4] = (uint8_t) (((in[2] >> 6) & 0x7f) | (in[3] << 7));
out[5] = in[3] >> 1; out[5] = (uint8_t) (in[3] >> 1);
out[6] = ((in[3] >> 9) & 0x0f) | (in[4] << 4); out[6] = (uint8_t) (((in[3] >> 9) & 0x0f) | (in[4] << 4));
out[7] = in[4] >> 4; out[7] = (uint8_t) (in[4] >> 4);
out[8] = ((in[4] >> 12) & 0x01) | (in[5] << 1); out[8] = (uint8_t) (((in[4] >> 12) & 0x01) | (in[5] << 1));
out[9] = ((in[5] >> 7) & 0x3f) | (in[6] << 6); out[9] = (uint8_t) (((in[5] >> 7) & 0x3f) | (in[6] << 6));
out[10] = in[6] >> 2; out[10] = (uint8_t) (in[6] >> 2);
out[11] = ((in[6] >> 10) & 0x07) | (in[7] << 3); out[11] = (uint8_t) (((in[6] >> 10) & 0x07) | (in[7] << 3));
out[12] = in[7] >> 5; out[12] = (uint8_t) (in[7] >> 5);
in += 8; in += 8;
out += 13; out += 13;
} }
@ -78,11 +78,11 @@ static void POLp2BS(uint8_t bytes[SABER_POLYCOMPRESSEDBYTES], const poly *data)
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x03) | (in[1] << 2); out[1] = (uint8_t) (((in[0] >> 8) & 0x03) | (in[1] << 2));
out[2] = ((in[1] >> 6) & 0x0f) | (in[2] << 4); out[2] = (uint8_t) (((in[1] >> 6) & 0x0f) | (in[2] << 4));
out[3] = ((in[2] >> 4) & 0x3f) | (in[3] << 6); out[3] = (uint8_t) (((in[2] >> 4) & 0x3f) | (in[3] << 6));
out[4] = in[3] >> 2; out[4] = (uint8_t) (in[3] >> 2);
in += 4; in += 4;
out += 5; out += 5;
} }

View File

@ -14,9 +14,9 @@ principal-submitters:
- Frederik Vercauteren - Frederik Vercauteren
implementations: implementations:
- name: clean - name: clean
version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/90d072e4/saber version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/3a63008f/saber
- name: avx2 - name: avx2
version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/90d072e4/saber version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/3a63008f/saber
supported_platforms: supported_platforms:
- architecture: x86_64 - architecture: x86_64
operating_systems: operating_systems:

View File

@ -8,9 +8,9 @@ void PQCLEAN_LIGHTSABER_AVX2_POLT2BS(uint8_t bytes[SABER_SCALEBYTES_KEM], const
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = (in[0] & 0x7) | ((in[1] & 0x7) << 3) | (in[2] << 6); out[0] = (uint8_t) ((in[0] & 0x7) | ((in[1] & 0x7) << 3) | (in[2] << 6));
out[1] = ((in[2] >> 2) & 0x01) | ((in[3] & 0x7) << 1) | ((in[4] & 0x7) << 4) | (in[5] << 7); out[1] = (uint8_t) (((in[2] >> 2) & 0x01) | ((in[3] & 0x7) << 1) | ((in[4] & 0x7) << 4) | (in[5] << 7));
out[2] = ((in[5] >> 1) & 0x03) | ((in[6] & 0x7) << 2) | (in[7] << 5); out[2] = (uint8_t) (((in[5] >> 1) & 0x03) | ((in[6] & 0x7) << 2) | (in[7] << 5));
in += 8; in += 8;
out += 3; out += 3;
} }
@ -40,19 +40,19 @@ static void POLq2BS(uint8_t bytes[SABER_POLYBYTES], const poly *data) {
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x1f) | (in[1] << 5); out[1] = (uint8_t) (((in[0] >> 8) & 0x1f) | (in[1] << 5));
out[2] = in[1] >> 3; out[2] = (uint8_t) (in[1] >> 3);
out[3] = ((in[1] >> 11) & 0x03) | (in[2] << 2); out[3] = (uint8_t) (((in[1] >> 11) & 0x03) | (in[2] << 2));
out[4] = ((in[2] >> 6) & 0x7f) | (in[3] << 7); out[4] = (uint8_t) (((in[2] >> 6) & 0x7f) | (in[3] << 7));
out[5] = in[3] >> 1; out[5] = (uint8_t) (in[3] >> 1);
out[6] = ((in[3] >> 9) & 0x0f) | (in[4] << 4); out[6] = (uint8_t) (((in[3] >> 9) & 0x0f) | (in[4] << 4));
out[7] = in[4] >> 4; out[7] = (uint8_t) (in[4] >> 4);
out[8] = ((in[4] >> 12) & 0x01) | (in[5] << 1); out[8] = (uint8_t) (((in[4] >> 12) & 0x01) | (in[5] << 1));
out[9] = ((in[5] >> 7) & 0x3f) | (in[6] << 6); out[9] = (uint8_t) (((in[5] >> 7) & 0x3f) | (in[6] << 6));
out[10] = in[6] >> 2; out[10] = (uint8_t) (in[6] >> 2);
out[11] = ((in[6] >> 10) & 0x07) | (in[7] << 3); out[11] = (uint8_t) (((in[6] >> 10) & 0x07) | (in[7] << 3));
out[12] = in[7] >> 5; out[12] = (uint8_t) (in[7] >> 5);
in += 8; in += 8;
out += 13; out += 13;
} }
@ -82,11 +82,11 @@ static void POLp2BS(uint8_t bytes[SABER_POLYCOMPRESSEDBYTES], const poly *data)
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x03) | (in[1] << 2); out[1] = (uint8_t) (((in[0] >> 8) & 0x03) | (in[1] << 2));
out[2] = ((in[1] >> 6) & 0x0f) | (in[2] << 4); out[2] = (uint8_t) (((in[1] >> 6) & 0x0f) | (in[2] << 4));
out[3] = ((in[2] >> 4) & 0x3f) | (in[3] << 6); out[3] = (uint8_t) (((in[2] >> 4) & 0x3f) | (in[3] << 6));
out[4] = in[3] >> 2; out[4] = (uint8_t) (in[3] >> 2);
in += 4; in += 4;
out += 5; out += 5;
} }

View File

@ -8,9 +8,9 @@ void PQCLEAN_LIGHTSABER_CLEAN_POLT2BS(uint8_t bytes[SABER_SCALEBYTES_KEM], const
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = (in[0] & 0x7) | ((in[1] & 0x7) << 3) | (in[2] << 6); out[0] = (uint8_t) ((in[0] & 0x7) | ((in[1] & 0x7) << 3) | (in[2] << 6));
out[1] = ((in[2] >> 2) & 0x01) | ((in[3] & 0x7) << 1) | ((in[4] & 0x7) << 4) | (in[5] << 7); out[1] = (uint8_t) (((in[2] >> 2) & 0x01) | ((in[3] & 0x7) << 1) | ((in[4] & 0x7) << 4) | (in[5] << 7));
out[2] = ((in[5] >> 1) & 0x03) | ((in[6] & 0x7) << 2) | (in[7] << 5); out[2] = (uint8_t) (((in[5] >> 1) & 0x03) | ((in[6] & 0x7) << 2) | (in[7] << 5));
in += 8; in += 8;
out += 3; out += 3;
} }
@ -40,19 +40,19 @@ static void POLq2BS(uint8_t bytes[SABER_POLYBYTES], const poly *data) {
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x1f) | (in[1] << 5); out[1] = (uint8_t) (((in[0] >> 8) & 0x1f) | (in[1] << 5));
out[2] = in[1] >> 3; out[2] = (uint8_t) (in[1] >> 3);
out[3] = ((in[1] >> 11) & 0x03) | (in[2] << 2); out[3] = (uint8_t) (((in[1] >> 11) & 0x03) | (in[2] << 2));
out[4] = ((in[2] >> 6) & 0x7f) | (in[3] << 7); out[4] = (uint8_t) (((in[2] >> 6) & 0x7f) | (in[3] << 7));
out[5] = in[3] >> 1; out[5] = (uint8_t) (in[3] >> 1);
out[6] = ((in[3] >> 9) & 0x0f) | (in[4] << 4); out[6] = (uint8_t) (((in[3] >> 9) & 0x0f) | (in[4] << 4));
out[7] = in[4] >> 4; out[7] = (uint8_t) (in[4] >> 4);
out[8] = ((in[4] >> 12) & 0x01) | (in[5] << 1); out[8] = (uint8_t) (((in[4] >> 12) & 0x01) | (in[5] << 1));
out[9] = ((in[5] >> 7) & 0x3f) | (in[6] << 6); out[9] = (uint8_t) (((in[5] >> 7) & 0x3f) | (in[6] << 6));
out[10] = in[6] >> 2; out[10] = (uint8_t) (in[6] >> 2);
out[11] = ((in[6] >> 10) & 0x07) | (in[7] << 3); out[11] = (uint8_t) (((in[6] >> 10) & 0x07) | (in[7] << 3));
out[12] = in[7] >> 5; out[12] = (uint8_t) (in[7] >> 5);
in += 8; in += 8;
out += 13; out += 13;
} }
@ -82,11 +82,11 @@ static void POLp2BS(uint8_t bytes[SABER_POLYCOMPRESSEDBYTES], const poly *data)
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x03) | (in[1] << 2); out[1] = (uint8_t) (((in[0] >> 8) & 0x03) | (in[1] << 2));
out[2] = ((in[1] >> 6) & 0x0f) | (in[2] << 4); out[2] = (uint8_t) (((in[1] >> 6) & 0x0f) | (in[2] << 4));
out[3] = ((in[2] >> 4) & 0x3f) | (in[3] << 6); out[3] = (uint8_t) (((in[2] >> 4) & 0x3f) | (in[3] << 6));
out[4] = in[3] >> 2; out[4] = (uint8_t) (in[3] >> 2);
in += 4; in += 4;
out += 5; out += 5;
} }

View File

@ -14,9 +14,9 @@ principal-submitters:
- Frederik Vercauteren - Frederik Vercauteren
implementations: implementations:
- name: clean - name: clean
version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/90d072e4/saber version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/3a63008f/saber
- name: avx2 - name: avx2
version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/90d072e4/saber version: https://github.com/KULeuven-COSIC/SABER/tree/509cc5ec3a7e12a751ccdd2ef5bd6e54e00bd350 via https://github.com/jschanck/package-pqclean/tree/3a63008f/saber
supported_platforms: supported_platforms:
- architecture: x86_64 - architecture: x86_64
operating_systems: operating_systems:

View File

@ -8,7 +8,7 @@ void PQCLEAN_SABER_AVX2_POLT2BS(uint8_t bytes[SABER_SCALEBYTES_KEM], const poly
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 2; j++) { for (j = 0; j < SABER_N / 2; j++) {
out[0] = (in[0] & 0x0f) | (in[1] << 4); out[0] = (uint8_t) ((in[0] & 0x0f) | (in[1] << 4));
in += 2; in += 2;
out += 1; out += 1;
} }
@ -32,19 +32,19 @@ static void POLq2BS(uint8_t bytes[SABER_POLYBYTES], const poly *data) {
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x1f) | (in[1] << 5); out[1] = (uint8_t) (((in[0] >> 8) & 0x1f) | (in[1] << 5));
out[2] = in[1] >> 3; out[2] = (uint8_t) (in[1] >> 3);
out[3] = ((in[1] >> 11) & 0x03) | (in[2] << 2); out[3] = (uint8_t) (((in[1] >> 11) & 0x03) | (in[2] << 2));
out[4] = ((in[2] >> 6) & 0x7f) | (in[3] << 7); out[4] = (uint8_t) (((in[2] >> 6) & 0x7f) | (in[3] << 7));
out[5] = in[3] >> 1; out[5] = (uint8_t) (in[3] >> 1);
out[6] = ((in[3] >> 9) & 0x0f) | (in[4] << 4); out[6] = (uint8_t) (((in[3] >> 9) & 0x0f) | (in[4] << 4));
out[7] = in[4] >> 4; out[7] = (uint8_t) (in[4] >> 4);
out[8] = ((in[4] >> 12) & 0x01) | (in[5] << 1); out[8] = (uint8_t) (((in[4] >> 12) & 0x01) | (in[5] << 1));
out[9] = ((in[5] >> 7) & 0x3f) | (in[6] << 6); out[9] = (uint8_t) (((in[5] >> 7) & 0x3f) | (in[6] << 6));
out[10] = in[6] >> 2; out[10] = (uint8_t) (in[6] >> 2);
out[11] = ((in[6] >> 10) & 0x07) | (in[7] << 3); out[11] = (uint8_t) (((in[6] >> 10) & 0x07) | (in[7] << 3));
out[12] = in[7] >> 5; out[12] = (uint8_t) (in[7] >> 5);
in += 8; in += 8;
out += 13; out += 13;
} }
@ -74,11 +74,11 @@ static void POLp2BS(uint8_t bytes[SABER_POLYCOMPRESSEDBYTES], const poly *data)
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x03) | (in[1] << 2); out[1] = (uint8_t) (((in[0] >> 8) & 0x03) | (in[1] << 2));
out[2] = ((in[1] >> 6) & 0x0f) | (in[2] << 4); out[2] = (uint8_t) (((in[1] >> 6) & 0x0f) | (in[2] << 4));
out[3] = ((in[2] >> 4) & 0x3f) | (in[3] << 6); out[3] = (uint8_t) (((in[2] >> 4) & 0x3f) | (in[3] << 6));
out[4] = in[3] >> 2; out[4] = (uint8_t) (in[3] >> 2);
in += 4; in += 4;
out += 5; out += 5;
} }

View File

@ -8,7 +8,7 @@ void PQCLEAN_SABER_CLEAN_POLT2BS(uint8_t bytes[SABER_SCALEBYTES_KEM], const poly
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 2; j++) { for (j = 0; j < SABER_N / 2; j++) {
out[0] = (in[0] & 0x0f) | (in[1] << 4); out[0] = (uint8_t) ((in[0] & 0x0f) | (in[1] << 4));
in += 2; in += 2;
out += 1; out += 1;
} }
@ -32,19 +32,19 @@ static void POLq2BS(uint8_t bytes[SABER_POLYBYTES], const poly *data) {
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 8; j++) { for (j = 0; j < SABER_N / 8; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x1f) | (in[1] << 5); out[1] = (uint8_t) (((in[0] >> 8) & 0x1f) | (in[1] << 5));
out[2] = in[1] >> 3; out[2] = (uint8_t) (in[1] >> 3);
out[3] = ((in[1] >> 11) & 0x03) | (in[2] << 2); out[3] = (uint8_t) (((in[1] >> 11) & 0x03) | (in[2] << 2));
out[4] = ((in[2] >> 6) & 0x7f) | (in[3] << 7); out[4] = (uint8_t) (((in[2] >> 6) & 0x7f) | (in[3] << 7));
out[5] = in[3] >> 1; out[5] = (uint8_t) (in[3] >> 1);
out[6] = ((in[3] >> 9) & 0x0f) | (in[4] << 4); out[6] = (uint8_t) (((in[3] >> 9) & 0x0f) | (in[4] << 4));
out[7] = in[4] >> 4; out[7] = (uint8_t) (in[4] >> 4);
out[8] = ((in[4] >> 12) & 0x01) | (in[5] << 1); out[8] = (uint8_t) (((in[4] >> 12) & 0x01) | (in[5] << 1));
out[9] = ((in[5] >> 7) & 0x3f) | (in[6] << 6); out[9] = (uint8_t) (((in[5] >> 7) & 0x3f) | (in[6] << 6));
out[10] = in[6] >> 2; out[10] = (uint8_t) (in[6] >> 2);
out[11] = ((in[6] >> 10) & 0x07) | (in[7] << 3); out[11] = (uint8_t) (((in[6] >> 10) & 0x07) | (in[7] << 3));
out[12] = in[7] >> 5; out[12] = (uint8_t) (in[7] >> 5);
in += 8; in += 8;
out += 13; out += 13;
} }
@ -74,11 +74,11 @@ static void POLp2BS(uint8_t bytes[SABER_POLYCOMPRESSEDBYTES], const poly *data)
const uint16_t *in = data->coeffs; const uint16_t *in = data->coeffs;
uint8_t *out = bytes; uint8_t *out = bytes;
for (j = 0; j < SABER_N / 4; j++) { for (j = 0; j < SABER_N / 4; j++) {
out[0] = in[0]; out[0] = (uint8_t) (in[0]);
out[1] = ((in[0] >> 8) & 0x03) | (in[1] << 2); out[1] = (uint8_t) (((in[0] >> 8) & 0x03) | (in[1] << 2));
out[2] = ((in[1] >> 6) & 0x0f) | (in[2] << 4); out[2] = (uint8_t) (((in[1] >> 6) & 0x0f) | (in[2] << 4));
out[3] = ((in[2] >> 4) & 0x3f) | (in[3] << 6); out[3] = (uint8_t) (((in[2] >> 4) & 0x3f) | (in[3] << 6));
out[4] = in[3] >> 2; out[4] = (uint8_t) (in[3] >> 2);
in += 4; in += 4;
out += 5; out += 5;
} }