diff options
author | Samuel Neves <sneves@dei.uc.pt> | 2018-11-12 08:28:55 +0000 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-11-14 23:59:05 -0800 |
commit | 0a70a49b232a8a578d0706f5e34aede2b04dacee (patch) | |
tree | b64eebf3c840e1bf309a25785ae593417e62cb2f | |
parent | 7fc7454e8808e17a31c26ad9e277cd2934e69882 (diff) |
chacha20: add hchacha_ssse3
Signed-off-by: Samuel Neves <sneves@dei.uc.pt>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r-- | src/crypto/zinc/chacha20/chacha20-x86_64.pl | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/crypto/zinc/chacha20/chacha20-x86_64.pl b/src/crypto/zinc/chacha20/chacha20-x86_64.pl index 20e9786..e6f8d71 100644 --- a/src/crypto/zinc/chacha20/chacha20-x86_64.pl +++ b/src/crypto/zinc/chacha20/chacha20-x86_64.pl @@ -504,6 +504,45 @@ my $xframe = $win64 ? 32+8 : 8; if($kernel) { $code .= "#ifdef CONFIG_AS_SSSE3\n"; } + +if($kernel) { +&declare_function("hchacha20_ssse3", 32); +$code.=<<___; + movdqa .Lsigma(%rip),$a + movdqu ($len),$b + movdqu 16($len),$c + movdqu ($inp),$d + # This code is only used when targeting kernel. + # If targeting win64, xmm{6,7} preserving needs to be added. + movdqa .Lrot16(%rip),$rot16 + movdqa .Lrot24(%rip),$rot24 + mov \$10,$counter # reuse $counter + jmp 1f +.align 32 +1: +___ + &SSSE3ROUND(); + &pshufd ($c,$c,0b01001110); + &pshufd ($b,$b,0b00111001); + &pshufd ($d,$d,0b10010011); + &nop (); + + &SSSE3ROUND(); + &pshufd ($c,$c,0b01001110); + &pshufd ($b,$b,0b10010011); + &pshufd ($d,$d,0b00111001); + + &dec ($counter); + &jnz ("1b"); + +$code.=<<___; + movdqu $a, ($out) + movdqu $d, 16($out) + ret +___ +&end_function("hchacha20_ssse3"); +} + &declare_function("chacha20_ssse3", 32); $code.=<<___; .cfi_startproc |