diff --git a/Cargo.lock b/Cargo.lock index 821deea..a1af01a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,7 @@ dependencies = [ "cfg-if", "cipher", "cpufeatures", + "zeroize", ] [[package]] @@ -328,6 +329,7 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e0196ed..1db212d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,9 @@ rust-version = "1.89" # Crypto x25519-dalek = { version = "2", features = ["static_secrets"] } ed25519-dalek = { version = "2", features = ["hazmat", "rand_core"] } -aes = "0.8" +aes = { version = "0.8", features = ["zeroize"] } des = "0.8" -cbc = { version = "0.1", features = ["alloc"] } +cbc = { version = "0.1", features = ["alloc", "zeroize"] } hkdf = "0.12" hmac = "0.12" md-5 = "0.10" diff --git a/api/fixtures/Cargo.lock b/api/fixtures/Cargo.lock index b746ee7..d337fcb 100644 --- a/api/fixtures/Cargo.lock +++ b/api/fixtures/Cargo.lock @@ -11,6 +11,7 @@ dependencies = [ "cfg-if", "cipher", "cpufeatures", + "zeroize", ] [[package]] @@ -225,6 +226,7 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] diff --git a/api/migrations/1.4.md b/api/migrations/1.4.md index 3f02646..a2f097e 100644 --- a/api/migrations/1.4.md +++ b/api/migrations/1.4.md @@ -117,6 +117,9 @@ wiped when it is dropped. Pass `&key[..]` where a slice is expected; the bytes are unchanged. `token::decrypt` still returns `Vec` and wipes its buffer when decryption fails; wrap a secret plaintext in `Zeroizing`. `Identity::from_file` refuses a file larger than 1 KiB without reading it. +rns-crypto enables the `zeroize` features of `aes` and `cbc`, so AES key +schedules and CBC state are wiped when dropped; dependents that build with +`--locked` refresh their lock files. The compatibility floor remains unchanged. Its cumulative exact-removal list also retains the already-reviewed [1.3 migration](1.3.md) for discovery ownership diff --git a/api/snapshots/manifest-contract.json b/api/snapshots/manifest-contract.json index 0e60591..b3ee50c 100644 --- a/api/snapshots/manifest-contract.json +++ b/api/snapshots/manifest-contract.json @@ -34,7 +34,9 @@ "requirement": "^0.8", "optional": false, "defaultFeatures": true, - "features": [], + "features": [ + "zeroize" + ], "sourceKind": "registry" }, { @@ -46,7 +48,8 @@ "optional": false, "defaultFeatures": true, "features": [ - "alloc" + "alloc", + "zeroize" ], "sourceKind": "registry" }, @@ -1052,7 +1055,9 @@ "requirement": "^0.8", "optional": false, "defaultFeatures": true, - "features": [], + "features": [ + "zeroize" + ], "sourceKind": "registry" }, { diff --git a/crates/rns-crypto/src/aes_cbc.rs b/crates/rns-crypto/src/aes_cbc.rs index 46c5599..f31b0d3 100644 --- a/crates/rns-crypto/src/aes_cbc.rs +++ b/crates/rns-crypto/src/aes_cbc.rs @@ -176,6 +176,15 @@ mod tests { assert_eq!(&pt[..], &plaintext[..]); } + #[test] + fn cipher_state_is_wiped_on_drop() { + fn wiped_on_drop() {} + wiped_on_drop::>(); + wiped_on_drop::>(); + wiped_on_drop::>(); + wiped_on_drop::>(); + } + /// Different key sizes must produce different ciphertexts for the same input. #[test] fn test_aes128_vs_aes256_distinct_ciphertexts() {