Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch Kyber to fix ASAN error on ARM64 #1922

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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