__wmmintrin_aes.h revision 341825
1258882Semaste/*===---- __wmmintrin_aes.h - AES intrinsics -------------------------------=== 2258882Semaste * 3258882Semaste * Permission is hereby granted, free of charge, to any person obtaining a copy 4258882Semaste * of this software and associated documentation files (the "Software"), to deal 5258882Semaste * in the Software without restriction, including without limitation the rights 6258882Semaste * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7258882Semaste * copies of the Software, and to permit persons to whom the Software is 8258882Semaste * furnished to do so, subject to the following conditions: 9258882Semaste * 10258882Semaste * The above copyright notice and this permission notice shall be included in 11258882Semaste * all copies or substantial portions of the Software. 12258882Semaste * 13258882Semaste * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14258882Semaste * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15258882Semaste * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16258882Semaste * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17258882Semaste * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18258882Semaste * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19258882Semaste * THE SOFTWARE. 20258882Semaste * 21258882Semaste *===-----------------------------------------------------------------------=== 22258882Semaste */ 23258882Semaste 24258882Semaste#ifndef __WMMINTRIN_H 25258882Semaste#error "Never use <__wmmintrin_aes.h> directly; include <wmmintrin.h> instead." 26258882Semaste#endif 27258882Semaste 28258882Semaste#ifndef __WMMINTRIN_AES_H 29258882Semaste#define __WMMINTRIN_AES_H 30258882Semaste 31258882Semaste/* Define the default attributes for the functions in this file. */ 32258882Semaste#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("aes"), __min_vector_width__(128))) 33258882Semaste 34258882Semaste/// Performs a single round of AES encryption using the Equivalent 35258882Semaste/// Inverse Cipher, transforming the state value from the first source 36258882Semaste/// operand using a 128-bit round key value contained in the second source 37258882Semaste/// operand, and writes the result to the destination. 38258882Semaste/// 39258882Semaste/// \headerfile <x86intrin.h> 40258882Semaste/// 41258882Semaste/// This intrinsic corresponds to the <c> VAESENC </c> instruction. 42258882Semaste/// 43258882Semaste/// \param __V 44258882Semaste/// A 128-bit integer vector containing the state value. 45258882Semaste/// \param __R 46258882Semaste/// A 128-bit integer vector containing the round key value. 47258882Semaste/// \returns A 128-bit integer vector containing the encrypted value. 48258882Semastestatic __inline__ __m128i __DEFAULT_FN_ATTRS 49258882Semaste_mm_aesenc_si128(__m128i __V, __m128i __R) 50258882Semaste{ 51258882Semaste return (__m128i)__builtin_ia32_aesenc128((__v2di)__V, (__v2di)__R); 52258882Semaste} 53258882Semaste 54258882Semaste/// Performs the final round of AES encryption using the Equivalent 55258882Semaste/// Inverse Cipher, transforming the state value from the first source 56258882Semaste/// operand using a 128-bit round key value contained in the second source 57258882Semaste/// operand, and writes the result to the destination. 58258882Semaste/// 59258882Semaste/// \headerfile <x86intrin.h> 60258882Semaste/// 61258882Semaste/// This intrinsic corresponds to the <c> VAESENCLAST </c> instruction. 62258882Semaste/// 63258882Semaste/// \param __V 64258882Semaste/// A 128-bit integer vector containing the state value. 65258882Semaste/// \param __R 66258882Semaste/// A 128-bit integer vector containing the round key value. 67258882Semaste/// \returns A 128-bit integer vector containing the encrypted value. 68258882Semastestatic __inline__ __m128i __DEFAULT_FN_ATTRS 69258882Semaste_mm_aesenclast_si128(__m128i __V, __m128i __R) 70258882Semaste{ 71258882Semaste return (__m128i)__builtin_ia32_aesenclast128((__v2di)__V, (__v2di)__R); 72} 73 74/// Performs a single round of AES decryption using the Equivalent 75/// Inverse Cipher, transforming the state value from the first source 76/// operand using a 128-bit round key value contained in the second source 77/// operand, and writes the result to the destination. 78/// 79/// \headerfile <x86intrin.h> 80/// 81/// This intrinsic corresponds to the <c> VAESDEC </c> instruction. 82/// 83/// \param __V 84/// A 128-bit integer vector containing the state value. 85/// \param __R 86/// A 128-bit integer vector containing the round key value. 87/// \returns A 128-bit integer vector containing the decrypted value. 88static __inline__ __m128i __DEFAULT_FN_ATTRS 89_mm_aesdec_si128(__m128i __V, __m128i __R) 90{ 91 return (__m128i)__builtin_ia32_aesdec128((__v2di)__V, (__v2di)__R); 92} 93 94/// Performs the final round of AES decryption using the Equivalent 95/// Inverse Cipher, transforming the state value from the first source 96/// operand using a 128-bit round key value contained in the second source 97/// operand, and writes the result to the destination. 98/// 99/// \headerfile <x86intrin.h> 100/// 101/// This intrinsic corresponds to the <c> VAESDECLAST </c> instruction. 102/// 103/// \param __V 104/// A 128-bit integer vector containing the state value. 105/// \param __R 106/// A 128-bit integer vector containing the round key value. 107/// \returns A 128-bit integer vector containing the decrypted value. 108static __inline__ __m128i __DEFAULT_FN_ATTRS 109_mm_aesdeclast_si128(__m128i __V, __m128i __R) 110{ 111 return (__m128i)__builtin_ia32_aesdeclast128((__v2di)__V, (__v2di)__R); 112} 113 114/// Applies the AES InvMixColumns() transformation to an expanded key 115/// contained in the source operand, and writes the result to the 116/// destination. 117/// 118/// \headerfile <x86intrin.h> 119/// 120/// This intrinsic corresponds to the <c> VAESIMC </c> instruction. 121/// 122/// \param __V 123/// A 128-bit integer vector containing the expanded key. 124/// \returns A 128-bit integer vector containing the transformed value. 125static __inline__ __m128i __DEFAULT_FN_ATTRS 126_mm_aesimc_si128(__m128i __V) 127{ 128 return (__m128i)__builtin_ia32_aesimc128((__v2di)__V); 129} 130 131/// Generates a round key for AES encryption, operating on 128-bit data 132/// specified in the first source operand and using an 8-bit round constant 133/// specified by the second source operand, and writes the result to the 134/// destination. 135/// 136/// \headerfile <x86intrin.h> 137/// 138/// \code 139/// __m128i _mm_aeskeygenassist_si128(__m128i C, const int R); 140/// \endcode 141/// 142/// This intrinsic corresponds to the <c> AESKEYGENASSIST </c> instruction. 143/// 144/// \param C 145/// A 128-bit integer vector that is used to generate the AES encryption key. 146/// \param R 147/// An 8-bit round constant used to generate the AES encryption key. 148/// \returns A 128-bit round key for AES encryption. 149#define _mm_aeskeygenassist_si128(C, R) \ 150 (__m128i)__builtin_ia32_aeskeygenassist128((__v2di)(__m128i)(C), (int)(R)) 151 152#undef __DEFAULT_FN_ATTRS 153 154#endif /* __WMMINTRIN_AES_H */ 155