]> git.proxmox.com Git - ceph.git/blob - ceph/src/crypto/isa-l/isa-l_crypto/aes/cbc_enc_192_x8_sb.asm
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / crypto / isa-l / isa-l_crypto / aes / cbc_enc_192_x8_sb.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 a 192 bit CBC AES encrypt
31 ;; clobbers all registers except for ARG1 and rbp
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 ;;; Updates In and Out pointers at end
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35 ;;void aes_cbc_enc_192_x8(void *in,
36 ;; uint8_t *IV,
37 ;; uint8_t keys,
38 ;; void *out,
39 ;; uint64_t len_bytes);
40 ; arg 1: IN: pointer to input (cipher text)
41 ; arg 2: IV: pointer to IV
42 ; arg 3: KEYS: pointer to keys
43 ; arg 4: OUT: pointer to output (plain text)
44 ; arg 5: LEN: length in bytes (multiple of 16)
45 ;; clobbers all registers except for ARG1 and rbp
46
47 %include "reg_sizes.asm"
48
49 %ifidn __OUTPUT_FORMAT__, elf64
50 %define IN0 rdi
51 %define IN rdi
52 %define IV rsi
53 %define KEYS rdx
54 %define OUT rcx
55 %define LEN r8
56 %define KEYS0 rdx
57 %define OUT0 rcx
58 %define func(x) x:
59 %define FUNC_SAVE
60 %define FUNC_RESTORE
61 %endif
62
63 %ifidn __OUTPUT_FORMAT__, win64
64 %define IN0 rcx
65 %define IN rcx
66 %define IV rdx
67 %define KEYS0 r8
68 %define OUT0 r9
69 %define KEYS r8
70 %define OUT r9
71 %define LEN r10
72 %define PS 8
73 %define stack_size 10*16 + 1*8 ; must be an odd multiple of 8
74 %define arg(x) [rsp + stack_size + PS + PS*x]
75
76 %define func(x) proc_frame x
77 %macro FUNC_SAVE 0
78 alloc_stack stack_size
79 vmovdqa [rsp + 0*16], xmm6
80 vmovdqa [rsp + 1*16], xmm7
81 vmovdqa [rsp + 2*16], xmm8
82 vmovdqa [rsp + 3*16], xmm9
83 vmovdqa [rsp + 4*16], xmm10
84 vmovdqa [rsp + 5*16], xmm11
85 vmovdqa [rsp + 6*16], xmm12
86 vmovdqa [rsp + 7*16], xmm13
87 vmovdqa [rsp + 8*16], xmm14
88 vmovdqa [rsp + 9*16], xmm15
89 end_prolog
90 mov LEN, arg(4)
91 %endmacro
92
93 %macro FUNC_RESTORE 0
94 vmovdqa xmm6, [rsp + 0*16]
95 vmovdqa xmm7, [rsp + 1*16]
96 vmovdqa xmm8, [rsp + 2*16]
97 vmovdqa xmm9, [rsp + 3*16]
98 vmovdqa xmm10, [rsp + 4*16]
99 vmovdqa xmm11, [rsp + 5*16]
100 vmovdqa xmm12, [rsp + 6*16]
101 vmovdqa xmm13, [rsp + 7*16]
102 vmovdqa xmm14, [rsp + 8*16]
103 vmovdqa xmm15, [rsp + 9*16]
104 add rsp, stack_size
105 %endmacro
106 %endif
107
108 %define KEY_ROUNDS 13
109 %define XMM_USAGE (16)
110 %DEFINE UNROLLED_LOOPS (3)
111 %define PARALLEL_BLOCKS (UNROLLED_LOOPS)
112
113 ; instruction set specific operation definitions
114 %define MOVDQ vmovdqu
115 %macro PXOR 2
116 vpxor %1, %1, %2
117 %endm
118
119 %macro AES_ENC 2
120 vaesenc %1, %1, %2
121 %endm
122
123 %macro AES_ENC_LAST 2
124 vaesenclast %1, %1, %2
125 %endm
126
127 %include "cbc_common.asm"
128
129 mk_global aes_cbc_enc_192_x8, function
130 func(aes_cbc_enc_192_x8)
131 endbranch
132 FUNC_SAVE
133
134 mov IDX, 0
135
136 FILL_KEY_CACHE CKEY_CNT, FIRST_CKEY, KEYS, MOVDQ
137 CBC_ENC_INIT FIRST_XDATA, TMP, MOVDQ, PXOR, IV, IN, IDX
138
139 main_loop:
140 CBC_ENC_SUBLOOP KEY_ROUNDS, UNROLLED_LOOPS, FIRST_XDATA, MOVDQ, PXOR, AES_ENC, AES_ENC_LAST, TMP, TMP_CNT, FIRST_CKEY, CKEY_CNT, KEYS, CACHED_KEYS, IN, OUT, IDX, LEN
141 jne main_loop
142
143 done:
144 FUNC_RESTORE
145 ret
146
147 endproc_frame