2 * Copyright (c) 2010 Konstantin Belousov <kib@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/sys/crypto/aesni/aesencdec_amd64.S,v 1.1 2010/07/23 11:00:46 kib Exp $
29 #include <machine/asmacros.h>
38 movdqu (%r8),%xmm1 /* unaligned load into reg */
39 pxor %xmm1,%xmm0 /* pxor otherwise can fault on iv */
44 // aesenc (%rsi),%xmm0
45 .byte 0x66,0x0f,0x38,0xdc,0x06
49 // aesenclast (%rsi),%xmm0
50 .byte 0x66,0x0f,0x38,0xdd,0x06
62 // aesdec (%rsi),%xmm0
63 .byte 0x66,0x0f,0x38,0xde,0x06
67 // aesdeclast (%rsi),%xmm0
68 .byte 0x66,0x0f,0x38,0xdf,0x06
79 ENTRY(aesni_decrypt_cbc)
88 // aesdec 0x10(%rsi),%xmm0
89 .byte 0x66,0x0f,0x38,0xde,0x46,0x10
90 // aesdec 0x20(%rsi),%xmm0
91 .byte 0x66,0x0f,0x38,0xde,0x46,0x20
92 // aesdec 0x30(%rsi),%xmm0
93 .byte 0x66,0x0f,0x38,0xde,0x46,0x30
94 // aesdec 0x40(%rsi),%xmm0
95 .byte 0x66,0x0f,0x38,0xde,0x46,0x40
96 // aesdec 0x50(%rsi),%xmm0
97 .byte 0x66,0x0f,0x38,0xde,0x46,0x50
98 // aesdec 0x60(%rsi),%xmm0
99 .byte 0x66,0x0f,0x38,0xde,0x46,0x60
100 // aesdec 0x70(%rsi),%xmm0
101 .byte 0x66,0x0f,0x38,0xde,0x46,0x70
102 // aesdec 0x80(%rsi),%xmm0
103 .byte 0x66,0x0f,0x38,0xde,0x86,0x80,0x00,0x00,0x00
104 // aesdec 0x90(%rsi),%xmm0
105 .byte 0x66,0x0f,0x38,0xde,0x86,0x90,0x00,0x00,0x00
107 // aesdeclast 0xa0(%rsi),%xmm0
108 .byte 0x66,0x0f,0x38,0xdf,0x86,0xa0,0x00,0x00,0x00
111 // aesdec 0xa0(%rsi),%xmm0
112 .byte 0x66,0x0f,0x38,0xde,0x86,0xa0,0x00,0x00,0x00
113 // aesdec 0xb0(%rsi),%xmm0
114 .byte 0x66,0x0f,0x38,0xde,0x86,0xb0,0x00,0x00,0x00
116 // aesdeclast 0xc0(%rsi),%xmm0
117 .byte 0x66,0x0f,0x38,0xdf,0x86,0xc0,0x00,0x00,0x00
120 // aesdec 0xc0(%rsi),%xmm0
121 .byte 0x66,0x0f,0x38,0xde,0x86,0xc0,0x00,0x00,0x00
122 // aesdec 0xd0(%rsi),%xmm0
123 .byte 0x66,0x0f,0x38,0xde,0x86,0xd0,0x00,0x00,0x00
124 // aesdeclast 0xe0(%rsi),%xmm0
125 .byte 0x66,0x0f,0x38,0xdf,0x86,0xe0,0x00,0x00,0x00
129 movdqa %xmm2,%xmm1 // iv
135 END(aesni_decrypt_cbc)