[PATCH v11 4/9] aarch64: Add optimized chacha20
Szabolcs Nagy
szabolcs.nagy@arm.com
Fri Jul 22 09:00:53 GMT 2022
The 07/21/2022 11:28, Adhemerval Zanella Netto wrote:
>
>
> On 21/07/22 11:11, Szabolcs Nagy wrote:
> > The 07/21/2022 10:05, Adhemerval Zanella via Libc-alpha wrote:
> >> +unsigned int __chacha20_neon_blocks4 (uint32_t *state, uint8_t *dst,
> >> + const uint8_t *src, size_t nblks)
> >> + attribute_hidden;
> >> +
> >> +static void
> >> +chacha20_crypt (uint32_t *state, uint8_t *dst, const uint8_t *src,
> >> + size_t bytes)
> >> +{
> >> + _Static_assert (CHACHA20_BUFSIZE % 4 == 0,
> >> + "CHACHA20_BUFSIZE not multiple of 4");
> >> + _Static_assert (CHACHA20_BUFSIZE > CHACHA20_BLOCK_SIZE * 4,
> >> + "CHACHA20_BUFSIZE <= CHACHA20_BLOCK_SIZE * 4");
> >> +#ifdef __AARCH64EL__
> >> + __chacha20_neon_blocks4 (state, dst, src,
> >> + CHACHA20_BUFSIZE / CHACHA20_BLOCK_SIZE);
> >> +#else
> >> + chacha20_crypt_generic (state, dst, src, bytes);
> >> +#endif
> >> +}
> >
> > how is it possible that the optimized code does not use the bytes argument?
>
> It operates multiple of CHACHA20_BUFSIZE / CHACHA20_BLOCK_SIZE blocks. Maybe
> we should just remove the bytes and assume src and dst to be always
> CHACHA20_BUFSIZE.
if the size is fixed then remove the bytes argument from the interface.
the interface contract of chacha20_crypt should be clear as it can
have several implementations across targets.
More information about the Libc-alpha
mailing list