From 2295098032556f55ef2314613269c76001461605 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 20 Dec 2024 15:26:45 +0100 Subject: [PATCH] Fix build --- Cargo.lock | 46 +++++++++++++++++++------ crates/bitwarden-crypto/Cargo.toml | 13 +++++-- crates/bitwarden-crypto/src/chacha20.rs | 2 +- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 524b990b..6252b41b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,7 +34,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", - "cipher", + "cipher 0.4.4", "cpufeatures", "zeroize", ] @@ -47,7 +47,7 @@ checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ "aead", "aes", - "cipher", + "cipher 0.4.4", "ctr", "ghash", "subtle", @@ -441,6 +441,7 @@ dependencies = [ "base64", "blake3", "cbc", + "chacha20 0.8.2", "chacha20poly1305", "criterion", "generic-array", @@ -449,6 +450,7 @@ dependencies = [ "num-bigint", "num-traits", "pbkdf2", + "poly1305", "rand", "rand_chacha", "rayon", @@ -732,7 +734,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e412e2cd0f2b2d93e02543ceae7917b3c70331573df19ee046bcbc35e45e87d7" dependencies = [ "byteorder", - "cipher", + "cipher 0.4.4", ] [[package]] @@ -815,7 +817,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -845,6 +847,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "chacha20" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures", + "zeroize", +] + [[package]] name = "chacha20" version = "0.9.1" @@ -852,7 +866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", - "cipher", + "cipher 0.4.4", "cpufeatures", ] @@ -863,8 +877,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ "aead", - "chacha20", - "cipher", + "chacha20 0.9.1", + "cipher 0.4.4", "poly1305", "zeroize", ] @@ -911,6 +925,15 @@ dependencies = [ "half", ] +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array", +] + [[package]] name = "cipher" version = "0.4.4" @@ -1251,7 +1274,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -2864,6 +2887,7 @@ dependencies = [ "cpufeatures", "opaque-debug", "universal-hash", + "zeroize", ] [[package]] @@ -3310,7 +3334,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -3724,8 +3748,8 @@ dependencies = [ "aes", "aes-gcm", "cbc", - "chacha20", - "cipher", + "chacha20 0.9.1", + "cipher 0.4.4", "ctr", "poly1305", "ssh-encoding", diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index d3b8a065..f12791b4 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -14,13 +14,18 @@ license-file.workspace = true keywords.workspace = true [features] -default = [] +default = [] # Default features wasm = ["dep:tsify-next", "dep:wasm-bindgen"] # WASM support uniffi = ["dep:uniffi"] # Uniffi bindings no-memory-hardening = [] # Disable memory hardening features -aead-crypto = [] +aead-crypto = [ + "dep:blake3", + "dep:chacha20", + "dep:chacha20poly1305", + "dep:poly1305", +] [dependencies] aes = { version = ">=0.8.2, <0.9", features = ["zeroize"] } @@ -31,6 +36,9 @@ argon2 = { version = ">=0.5.0, <0.6", features = [ base64 = ">=0.22.1, <0.23" blake3 = { version = "1.5.5", features = ["zeroize"], optional = true } cbc = { version = ">=0.1.2, <0.2", features = ["alloc", "zeroize"] } +chacha20 = { version = ">=0.8.2, <0.9", features = [ + "zeroize", +], optional = true } chacha20poly1305 = { version = "0.10.1", optional = true } generic-array = { version = ">=0.14.7, <1.0", features = ["zeroize"] } hkdf = ">=0.12.3, <0.13" @@ -38,6 +46,7 @@ hmac = ">=0.12.1, <0.13" num-bigint = ">=0.4, <0.5" num-traits = ">=0.2.15, <0.3" pbkdf2 = { version = ">=0.12.1, <0.13", default-features = false } +poly1305 = { version = "0.8.0", features = ["zeroize"], optional = true } rand = ">=0.8.5, <0.9" rayon = ">=1.8.1, <2.0" rsa = ">=0.9.2, <0.10" diff --git a/crates/bitwarden-crypto/src/chacha20.rs b/crates/bitwarden-crypto/src/chacha20.rs index c437bce0..096d0fee 100644 --- a/crates/bitwarden-crypto/src/chacha20.rs +++ b/crates/bitwarden-crypto/src/chacha20.rs @@ -1,5 +1,5 @@ use chacha20::{ - cipher::{KeyIvInit, StreamCipher}, + cipher::{NewCipher, StreamCipher}, XChaCha20, }; use chacha20poly1305::{AeadCore, AeadInPlace, KeyInit, XChaCha20Poly1305};