]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/intel-ipsec-mb/gcm.c
1 /*******************************************************************************
2 Copyright (c) 2018, Intel Corporation
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
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.
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 *******************************************************************************/
29 #include "intel-ipsec-mb.h"
34 * @brief Pre-processes GCM key data
36 * Prefills the gcm key data with key values for each round and
37 * the initial sub hash key for tag encoding
39 * @param key pointer to key data
40 * @param key_data GCM expanded key data
44 void aes_gcm_pre_128_sse(const void *key
, struct gcm_key_data
*key_data
)
47 if (key
== NULL
|| key_data
== NULL
)
50 aes_keyexp_128_enc_sse(key
, key_data
->expanded_keys
);
51 aes_gcm_precomp_128_sse(key_data
);
54 void aes_gcm_pre_128_sse_no_aesni(const void *key
,
55 struct gcm_key_data
*key_data
)
58 if (key
== NULL
|| key_data
== NULL
)
61 aes_keyexp_128_enc_sse_no_aesni(key
, key_data
->expanded_keys
);
62 aes_gcm_precomp_128_sse_no_aesni(key_data
);
65 void aes_gcm_pre_128_avx_gen2(const void *key
, struct gcm_key_data
*key_data
)
68 if (key
== NULL
|| key_data
== NULL
)
71 aes_keyexp_128_enc_avx(key
, key_data
->expanded_keys
);
72 aes_gcm_precomp_128_avx_gen2(key_data
);
75 void aes_gcm_pre_128_avx_gen4(const void *key
, struct gcm_key_data
*key_data
)
78 if (key
== NULL
|| key_data
== NULL
)
81 aes_keyexp_128_enc_avx2(key
, key_data
->expanded_keys
);
82 aes_gcm_precomp_128_avx_gen4(key_data
);
85 void aes_gcm_pre_128_avx512(const void *key
, struct gcm_key_data
*key_data
)
88 if (key
== NULL
|| key_data
== NULL
)
91 aes_keyexp_128_enc_avx2(key
, key_data
->expanded_keys
);
92 aes_gcm_precomp_128_avx512(key_data
);
95 void aes_gcm_pre_128_vaes_avx512(const void *key
, struct gcm_key_data
*key_data
)
98 if (key
== NULL
|| key_data
== NULL
)
101 aes_keyexp_128_enc_avx2(key
, key_data
->expanded_keys
);
102 aes_gcm_precomp_128_vaes_avx512(key_data
);
105 void aes_gcm_pre_192_sse(const void *key
, struct gcm_key_data
*key_data
)
108 if (key
== NULL
|| key_data
== NULL
)
111 aes_keyexp_192_enc_sse(key
, key_data
->expanded_keys
);
112 aes_gcm_precomp_192_sse(key_data
);
115 void aes_gcm_pre_192_sse_no_aesni(const void *key
,
116 struct gcm_key_data
*key_data
)
119 if (key
== NULL
|| key_data
== NULL
)
122 aes_keyexp_192_enc_sse_no_aesni(key
, key_data
->expanded_keys
);
123 aes_gcm_precomp_192_sse_no_aesni(key_data
);
126 void aes_gcm_pre_192_avx_gen2(const void *key
, struct gcm_key_data
*key_data
)
129 if (key
== NULL
|| key_data
== NULL
)
132 aes_keyexp_192_enc_avx(key
, key_data
->expanded_keys
);
133 aes_gcm_precomp_192_avx_gen2(key_data
);
136 void aes_gcm_pre_192_avx_gen4(const void *key
, struct gcm_key_data
*key_data
)
139 if (key
== NULL
|| key_data
== NULL
)
142 aes_keyexp_192_enc_avx2(key
, key_data
->expanded_keys
);
143 aes_gcm_precomp_192_avx_gen4(key_data
);
146 void aes_gcm_pre_192_avx512(const void *key
, struct gcm_key_data
*key_data
)
149 if (key
== NULL
|| key_data
== NULL
)
152 aes_keyexp_192_enc_avx2(key
, key_data
->expanded_keys
);
153 aes_gcm_precomp_192_avx512(key_data
);
156 void aes_gcm_pre_192_vaes_avx512(const void *key
, struct gcm_key_data
*key_data
)
159 if (key
== NULL
|| key_data
== NULL
)
162 aes_keyexp_192_enc_avx2(key
, key_data
->expanded_keys
);
163 aes_gcm_precomp_192_vaes_avx512(key_data
);
166 void aes_gcm_pre_256_sse(const void *key
, struct gcm_key_data
*key_data
)
169 if (key
== NULL
|| key_data
== NULL
)
172 aes_keyexp_256_enc_sse(key
, key_data
->expanded_keys
);
173 aes_gcm_precomp_256_sse(key_data
);
176 void aes_gcm_pre_256_sse_no_aesni(const void *key
,
177 struct gcm_key_data
*key_data
)
180 if (key
== NULL
|| key_data
== NULL
)
183 aes_keyexp_256_enc_sse_no_aesni(key
, key_data
->expanded_keys
);
184 aes_gcm_precomp_256_sse_no_aesni(key_data
);
187 void aes_gcm_pre_256_avx_gen2(const void *key
, struct gcm_key_data
*key_data
)
190 if (key
== NULL
|| key_data
== NULL
)
193 aes_keyexp_256_enc_avx(key
, key_data
->expanded_keys
);
194 aes_gcm_precomp_256_avx_gen2(key_data
);
197 void aes_gcm_pre_256_avx_gen4(const void *key
, struct gcm_key_data
*key_data
)
200 if (key
== NULL
|| key_data
== NULL
)
203 aes_keyexp_256_enc_avx2(key
, key_data
->expanded_keys
);
204 aes_gcm_precomp_256_avx_gen4(key_data
);
207 void aes_gcm_pre_256_avx512(const void *key
, struct gcm_key_data
*key_data
)
210 if (key
== NULL
|| key_data
== NULL
)
213 aes_keyexp_256_enc_avx2(key
, key_data
->expanded_keys
);
214 aes_gcm_precomp_256_avx512(key_data
);
217 void aes_gcm_pre_256_vaes_avx512(const void *key
, struct gcm_key_data
*key_data
)
220 if (key
== NULL
|| key_data
== NULL
)
223 aes_keyexp_256_enc_avx2(key
, key_data
->expanded_keys
);
224 aes_gcm_precomp_256_vaes_avx512(key_data
);