Skip to content

Commit

Permalink
mark AES intrinsics as safe
Browse files Browse the repository at this point in the history
Mark all AES intrinsics as safe.
  • Loading branch information
usamoi authored and Amanieu committed Feb 24, 2025
1 parent 9c01812 commit 930915c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions crates/core_arch/src/x86/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ unsafe extern "C" {
#[target_feature(enable = "aes")]
#[cfg_attr(test, assert_instr(aesdec))]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_aesdec_si128(a: __m128i, round_key: __m128i) -> __m128i {
aesdec(a, round_key)
pub fn _mm_aesdec_si128(a: __m128i, round_key: __m128i) -> __m128i {
unsafe { aesdec(a, round_key) }
}

/// Performs the last round of an AES decryption flow on data (state) in `a`.
Expand All @@ -46,8 +46,8 @@ pub unsafe fn _mm_aesdec_si128(a: __m128i, round_key: __m128i) -> __m128i {
#[target_feature(enable = "aes")]
#[cfg_attr(test, assert_instr(aesdeclast))]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_aesdeclast_si128(a: __m128i, round_key: __m128i) -> __m128i {
aesdeclast(a, round_key)
pub fn _mm_aesdeclast_si128(a: __m128i, round_key: __m128i) -> __m128i {
unsafe { aesdeclast(a, round_key) }
}

/// Performs one round of an AES encryption flow on data (state) in `a`.
Expand All @@ -57,8 +57,8 @@ pub unsafe fn _mm_aesdeclast_si128(a: __m128i, round_key: __m128i) -> __m128i {
#[target_feature(enable = "aes")]
#[cfg_attr(test, assert_instr(aesenc))]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_aesenc_si128(a: __m128i, round_key: __m128i) -> __m128i {
aesenc(a, round_key)
pub fn _mm_aesenc_si128(a: __m128i, round_key: __m128i) -> __m128i {
unsafe { aesenc(a, round_key) }
}

/// Performs the last round of an AES encryption flow on data (state) in `a`.
Expand All @@ -68,8 +68,8 @@ pub unsafe fn _mm_aesenc_si128(a: __m128i, round_key: __m128i) -> __m128i {
#[target_feature(enable = "aes")]
#[cfg_attr(test, assert_instr(aesenclast))]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_aesenclast_si128(a: __m128i, round_key: __m128i) -> __m128i {
aesenclast(a, round_key)
pub fn _mm_aesenclast_si128(a: __m128i, round_key: __m128i) -> __m128i {
unsafe { aesenclast(a, round_key) }
}

/// Performs the `InvMixColumns` transformation on `a`.
Expand All @@ -79,8 +79,8 @@ pub unsafe fn _mm_aesenclast_si128(a: __m128i, round_key: __m128i) -> __m128i {
#[target_feature(enable = "aes")]
#[cfg_attr(test, assert_instr(aesimc))]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_aesimc_si128(a: __m128i) -> __m128i {
aesimc(a)
pub fn _mm_aesimc_si128(a: __m128i) -> __m128i {
unsafe { aesimc(a) }
}

/// Assist in expanding the AES cipher key.
Expand All @@ -95,9 +95,9 @@ pub unsafe fn _mm_aesimc_si128(a: __m128i) -> __m128i {
#[cfg_attr(test, assert_instr(aeskeygenassist, IMM8 = 0))]
#[rustc_legacy_const_generics(1)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_aeskeygenassist_si128<const IMM8: i32>(a: __m128i) -> __m128i {
pub fn _mm_aeskeygenassist_si128<const IMM8: i32>(a: __m128i) -> __m128i {
static_assert_uimm_bits!(IMM8, 8);
aeskeygenassist(a, IMM8 as u8)
unsafe { aeskeygenassist(a, IMM8 as u8) }
}

#[cfg(test)]
Expand Down

0 comments on commit 930915c

Please sign in to comment.