]> git.proxmox.com Git - ceph.git/blob - ceph/src/crypto/isa-l/isa-l_crypto/aes/cbc_dec_192_x8_avx.asm
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / aes / cbc_dec_192_x8_avx.asm
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; Copyright(c) 2011-2016 Intel Corporation All rights reserved.
3 ;
4 ; Redistribution and use in source and binary forms, with or without
5 ; modification, are permitted provided that the following conditions
6 ; are met:
7 ; * Redistributions of source code must retain the above copyright
8 ; notice, this list of conditions and the following disclaimer.
9 ; * Redistributions in binary form must reproduce the above copyright
10 ; notice, this list of conditions and the following disclaimer in
11 ; the documentation and/or other materials provided with the
12 ; distribution.
13 ; * Neither the name of Intel Corporation nor the names of its
14 ; contributors may be used to endorse or promote products derived
15 ; from this software without specific prior written permission.
16 ;
17 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
29
30 ; routine to do AES192 CBC decrypt
31
32 %include "reg_sizes.asm"
33
34 %ifidn __OUTPUT_FORMAT__, elf64
35 %define IN rdi
36 %define IV rsi
37 %define KEYS rdx
38 %define OUT rcx
39 %define LEN r8
40 %define func(x) x:
41 %define FUNC_SAVE
42 %define FUNC_RESTORE
43 %endif
44
45 %ifidn __OUTPUT_FORMAT__, win64
46 %define IN rcx
47 %define IV rdx
48 %define KEYS r8
49 %define OUT r9
50 %define LEN r10
51 %define PS 8
52 %define stack_size 10*16 + 1*8 ; must be an odd multiple of 8
53 %define arg(x) [rsp + stack_size + PS + PS*x]
54
55 %define func(x) proc_frame x
56 %macro FUNC_SAVE 0
57 alloc_stack stack_size
58 save_xmm128 xmm6, 0*16
59 save_xmm128 xmm7, 1*16
60 save_xmm128 xmm8, 2*16
61 save_xmm128 xmm9, 3*16
62 save_xmm128 xmm10, 4*16
63 save_xmm128 xmm11, 5*16
64 save_xmm128 xmm12, 6*16
65 save_xmm128 xmm13, 7*16
66 save_xmm128 xmm14, 8*16
67 save_xmm128 xmm15, 9*16
68 end_prolog
69 mov LEN, arg(4)
70 %endmacro
71
72 %macro FUNC_RESTORE 0
73 movdqa xmm6, [rsp + 0*16]
74 movdqa xmm7, [rsp + 1*16]
75 movdqa xmm8, [rsp + 2*16]
76 movdqa xmm9, [rsp + 3*16]
77 movdqa xmm10, [rsp + 4*16]
78 movdqa xmm11, [rsp + 5*16]
79 movdqa xmm12, [rsp + 6*16]
80 movdqa xmm13, [rsp + 7*16]
81 movdqa xmm14, [rsp + 8*16]
82 movdqa xmm15, [rsp + 9*16]
83 add rsp, stack_size
84 %endmacro
85 %endif
86
87 ; configuration paramaters for AES-CBC
88 %define KEY_ROUNDS 13
89 %define XMM_USAGE (16)
90 %define EARLY_BLOCKS (4)
91 %define PARALLEL_BLOCKS (11)
92 %define IV_CNT (1)
93
94 ; instruction set specific operation definitions
95 %define MOVDQ vmovdqu
96 %macro PXOR 2
97 vpxor %1, %1, %2
98 %endm
99
100 %macro AES_DEC 2
101 vaesdec %1, %1, %2
102 %endm
103
104 %macro AES_DEC_LAST 2
105 vaesdeclast %1, %1, %2
106 %endm
107
108 %include "cbc_common.asm"
109
110
111 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
113 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
114 ;; aes_cbc_dec_192_avx(void *in, void *IV, void *keys, void *out, UINT64 num_bytes)
115 mk_global aes_cbc_dec_192_avx, function
116 func(aes_cbc_dec_192_avx)
117 endbranch
118 FUNC_SAVE
119
120 FILL_KEY_CACHE CKEY_CNT, FIRST_CKEY, KEYS, MOVDQ
121
122 MOVDQ reg(IV_IDX), [IV] ; Load IV for next round of block decrypt
123 mov IDX, 0
124 cmp LEN, PARALLEL_BLOCKS*16
125 jge main_loop ; if enough data blocks remain enter main_loop
126 jmp partials
127
128 main_loop:
129 CBC_DECRYPT_BLOCKS KEY_ROUNDS, PARALLEL_BLOCKS, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
130 cmp LEN, PARALLEL_BLOCKS*16
131 jge main_loop ; enough blocks to do another full parallel set
132 jz done
133
134 partials: ; fewer than 'PARALLEL_BLOCKS' left do in groups of 4, 2 or 1
135 cmp LEN, 0
136 je done
137 cmp LEN, 4*16
138 jge initial_4
139 cmp LEN, 2*16
140 jge initial_2
141
142 initial_1:
143 CBC_DECRYPT_BLOCKS KEY_ROUNDS, 1, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
144 jmp done
145
146 initial_2:
147 CBC_DECRYPT_BLOCKS KEY_ROUNDS, 2, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
148 jz done
149 jmp partials
150
151 initial_4:
152 CBC_DECRYPT_BLOCKS KEY_ROUNDS, 4, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
153 jnz partials
154 done:
155 FUNC_RESTORE
156 ret
157
158 endproc_frame