diff --git a/cipher/src/lib.rs b/cipher/src/lib.rs index c97ae4368..59b0d75d2 100644 --- a/cipher/src/lib.rs +++ b/cipher/src/lib.rs @@ -51,21 +51,11 @@ pub use crypto_common::{ generic_array, typenum::{self, consts}, AlgorithmName, Block, InnerIvInit, InvalidLength, Iv, IvSizeUser, Key, KeyInit, KeyIvInit, - KeySizeUser, + KeySizeUser, ParBlocks, ParBlocksSizeUser, }; -use generic_array::{ArrayLength, GenericArray}; /// Trait for loading current IV state. pub trait IvState: IvSizeUser { /// Returns current IV state. fn iv_state(&self) -> Iv; } - -/// Types which process blocks in parallel. -pub trait ParBlocksSizeUser: BlockSizeUser { - /// Number of blocks which can be processed in parallel. - type ParBlocksSize: ArrayLength>; -} - -/// Parallel blocks on which [`ParBlocksSizeUser`] implementors operate. -pub type ParBlocks = GenericArray, ::ParBlocksSize>; diff --git a/crypto-common/src/lib.rs b/crypto-common/src/lib.rs index 15c01c2dd..c49984cd2 100644 --- a/crypto-common/src/lib.rs +++ b/crypto-common/src/lib.rs @@ -25,10 +25,16 @@ use rand_core::{CryptoRng, RngCore}; /// Block on which [`BlockSizeUser`] implementors operate. pub type Block = GenericArray::BlockSize>; + +/// Parallel blocks on which [`ParBlocksSizeUser`] implementors operate. +pub type ParBlocks = GenericArray, ::ParBlocksSize>; + /// Output array of [`OutputSizeUser`] implementors. pub type Output = GenericArray::OutputSize>; + /// Key used by [`KeySizeUser`] implementors. pub type Key = GenericArray::KeySize>; + /// Initialization vector (nonce) used by [`IvSizeUser`] implementors. pub type Iv = GenericArray::IvSize>; @@ -51,6 +57,12 @@ impl BlockSizeUser for &mut T { type BlockSize = T::BlockSize; } +/// Types which can process blocks in parallel. +pub trait ParBlocksSizeUser: BlockSizeUser { + /// Number of blocks which can be processed in parallel. + type ParBlocksSize: ArrayLength>; +} + /// Types which return data with the given size. pub trait OutputSizeUser { /// Size of the output in bytes.