Hi Philippe,
On Wed, 2026-10-21 at 09:26 +0200, Philippe Mathieu-Daudé wrote:
> > +/* Combine the transformed word with the two words in rs1. */
> > +static uint64_t aes_kexpand(uint64_t rs1, uint32_t t)
> > +{
> > + uint32_t hi = (rs1 >> 32) ^ t;
> > + uint32_t lo = (uint32_t)rs1 ^ hi;
> > +
> > + return ((uint64_t)hi << 32) | lo;
>
> Alternatively:
>
> return deposit64(lo, 32, 32, hi);
Will be adopted in v3.
>
> > +}
> > +
> > +/* Apply the AES S-box to each byte, preserving byte positions. */
> > +static uint32_t aes_subword(uint32_t x)
> > +{
> > + return ((uint32_t)AES_sbox[x >> 24] << 24) |
> > + ((uint32_t)AES_sbox[(x >> 16) & 0xff] << 16) |
> > + ((uint32_t)AES_sbox[(x >> 8) & 0xff] << 8) |
> > + (uint32_t)AES_sbox[x & 0xff];
> > +}
>
> We could move that method to include/crypto/aes.h and re-use
> it in RISCV's vaeskf1_vi / vaeskf2_vi helpers.
Yes, makes sense. I would prefer to do it in a follow-up that also
converts the RISC-V helpers. Keeping this SPARC-only.
>
> > +
> > +/*
> > + * AES Cryptographic Operations 4-operand (Section 7.3)
> > + * AES key expansion with RotWord, SubWord, and RCON.
> > + */
> > +uint64_t helper_aes_kexpand1(uint64_t rs1, uint64_t rs2, uint32_t
> > imm)
> > +{
> > + static const uint8_t rcon[10] = {
> > + 0x01, 0x02, 0x04, 0x08, 0x10,
> > + 0x20, 0x40, 0x80, 0x1b, 0x36,
>
> This table is also used by RISCV aes64ks1i, vaeskf1_vi, and
> vaeskf2_vi,
> so we could add a common const uint8_t AES_rcon[10] in
> include/crypto/aes.h:
Same for this one. If you'd rather have it in this series, I can add it
as a preparatory patch in v3.
/Stian
signature.asc
Description: This is a digitally signed message part
