diff options
author | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2019-04-05 17:37:42 +0300 |
---|---|---|
committer | Jussi Kivilinna <jussi.kivilinna@iki.fi> | 2019-04-05 17:57:45 +0300 |
commit | f3d4bd90662faaedd37ce0dae1f9e7f91748e91e (patch) | |
tree | eb006660288eecc568a0c9594bd81797a7b1b4f4 /cipher/sha1-ssse3-amd64.S | |
parent | b982900bfe6403e95a157271d8d811c9c573af9e (diff) | |
download | libgcrypt-f3d4bd90662faaedd37ce0dae1f9e7f91748e91e.tar.gz |
Burn stack in transform functions for SHA1 AMD64 implementations
* cipher/sha1-avx-amd64.S: Burn stack inside transform functions.
* cipher/sha1-avx-bmi2-amd64.S: Ditto.
* cipher/sha1-avx2-bmi2-amd64.S: Ditto.
* cipher/sha1-ssse3-amd64.S: Ditto.
--
This change reduces per call overhead for SHA1.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/sha1-ssse3-amd64.S')
-rw-r--r-- | cipher/sha1-ssse3-amd64.S | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/cipher/sha1-ssse3-amd64.S b/cipher/sha1-ssse3-amd64.S index 421bebec..fff14034 100644 --- a/cipher/sha1-ssse3-amd64.S +++ b/cipher/sha1-ssse3-amd64.S @@ -388,7 +388,7 @@ _gcry_sha1_transform_amd64_ssse3: .align 16 .Lend: - /* Transform 64-79 + Clear XMM registers. */ + /* Transform 64-79 + Clear XMM registers + Burn stack. */ R( b, c, d, e, a, F4, 64 ); CLEAR_REG(BSWAP_REG); R( a, b, c, d, e, F4, 65 ); CLEAR_REG(Wtmp0); R( e, a, b, c, d, F4, 66 ); CLEAR_REG(Wtmp1); @@ -401,12 +401,15 @@ _gcry_sha1_transform_amd64_ssse3: R( c, d, e, a, b, F4, 73 ); CLEAR_REG(W6); R( b, c, d, e, a, F4, 74 ); CLEAR_REG(W7); R( a, b, c, d, e, F4, 75 ); - R( e, a, b, c, d, F4, 76 ); - R( d, e, a, b, c, F4, 77 ); - R( c, d, e, a, b, F4, 78 ); + R( e, a, b, c, d, F4, 76 ); movdqa Wtmp0, (0*16)(%rsp); + R( d, e, a, b, c, F4, 77 ); movdqa Wtmp0, (1*16)(%rsp); + R( c, d, e, a, b, F4, 78 ); movdqa Wtmp0, (2*16)(%rsp); addl state_h0(RSTATE), a; R( b, c, d, e, a, F4, 79 ); + /* 16*4/16-1 = 3 */ + vmovdqa Wtmp0, (3*16)(%rsp); + /* Update the chaining variables. */ addl state_h3(RSTATE), d; addl state_h2(RSTATE), c; @@ -424,8 +427,8 @@ _gcry_sha1_transform_amd64_ssse3: popq %rbp; popq %rbx; - /* burn_stack */ - movl $(16*4 + 2*8 + 31), %eax; + /* stack already burned */ + xorl %eax, %eax; .Lret: ret; |