|
| 1 | +use x86::__m128i; |
| 2 | + |
| 3 | +#[allow(improper_ctypes)] |
| 4 | +extern "C" { |
| 5 | + #[link_name = "llvm.x86.aesni.aesdec"] |
| 6 | + fn aesdec(a: __m128i, round_key: __m128i) -> __m128i; |
| 7 | + #[link_name = "llvm.x86.aesni.aesdeclast"] |
| 8 | + fn aesdeclast(a: __m128i, round_key: __m128i) -> __m128i; |
| 9 | + #[link_name = "llvm.x86.aesni.aesenc"] |
| 10 | + fn aesenc(a: __m128i, round_key: __m128i) -> __m128i; |
| 11 | + #[link_name = "llvm.x86.aesni.aesenclast"] |
| 12 | + fn aesenclast(a: __m128i, round_key: __m128i) -> __m128i; |
| 13 | + #[link_name = "llvm.x86.aesni.aesimc"] |
| 14 | + fn aesimc(a: __m128i) -> __m128i; |
| 15 | + #[link_name = "llvm.x86.aesni.aeskeygenassist"] |
| 16 | + fn aeskeygenassist(a: __m128i, imm8: u8) -> __m128i; |
| 17 | +} |
| 18 | + |
| 19 | +/// Perform one round of an AES decryption flow on data (state) in `a`. |
| 20 | +#[inline] |
| 21 | +#[target_feature(enable = "aes")] |
| 22 | +#[cfg_attr(test, assert_instr(aesdec))] |
| 23 | +pub unsafe fn _mm_aesdec_si128(a: __m128i, round_key: __m128i) -> __m128i { |
| 24 | + aesdec(a, round_key) |
| 25 | +} |
| 26 | + |
| 27 | +/// Perform the last round of an AES decryption flow on data (state) in `a`. |
| 28 | +#[inline] |
| 29 | +#[target_feature(enable = "aes")] |
| 30 | +#[cfg_attr(test, assert_instr(aesdeclast))] |
| 31 | +pub unsafe fn _mm_aesdeclast_si128(a: __m128i, round_key: __m128i) -> __m128i { |
| 32 | + aesdeclast(a, round_key) |
| 33 | +} |
| 34 | + |
| 35 | +/// Perform one round of an AES encryption flow on data (state) in `a`. |
| 36 | +#[inline] |
| 37 | +#[target_feature(enable = "aes")] |
| 38 | +#[cfg_attr(test, assert_instr(aesenc))] |
| 39 | +pub unsafe fn _mm_aesenc_si128(a: __m128i, round_key: __m128i) -> __m128i { |
| 40 | + aesenc(a, round_key) |
| 41 | +} |
| 42 | + |
| 43 | +/// Perform the last round of an AES encryption flow on data (state) in `a`. |
| 44 | +#[inline] |
| 45 | +#[target_feature(enable = "aes")] |
| 46 | +#[cfg_attr(test, assert_instr(aesenclast))] |
| 47 | +pub unsafe fn _mm_aesenclast_si128(a: __m128i, round_key: __m128i) -> __m128i { |
| 48 | + aesenclast(a, round_key) |
| 49 | +} |
| 50 | + |
| 51 | +/// Perform the “InvMixColumns” transformation on `a`. |
| 52 | +#[inline] |
| 53 | +#[target_feature(enable = "aes")] |
| 54 | +#[cfg_attr(test, assert_instr(aesimc))] |
| 55 | +pub unsafe fn _mm_aesimc_si128(a: __m128i) -> __m128i { |
| 56 | + aesimc(a) |
| 57 | +} |
| 58 | + |
| 59 | +/// Assist in expanding the AES cipher key. |
| 60 | +/// |
| 61 | +/// Assist in expanding the AES cipher key by computing steps towards generating |
| 62 | +/// a round key for encryption cipher using data from `a` and an 8-bit round constant. |
| 63 | +#[inline] |
| 64 | +#[target_feature(enable = "aes")] |
| 65 | +#[cfg_attr(test, assert_instr(aeskeygenassist))] |
| 66 | +pub unsafe fn _mm_aeskeygenassist_si128(a: __m128i, imm8: u8) -> __m128i { |
| 67 | + aeskeygenassist(a, imm8) |
| 68 | +} |
0 commit comments