From b08c6f3418fb603c6b665e3648ebf104c3550a40 Mon Sep 17 00:00:00 2001 From: satoshiotomakan <127754187+satoshiotomakan@users.noreply.github.com> Date: Thu, 19 Oct 2023 11:27:46 +0200 Subject: [PATCH] [Crypto]: Fix salsa20_8(B) when compiled with `-Os` optimisation level (#3491) --- trezor-crypto/crypto/scrypt.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/trezor-crypto/crypto/scrypt.c b/trezor-crypto/crypto/scrypt.c index c1856dcbda5..4e94beab0e8 100644 --- a/trezor-crypto/crypto/scrypt.c +++ b/trezor-crypto/crypto/scrypt.c @@ -42,7 +42,7 @@ #include #include -static void blkcpy(void *, void *, size_t); +static void blkcpy(uint32_t *, const uint32_t *, size_t); static void blkxor(void *, void *, size_t); static void salsa20_8(uint32_t[16]); static void blockmix_salsa8(uint32_t *, uint32_t *, uint32_t *, size_t); @@ -50,15 +50,12 @@ static uint64_t integerify(void *, size_t); static void smix(uint8_t *, size_t, uint64_t, uint32_t *, uint32_t *); static void -blkcpy(void * dest, void * src, size_t len) +blkcpy(uint32_t * dest, const uint32_t * src, size_t len) { - size_t * D = dest; - size_t * S = src; - size_t L = len / sizeof(size_t); - size_t i; + size_t L = len / sizeof(uint32_t); - for (i = 0; i < L; i++) - D[i] = S[i]; + for (size_t i = 0; i < L; i++) + dest[i] = src[i]; } static void