Skip to content

Commit

Permalink
Patch Kyber to fix ASAN error on ARM64 (#1922)
Browse files Browse the repository at this point in the history
* Update oldpqclean kyber patches.

Signed-off-by: Pravek Sharma <[email protected]>

* Run copy_from_upstream.py

Signed-off-by: Pravek Sharma <[email protected]>

* Add co-authors. [skip ci]

Co-Authored-By: Kyle Nekritz <[email protected]>
Co-Authored-By: Mingtao Yang <[email protected]>
Signed-off-by: Pravek Sharma <[email protected]>

---------

Signed-off-by: Pravek Sharma <[email protected]>
Co-authored-by: Kyle Nekritz <[email protected]>
Co-authored-by: Mingtao Yang <[email protected]>
  • Loading branch information
3 people authored Sep 13, 2024
1 parent a7bfc8d commit 306140e
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 10 deletions.
3 changes: 2 additions & 1 deletion scripts/copy_from_upstream/copy_from_upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ upstreams:
sig_meta_path: 'crypto_sign/{pqclean_scheme}/META.yml'
kem_scheme_path: 'crypto_kem/{pqclean_scheme}'
sig_scheme_path: 'crypto_sign/{pqclean_scheme}'
patches: [pqclean-dilithium-arm-randomized-signing.patch, pqclean-kyber-armneon-shake-fixes.patch, pqclean-kyber-armneon-768-1024-fixes.patch, pqclean-kyber-armneon-variable-timing-fix.patch]
patches: [pqclean-dilithium-arm-randomized-signing.patch, pqclean-kyber-armneon-shake-fixes.patch, pqclean-kyber-armneon-768-1024-fixes.patch, pqclean-kyber-armneon-variable-timing-fix.patch,
pqclean-kyber-armneon-asan.patch]
ignore: pqclean_sphincs-shake-256s-simple_aarch64, pqclean_sphincs-shake-256s-simple_aarch64, pqclean_sphincs-shake-256f-simple_aarch64, pqclean_sphincs-shake-192s-simple_aarch64, pqclean_sphincs-shake-192f-simple_aarch64, pqclean_sphincs-shake-128s-simple_aarch64, pqclean_sphincs-shake-128f-simple_aarch64
-
name: pqclean
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
diff --git a/crypto_kem/kyber1024/aarch64/neon_symmetric-shake.c b/crypto_kem/kyber1024/aarch64/neon_symmetric-shake.c
index 8aced5e4..364d9fdd 100644
--- a/crypto_kem/kyber1024/aarch64/neon_symmetric-shake.c
+++ b/crypto_kem/kyber1024/aarch64/neon_symmetric-shake.c
@@ -56,8 +56,8 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
uint8_t y1, uint8_t y2)
{
unsigned int i;
- uint8_t extseed1[KYBER_SYMBYTES+2];
- uint8_t extseed2[KYBER_SYMBYTES+2];
+ uint8_t extseed1[KYBER_SYMBYTES+2+6];
+ uint8_t extseed2[KYBER_SYMBYTES+2+6];

for(i=0;i<KYBER_SYMBYTES;i++){
extseed1[i] = seed[i];
@@ -69,7 +69,7 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
extseed2[KYBER_SYMBYTES ] = x2;
extseed2[KYBER_SYMBYTES+1] = y2;

- shake128x2_absorb(state, extseed1, extseed2, sizeof(extseed1));
+ shake128x2_absorb(state, extseed1, extseed2, KYBER_SYMBYTES+2);
}

/*************************************************
diff --git a/crypto_kem/kyber512/aarch64/neon_symmetric-shake.c b/crypto_kem/kyber512/aarch64/neon_symmetric-shake.c
index 8aced5e4..364d9fdd 100644
--- a/crypto_kem/kyber512/aarch64/neon_symmetric-shake.c
+++ b/crypto_kem/kyber512/aarch64/neon_symmetric-shake.c
@@ -56,8 +56,8 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
uint8_t y1, uint8_t y2)
{
unsigned int i;
- uint8_t extseed1[KYBER_SYMBYTES+2];
- uint8_t extseed2[KYBER_SYMBYTES+2];
+ uint8_t extseed1[KYBER_SYMBYTES+2+6];
+ uint8_t extseed2[KYBER_SYMBYTES+2+6];

for(i=0;i<KYBER_SYMBYTES;i++){
extseed1[i] = seed[i];
@@ -69,7 +69,7 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
extseed2[KYBER_SYMBYTES ] = x2;
extseed2[KYBER_SYMBYTES+1] = y2;

- shake128x2_absorb(state, extseed1, extseed2, sizeof(extseed1));
+ shake128x2_absorb(state, extseed1, extseed2, KYBER_SYMBYTES+2);
}

/*************************************************
diff --git a/crypto_kem/kyber768/aarch64/neon_symmetric-shake.c b/crypto_kem/kyber768/aarch64/neon_symmetric-shake.c
index 8aced5e4..364d9fdd 100644
--- a/crypto_kem/kyber768/aarch64/neon_symmetric-shake.c
+++ b/crypto_kem/kyber768/aarch64/neon_symmetric-shake.c
@@ -56,8 +56,8 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
uint8_t y1, uint8_t y2)
{
unsigned int i;
- uint8_t extseed1[KYBER_SYMBYTES+2];
- uint8_t extseed2[KYBER_SYMBYTES+2];
+ uint8_t extseed1[KYBER_SYMBYTES+2+6];
+ uint8_t extseed2[KYBER_SYMBYTES+2+6];

for(i=0;i<KYBER_SYMBYTES;i++){
extseed1[i] = seed[i];
@@ -69,7 +69,7 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
extseed2[KYBER_SYMBYTES ] = x2;
extseed2[KYBER_SYMBYTES+1] = y2;

- shake128x2_absorb(state, extseed1, extseed2, sizeof(extseed1));
+ shake128x2_absorb(state, extseed1, extseed2, KYBER_SYMBYTES+2);
}

/*************************************************
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
uint8_t y1, uint8_t y2)
{
unsigned int i;
uint8_t extseed1[KYBER_SYMBYTES+2];
uint8_t extseed2[KYBER_SYMBYTES+2];
uint8_t extseed1[KYBER_SYMBYTES+2+6];
uint8_t extseed2[KYBER_SYMBYTES+2+6];

for(i=0;i<KYBER_SYMBYTES;i++){
extseed1[i] = seed[i];
Expand All @@ -69,7 +69,7 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
extseed2[KYBER_SYMBYTES ] = x2;
extseed2[KYBER_SYMBYTES+1] = y2;

shake128x2_absorb(state, extseed1, extseed2, sizeof(extseed1));
shake128x2_absorb(state, extseed1, extseed2, KYBER_SYMBYTES+2);
}

/*************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
uint8_t y1, uint8_t y2)
{
unsigned int i;
uint8_t extseed1[KYBER_SYMBYTES+2];
uint8_t extseed2[KYBER_SYMBYTES+2];
uint8_t extseed1[KYBER_SYMBYTES+2+6];
uint8_t extseed2[KYBER_SYMBYTES+2+6];

for(i=0;i<KYBER_SYMBYTES;i++){
extseed1[i] = seed[i];
Expand All @@ -69,7 +69,7 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
extseed2[KYBER_SYMBYTES ] = x2;
extseed2[KYBER_SYMBYTES+1] = y2;

shake128x2_absorb(state, extseed1, extseed2, sizeof(extseed1));
shake128x2_absorb(state, extseed1, extseed2, KYBER_SYMBYTES+2);
}

/*************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
uint8_t y1, uint8_t y2)
{
unsigned int i;
uint8_t extseed1[KYBER_SYMBYTES+2];
uint8_t extseed2[KYBER_SYMBYTES+2];
uint8_t extseed1[KYBER_SYMBYTES+2+6];
uint8_t extseed2[KYBER_SYMBYTES+2+6];

for(i=0;i<KYBER_SYMBYTES;i++){
extseed1[i] = seed[i];
Expand All @@ -69,7 +69,7 @@ void neon_kyber_shake128_absorb(keccakx2_state *state,
extseed2[KYBER_SYMBYTES ] = x2;
extseed2[KYBER_SYMBYTES+1] = y2;

shake128x2_absorb(state, extseed1, extseed2, sizeof(extseed1));
shake128x2_absorb(state, extseed1, extseed2, KYBER_SYMBYTES+2);
}

/*************************************************
Expand Down

0 comments on commit 306140e

Please sign in to comment.