]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/intel-ipsec-mb/gcm.c
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / intel-ipsec-mb / gcm.c
1 /*******************************************************************************
2 Copyright (c) 2018, Intel Corporation
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright notice,
8 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 the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of Intel Corporation nor the names of its contributors
13 may be used to endorse or promote products derived from this software
14 without specific prior written permission.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *******************************************************************************/
27
28 #include <stdint.h>
29 #include "intel-ipsec-mb.h"
30 #include "gcm.h"
31 #include "noaesni.h"
32
33 /**
34 * @brief Pre-processes GCM key data
35 *
36 * Prefills the gcm key data with key values for each round and
37 * the initial sub hash key for tag encoding
38 *
39 * @param key pointer to key data
40 * @param key_data GCM expanded key data
41 *
42 */
43
44 void aes_gcm_pre_128_sse(const void *key, struct gcm_key_data *key_data)
45 {
46 #ifdef SAFE_PARAM
47 if (key == NULL || key_data == NULL)
48 return;
49 #endif
50 aes_keyexp_128_enc_sse(key, key_data->expanded_keys);
51 aes_gcm_precomp_128_sse(key_data);
52 }
53
54 void aes_gcm_pre_128_sse_no_aesni(const void *key,
55 struct gcm_key_data *key_data)
56 {
57 #ifdef SAFE_PARAM
58 if (key == NULL || key_data == NULL)
59 return;
60 #endif
61 aes_keyexp_128_enc_sse_no_aesni(key, key_data->expanded_keys);
62 aes_gcm_precomp_128_sse_no_aesni(key_data);
63 }
64
65 void aes_gcm_pre_128_avx_gen2(const void *key, struct gcm_key_data *key_data)
66 {
67 #ifdef SAFE_PARAM
68 if (key == NULL || key_data == NULL)
69 return;
70 #endif
71 aes_keyexp_128_enc_avx(key, key_data->expanded_keys);
72 aes_gcm_precomp_128_avx_gen2(key_data);
73 }
74
75 void aes_gcm_pre_128_avx_gen4(const void *key, struct gcm_key_data *key_data)
76 {
77 #ifdef SAFE_PARAM
78 if (key == NULL || key_data == NULL)
79 return;
80 #endif
81 aes_keyexp_128_enc_avx2(key, key_data->expanded_keys);
82 aes_gcm_precomp_128_avx_gen4(key_data);
83 }
84
85 void aes_gcm_pre_128_avx512(const void *key, struct gcm_key_data *key_data)
86 {
87 #ifdef SAFE_PARAM
88 if (key == NULL || key_data == NULL)
89 return;
90 #endif
91 aes_keyexp_128_enc_avx2(key, key_data->expanded_keys);
92 aes_gcm_precomp_128_avx512(key_data);
93 }
94
95 void aes_gcm_pre_128_vaes_avx512(const void *key, struct gcm_key_data *key_data)
96 {
97 #ifdef SAFE_PARAM
98 if (key == NULL || key_data == NULL)
99 return;
100 #endif
101 aes_keyexp_128_enc_avx2(key, key_data->expanded_keys);
102 aes_gcm_precomp_128_vaes_avx512(key_data);
103 }
104
105 void aes_gcm_pre_192_sse(const void *key, struct gcm_key_data *key_data)
106 {
107 #ifdef SAFE_PARAM
108 if (key == NULL || key_data == NULL)
109 return;
110 #endif
111 aes_keyexp_192_enc_sse(key, key_data->expanded_keys);
112 aes_gcm_precomp_192_sse(key_data);
113 }
114
115 void aes_gcm_pre_192_sse_no_aesni(const void *key,
116 struct gcm_key_data *key_data)
117 {
118 #ifdef SAFE_PARAM
119 if (key == NULL || key_data == NULL)
120 return;
121 #endif
122 aes_keyexp_192_enc_sse_no_aesni(key, key_data->expanded_keys);
123 aes_gcm_precomp_192_sse_no_aesni(key_data);
124 }
125
126 void aes_gcm_pre_192_avx_gen2(const void *key, struct gcm_key_data *key_data)
127 {
128 #ifdef SAFE_PARAM
129 if (key == NULL || key_data == NULL)
130 return;
131 #endif
132 aes_keyexp_192_enc_avx(key, key_data->expanded_keys);
133 aes_gcm_precomp_192_avx_gen2(key_data);
134 }
135
136 void aes_gcm_pre_192_avx_gen4(const void *key, struct gcm_key_data *key_data)
137 {
138 #ifdef SAFE_PARAM
139 if (key == NULL || key_data == NULL)
140 return;
141 #endif
142 aes_keyexp_192_enc_avx2(key, key_data->expanded_keys);
143 aes_gcm_precomp_192_avx_gen4(key_data);
144 }
145
146 void aes_gcm_pre_192_avx512(const void *key, struct gcm_key_data *key_data)
147 {
148 #ifdef SAFE_PARAM
149 if (key == NULL || key_data == NULL)
150 return;
151 #endif
152 aes_keyexp_192_enc_avx2(key, key_data->expanded_keys);
153 aes_gcm_precomp_192_avx512(key_data);
154 }
155
156 void aes_gcm_pre_192_vaes_avx512(const void *key, struct gcm_key_data *key_data)
157 {
158 #ifdef SAFE_PARAM
159 if (key == NULL || key_data == NULL)
160 return;
161 #endif
162 aes_keyexp_192_enc_avx2(key, key_data->expanded_keys);
163 aes_gcm_precomp_192_vaes_avx512(key_data);
164 }
165
166 void aes_gcm_pre_256_sse(const void *key, struct gcm_key_data *key_data)
167 {
168 #ifdef SAFE_PARAM
169 if (key == NULL || key_data == NULL)
170 return;
171 #endif
172 aes_keyexp_256_enc_sse(key, key_data->expanded_keys);
173 aes_gcm_precomp_256_sse(key_data);
174 }
175
176 void aes_gcm_pre_256_sse_no_aesni(const void *key,
177 struct gcm_key_data *key_data)
178 {
179 #ifdef SAFE_PARAM
180 if (key == NULL || key_data == NULL)
181 return;
182 #endif
183 aes_keyexp_256_enc_sse_no_aesni(key, key_data->expanded_keys);
184 aes_gcm_precomp_256_sse_no_aesni(key_data);
185 }
186
187 void aes_gcm_pre_256_avx_gen2(const void *key, struct gcm_key_data *key_data)
188 {
189 #ifdef SAFE_PARAM
190 if (key == NULL || key_data == NULL)
191 return;
192 #endif
193 aes_keyexp_256_enc_avx(key, key_data->expanded_keys);
194 aes_gcm_precomp_256_avx_gen2(key_data);
195 }
196
197 void aes_gcm_pre_256_avx_gen4(const void *key, struct gcm_key_data *key_data)
198 {
199 #ifdef SAFE_PARAM
200 if (key == NULL || key_data == NULL)
201 return;
202 #endif
203 aes_keyexp_256_enc_avx2(key, key_data->expanded_keys);
204 aes_gcm_precomp_256_avx_gen4(key_data);
205 }
206
207 void aes_gcm_pre_256_avx512(const void *key, struct gcm_key_data *key_data)
208 {
209 #ifdef SAFE_PARAM
210 if (key == NULL || key_data == NULL)
211 return;
212 #endif
213 aes_keyexp_256_enc_avx2(key, key_data->expanded_keys);
214 aes_gcm_precomp_256_avx512(key_data);
215 }
216
217 void aes_gcm_pre_256_vaes_avx512(const void *key, struct gcm_key_data *key_data)
218 {
219 #ifdef SAFE_PARAM
220 if (key == NULL || key_data == NULL)
221 return;
222 #endif
223 aes_keyexp_256_enc_avx2(key, key_data->expanded_keys);
224 aes_gcm_precomp_256_vaes_avx512(key_data);
225 }