diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_avx2/fors.c index 3097a80eaa..1d317301ca 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_avx2/fors.c @@ -120,7 +120,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-128f-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_avx2/fors.c index 3097a80eaa..1d317301ca 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_avx2/fors.c @@ -120,7 +120,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-128s-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_avx2/fors.c index 3097a80eaa..1d317301ca 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_avx2/fors.c @@ -120,7 +120,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-192f-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_avx2/fors.c index 3097a80eaa..1d317301ca 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_avx2/fors.c @@ -120,7 +120,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-192s-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_avx2/fors.c index 3097a80eaa..1d317301ca 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_avx2/fors.c @@ -120,7 +120,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-256f-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_avx2/fors.c index 3097a80eaa..1d317301ca 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_avx2/fors.c @@ -120,7 +120,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-sha2-256s-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_aarch64/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_aarch64/fors.c index 39193d04e2..e5ef891ac1 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_aarch64/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_aarch64/fors.c @@ -86,7 +86,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_avx2/fors.c index f1b0639cfc..c348c61962 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_avx2/fors.c @@ -97,7 +97,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-128f-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_aarch64/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_aarch64/fors.c index 39193d04e2..e5ef891ac1 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_aarch64/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_aarch64/fors.c @@ -86,7 +86,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_avx2/fors.c index f1b0639cfc..c348c61962 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_avx2/fors.c @@ -97,7 +97,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-128s-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_aarch64/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_aarch64/fors.c index 39193d04e2..e5ef891ac1 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_aarch64/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_aarch64/fors.c @@ -86,7 +86,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_avx2/fors.c index f1b0639cfc..c348c61962 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_avx2/fors.c @@ -97,7 +97,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-192f-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_aarch64/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_aarch64/fors.c index 39193d04e2..e5ef891ac1 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_aarch64/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_aarch64/fors.c @@ -86,7 +86,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_avx2/fors.c index f1b0639cfc..c348c61962 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_avx2/fors.c @@ -97,7 +97,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-192s-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_aarch64/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_aarch64/fors.c index 39193d04e2..e5ef891ac1 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_aarch64/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_aarch64/fors.c @@ -86,7 +86,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_avx2/fors.c index f1b0639cfc..c348c61962 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_avx2/fors.c @@ -97,7 +97,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-256f-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_aarch64/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_aarch64/fors.c index 39193d04e2..e5ef891ac1 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_aarch64/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_aarch64/fors.c @@ -86,7 +86,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_avx2/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_avx2/fors.c index f1b0639cfc..c348c61962 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_avx2/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_avx2/fors.c @@ -97,7 +97,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } } diff --git a/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_clean/fors.c b/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_clean/fors.c index 96ca72e986..a217797718 100644 --- a/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_clean/fors.c +++ b/src/sig/sphincs/pqclean_sphincs-shake-256s-simple_clean/fors.c @@ -53,7 +53,7 @@ static void message_to_indices(uint32_t *indices, const unsigned char *m) { for (i = 0; i < SPX_FORS_TREES; i++) { indices[i] = 0; for (j = 0; j < SPX_FORS_HEIGHT; j++) { - indices[i] ^= (uint32_t)(((m[offset >> 3] >> (offset & 0x7)) & 0x1) << j); + indices[i] ^= (uint32_t)(((m[offset >> 3] >> (~offset & 0x7)) & 0x1) << (SPX_FORS_HEIGHT-1-j)); offset++; } }