Skip to content

Commit

Permalink
Size: improve counter increment operation
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Rodgman <[email protected]>
  • Loading branch information
daverodgman committed Oct 17, 2024
1 parent 512f2e5 commit 6f632fc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tf-psa-crypto/drivers/builtin/src/chacha20.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ static inline uint32x4_t chacha20_neon_vrotlq_7_u32(uint32x4_t v)
// Increment the 32-bit element within v that corresponds to the ChaCha20 counter
static inline uint32x4_t chacha20_neon_inc_counter(uint32x4_t v)
{
const uint32_t inc_const_scalar[4] = { 1, 0, 0, 0 };
const uint32x4_t inc_const = vld1q_u32(inc_const_scalar);
return vaddq_u32(v, inc_const);
if (MBEDTLS_IS_BIG_ENDIAN) {
v[3]++;
} else {
v[0]++;
}
return v;
}

typedef struct {
Expand Down

0 comments on commit 6f632fc

Please sign in to comment.