Fix build error and set version 2.7.1
[platform/upstream/nettle.git] / x86_64 / umac-nh.asm
1 C nettle, low-level cryptographics library
2
3 C Copyright (C) 2013 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 define(<KEY>, <%rdi>)
21 define(<LENGTH>, <%rsi>)
22 define(<MSG>, <%rdx>)
23
24 define(<XA>, <%xmm0>)
25 define(<XB>, <%xmm1>)
26 define(<XK0>, <%xmm2>)
27 define(<XK1>, <%xmm3>)
28 define(<XY>, <%xmm4>)
29 define(<XT0>, <%xmm5>)
30 define(<XT1>, <%xmm6>)
31
32 C FIXME: Would be nice if we could force the key array to be 16-byte
33 C aligned.
34
35         .file "umac-nh.asm"
36         
37         C umac_nh(const uint32_t *key, unsigned length, const uint8_t *msg)
38         .text
39         ALIGN(16)
40 PROLOGUE(_nettle_umac_nh)
41         W64_ENTRY(3, 7)
42         pxor    XY, XY
43 .Loop:
44         movups  (KEY), XK0
45         movups  16(KEY), XK1
46         movups  (MSG), XA
47         movups  16(MSG), XB
48         paddd   XK0, XA
49         paddd   XK1, XB
50         pshufd  $0x31, XA, XT0
51         pshufd  $0x31, XB, XT1
52         pmuludq XT0, XT1
53         paddq   XT1, XY 
54         pmuludq XA, XB
55         paddq   XB, XY
56         C Length is only 32 bits
57         subl    $32, XREG(LENGTH)
58         lea     32(KEY), KEY
59         lea     32(MSG), MSG
60         ja      .Loop
61
62         pshufd  $0xe, XY, XT0
63         paddq   XT0, XY
64         C Really a movq, but write as movd to please Apple's assembler
65         movd    XY, %rax
66         W64_EXIT(3, 7)
67         ret
68 EPILOGUE(_nettle_umac_nh)