From 27c4444d7c9173547ece45f9a35cbee78d1a7beb Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Wed, 2 Jun 2021 13:52:16 +0800 Subject: [PATCH] aes-test: more pruning of C-isms Signed-off-by: Sean Cross --- services/aes-test/src/aes.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/services/aes-test/src/aes.rs b/services/aes-test/src/aes.rs index 4a03a12f0..ec5b28a0e 100644 --- a/services/aes-test/src/aes.rs +++ b/services/aes-test/src/aes.rs @@ -367,7 +367,7 @@ fn aes_dec_round_last(arg1: u32, arg2: u32, id: AesByte) -> u32 { } } -// use core::convert::TryInto; +use core::convert::TryInto; fn get_u32(input: &[u8], offset: usize) -> u32 { // let tmp = [ @@ -376,23 +376,17 @@ fn get_u32(input: &[u8], offset: usize) -> u32 { // input[offset + 2], // input[offset + 3], // ]; - let tmp = [ - input[offset + 3], - input[offset + 2], - input[offset + 1], - input[offset + 0], - ]; - u32::from_le_bytes(tmp) + // let tmp = [ + // input[offset + 3], + // input[offset + 2], + // input[offset + 1], + // input[offset + 0], + // ]; + u32::from_be_bytes(input[offset..offset+4].try_into().unwrap()) } fn get_u32_swapped(input: &[u8], offset: usize) -> u32 { - let tmp = [ - input[offset + 0], - input[offset + 1], - input[offset + 2], - input[offset + 3], - ]; - u32::from_le_bytes(tmp) + u32::from_le_bytes(input[offset..offset+4].try_into().unwrap()) } fn set_u32(output: &mut [u8], offset: usize, value: u32) {