1 C nettle, low-level cryptographics library
3 C Copyright (C) 2012 Niels Möller
5 C The nettle library is free software; you can redistribute it and/or modify
6 C it under the terms of the GNU Lesser General Public License as published by
7 C the Free Software Foundation; either version 2.1 of the License, or (at your
8 C option) any later version.
10 C The nettle library is distributed in the hope that it will be useful, but
11 C WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 C or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 C License for more details.
15 C You should have received a copy of the GNU Lesser General Public License
16 C along with the nettle library; see the file COPYING.LIB. If not, write to
17 C the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 define(<COUNT>, <%rdx>)
29 define(<M0101>, <%xmm6>)
30 define(<M0110>, <%xmm7>)
31 define(<M0011>, <%xmm8>)
33 include_src(<x86_64/salsa20.m4>)
35 C _salsa20_core(uint32_t *dst, const uint32_t *src, unsigned rounds)
38 PROLOGUE(_nettle_salsa20_core)
44 pshufd $0x09, M0101, M0011 C 01 01 00 00
45 pshufd $0x41, M0101, M0110 C 01 00 00 01
46 pshufd $0x22, M0101, M0101 C 01 00 01 00
53 C The original rows are now diagonals.
63 QROUND(X0, X1, X2, X3)
64 pshufd $0x93, X1, X1 C 11 00 01 10 (least sign. left)
65 pshufd $0x4e, X2, X2 C 10 11 00 01
66 pshufd $0x39, X3, X3 C 01 10 11 00
68 QROUND(X0, X3, X2, X1)
70 C Inverse rotation of the rows
71 pshufd $0x39, X1, X1 C 01 10 11 00
72 pshufd $0x4e, X2, X2 C 10 11 00 01
73 pshufd $0x93, X3, X3 C 11 00 01 10
98 EPILOGUE(_nettle_salsa20_core)