Skip to content

Commit 7a0ef8c

Browse files
committed
Deoxys: use aes inv_mix_collumns
1 parent d29c975 commit 7a0ef8c

3 files changed

Lines changed: 28 additions & 26 deletions

File tree

Cargo.lock

Lines changed: 23 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deoxys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ subtle = "2.4.0"
1818
zeroize = { version = "1", default-features = false }
1919

2020
[target.'cfg(target_feature="aes")'.dependencies]
21-
aes = {path = "./block-ciphers/aes", features = ["hazmat"]}
21+
aes = { git = "https://github.com/RustCrypto/block-ciphers", rev="45061f3aafc97e082eb398b368d1f97453465ebd", features=["hazmat"]}
2222

2323
[dev-dependencies]
2424
aead = { version = "0.4", features = ["dev"], default-features = false }

deoxys/src/lib.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ pub trait DeoxysBcType: deoxys_bc::DeoxysBcInternal {
213213

214214
for k in &keys[1..] {
215215
#[cfg(target_feature = "aes")]
216-
aes::round::cipher(block.into(), k.into());
216+
aes::hazmat::cipher_round(block.into(), k.into());
217217

218218
#[cfg(not(target_feature = "aes"))]
219219
aes_ref::encrypt_round(block, k);
@@ -231,26 +231,15 @@ pub trait DeoxysBcType: deoxys_bc::DeoxysBcInternal {
231231
*b ^= k;
232232
}
233233

234-
// Will be replaced with the aes crate
235-
unsafe {
236-
use core::arch::x86_64::*;
237-
let b = _mm_loadu_si128(block.as_ptr() as *const __m128i);
238-
let out = _mm_aesimc_si128(b);
239-
_mm_storeu_si128(block.as_mut_ptr() as *mut __m128i, out);
240-
}
234+
aes::hazmat::inv_mix_columns(block.into());
241235

242236
for k in keys[..r - 1].iter_mut() {
243237
// Will be replaced with the aes crate
244-
unsafe {
245-
use core::arch::x86_64::*;
246-
let k2 = _mm_loadu_si128(k.as_ptr() as *const __m128i);
247-
let out = _mm_aesimc_si128(k2);
248-
_mm_storeu_si128(k.as_mut_ptr() as *mut __m128i, out);
249-
}
238+
aes::hazmat::inv_mix_columns(k.into());
250239
}
251240

252241
for k in keys[..r - 1].iter().rev() {
253-
aes::round::equiv_inv_cipher(block.into(), k.into());
242+
aes::hazmat::equiv_inv_cipher_round(block.into(), k.into());
254243
}
255244

256245
aes_ref::mix_columns(block, &aes_ref::MIX_COLUMNS_MATRIX);

0 commit comments

Comments
 (0)