From ac04ed70e4e3d4904130dbacc052b05fd6bc8f10 Mon Sep 17 00:00:00 2001 From: Michael Rosenberg Date: Fri, 29 Apr 2022 03:57:21 -0400 Subject: [PATCH 1/3] impl'd ParBlocksUser for AES types --- aes/src/armv8.rs | 4 ++++ aes/src/ni.rs | 4 ++++ aes/src/soft.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/aes/src/armv8.rs b/aes/src/armv8.rs index 4ecc471d..3e68ebbe 100644 --- a/aes/src/armv8.rs +++ b/aes/src/armv8.rs @@ -110,6 +110,10 @@ macro_rules! define_aes_impl { } } + impl ParBlocksSizeUser for $name { + type ParBlocksSize = U8; + } + impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.write_str(concat!(stringify!($name), " { .. }")) diff --git a/aes/src/ni.rs b/aes/src/ni.rs index 15b49ef5..8925ec51 100644 --- a/aes/src/ni.rs +++ b/aes/src/ni.rs @@ -121,6 +121,10 @@ macro_rules! define_aes_impl { } } + impl ParBlocksSizeUser for $name { + type ParBlocksSize = U8; + } + impl fmt::Debug for $name { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.write_str(concat!(stringify!($name), " { .. }")) diff --git a/aes/src/soft.rs b/aes/src/soft.rs index 5f90b1e2..263704e2 100644 --- a/aes/src/soft.rs +++ b/aes/src/soft.rs @@ -86,6 +86,10 @@ macro_rules! define_aes_impl { } } + impl ParBlocksSizeUser for $name { + type ParBlocksSize = FixsliceBlocks; + } + impl From<$name_enc> for $name { #[inline] fn from(enc: $name_enc) -> $name { From 6d3ade71de5cc0e5822b57178471249bb7e10c89 Mon Sep 17 00:00:00 2001 From: Michael Rosenberg Date: Fri, 29 Apr 2022 04:03:31 -0400 Subject: [PATCH 2/3] impl'd ParBlocksUser for Kuznyechik types --- kuznyechik/src/soft/mod.rs | 8 ++++++-- kuznyechik/src/sse2/mod.rs | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kuznyechik/src/soft/mod.rs b/kuznyechik/src/soft/mod.rs index c972cbab..ac3f8514 100644 --- a/kuznyechik/src/soft/mod.rs +++ b/kuznyechik/src/soft/mod.rs @@ -1,7 +1,7 @@ use crate::{BlockSize, Key, KeySize}; use cipher::{ - AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit, - KeySizeUser, + consts::U1, AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, + BlockSizeUser, KeyInit, KeySizeUser, ParBlocksSizeUser, }; use core::fmt; @@ -65,6 +65,10 @@ impl BlockDecrypt for Kuznyechik { } } +impl ParBlocksSizeUser for Kuznyechik { + type ParBlocksSize = U1; +} + impl fmt::Debug for Kuznyechik { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.write_str("Kuznyechik { ... }") diff --git a/kuznyechik/src/sse2/mod.rs b/kuznyechik/src/sse2/mod.rs index 3ba16862..0a460f09 100644 --- a/kuznyechik/src/sse2/mod.rs +++ b/kuznyechik/src/sse2/mod.rs @@ -3,7 +3,7 @@ use crate::{BlockSize, Key, KeySize}; use cipher::{ AlgorithmName, BlockCipher, BlockClosure, BlockDecrypt, BlockEncrypt, BlockSizeUser, KeyInit, - KeySizeUser, + KeySizeUser, ParBlocksSizeUser, }; use core::fmt; @@ -72,6 +72,10 @@ impl BlockDecrypt for Kuznyechik { } } +impl ParBlocksSizeUser for Kuznyechik { + type ParBlocksSize = backends::ParBlocksSize; +} + impl fmt::Debug for Kuznyechik { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { f.write_str("Kuznyechik { ... }") From f16732be15633abb059a1fbba20cabe5acee7d18 Mon Sep 17 00:00:00 2001 From: Michael Rosenberg Date: Fri, 29 Apr 2022 04:05:41 -0400 Subject: [PATCH 3/3] Wibble --- kuznyechik/src/sse2/backends.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kuznyechik/src/sse2/backends.rs b/kuznyechik/src/sse2/backends.rs index 3ffda10d..c0a278fb 100644 --- a/kuznyechik/src/sse2/backends.rs +++ b/kuznyechik/src/sse2/backends.rs @@ -13,7 +13,7 @@ use core::arch::x86_64::*; pub(super) type RoundKeys = [__m128i; 10]; -type ParBlocksSize = U4; +pub(crate) type ParBlocksSize = U4; #[rustfmt::skip] macro_rules! unroll_par {