Skip to contentSkip to conversation

crypto: s(h)aving 16 byte constant off arch/x86/crypto/sha1_ni_asm.S

PATCH Ard Biesheuvel 1 participant 1 message Apr 8, 2024 1 message not in the archive Crypto API

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 3 lines · Stefan Kanthak

Get rid of 16 byte constant, use shift instead of mask

This is missing a signoff

arch/x86/crypto/sha1_ni_asm.S line 111

Quoted 13 lines
arch/x86/crypto/sha1_ni_asm.S +2 -2
@@ -104,9 +104,9 @@
        add             DATA_PTR, NUM_BLKS      /* pointer to end of data */
 
        /* load initial hash values */
-       pinsrd          $3, 1*16(DIGEST_PTR), E0
+       pinsrd          $0, 1*16(DIGEST_PTR), E0
        movdqu          0*16(DIGEST_PTR), ABCD
-       pand            UPPER_WORD_MASK(%rip), E0
+       pslldq          $12, E0
        pshufd          $0x1B, ABCD, ABCD
 

Wouldn't it be simpler and therefore better to simply zero register E0 before loading E into the top lane?

Quoted 11 lines
arch/x86/crypto/sha1_ni_asm.S +0 -5
        movdqa          PSHUFFLE_BYTE_FLIP_MASK(%rip), SHUF_MASK
@@ -297,8 +297,3 @@
 .align 16
 PSHUFFLE_BYTE_FLIP_MASK:
        .octa 0x000102030405060708090a0b0c0d0e0f
-
-.section       .rodata.cst16.UPPER_WORD_MASK, "aM", @progbits, 16
-.align 16
-UPPER_WORD_MASK:
-       .octa 0xFFFFFFFF000000000000000000000000