1 C nettle, low-level cryptographics library
3 C Copyright (C) 2011 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,
24 psrld <$>eval(32 - $1), T0
28 C Note: Diagrams use little-endian representation, with least
29 C significant word to the left.
31 C Transpose values from:
32 C +----+----+----+----+
33 C x0: | a0 | a1 | a2 | a3 |
34 C x1: | b0 | b1 | b2 | b3 |
35 C x2: | c0 | c1 | c2 | c3 |
36 C x3: | d0 | d1 | d2 | d3 |
37 C +----+----+----+----+
39 C +----+----+----+----+
40 C x0: | a0 | b0 | c0 | d0 |
41 C x1: | a1 | b1 | c1 | d1 |
42 C x2: | a2 | b2 | c2 | d2 |
43 C x3: | a3 | b3 | c3 | d3 |
44 C +----+----+----+----+
46 define(<WTRANSPOSE>, <
48 punpcklqdq $3, T0 C |a0 a1 c0 c1|
49 punpckhqdq $3, $1 C |a2 a3 c2 c3|
50 pshufd <$>0xd8, T0, T0 C |a0 c0 a1 c1|
51 pshufd <$>0xd8, $1, T1 C |a2 c2 a3 c3|
54 punpcklqdq $4, T2 C |b0 b1 d0 11|
55 punpckhqdq $4, $2 C |b2 b3 d2 d3|
56 pshufd <$>0xd8, T2, T2 C |b0 d0 b1 d1|
57 pshufd <$>0xd8, $2, T3 C |b2 d2 b3 d3|
60 punpckldq T2, $1 C |a0 b0 c0 d0|
62 punpckhdq T2, $2 C |a1 b1 c1 d1|
65 punpckldq T3, $3 C |a2 b2 c2 d2|
67 punpckhdq T3, $4 C |a3 b3 c3 d3|
70 C FIXME: Arrange 16-byte alignment, so we can use movaps?
72 movups $1(CTX, CNT), T0
73 pshufd <$>0x55, T0, T1
74 pshufd <$>0xaa, T0, T2
77 pshufd <$>0xff, T0, T1
78 pshufd <$>0x00, T0, T0