From bc6c2d6eb5c4769f21492589cbab572db629d6d8 Mon Sep 17 00:00:00 2001 From: sayantn Date: Mon, 20 May 2024 00:27:22 +0530 Subject: [PATCH] cleanup, bump version to 1.2.0. the allow(unused) is due to avx512f-vaes targets - in that case that is never used --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- src/aes_riscv32.rs | 8 ++++---- src/lib.rs | 32 ++++++++++++++++---------------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f22f9f2..656f9df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "aes_crypto" -version = "1.1.0" +version = "1.2.0" dependencies = [ "cfg-if", "hex", diff --git a/Cargo.toml b/Cargo.toml index c415a12..a874d10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aes_crypto" -version = "1.1.0" +version = "1.2.0" authors = ["Sayantan Chakraborty "] edition = "2021" license = "MIT" diff --git a/README.md b/README.md index 157715d..0c730bf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ This is a pure-Rust platform-agnostic [AES](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197-upd1.pdf) library, that is focused on reusability and optimal performance. -This library guarantees the best performance on the `target_cpu` (if correctly specified). This currently has 5 +This library guarantees the best performance on the `target_cpu` (if correctly specified). This currently has 6 implementations, among which it automatically decides the best (most performant) using Cargo's `target_feature` flags. # The implementations and their requirements are: diff --git a/src/aes_riscv32.rs b/src/aes_riscv32.rs index c3e7914..32cbc58 100644 --- a/src/aes_riscv32.rs +++ b/src/aes_riscv32.rs @@ -9,10 +9,10 @@ pub struct AesBlock(u32, u32, u32, u32); macro_rules! _asm { ($instruction:expr, $idx:literal, $rsd:ident, $rs:expr) => { asm!( - concat!($instruction, "i {},{},{},", $idx), - lateout(reg) $rsd, - in(reg) $rsd, - in(reg) $rs, + concat!($instruction, "i {rd},{rs1},{rs2},", $idx), + rd = lateout(reg) $rsd, + rs1 = in(reg) $rsd, + rs2 = in(reg) $rs, options(pure, nomem, nostack) ) }; diff --git a/src/lib.rs b/src/lib.rs index 2b7e65d..87ef21d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -109,6 +109,7 @@ fn try_from_slice>(value: &[u8]) -> Result(value: &[u8], offset: usize) -> [u8; N] { debug_assert!(value.len() - offset >= N); @@ -491,21 +492,20 @@ fn enc_round_keys(dec_round_keys: &[AesBlock; N]) -> [AesBlock; } cfg_if! { -if #[cfg(any( - all( - any( - target_arch = "aarch64", - target_arch = "arm64ec", - all(feature = "nightly", target_arch = "arm", target_feature = "v8") - ), - target_feature = "aes", - ), all( - feature = "nightly", - target_arch = "riscv32", - target_feature = "zkne", - target_feature = "zknd" - ) - ))] { + if #[cfg(any( + all( + any( + target_arch = "aarch64", + target_arch = "arm64ec", + all(feature = "nightly", target_arch = "arm", target_feature = "v8") + ), + target_feature = "aes", + ), all( + feature = "nightly", + target_arch = "riscv32", + target_feature = "zkne", + target_feature = "zknd" + )))] { macro_rules! aes_intr { ($($name:ident),*) => {$( impl $name { @@ -558,7 +558,7 @@ if #[cfg(any( acc.pre_dec_last($round_keys[$max - 1].into()) ^ $round_keys[$max].into() }}; } -}else{ + } else { macro_rules! impl_aes { (enc: $round_keys: expr, $plaintext: expr, $max:literal) => {{ let mut acc = $plaintext ^ $round_keys[0].into();