diff --git a/.github/workflows/blobby.yml b/.github/workflows/blobby.yml index 2834a42f..0b2550f5 100644 --- a/.github/workflows/blobby.yml +++ b/.github/workflows/blobby.yml @@ -32,3 +32,8 @@ jobs: toolchain: ${{ matrix.rust }} override: true - run: cargo test --release + + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} diff --git a/.github/workflows/block-buffer.yml b/.github/workflows/block-buffer.yml index 11f5d2f3..2a733905 100644 --- a/.github/workflows/block-buffer.yml +++ b/.github/workflows/block-buffer.yml @@ -36,6 +36,12 @@ jobs: target: ${{ matrix.target }} override: true - run: cargo build --release --target ${{ matrix.target }} + + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/block-padding.yml b/.github/workflows/block-padding.yml index 6d5e38a9..391bb0bb 100644 --- a/.github/workflows/block-padding.yml +++ b/.github/workflows/block-padding.yml @@ -36,6 +36,12 @@ jobs: target: ${{ matrix.target }} override: true - run: cargo build --target ${{ matrix.target }} + + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/cpufeatures.yml b/.github/workflows/cpufeatures.yml index 8d6828e8..68a68cc1 100644 --- a/.github/workflows/cpufeatures.yml +++ b/.github/workflows/cpufeatures.yml @@ -17,6 +17,11 @@ env: RUSTFLAGS: "-Dwarnings" jobs: + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + # Linux tests linux: strategy: diff --git a/.github/workflows/dbl.yml b/.github/workflows/dbl.yml index 8d431bbb..2bf9a9ec 100644 --- a/.github/workflows/dbl.yml +++ b/.github/workflows/dbl.yml @@ -36,6 +36,12 @@ jobs: target: ${{ matrix.target }} override: true - run: cargo build --release --target ${{ matrix.target }} + + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/hex-literal.yml b/.github/workflows/hex-literal.yml index 0eecb706..53382371 100644 --- a/.github/workflows/hex-literal.yml +++ b/.github/workflows/hex-literal.yml @@ -36,6 +36,12 @@ jobs: target: ${{ matrix.target }} override: true - run: cargo build --release --target ${{ matrix.target }} + + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/inout.yml b/.github/workflows/inout.yml index ccd5cbb5..a8e263d0 100644 --- a/.github/workflows/inout.yml +++ b/.github/workflows/inout.yml @@ -37,6 +37,12 @@ jobs: override: true - run: cargo build --target ${{ matrix.target }} - run: cargo build --features block-padding --target ${{ matrix.target }} + + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/opaque-debug.yml b/.github/workflows/opaque-debug.yml index 8493e54b..6834ae10 100644 --- a/.github/workflows/opaque-debug.yml +++ b/.github/workflows/opaque-debug.yml @@ -36,6 +36,12 @@ jobs: target: ${{ matrix.target }} override: true - run: cargo build --release --target ${{ matrix.target }} + + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/zeroize.yml b/.github/workflows/zeroize.yml index efdb8de8..03245b7d 100644 --- a/.github/workflows/zeroize.yml +++ b/.github/workflows/zeroize.yml @@ -38,6 +38,11 @@ jobs: profile: minimal - run: cargo build --no-default-features --release --target ${{ matrix.target }} + minimal-versions: + uses: RustCrypto/actions/.github/workflows/minimal-versions.yml@master + with: + working-directory: ${{ github.workflow }} + test: strategy: matrix: diff --git a/Cargo.lock b/Cargo.lock index a4b8026f..cacdc42b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -62,9 +62,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "libc" -version = "0.2.117" +version = "0.2.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c" +checksum = "06e509672465a0504304aa87f9f176f2b2b716ed8fb105ebe5c02dc6dce96a94" [[package]] name = "opaque-debug" @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" +checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" dependencies = [ "itoa", "ryu", @@ -185,7 +185,7 @@ dependencies = [ [[package]] name = "zeroize_derive" -version = "1.3.1" +version = "1.3.2" dependencies = [ "proc-macro2", "quote", diff --git a/zeroize/derive/CHANGELOG.md b/zeroize/derive/CHANGELOG.md index 4c49d8b4..1ecaef26 100644 --- a/zeroize/derive/CHANGELOG.md +++ b/zeroize/derive/CHANGELOG.md @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 1.3.1 (2021-01-14) +## 1.3.2 (2022-02-18) +### Fixed +- Min versions build ([#732]) + +[#732]: https://github.com/RustCrypto/utils/pull/732 + +## 1.3.1 (2021-01-14) [YANKED] ### Removed - `ZeroizeOnDrop` implementation for `#[zeroize(drop)]` ([#715]) diff --git a/zeroize/derive/Cargo.toml b/zeroize/derive/Cargo.toml index bad02b70..4bac91a3 100644 --- a/zeroize/derive/Cargo.toml +++ b/zeroize/derive/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "zeroize_derive" description = "Custom derive support for zeroize" -version = "1.3.1" +version = "1.3.2" authors = ["The RustCrypto Project Developers"] license = "Apache-2.0 OR MIT" repository = "https://github.com/RustCrypto/utils/tree/master/zeroize/derive" diff --git a/zeroize/tests/zeroize_derive.rs b/zeroize/tests/zeroize_derive.rs index 9775ab06..5df21488 100644 --- a/zeroize/tests/zeroize_derive.rs +++ b/zeroize/tests/zeroize_derive.rs @@ -1,288 +1,289 @@ //! Integration tests for `zeroize_derive` proc macros +#![cfg(feature = "zeroize_derive")] -#[cfg(feature = "zeroize_derive")] -mod custom_derive_tests { - use zeroize::{Zeroize, ZeroizeOnDrop}; +use zeroize::{Zeroize, ZeroizeOnDrop}; - #[test] - fn derive_tuple_struct_test() { - #[derive(Zeroize, ZeroizeOnDrop)] - struct Z([u8; 3]); +#[test] +fn derive_tuple_struct_test() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z([u8; 3]); - let mut value = Z([1, 2, 3]); - value.zeroize(); - assert_eq!(&value.0, &[0, 0, 0]) + let mut value = Z([1, 2, 3]); + value.zeroize(); + assert_eq!(&value.0, &[0, 0, 0]) +} + +#[test] +#[cfg(feature = "alloc")] +fn derive_struct_test() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z { + string: String, + vec: Vec, + bytearray: [u8; 3], + number: usize, + boolean: bool, } - #[test] - fn derive_struct_test() { - #[derive(Zeroize, ZeroizeOnDrop)] - struct Z { - string: String, - vec: Vec, - bytearray: [u8; 3], - number: usize, - boolean: bool, - } - - let mut value = Z { - string: String::from("Hello, world!"), - vec: vec![1, 2, 3], - bytearray: [4, 5, 6], - number: 42, - boolean: true, - }; - - value.zeroize(); - - assert!(value.string.is_empty()); - assert!(value.vec.is_empty()); - assert_eq!(&value.bytearray, &[0, 0, 0]); - assert_eq!(value.number, 0); - assert!(!value.boolean); + let mut value = Z { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(value.string.is_empty()); + assert!(value.vec.is_empty()); + assert_eq!(&value.bytearray, &[0, 0, 0]); + assert_eq!(value.number, 0); + assert!(!value.boolean); +} + +#[test] +fn derive_enum_test() { + #[derive(Zeroize, ZeroizeOnDrop)] + enum Z { + #[allow(dead_code)] + Variant1, + Variant2(usize), } - #[test] - fn derive_enum_test() { - #[derive(Zeroize, ZeroizeOnDrop)] - enum Z { - #[allow(dead_code)] - Variant1, - Variant2(usize), - } + let mut value = Z::Variant2(26); - let mut value = Z::Variant2(26); + value.zeroize(); - value.zeroize(); + assert!(matches!(value, Z::Variant2(0))); +} - assert!(matches!(value, Z::Variant2(0))); - } +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_struct_drop() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z([u8; 3]); - /// Test that the custom macro actually derived `Drop` for `Z` - #[test] - fn derive_struct_drop() { - #[derive(Zeroize, ZeroizeOnDrop)] - struct Z([u8; 3]); + assert!(std::mem::needs_drop::()); +} - assert!(std::mem::needs_drop::()); +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_enum_drop() { + #[allow(dead_code)] + #[derive(Zeroize, ZeroizeOnDrop)] + enum Z { + Variant1, + Variant2(usize), } - /// Test that the custom macro actually derived `Drop` for `Z` - #[test] - fn derive_enum_drop() { - #[allow(dead_code)] - #[derive(Zeroize, ZeroizeOnDrop)] - enum Z { - Variant1, - Variant2(usize), - } + assert!(std::mem::needs_drop::()); +} - assert!(std::mem::needs_drop::()); - } +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_struct_only_drop() { + #[derive(ZeroizeOnDrop)] + struct Z([u8; 3]); - /// Test that the custom macro actually derived `Drop` for `Z` - #[test] - fn derive_struct_only_drop() { - #[derive(ZeroizeOnDrop)] - struct Z([u8; 3]); + assert!(std::mem::needs_drop::()); +} - assert!(std::mem::needs_drop::()); +/// Test that the custom macro actually derived `Drop` for `Z` +#[test] +fn derive_enum_only_drop() { + #[allow(dead_code)] + #[derive(ZeroizeOnDrop)] + enum Z { + Variant1, + Variant2(usize), } - /// Test that the custom macro actually derived `Drop` for `Z` - #[test] - fn derive_enum_only_drop() { - #[allow(dead_code)] - #[derive(ZeroizeOnDrop)] - enum Z { - Variant1, - Variant2(usize), - } + assert!(std::mem::needs_drop::()); +} - assert!(std::mem::needs_drop::()); - } +/// Test that `Drop` is not derived in the following case by defining a +/// `Drop` impl which should conflict if the custom derive defined one too +#[allow(dead_code)] +#[derive(Zeroize)] +struct ZeroizeNoDropStruct([u8; 3]); - /// Test that `Drop` is not derived in the following case by defining a - /// `Drop` impl which should conflict if the custom derive defined one too - #[allow(dead_code)] - #[derive(Zeroize)] - struct ZeroizeNoDropStruct([u8; 3]); +impl Drop for ZeroizeNoDropStruct { + fn drop(&mut self) {} +} - impl Drop for ZeroizeNoDropStruct { - fn drop(&mut self) {} - } +#[allow(dead_code)] +#[derive(Zeroize)] +enum ZeroizeNoDropEnum { + Variant([u8; 3]), +} - #[allow(dead_code)] - #[derive(Zeroize)] - enum ZeroizeNoDropEnum { - Variant([u8; 3]), - } +impl Drop for ZeroizeNoDropEnum { + fn drop(&mut self) {} +} - impl Drop for ZeroizeNoDropEnum { - fn drop(&mut self) {} +#[test] +#[cfg(feature = "alloc")] +fn derive_struct_skip() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z { + string: String, + vec: Vec, + #[zeroize(skip)] + bytearray: [u8; 3], + number: usize, + boolean: bool, } - #[test] - fn derive_struct_skip() { - #[derive(Zeroize, ZeroizeOnDrop)] - struct Z { + let mut value = Z { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(value.string.is_empty()); + assert!(value.vec.is_empty()); + assert_eq!(&value.bytearray, &[4, 5, 6]); + assert_eq!(value.number, 0); + assert!(!value.boolean); +} + +#[test] +#[cfg(feature = "alloc")] +fn derive_enum_skip() { + #[derive(Zeroize, ZeroizeOnDrop)] + enum Z { + #[allow(dead_code)] + Variant1, + #[zeroize(skip)] + Variant2([u8; 3]), + #[zeroize(skip)] + Variant3 { + string: String, + vec: Vec, + bytearray: [u8; 3], + number: usize, + boolean: bool, + }, + Variant4 { string: String, vec: Vec, #[zeroize(skip)] bytearray: [u8; 3], number: usize, boolean: bool, - } - - let mut value = Z { - string: String::from("Hello, world!"), - vec: vec![1, 2, 3], - bytearray: [4, 5, 6], - number: 42, - boolean: true, - }; - - value.zeroize(); - - assert!(value.string.is_empty()); - assert!(value.vec.is_empty()); - assert_eq!(&value.bytearray, &[4, 5, 6]); - assert_eq!(value.number, 0); - assert!(!value.boolean); + }, } - #[test] - fn derive_enum_skip() { - #[derive(Zeroize, ZeroizeOnDrop)] - enum Z { - #[allow(dead_code)] - Variant1, - #[zeroize(skip)] - Variant2([u8; 3]), - #[zeroize(skip)] - Variant3 { - string: String, - vec: Vec, - bytearray: [u8; 3], - number: usize, - boolean: bool, - }, - Variant4 { - string: String, - vec: Vec, - #[zeroize(skip)] - bytearray: [u8; 3], - number: usize, - boolean: bool, - }, - } - - let mut value = Z::Variant2([4, 5, 6]); - - value.zeroize(); - - assert!(matches!(&value, Z::Variant2([4, 5, 6]))); - - let mut value = Z::Variant3 { - string: String::from("Hello, world!"), - vec: vec![1, 2, 3], - bytearray: [4, 5, 6], - number: 42, - boolean: true, - }; - - value.zeroize(); - - assert!(matches!( - &value, - Z::Variant3 { string, vec, bytearray, number, boolean } - if string == "Hello, world!" && - vec == &[1, 2, 3] && - bytearray == &[4, 5, 6] && - *number == 42 && - *boolean - )); - - let mut value = Z::Variant4 { - string: String::from("Hello, world!"), - vec: vec![1, 2, 3], - bytearray: [4, 5, 6], - number: 42, - boolean: true, - }; - - value.zeroize(); - - assert!(matches!( - &value, - Z::Variant4 { string, vec, bytearray, number, boolean } - if string.is_empty() && - vec.is_empty() && - bytearray == &[4, 5, 6] && - *number == 0 && - !boolean - )); - } + let mut value = Z::Variant2([4, 5, 6]); + + value.zeroize(); + + assert!(matches!(&value, Z::Variant2([4, 5, 6]))); + + let mut value = Z::Variant3 { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(matches!( + &value, + Z::Variant3 { string, vec, bytearray, number, boolean } + if string == "Hello, world!" && + vec == &[1, 2, 3] && + bytearray == &[4, 5, 6] && + *number == 42 && + *boolean + )); + + let mut value = Z::Variant4 { + string: String::from("Hello, world!"), + vec: vec![1, 2, 3], + bytearray: [4, 5, 6], + number: 42, + boolean: true, + }; + + value.zeroize(); + + assert!(matches!( + &value, + Z::Variant4 { string, vec, bytearray, number, boolean } + if string.is_empty() && + vec.is_empty() && + bytearray == &[4, 5, 6] && + *number == 0 && + !boolean + )); +} - #[test] - fn derive_bound() { - trait T: Zeroize {} +#[test] +fn derive_bound() { + trait T: Zeroize {} - impl T for u8 {} + impl T for u8 {} - #[derive(Zeroize)] - #[zeroize(bound = "X: T")] - struct Z(X); + #[derive(Zeroize)] + #[zeroize(bound = "X: T")] + struct Z(X); - let mut value = Z(5_u8); + let mut value = Z(5_u8); - value.zeroize(); + value.zeroize(); - assert_eq!(value.0, 0); - } + assert_eq!(value.0, 0); +} - #[test] - fn derive_inherit_zeroize_on_drop() { - #[derive(ZeroizeOnDrop)] - struct X([u8; 3]); +#[test] +fn derive_inherit_zeroize_on_drop() { + #[derive(ZeroizeOnDrop)] + struct X([u8; 3]); - #[derive(ZeroizeOnDrop)] - struct Z(X); + #[derive(ZeroizeOnDrop)] + struct Z(X); - let mut value = Z(X([1, 2, 3])); - unsafe { - std::ptr::drop_in_place(&mut value); - } - assert_eq!(&value.0 .0, &[0, 0, 0]) + let mut value = Z(X([1, 2, 3])); + unsafe { + std::ptr::drop_in_place(&mut value); } + assert_eq!(&value.0 .0, &[0, 0, 0]) +} - #[test] - fn derive_inherit_from_both() { - #[derive(Zeroize, ZeroizeOnDrop)] - struct X([u8; 3]); +#[test] +fn derive_inherit_from_both() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct X([u8; 3]); - #[derive(ZeroizeOnDrop)] - struct Z(X); + #[derive(ZeroizeOnDrop)] + struct Z(X); - let mut value = Z(X([1, 2, 3])); - unsafe { - std::ptr::drop_in_place(&mut value); - } - assert_eq!(&value.0 .0, &[0, 0, 0]) + let mut value = Z(X([1, 2, 3])); + unsafe { + std::ptr::drop_in_place(&mut value); } + assert_eq!(&value.0 .0, &[0, 0, 0]) +} - #[test] - fn derive_inherit_both() { - #[derive(Zeroize, ZeroizeOnDrop)] - struct X([u8; 3]); +#[test] +fn derive_inherit_both() { + #[derive(Zeroize, ZeroizeOnDrop)] + struct X([u8; 3]); - #[derive(Zeroize, ZeroizeOnDrop)] - struct Z(X); + #[derive(Zeroize, ZeroizeOnDrop)] + struct Z(X); - let mut value = Z(X([1, 2, 3])); - unsafe { - std::ptr::drop_in_place(&mut value); - } - assert_eq!(&value.0 .0, &[0, 0, 0]) + let mut value = Z(X([1, 2, 3])); + unsafe { + std::ptr::drop_in_place(&mut value); } + assert_eq!(&value.0 .0, &[0, 0, 0]) }