blob: 68b0a5689618a7bd104e2c74290d2812b1e57551 [file] [log] [blame]
Sasha Smundak4b1f33a2021-01-11 15:05:07 -08001/*===----------------- keylockerintrin.h - KL Intrinsics -------------------===
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 *
21 *===-----------------------------------------------------------------------===
22 */
23
24#ifndef __IMMINTRIN_H
25#error "Never use <keylockerintrin.h> directly; include <immintrin.h> instead."
26#endif
27
28#ifndef _KEYLOCKERINTRIN_H
29#define _KEYLOCKERINTRIN_H
30
31#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
32 defined(__KL__)
33
34/* Define the default attributes for the functions in this file. */
35#define __DEFAULT_FN_ATTRS \
36 __attribute__((__always_inline__, __nodebug__, __target__("kl"),\
37 __min_vector_width__(128)))
38
39/// Load internal wrapping key from __intkey, __enkey_lo and __enkey_hi. __ctl
40/// will assigned to EAX, whch specifies the KeySource and whether backing up
41/// the key is permitted. The 256-bit encryption key is loaded from the two
42/// explicit operands (__enkey_lo and __enkey_hi). The 128-bit integrity key is
43/// loaded from the implicit operand XMM0 which assigned by __intkey.
44///
45/// \headerfile <x86intrin.h>
46///
47/// This intrinsic corresponds to the <c> LOADIWKEY </c> instructions.
48///
49/// \operation
50/// IF CPL > 0 // LOADKWKEY only allowed at ring 0 (supervisor mode)
51/// GP (0)
52/// FI
53/// IF “LOADIWKEY exiting” VM execution control set
54/// VMexit
55/// FI
56/// IF __ctl[4:1] > 1 // Reserved KeySource encoding used
57/// GP (0)
58/// FI
59/// IF __ctl[31:5] != 0 // Reserved bit in __ctl is set
60/// GP (0)
61/// FI
62/// IF __ctl[0] AND (CPUID.19H.ECX[0] == 0) // NoBackup is not supported on this part
63/// GP (0)
64/// FI
65/// IF (__ctl[4:1] == 1) AND (CPUID.19H.ECX[1] == 0) // KeySource of 1 is not supported on this part
66/// GP (0)
67/// FI
68/// IF (__ctl[4:1] == 0) // KeySource of 0.
69/// IWKey.Encryption Key[127:0] := __enkey_hi[127:0]:
70/// IWKey.Encryption Key[255:128] := __enkey_lo[127:0]
71/// IWKey.IntegrityKey[127:0] := __intkey[127:0]
72/// IWKey.NoBackup := __ctl[0]
73/// IWKey.KeySource := __ctl[4:1]
74/// ZF := 0
75/// ELSE // KeySource of 1. See RDSEED definition for details of randomness
76/// IF HW_NRND_GEN.ready == 1 // Full-entropy random data from RDSEED was received
77/// IWKey.Encryption Key[127:0] := __enkey_hi[127:0] XOR HW_NRND_GEN.data[127:0]
78/// IWKey.Encryption Key[255:128] := __enkey_lo[127:0] XOR HW_NRND_GEN.data[255:128]
79/// IWKey.Encryption Key[255:0] := __enkey_hi[127:0]:__enkey_lo[127:0] XOR HW_NRND_GEN.data[255:0]
80/// IWKey.IntegrityKey[127:0] := __intkey[127:0] XOR HW_NRND_GEN.data[383:256]
81/// IWKey.NoBackup := __ctl[0]
82/// IWKey.KeySource := __ctl[4:1]
83/// ZF := 0
84/// ELSE // Random data was not returned from RDSEED. IWKey was not loaded
85/// ZF := 1
86/// FI
87/// FI
88/// dst := ZF
89/// OF := 0
90/// SF := 0
91/// AF := 0
92/// PF := 0
93/// CF := 0
94/// \endoperation
95static __inline__ void __DEFAULT_FN_ATTRS
96_mm_loadiwkey (unsigned int __ctl, __m128i __intkey,
97 __m128i __enkey_lo, __m128i __enkey_hi) {
98 __builtin_ia32_loadiwkey (__intkey, __enkey_lo, __enkey_hi, __ctl);
99}
100
101/// Wrap a 128-bit AES key from __key into a key handle and output in
102/// ((__m128i*)__h) to ((__m128i*)__h) + 5 and a 32-bit value as return.
103/// The explicit source operand __htype specifies handle restrictions.
104///
105/// \headerfile <x86intrin.h>
106///
107/// This intrinsic corresponds to the <c> ENCODEKEY128 </c> instructions.
108///
109/// \operation
110/// InputKey[127:0] := __key[127:0]
111/// KeyMetadata[2:0] := __htype[2:0]
112/// KeyMetadata[23:3] := 0 // Reserved for future usage
113/// KeyMetadata[27:24] := 0 // KeyType is AES-128 (value of 0)
114/// KeyMetadata[127:28] := 0 // Reserved for future usage
115/// Handle[383:0] := WrapKey128(InputKey[127:0], KeyMetadata[127:0],
116/// IWKey.Integrity Key[127:0], IWKey.Encryption Key[255:0])
117/// dst[0] := IWKey.NoBackup
118/// dst[4:1] := IWKey.KeySource[3:0]
119/// dst[31:5] := 0
120/// MEM[__h+127:__h] := Handle[127:0] // AAD
121/// MEM[__h+255:__h+128] := Handle[255:128] // Integrity Tag
122/// MEM[__h+383:__h+256] := Handle[383:256] // CipherText
123/// MEM[__h+511:__h+384] := 0 // Reserved for future usage
124/// MEM[__h+639:__h+512] := 0 // Reserved for future usage
125/// MEM[__h+767:__h+640] := 0 // Reserved for future usage
126/// OF := 0
127/// SF := 0
128/// ZF := 0
129/// AF := 0
130/// PF := 0
131/// CF := 0
132/// \endoperation
133static __inline__ unsigned int __DEFAULT_FN_ATTRS
134_mm_encodekey128_u32(unsigned int __htype, __m128i __key, void *__h) {
135 return __builtin_ia32_encodekey128_u32(__htype, (__v2di)__key, __h);
136}
137
138/// Wrap a 256-bit AES key from __key_hi:__key_lo into a key handle, then
139/// output handle in ((__m128i*)__h) to ((__m128i*)__h) + 6 and
140/// a 32-bit value as return.
141/// The explicit source operand __htype specifies handle restrictions.
142///
143/// \headerfile <x86intrin.h>
144///
145/// This intrinsic corresponds to the <c> ENCODEKEY256 </c> instructions.
146///
147/// \operation
148/// InputKey[127:0] := __key_lo[127:0]
149/// InputKey[255:128] := __key_hi[255:128]
150/// KeyMetadata[2:0] := __htype[2:0]
151/// KeyMetadata[23:3] := 0 // Reserved for future usage
152/// KeyMetadata[27:24] := 1 // KeyType is AES-256 (value of 1)
153/// KeyMetadata[127:28] := 0 // Reserved for future usage
154/// Handle[511:0] := WrapKey256(InputKey[255:0], KeyMetadata[127:0],
155/// IWKey.Integrity Key[127:0], IWKey.Encryption Key[255:0])
156/// dst[0] := IWKey.NoBackup
157/// dst[4:1] := IWKey.KeySource[3:0]
158/// dst[31:5] := 0
159/// MEM[__h+127:__h] := Handle[127:0] // AAD
160/// MEM[__h+255:__h+128] := Handle[255:128] // Tag
161/// MEM[__h+383:__h+256] := Handle[383:256] // CipherText[127:0]
162/// MEM[__h+511:__h+384] := Handle[511:384] // CipherText[255:128]
163/// MEM[__h+639:__h+512] := 0 // Reserved for future usage
164/// MEM[__h+767:__h+640] := 0 // Reserved for future usage
165/// MEM[__h+895:__h+768] := 0 Integrity// Reserved for future usage
166/// OF := 0
167/// SF := 0
168/// ZF := 0
169/// AF := 0
170/// PF := 0
171/// CF := 0
172/// \endoperation
173static __inline__ unsigned int __DEFAULT_FN_ATTRS
174_mm_encodekey256_u32(unsigned int __htype, __m128i __key_lo, __m128i __key_hi,
175 void *__h) {
176 return __builtin_ia32_encodekey256_u32(__htype, (__v2di)__key_lo,
177 (__v2di)__key_hi, __h);
178}
179
180/// The AESENC128KL performs 10 rounds of AES to encrypt the __idata using
181/// the 128-bit key in the handle from the __h. It stores the result in the
182/// __odata. And return the affected ZF flag status.
183///
184/// \headerfile <x86intrin.h>
185///
186/// This intrinsic corresponds to the <c> AESENC128KL </c> instructions.
187///
188/// \operation
189/// Handle[383:0] := MEM[__h+383:__h] // Load is not guaranteed to be atomic.
190/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
191/// (Handle[127:0] AND (CPL > 0)) ||
192/// Handle[383:256] ||
193/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128 )
194/// IF (IllegalHandle)
195/// ZF := 1
196/// ELSE
197/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
198/// IF (Authentic == 0)
199/// ZF := 1
200/// ELSE
201/// MEM[__odata+127:__odata] := AES128Encrypt (__idata[127:0], UnwrappedKey)
202/// ZF := 0
203/// FI
204/// FI
205/// dst := ZF
206/// OF := 0
207/// SF := 0
208/// AF := 0
209/// PF := 0
210/// CF := 0
211/// \endoperation
212static __inline__ unsigned char __DEFAULT_FN_ATTRS
213_mm_aesenc128kl_u8(__m128i* __odata, __m128i __idata, const void *__h) {
214 return __builtin_ia32_aesenc128kl_u8((__v2di *)__odata, (__v2di)__idata, __h);
215}
216
217/// The AESENC256KL performs 14 rounds of AES to encrypt the __idata using
218/// the 256-bit key in the handle from the __h. It stores the result in the
219/// __odata. And return the affected ZF flag status.
220///
221/// \headerfile <x86intrin.h>
222///
223/// This intrinsic corresponds to the <c> AESENC256KL </c> instructions.
224///
225/// \operation
226/// Handle[511:0] := MEM[__h+511:__h] // Load is not guaranteed to be atomic.
227/// IllegalHandle := ( HandleReservedBitSet (Handle[511:0]) ||
228/// (Handle[127:0] AND (CPL > 0)) ||
229/// Handle[255:128] ||
230/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES256 )
231/// IF (IllegalHandle)
232/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800233/// MEM[__odata+127:__odata] := 0
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800234/// ELSE
235/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
236/// IF (Authentic == 0)
237/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800238/// MEM[__odata+127:__odata] := 0
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800239/// ELSE
240/// MEM[__odata+127:__odata] := AES256Encrypt (__idata[127:0], UnwrappedKey)
241/// ZF := 0
242/// FI
243/// FI
244/// dst := ZF
245/// OF := 0
246/// SF := 0
247/// AF := 0
248/// PF := 0
249/// CF := 0
250/// \endoperation
251static __inline__ unsigned char __DEFAULT_FN_ATTRS
252_mm_aesenc256kl_u8(__m128i* __odata, __m128i __idata, const void *__h) {
253 return __builtin_ia32_aesenc256kl_u8((__v2di *)__odata, (__v2di)__idata, __h);
254}
255
256/// The AESDEC128KL performs 10 rounds of AES to decrypt the __idata using
257/// the 128-bit key in the handle from the __h. It stores the result in the
258/// __odata. And return the affected ZF flag status.
259///
260/// \headerfile <x86intrin.h>
261///
262/// This intrinsic corresponds to the <c> AESDEC128KL </c> instructions.
263///
264/// \operation
265/// Handle[383:0] := MEM[__h+383:__h] // Load is not guaranteed to be atomic.
266/// IllegalHandle := (HandleReservedBitSet (Handle[383:0]) ||
267/// (Handle[127:0] AND (CPL > 0)) ||
268/// Handle[383:256] ||
269/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128)
270/// IF (IllegalHandle)
271/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800272/// MEM[__odata+127:__odata] := 0
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800273/// ELSE
274/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
275/// IF (Authentic == 0)
276/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800277/// MEM[__odata+127:__odata] := 0
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800278/// ELSE
279/// MEM[__odata+127:__odata] := AES128Decrypt (__idata[127:0], UnwrappedKey)
280/// ZF := 0
281/// FI
282/// FI
283/// dst := ZF
284/// OF := 0
285/// SF := 0
286/// AF := 0
287/// PF := 0
288/// CF := 0
289/// \endoperation
290static __inline__ unsigned char __DEFAULT_FN_ATTRS
291_mm_aesdec128kl_u8(__m128i* __odata, __m128i __idata, const void *__h) {
292 return __builtin_ia32_aesdec128kl_u8((__v2di *)__odata, (__v2di)__idata, __h);
293}
294
295/// The AESDEC256KL performs 10 rounds of AES to decrypt the __idata using
296/// the 256-bit key in the handle from the __h. It stores the result in the
297/// __odata. And return the affected ZF flag status.
298///
299/// \headerfile <x86intrin.h>
300///
301/// This intrinsic corresponds to the <c> AESDEC256KL </c> instructions.
302///
303/// \operation
304/// Handle[511:0] := MEM[__h+511:__h]
305/// IllegalHandle := (HandleReservedBitSet (Handle[511:0]) ||
306/// (Handle[127:0] AND (CPL > 0)) ||
307/// Handle[383:256] ||
308/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES256)
309/// IF (IllegalHandle)
310/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800311/// MEM[__odata+127:__odata] := 0
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800312/// ELSE
313/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
314/// IF (Authentic == 0)
315/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800316/// MEM[__odata+127:__odata] := 0
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800317/// ELSE
318/// MEM[__odata+127:__odata] := AES256Decrypt (__idata[127:0], UnwrappedKey)
319/// ZF := 0
320/// FI
321/// FI
322/// dst := ZF
323/// OF := 0
324/// SF := 0
325/// AF := 0
326/// PF := 0
327/// CF := 0
328/// \endoperation
329static __inline__ unsigned char __DEFAULT_FN_ATTRS
330_mm_aesdec256kl_u8(__m128i* __odata, __m128i __idata, const void *__h) {
331 return __builtin_ia32_aesdec256kl_u8((__v2di *)__odata, (__v2di)__idata, __h);
332}
333
334#undef __DEFAULT_FN_ATTRS
335
336#endif /* !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) \
337 || defined(__KL__) */
338
339#if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) || \
340 defined(__WIDEKL__)
341
342/* Define the default attributes for the functions in this file. */
343#define __DEFAULT_FN_ATTRS \
344 __attribute__((__always_inline__, __nodebug__, __target__("kl,widekl"),\
345 __min_vector_width__(128)))
346
347/// Encrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle
348/// at __h and store each resultant block back from __odata to __odata+7. And
349/// return the affected ZF flag status.
350///
351/// \headerfile <x86intrin.h>
352///
353/// This intrinsic corresponds to the <c> AESENCWIDE128KL </c> instructions.
354///
355/// \operation
356/// Handle := MEM[__h+383:__h]
357/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
358/// (Handle[127:0] AND (CPL > 0)) ||
359/// Handle[255:128] ||
360/// HandleKeyType (Handle[383:0]) != HANDLE_KEY_TYPE_AES128 )
361/// IF (IllegalHandle)
362/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800363/// FOR i := 0 to 7
364/// __odata[i] := 0
365/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800366/// ELSE
367/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
368/// IF Authentic == 0
369/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800370/// FOR i := 0 to 7
371/// __odata[i] := 0
372/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800373/// ELSE
374/// FOR i := 0 to 7
375/// __odata[i] := AES128Encrypt (__idata[i], UnwrappedKey)
376/// ENDFOR
377/// ZF := 0
378/// FI
379/// FI
380/// dst := ZF
381/// OF := 0
382/// SF := 0
383/// AF := 0
384/// PF := 0
385/// CF := 0
386/// \endoperation
387static __inline__ unsigned char __DEFAULT_FN_ATTRS
388_mm_aesencwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
389 return __builtin_ia32_aesencwide128kl_u8((__v2di *)__odata,
390 (const __v2di *)__idata, __h);
391}
392
393/// Encrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle
394/// at __h and store each resultant block back from __odata to __odata+7. And
395/// return the affected ZF flag status.
396///
397/// \headerfile <x86intrin.h>
398///
399/// This intrinsic corresponds to the <c> AESENCWIDE256KL </c> instructions.
400///
401/// \operation
402/// Handle[511:0] := MEM[__h+511:__h]
403/// IllegalHandle := ( HandleReservedBitSet (Handle[511:0]) ||
404/// (Handle[127:0] AND (CPL > 0)) ||
405/// Handle[255:128] ||
406/// HandleKeyType (Handle[511:0]) != HANDLE_KEY_TYPE_AES512 )
407/// IF (IllegalHandle)
408/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800409/// FOR i := 0 to 7
410/// __odata[i] := 0
411/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800412/// ELSE
413/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
414/// IF Authentic == 0
415/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800416/// FOR i := 0 to 7
417/// __odata[i] := 0
418/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800419/// ELSE
420/// FOR i := 0 to 7
421/// __odata[i] := AES256Encrypt (__idata[i], UnwrappedKey)
422/// ENDFOR
423/// ZF := 0
424/// FI
425/// FI
426/// dst := ZF
427/// OF := 0
428/// SF := 0
429/// AF := 0
430/// PF := 0
431/// CF := 0
432/// \endoperation
433static __inline__ unsigned char __DEFAULT_FN_ATTRS
434_mm_aesencwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
435 return __builtin_ia32_aesencwide256kl_u8((__v2di *)__odata,
436 (const __v2di *)__idata, __h);
437}
438
439/// Decrypt __idata[0] to __idata[7] using 128-bit AES key indicated by handle
440/// at __h and store each resultant block back from __odata to __odata+7. And
441/// return the affected ZF flag status.
442///
443/// \headerfile <x86intrin.h>
444///
445/// This intrinsic corresponds to the <c> AESDECWIDE128KL </c> instructions.
446///
447/// \operation
448/// Handle[383:0] := MEM[__h+383:__h]
449/// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
450/// (Handle[127:0] AND (CPL > 0)) ||
451/// Handle[255:128] ||
452/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES128 )
453/// IF (IllegalHandle)
454/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800455/// FOR i := 0 to 7
456/// __odata[i] := 0
457/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800458/// ELSE
459/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate384 (Handle[383:0], IWKey)
460/// IF Authentic == 0
461/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800462/// FOR i := 0 to 7
463/// __odata[i] := 0
464/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800465/// ELSE
466/// FOR i := 0 to 7
467/// __odata[i] := AES128Decrypt (__idata[i], UnwrappedKey)
468/// ENDFOR
469/// ZF := 0
470/// FI
471/// FI
472/// dst := ZF
473/// OF := 0
474/// SF := 0
475/// AF := 0
476/// PF := 0
477/// CF := 0
478/// \endoperation
479static __inline__ unsigned char __DEFAULT_FN_ATTRS
480_mm_aesdecwide128kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
481 return __builtin_ia32_aesdecwide128kl_u8((__v2di *)__odata,
482 (const __v2di *)__idata, __h);
483}
484
485/// Decrypt __idata[0] to __idata[7] using 256-bit AES key indicated by handle
486/// at __h and store each resultant block back from __odata to __odata+7. And
487/// return the affected ZF flag status.
488///
489/// \headerfile <x86intrin.h>
490///
491/// This intrinsic corresponds to the <c> AESDECWIDE256KL </c> instructions.
492///
493/// \operation
494/// Handle[511:0] := MEM[__h+511:__h]
495/// IllegalHandle = ( HandleReservedBitSet (Handle[511:0]) ||
496/// (Handle[127:0] AND (CPL > 0)) ||
497/// Handle[255:128] ||
498/// HandleKeyType (Handle) != HANDLE_KEY_TYPE_AES512 )
499/// If (IllegalHandle)
500/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800501/// FOR i := 0 to 7
502/// __odata[i] := 0
503/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800504/// ELSE
505/// (UnwrappedKey, Authentic) := UnwrapKeyAndAuthenticate512 (Handle[511:0], IWKey)
506/// IF Authentic == 0
507/// ZF := 1
Pirama Arumuga Nainar494f6452021-12-02 10:42:14 -0800508/// FOR i := 0 to 7
509/// __odata[i] := 0
510/// ENDFOR
Sasha Smundak4b1f33a2021-01-11 15:05:07 -0800511/// ELSE
512/// FOR i := 0 to 7
513/// __odata[i] := AES256Decrypt (__idata[i], UnwrappedKey)
514/// ENDFOR
515/// ZF := 0
516/// FI
517/// FI
518/// dst := ZF
519/// OF := 0
520/// SF := 0
521/// AF := 0
522/// PF := 0
523/// CF := 0
524/// \endoperation
525static __inline__ unsigned char __DEFAULT_FN_ATTRS
526_mm_aesdecwide256kl_u8(__m128i __odata[8], const __m128i __idata[8], const void* __h) {
527 return __builtin_ia32_aesdecwide256kl_u8((__v2di *)__odata,
528 (const __v2di *)__idata, __h);
529}
530
531#undef __DEFAULT_FN_ATTRS
532
533#endif /* !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) \
534 || defined(__WIDEKL__) */
535
536#endif /* _KEYLOCKERINTRIN_H */