summaryrefslogtreecommitdiff
path: root/cipher/sha1-avx-amd64.S
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2019-04-05 17:37:42 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2019-04-05 17:57:45 +0300
commitf3d4bd90662faaedd37ce0dae1f9e7f91748e91e (patch)
treeeb006660288eecc568a0c9594bd81797a7b1b4f4 /cipher/sha1-avx-amd64.S
parentb982900bfe6403e95a157271d8d811c9c573af9e (diff)
downloadlibgcrypt-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-avx-amd64.S')
-rw-r--r--cipher/sha1-avx-amd64.S15
1 files changed, 9 insertions, 6 deletions
diff --git a/cipher/sha1-avx-amd64.S b/cipher/sha1-avx-amd64.S
index 143e4066..5d674c15 100644
--- a/cipher/sha1-avx-amd64.S
+++ b/cipher/sha1-avx-amd64.S
@@ -380,7 +380,7 @@ _gcry_sha1_transform_amd64_avx:
.Lend:
vzeroall;
- /* Transform 64-79. */
+ /* Transform 64-79 + burn stack */
R( b, c, d, e, a, F4, 64 );
R( a, b, c, d, e, F4, 65 );
R( e, a, b, c, d, F4, 66 );
@@ -393,12 +393,15 @@ _gcry_sha1_transform_amd64_avx:
R( c, d, e, a, b, F4, 73 );
R( b, c, d, e, a, F4, 74 );
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 ); vmovdqa %xmm0, (0*16)(%rsp);
+ R( d, e, a, b, c, F4, 77 ); vmovdqa %xmm0, (1*16)(%rsp);
+ R( c, d, e, a, b, F4, 78 ); vmovdqa %xmm0, (2*16)(%rsp);
addl state_h0(RSTATE), a;
R( b, c, d, e, a, F4, 79 );
+ /* 16*4/16-1 = 3 */
+ vmovdqa %xmm0, (3*16)(%rsp);
+
/* Update the chaining variables. */
addl state_h3(RSTATE), d;
addl state_h2(RSTATE), c;
@@ -416,8 +419,8 @@ _gcry_sha1_transform_amd64_avx:
popq %rbp;
popq %rbx;
- /* burn_stack */
- movl $(16*4 + 2*8 + 31), %eax;
+ /* stack already burned */
+ xorl %eax, %eax;
.Lret:
ret;