From 371db89daa4220e794225fb8a9f179e98e8ee8a9 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Sat, 23 May 2020 12:16:38 -0700 Subject: [PATCH] Re-export `typenum::consts` as `consts` Inspired by the `heapless` crate: https://github.com/RustCrypto/traits/issues/43#issuecomment-633109800 This re-export provides convenient access to the type-level numeric constants provided by `typenum`, which should make using `generic-array` less annoying. --- aead/src/lib.rs | 8 +++++--- block-cipher-trait/src/lib.rs | 2 +- crypto-mac/src/lib.rs | 2 +- digest/src/lib.rs | 2 +- stream-cipher/src/lib.rs | 2 +- universal-hash/src/lib.rs | 3 ++- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/aead/src/lib.rs b/aead/src/lib.rs index b6ccdd7d..cd358a88 100644 --- a/aead/src/lib.rs +++ b/aead/src/lib.rs @@ -25,15 +25,17 @@ extern crate alloc; #[cfg(feature = "std")] extern crate std; -pub use generic_array; +pub use generic_array::{self, typenum::consts}; + #[cfg(feature = "heapless")] pub use heapless; -#[cfg(feature = "alloc")] -use alloc::vec::Vec; use core::fmt; use generic_array::{typenum::Unsigned, ArrayLength, GenericArray}; +#[cfg(feature = "alloc")] +use alloc::vec::Vec; + /// Error type #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct Error; diff --git a/block-cipher-trait/src/lib.rs b/block-cipher-trait/src/lib.rs index 6b85de4f..11e2a555 100644 --- a/block-cipher-trait/src/lib.rs +++ b/block-cipher-trait/src/lib.rs @@ -15,7 +15,7 @@ pub mod dev; mod errors; pub use crate::errors::InvalidKeyLength; -pub use generic_array; +pub use generic_array::{self, typenum::consts}; use generic_array::typenum::Unsigned; use generic_array::{ArrayLength, GenericArray}; diff --git a/crypto-mac/src/lib.rs b/crypto-mac/src/lib.rs index a0477d69..4c04c3ad 100644 --- a/crypto-mac/src/lib.rs +++ b/crypto-mac/src/lib.rs @@ -14,7 +14,7 @@ pub mod dev; mod errors; pub use crate::errors::{InvalidKeyLength, MacError}; -pub use generic_array; +pub use generic_array::{self, typenum::consts}; use generic_array::typenum::Unsigned; use generic_array::{ArrayLength, GenericArray}; diff --git a/digest/src/lib.rs b/digest/src/lib.rs index 64e0e83a..ceb5186e 100644 --- a/digest/src/lib.rs +++ b/digest/src/lib.rs @@ -33,7 +33,7 @@ mod errors; pub use crate::digest::{Digest, Output}; pub use crate::errors::InvalidOutputSize; -pub use generic_array; +pub use generic_array::{self, typenum::consts}; #[cfg(feature = "std")] #[cfg_attr(docsrs, doc(cfg(feature = "std")))] diff --git a/stream-cipher/src/lib.rs b/stream-cipher/src/lib.rs index cf5b7d79..8a236690 100644 --- a/stream-cipher/src/lib.rs +++ b/stream-cipher/src/lib.rs @@ -18,7 +18,7 @@ pub mod dev; mod errors; pub use crate::errors::{InvalidKeyNonceLength, LoopError}; -pub use generic_array; +pub use generic_array::{self, typenum::consts}; use generic_array::typenum::Unsigned; use generic_array::{ArrayLength, GenericArray}; diff --git a/universal-hash/src/lib.rs b/universal-hash/src/lib.rs index 264bdd9a..2e6490e7 100644 --- a/universal-hash/src/lib.rs +++ b/universal-hash/src/lib.rs @@ -21,7 +21,7 @@ #[cfg(feature = "std")] extern crate std; -pub use generic_array; +pub use generic_array::{self, typenum::consts}; use generic_array::typenum::Unsigned; use generic_array::{ArrayLength, GenericArray}; @@ -32,6 +32,7 @@ use subtle::{Choice, ConstantTimeEq}; pub trait UniversalHash: Clone { /// Size of the key for the universal hash function type KeySize: ArrayLength; + /// Size of the inputs to and outputs from the universal hash function type BlockSize: ArrayLength;