diff --git a/Cargo.toml b/Cargo.toml index 4ba0e25..a0b69c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,22 +11,23 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -aes = { version = "0.7.4", features = ["ctr"] } -bs58 = "0.4.0" -x25519-dalek = { version = "2.0.0", features = ["static_secrets", "getrandom"] } -hmac = "0.11.0" -digest = "0.9" -log = "0.4" +aes = "0.8.4" +ctr = "0.9.2" +bs58 = "0.5.1" +x25519-dalek = { version = "2.0.1", features = ["static_secrets", "getrandom"] } +hmac = "0.12.1" +digest = "0.10.7" +log = "0.4.21" rand = "0.8.5" rand_distr = "0.4.3" -sha2 = "0.9.1" -hkdf = "0.11.0" +sha2 = "0.10.8" +hkdf = "0.12.4" lioness = "0.1.2" -arrayref = "0.3.5" +arrayref = "0.3.7" chacha = "0.3.0" blake2 = "0.8.0" # cannot be updated due to outdated dependency inside lioness -byteorder = "1.3.2" -subtle = "2.3.0" +byteorder = "1.5.0" +subtle = "2.4.1" [dev-dependencies] diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index a03081d..b9a5a3b 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -12,11 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -use aes::cipher::{NewCipher, StreamCipher}; -use aes::Aes128Ctr; -use digest::generic_array::{ArrayLength, GenericArray}; -use digest::{BlockInput, FixedOutput, Reset, Update}; -use hmac::{crypto_mac, Hmac, Mac, NewMac}; +use aes::{ + cipher::{KeyIvInit, StreamCipher}, + Aes128, +}; +use digest::{ + block_buffer::Eager, + consts::U256, + core_api::{BlockSizeUser, BufferKindUser, CoreProxy, FixedOutputCore}, + generic_array::GenericArray, + typenum::{IsLess, Le, NonZero}, + CtOutput, HashMarker, +}; +use hmac::{Hmac, Mac}; //type export and aliasing to keep compatibility pub use x25519_dalek::PublicKey; @@ -27,8 +35,9 @@ pub type EphemeralSecret = x25519_dalek::StaticSecret; pub const STREAM_CIPHER_KEY_SIZE: usize = 16; pub const STREAM_CIPHER_INIT_VECTOR: [u8; 16] = [0u8; 16]; -// Type alias for ease of use so that it would not require explicit import of crypto_mac or Hmac -pub type HmacOutput = crypto_mac::Output>; +// Type alias for ease of use +pub type HmacOutput = CtOutput>; +type Aes128Ctr = ctr::Ctr64BE; pub fn generate_pseudorandom_bytes( // TODO: those should use proper generic arrays to begin with!! @@ -50,9 +59,10 @@ pub fn generate_pseudorandom_bytes( /// Compute keyed hmac pub fn compute_keyed_hmac(key: &[u8], data: &[u8]) -> HmacOutput where - D: Update + BlockInput + FixedOutput + Reset + Default + Clone, - D::BlockSize: ArrayLength, - D::OutputSize: ArrayLength, + D: CoreProxy, + D::Core: HashMarker + FixedOutputCore + BufferKindUser + Default + Clone, + ::BlockSize: IsLess, + Le<::BlockSize, U256>: NonZero, { let mut hmac = Hmac::::new_from_slice(key).expect("HMAC should be able to take key of any size!");