1 /*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------===
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:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
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
21 *===-----------------------------------------------------------------------===
23 #ifndef _WMMINTRIN_AES_H
24 #define _WMMINTRIN_AES_H
26 #include <emmintrin.h>
28 /* Define the default attributes for the functions in this file. */
29 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes")))
31 /// \brief Performs a single round of AES encryption using the Equivalent
32 /// Inverse Cipher, transforming the state value from the first source
33 /// operand using a 128-bit round key value contained in the second source
34 /// operand, and writes the result to the destination.
36 /// \headerfile <x86intrin.h>
38 /// This intrinsic corresponds to the \c VAESENC instruction.
41 /// A 128-bit integer vector containing the state value.
43 /// A 128-bit integer vector containing the round key value.
44 /// \returns A 128-bit integer vector containing the encrypted value.
45 static __inline__ __m128i __DEFAULT_FN_ATTRS
46 _mm_aesenc_si128(__m128i __V
, __m128i __R
)
48 return (__m128i
)__builtin_ia32_aesenc128((__v2di
)__V
, (__v2di
)__R
);
51 /// \brief Performs the final round of AES encryption using the Equivalent
52 /// Inverse Cipher, transforming the state value from the first source
53 /// operand using a 128-bit round key value contained in the second source
54 /// operand, and writes the result to the destination.
56 /// \headerfile <x86intrin.h>
58 /// This intrinsic corresponds to the \c VAESENCLAST instruction.
61 /// A 128-bit integer vector containing the state value.
63 /// A 128-bit integer vector containing the round key value.
64 /// \returns A 128-bit integer vector containing the encrypted value.
65 static __inline__ __m128i __DEFAULT_FN_ATTRS
66 _mm_aesenclast_si128(__m128i __V
, __m128i __R
)
68 return (__m128i
)__builtin_ia32_aesenclast128((__v2di
)__V
, (__v2di
)__R
);
71 /// \brief Performs a single round of AES decryption using the Equivalent
72 /// Inverse Cipher, transforming the state value from the first source
73 /// operand using a 128-bit round key value contained in the second source
74 /// operand, and writes the result to the destination.
76 /// \headerfile <x86intrin.h>
78 /// This intrinsic corresponds to the \c VAESDEC instruction.
81 /// A 128-bit integer vector containing the state value.
83 /// A 128-bit integer vector containing the round key value.
84 /// \returns A 128-bit integer vector containing the decrypted value.
85 static __inline__ __m128i __DEFAULT_FN_ATTRS
86 _mm_aesdec_si128(__m128i __V
, __m128i __R
)
88 return (__m128i
)__builtin_ia32_aesdec128((__v2di
)__V
, (__v2di
)__R
);
91 /// \brief Performs the final round of AES decryption using the Equivalent
92 /// Inverse Cipher, transforming the state value from the first source
93 /// operand using a 128-bit round key value contained in the second source
94 /// operand, and writes the result to the destination.
96 /// \headerfile <x86intrin.h>
98 /// This intrinsic corresponds to the \c VAESDECLAST instruction.
101 /// A 128-bit integer vector containing the state value.
103 /// A 128-bit integer vector containing the round key value.
104 /// \returns A 128-bit integer vector containing the decrypted value.
105 static __inline__ __m128i __DEFAULT_FN_ATTRS
106 _mm_aesdeclast_si128(__m128i __V
, __m128i __R
)
108 return (__m128i
)__builtin_ia32_aesdeclast128((__v2di
)__V
, (__v2di
)__R
);
111 /// \brief Applies the AES InvMixColumns() transformation to an expanded key
112 /// contained in the source operand, and writes the result to the
115 /// \headerfile <x86intrin.h>
117 /// This intrinsic corresponds to the \c VAESIMC instruction.
120 /// A 128-bit integer vector containing the expanded key.
121 /// \returns A 128-bit integer vector containing the transformed value.
122 static __inline__ __m128i __DEFAULT_FN_ATTRS
123 _mm_aesimc_si128(__m128i __V
)
125 return (__m128i
)__builtin_ia32_aesimc128((__v2di
)__V
);
128 /// \brief Generates a round key for AES encyption, operating on 128-bit data
129 /// specified in the first source operand and using an 8-bit round constant
130 /// specified by the second source operand, and writes the result to the
133 /// \headerfile <x86intrin.h>
136 /// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R);
139 /// This intrinsic corresponds to the \c AESKEYGENASSIST instruction.
142 /// A 128-bit integer vector that is used to generate the AES encryption key.
144 /// An 8-bit round constant used to generate the AES encryption key.
145 /// \returns A 128-bit round key for AES encryption.
146 #define _mm_aeskeygenassist_si128(C, R) \
147 (__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R))
149 #undef __DEFAULT_FN_ATTRS
151 #endif /* _WMMINTRIN_AES_H */