Fix build error and set version 2.7.1
[platform/upstream/nettle.git] / x86_64 / serpent.m4
1 C nettle, low-level cryptographics library
2
3 C Copyright (C) 2011 Niels Möller
4 C  
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.
9
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.
14
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,
18 C MA 02111-1301, USA.
19         
20 C WROL(count, w)
21 define(<WROL>, <
22         movdqa  $2, T0
23         pslld   <$>$1, $2
24         psrld   <$>eval(32 - $1), T0
25         por     T0, $2
26 >)
27
28 C Note: Diagrams use little-endian representation, with least
29 C significant word to the left.
30         
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     +----+----+----+----+
38 C To:
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     +----+----+----+----+
45
46 define(<WTRANSPOSE>, <
47         movdqa          $1, T0
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|
52         
53         movdqa          $2, T2
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|
58
59         movdqa          T0, $1
60         punpckldq       T2, $1                  C |a0 b0 c0 d0|
61         movdqa          T0, $2
62         punpckhdq       T2, $2                  C |a1 b1 c1 d1|
63
64         movdqa          T1, $3
65         punpckldq       T3, $3                  C |a2 b2 c2 d2|
66         movdqa          T1, $4
67         punpckhdq       T3, $4                  C |a3 b3 c3 d3|
68 >)
69
70 C FIXME: Arrange 16-byte alignment, so we can use movaps?
71 define(<WKEYXOR>, <
72         movups  $1(CTX, CNT), T0
73         pshufd  <$>0x55, T0, T1
74         pshufd  <$>0xaa, T0, T2
75         pxor    T1, $3
76         pxor    T2, $4
77         pshufd  <$>0xff, T0, T1
78         pshufd  <$>0x00, T0, T0
79         pxor    T1, $5
80         pxor    T0, $2
81 >)