Hi Philippe,

I agree with the suggested consolidation changes.

I'll send a cleanup series on top when this one lands, along with
suggested AES cleanup in patch 4.

Thanks again for the very fast handling on this :)

/Stian


On Wed, 2026-10-21 at 09:39 +0200, Philippe Mathieu-Daudé wrote:
> On 21/10/26 08:46, Stian Halseth wrote:
> > Implement the SHA1, SHA256 and SHA512 instructions according
> > to OSA (Oracle SPARC Architecture) 2011 section 7.115,
> > using the algorithms defined in FIPS 180-4, and set the
> > SHA1/SHA256/SHA512 bits in the CFR.
> > 
> > Read and update the fixed floating-point registers and mark the
> > lower FPR bank dirty. Share the SHA-2 Boolean functions between
> > the SHA256 and SHA512 helpers.
> > 
> > Gated behind the crypto CPU feature and disabled for sparc32.
> > 
> > Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> > Tested-by: Philippe Mathieu-Daudé <[email protected]>
> > Signed-off-by: Stian Halseth <[email protected]>
> > ---
> >   target/sparc/crypto_helper.c | 274
> > +++++++++++++++++++++++++++++++++++
> >   target/sparc/helper.h        |   4 +
> >   target/sparc/insns.decode    |   4 +
> >   target/sparc/translate.c     |  21 ++-
> >   4 files changed, 302 insertions(+), 1 deletion(-)
> 
> 
> > +/*
> > + * Compress one SHA-1 block from f8-f23 into f0-f4.
> > + * Clear f5 to match SPARC M7 behavior.
> > + */
> > +void helper_sha1(CPUSPARCState *env)
> > +{
> 
> Looking deeper, this is a dup of mips::octeon_sha1_transform()
> in target/mips/tcg/octeon_crypto.c.
> 
> > +}
> > +
> > +/* SHA-2 Boolean functions. */
> > +static inline uint64_t sha_ch(uint64_t x, uint64_t y, uint64_t z)
> > +{
> > +    return (x & y) ^ (~x & z);
> > +}
> > +
> > +static inline uint64_t sha_maj(uint64_t x, uint64_t y, uint64_t z)
> > +{
> > +    return (x & y) ^ (x & z) ^ (y & z);
> > +}
> > +
> > +static const uint32_t sha256_k[64] = {
> 
> Dup of s390x::K and mips::k.
> (target/s390x/tcg/cpacf_sha256.c)
> 
> > +};
> > +
> > +static const uint64_t sha512_k[80] = {
> 
> Dup of s390x::K and mips::k.
> (target/s390x/tcg/cpacf_sha512.c)
> 
> > +};
> > +
> > +/* Compress 16 numeric message words into the supplied SHA-256
> > state. */
> > +static void sha256_compress(uint32_t state[8], const uint32_t
> > block[16])
> > +{
> 
> Dup of s390x::sha256_bda() and mips::octeon_sha256_transform().
> 
> Worth consolidate as include/crypto/sha-block.h
> 
> > +}
> > +
> > +/* Compress 16 numeric message words into the supplied SHA-512
> > state. */
> > +static void sha512_compress(uint64_t state[8], const uint64_t
> > block[16])
> > +{
> 
> Dup of s390x::sha512_bda() and mips::octeon_sha512_transform().
> 
> > +}
> Since this commit is reviewed, let's do a consolidation cleanup on
> top.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to