Skip to content

Commit

Permalink
Dilithium: backport pqclean:52851284 and change memmove to memcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
jschanck committed Jan 1, 2022
1 parent bd4493a commit 2ace366
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions dilithium/patches/avx2_fips202x4.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,30 @@
s[r/8 - 1] = _mm256_xor_si256(s[r/8 - 1], t);
}

@@ -68,11 +98,11 @@
@@ -62,17 +92,22 @@
__m256i s[25])
{
unsigned int i;
+ double temp0, temp1;
__m128d t;

while(nblocks > 0) {
f1600x4(s, KeccakF_RoundConstants);
for(i=0; i < r/8; ++i) {
t = _mm_castsi128_pd(_mm256_castsi256_si128(s[i]));
- _mm_storel_pd((__attribute__((__may_alias__)) double *)&out0[8*i], t);
- _mm_storeh_pd((__attribute__((__may_alias__)) double *)&out1[8*i], t);
+ _mm_storel_pd((double *)&out0[8*i], t);
+ _mm_storeh_pd((double *)&out1[8*i], t);
+ _mm_storel_pd(&temp0, t);
+ _mm_storeh_pd(&temp1, t);
+ memcpy(&out0[8 * i], &temp0, sizeof(double));
+ memcpy(&out1[8 * i], &temp1, sizeof(double));
t = _mm_castsi128_pd(_mm256_extracti128_si256(s[i],1));
- _mm_storel_pd((__attribute__((__may_alias__)) double *)&out2[8*i], t);
- _mm_storeh_pd((__attribute__((__may_alias__)) double *)&out3[8*i], t);
+ _mm_storel_pd((double *)&out2[8*i], t);
+ _mm_storeh_pd((double *)&out3[8*i], t);
+ _mm_storel_pd(&temp0, t);
+ _mm_storeh_pd(&temp1, t);
+ memcpy(&out2[8 * i], &temp0, sizeof(double));
+ memcpy(&out3[8 * i], &temp1, sizeof(double));
}

out0 += r;
Expand Down

0 comments on commit 2ace366

Please sign in to comment.