diff --git a/Cargo.toml b/Cargo.toml index 95b43b5..ce026a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,23 +12,23 @@ keywords = ["cryptography"] categories = ["cryptography"] # https://crates.io/category_slugs [dependencies] -bc-rand = "^0.4.0" -rand = "^0.8.5" -sha2 = "^0.10.6" -hmac = "^0.12.1" -pbkdf2 = "^0.12.1" -hkdf = "^0.12.3" +bc-rand = { git = "https://github.com/willrnch/bc-rand-rust.git", rev = "f6c187b211a39f159567fc6981d1676f015f88d7" } +rand = "^0.9.2" +sha2 = "0.11.0-rc.2" +hmac = "0.13.0-rc.1" +pbkdf2 = "0.13.0-rc.1" +hkdf = "0.13.0-rc.1" crc32fast = "^1.3.2" -chacha20poly1305 = "^0.10.1" +chacha20poly1305 = "0.11.0-rc.1" secp256k1 = "^0.30.0" -x25519-dalek = { version = "2.0.0-rc.2", features = ["static_secrets"] } +x25519-dalek = { version = "3.0.0-pre.1", features = ["static_secrets"] } thiserror = "^2.0" hex = "^0.4.3" -ed25519-dalek = { version = "2.1.1", features = ["rand_core"] } +ed25519-dalek = { version = "3.0.0-pre.1", features = ["rand_core"] } scrypt = { version = "0.11.0", default-features = false } -argon2 = "0.5.3" +argon2 = "0.6.0-rc.1" [dev-dependencies] -hex-literal = "^0.4.1" +hex-literal = "^1.0.0" hex = "^0.4.3" version-sync = "^0.9" diff --git a/src/ed25519_signing.rs b/src/ed25519_signing.rs index d8162bd..5402dab 100644 --- a/src/ed25519_signing.rs +++ b/src/ed25519_signing.rs @@ -1,13 +1,13 @@ -use chacha20poly1305::aead::rand_core::CryptoRngCore; use ed25519_dalek::ed25519::signature::Signer; use ed25519_dalek::SigningKey; use ed25519_dalek::Signature; +use rand::CryptoRng; pub const ED25519_PUBLIC_KEY_SIZE: usize = ed25519_dalek::PUBLIC_KEY_LENGTH; pub const ED25519_PRIVATE_KEY_SIZE: usize = ed25519_dalek::SECRET_KEY_LENGTH; pub const ED25519_SIGNATURE_SIZE: usize = ed25519_dalek::SIGNATURE_LENGTH; -pub fn ed25519_new_private_key_using(rng: &mut impl CryptoRngCore) -> [u8; ED25519_PRIVATE_KEY_SIZE] { +pub fn ed25519_new_private_key_using(rng: &mut impl CryptoRng) -> [u8; ED25519_PRIVATE_KEY_SIZE] { SigningKey::generate(rng).to_bytes() } diff --git a/src/hash.rs b/src/hash.rs index bc7087c..3a61911 100644 --- a/src/hash.rs +++ b/src/hash.rs @@ -1,5 +1,5 @@ use sha2::{Digest, Sha256, Sha512}; -use hmac::{Hmac, Mac}; +use hmac::{Hmac, KeyInit, Mac}; use pbkdf2::pbkdf2_hmac; use hkdf::Hkdf; diff --git a/src/symmetric_encryption.rs b/src/symmetric_encryption.rs index a60983c..1f59a5f 100644 --- a/src/symmetric_encryption.rs +++ b/src/symmetric_encryption.rs @@ -1,4 +1,5 @@ -use chacha20poly1305::{ChaCha20Poly1305, KeyInit, AeadInPlace}; +use chacha20poly1305::{AeadInOut, ChaCha20Poly1305, KeyInit}; + use crate::Result; pub const SYMMETRIC_KEY_SIZE: usize = 32; @@ -17,7 +18,7 @@ pub fn aead_chacha20_poly1305_encrypt_with_aad( ) -> (Vec, [u8; SYMMETRIC_AUTH_SIZE]) { let cipher = ChaCha20Poly1305::new(key.into()); let mut buffer = plaintext.as_ref().to_vec(); - let auth = cipher.encrypt_in_place_detached(nonce.into(), aad.as_ref(), &mut buffer).unwrap(); + let auth = cipher.encrypt_inout_detached(nonce.into(), aad.as_ref(), buffer.as_mut_slice().into()).unwrap(); (buffer, auth.to_vec().try_into().unwrap()) } @@ -49,7 +50,7 @@ pub fn aead_chacha20_poly1305_decrypt_with_aad( { let cipher = ChaCha20Poly1305::new(key.into()); let mut buffer = ciphertext.as_ref().to_vec(); - cipher.decrypt_in_place_detached(nonce.into(), aad.as_ref(), &mut buffer, auth.into())?; + cipher.decrypt_inout_detached(nonce.into(), aad.as_ref(), buffer.as_mut_slice().into(), auth.into())?; Ok(buffer) }