Skip to content

Commit 66cfbf5

Browse files
committed
Make aeskeygenassist imm8 argument i32, not u8
Intel documentation specifies it as an "8-bit round constant", but then goes on to give it a type "const int", which translates to i32 in Rust. The test that verifies the Rust signatures against Intel documentation failed on this. For now we will replicate the C API verbatim. Even when Rust could have a more accurate type signature that makes passing values more than 8 bits impossible, rather than silently mapping out-of-range values to 255.
1 parent 8665db2 commit 66cfbf5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

coresimd/src/x86/i686/aes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern "C" {
1616
#[link_name = "llvm.x86.aesni.aesimc"]
1717
fn aesimc(a: __m128i) -> __m128i;
1818
#[link_name = "llvm.x86.aesni.aeskeygenassist"]
19-
fn aeskeygenassist(a: __m128i, imm8: u8) -> __m128i;
19+
fn aeskeygenassist(a: __m128i, imm8: i32) -> __m128i;
2020
}
2121

2222
/// Perform one round of an AES decryption flow on data (state) in `a`.
@@ -62,11 +62,12 @@ pub unsafe fn _mm_aesimc_si128(a: __m128i) -> __m128i {
6262
/// Assist in expanding the AES cipher key.
6363
///
6464
/// Assist in expanding the AES cipher key by computing steps towards generating
65-
/// a round key for encryption cipher using data from `a` and an 8-bit round constant.
65+
/// a round key for encryption cipher using data from `a` and an 8-bit round
66+
/// constant `imm8`.
6667
#[inline]
6768
#[target_feature(enable = "aes")]
6869
#[cfg_attr(test, assert_instr(aeskeygenassist, imm8 = 0))]
69-
pub unsafe fn _mm_aeskeygenassist_si128(a: __m128i, imm8: u8) -> __m128i {
70+
pub unsafe fn _mm_aeskeygenassist_si128(a: __m128i, imm8: i32) -> __m128i {
7071
macro_rules! call {
7172
($imm8:expr) => (aeskeygenassist(a, $imm8))
7273
}

0 commit comments

Comments
 (0)