aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp31
-rw-r--r--CHANGELOG.md12
-rw-r--r--Cargo.toml6
-rw-r--r--Cargo.toml.orig5
-rw-r--r--LICENSE-MIT21
-rw-r--r--METADATA15
-rw-r--r--README.md4
-rw-r--r--TEST_MAPPING14
-rw-r--r--cargo2android.json1
-rw-r--r--cargo2android_nostd.bp20
-rw-r--r--src/aarch64.rs4
-rw-r--r--src/lib.rs31
-rw-r--r--tests/zeroize_derive.rs10
14 files changed, 154 insertions, 22 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 2a2f561..8ba8371 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "5e46d483c61cf2ab0a69cc060ea604946b0b28ce"
+ "sha1": "53030865ef42b362cdf21874b69c1ba21cda7b5b"
},
"path_in_vcs": "zeroize"
} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index c0c8306..1f468e4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -36,9 +36,9 @@ rust_library {
host_supported: true,
crate_name: "zeroize",
cargo_env_compat: true,
- cargo_pkg_version: "1.5.7",
+ cargo_pkg_version: "1.6.0",
srcs: ["src/lib.rs"],
- edition: "2018",
+ edition: "2021",
features: [
"alloc",
"zeroize_derive",
@@ -49,6 +49,7 @@ rust_library {
"com.android.uwb",
"com.android.virt",
],
+ product_available: true,
vendor_available: true,
min_sdk_version: "Tiramisu",
}
@@ -57,10 +58,10 @@ rust_defaults {
name: "zeroize_test_defaults",
crate_name: "zeroize",
cargo_env_compat: true,
- cargo_pkg_version: "1.5.7",
+ cargo_pkg_version: "1.6.0",
test_suites: ["general-tests"],
auto_gen_config: true,
- edition: "2018",
+ edition: "2021",
features: [
"alloc",
"zeroize_derive",
@@ -90,3 +91,25 @@ rust_test {
unit_test: true,
},
}
+
+rust_library_rlib {
+ name: "libzeroize_nostd",
+ crate_name: "zeroize",
+ cargo_env_compat: true,
+ cargo_pkg_version: "1.5.7",
+ srcs: ["src/lib.rs"],
+ edition: "2018",
+ proc_macros: ["libzeroize_derive"],
+ prefer_rlib: true,
+ no_stdlibs: true,
+ stdlibs: [
+ "libcompiler_builtins.rust_sysroot",
+ "libcore.rust_sysroot",
+ ],
+ features: [
+ "zeroize_derive",
+ ],
+ vendor_available: true,
+ min_sdk_version: "Tiramisu",
+}
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 83f8958..12fded9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,18 @@ 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.6.0 (2023-03-26)
+### Added
+- Impl `Zeroize` for `core::num::Wrapping` ([#818])
+- Impl `Zeroize` for `str` and `Box<str>` ([#842])
+
+### Changed
+- 2021 edition upgrade; MSRV 1.56 ([#869])
+
+[#818]: https://github.com/RustCrypto/utils/pull/818
+[#842]: https://github.com/RustCrypto/utils/pull/842
+[#869]: https://github.com/RustCrypto/utils/pull/869
+
## 1.5.7 (2022-07-20)
### Added
- Optional `serde` support ([#780])
diff --git a/Cargo.toml b/Cargo.toml
index a70f551..636d969 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,9 +10,10 @@
# See Cargo.toml.orig for the original contents.
[package]
-edition = "2018"
+edition = "2021"
+rust-version = "1.56"
name = "zeroize"
-version = "1.5.7"
+version = "1.6.0"
authors = ["The RustCrypto Project Developers"]
description = """
Securely clear secrets from memory with a simple trait built on
@@ -37,6 +38,7 @@ categories = [
]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/RustCrypto/utils/tree/master/zeroize"
+resolver = "1"
[package.metadata.docs.rs]
all-features = true
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 3efc8f4..d1bbf81 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,5 +1,6 @@
[package]
name = "zeroize"
+version = "1.6.0"
description = """
Securely clear secrets from memory with a simple trait built on
stable Rust primitives which guarantee memory is zeroed using an
@@ -7,14 +8,14 @@ operation will not be 'optimized away' by the compiler.
Uses a portable pure Rust implementation that works everywhere,
even WASM!
"""
-version = "1.5.7"
authors = ["The RustCrypto Project Developers"]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/RustCrypto/utils/tree/master/zeroize"
readme = "README.md"
categories = ["cryptography", "memory-management", "no-std", "os"]
keywords = ["memory", "memset", "secure", "volatile", "zero"]
-edition = "2018"
+edition = "2021"
+rust-version = "1.56"
[dependencies]
serde = { version = "1.0", default-features = false, optional = true }
diff --git a/LICENSE-MIT b/LICENSE-MIT
new file mode 100644
index 0000000..3a2b004
--- /dev/null
+++ b/LICENSE-MIT
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018-2021 The RustCrypto Project Developers
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/METADATA b/METADATA
index 9f11c02..a43848d 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/zeroize
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
name: "zeroize"
description: "Securely zero memory while avoiding compiler optimizations."
third_party {
@@ -7,14 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/zeroize/zeroize-1.5.7.crate"
+ value: "https://static.crates.io/crates/zeroize/zeroize-1.6.0.crate"
}
- version: "1.5.7"
- # Dual-licensed, using the least restrictive per go/thirdpartylicenses#same.
+ version: "1.6.0"
license_type: NOTICE
last_upgrade_date {
- year: 2022
- month: 9
- day: 6
+ year: 2023
+ month: 3
+ day: 30
}
}
diff --git a/README.md b/README.md
index 4f71ab4..0156ac0 100644
--- a/README.md
+++ b/README.md
@@ -36,7 +36,7 @@ thereof, implemented in pure Rust with no usage of FFI or assembly.
## Minimum Supported Rust Version
-Rust **1.51** or newer.
+Rust **1.56** or newer.
In the future, we reserve the right to change MSRV (i.e. MSRV is out-of-scope
for this crate's SemVer guarantees), however when we do it will be accompanied by
@@ -64,7 +64,7 @@ dual licensed as above, without any additional terms or conditions.
[docs-image]: https://docs.rs/zeroize/badge.svg
[docs-link]: https://docs.rs/zeroize/
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
-[rustc-image]: https://img.shields.io/badge/rustc-1.51+-blue.svg
+[rustc-image]: https://img.shields.io/badge/rustc-1.56+-blue.svg
[build-image]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml/badge.svg
[build-link]: https://github.com/RustCrypto/utils/actions/workflows/zeroize.yml
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..6a42101
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,14 @@
+// Generated by update_crate_tests.py for tests that depend on this crate.
+{
+ "imports": [
+ {
+ "path": "external/uwb/src"
+ },
+ {
+ "path": "system/keymint/derive"
+ },
+ {
+ "path": "system/keymint/hal"
+ }
+ ]
+}
diff --git a/cargo2android.json b/cargo2android.json
index 29e5445..d05dd9f 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -1,4 +1,5 @@
{
+ "add-toplevel-block": "cargo2android_nostd.bp",
"apex-available": [
"//apex_available:platform",
"com.android.uwb",
diff --git a/cargo2android_nostd.bp b/cargo2android_nostd.bp
new file mode 100644
index 0000000..d7f5eb2
--- /dev/null
+++ b/cargo2android_nostd.bp
@@ -0,0 +1,20 @@
+rust_library_rlib {
+ name: "libzeroize_nostd",
+ crate_name: "zeroize",
+ cargo_env_compat: true,
+ cargo_pkg_version: "1.5.7",
+ srcs: ["src/lib.rs"],
+ edition: "2018",
+ proc_macros: ["libzeroize_derive"],
+ prefer_rlib: true,
+ no_stdlibs: true,
+ stdlibs: [
+ "libcompiler_builtins.rust_sysroot",
+ "libcore.rust_sysroot",
+ ],
+ features: [
+ "zeroize_derive",
+ ],
+ vendor_available: true,
+ min_sdk_version: "Tiramisu",
+}
diff --git a/src/aarch64.rs b/src/aarch64.rs
index fc6c8f2..956f648 100644
--- a/src/aarch64.rs
+++ b/src/aarch64.rs
@@ -1,7 +1,7 @@
//! [`Zeroize`] impls for ARM64 SIMD registers.
//!
-//! Support for this is gated behind an `aarch64` feature because
-//! support for `core::arch::aarch64` is currently nightly-only.
+//! Gated behind the `aarch64` feature: MSRV 1.59
+//! (the overall crate is MSRV 1.51)
use crate::{atomic_fence, volatile_write, Zeroize};
diff --git a/src/lib.rs b/src/lib.rs
index 9de75bc..1dd35f2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -64,7 +64,7 @@
//!
//! With the `std` feature enabled (which it is **not** by default), [`Zeroize`]
//! is also implemented for [`CString`]. After calling `zeroize()` on a `CString`,
-//! it will its internal buffer will contain exactly one nul byte. The backing
+//! its internal buffer will contain exactly one nul byte. The backing
//! memory is zeroed by converting it to a `Vec<u8>` and back into a `CString`.
//! (NOTE: see "Stack/Heap Zeroing Notes" for important `Vec`/`String`/`CString` details)
//!
@@ -258,8 +258,8 @@ use core::{
marker::{PhantomData, PhantomPinned},
mem::{self, MaybeUninit},
num::{
- NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
- NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
+ self, NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize,
+ NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
},
ops, ptr,
slice::IterMut,
@@ -353,6 +353,15 @@ impl_zeroize_for_non_zero!(
NonZeroUsize
);
+impl<Z> Zeroize for num::Wrapping<Z>
+where
+ Z: Zeroize,
+{
+ fn zeroize(&mut self) {
+ self.0.zeroize();
+ }
+}
+
/// Impl [`Zeroize`] on arrays of types that impl [`Zeroize`].
impl<Z, const N: usize> Zeroize for [Z; N]
where
@@ -471,6 +480,14 @@ where
}
}
+impl Zeroize for str {
+ fn zeroize(&mut self) {
+ // Safety:
+ // A zeroized byte slice is a valid UTF-8 string.
+ unsafe { self.as_bytes_mut().zeroize() }
+ }
+}
+
/// [`PhantomData`] is always zero sized so provide a [`Zeroize`] implementation.
impl<Z> Zeroize for PhantomData<Z> {
fn zeroize(&mut self) {}
@@ -585,6 +602,14 @@ impl<Z> ZeroizeOnDrop for Box<[Z]> where Z: ZeroizeOnDrop {}
#[cfg(feature = "alloc")]
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
+impl Zeroize for Box<str> {
+ fn zeroize(&mut self) {
+ self.as_mut().zeroize();
+ }
+}
+
+#[cfg(feature = "alloc")]
+#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]
impl Zeroize for String {
fn zeroize(&mut self) {
unsafe { self.as_mut_vec() }.zeroize();
diff --git a/tests/zeroize_derive.rs b/tests/zeroize_derive.rs
index 4e0fdc6..96c10c3 100644
--- a/tests/zeroize_derive.rs
+++ b/tests/zeroize_derive.rs
@@ -315,3 +315,13 @@ fn derive_deref() {
}
assert_eq!(&value.0 .0, &[0, 0, 0])
}
+
+#[test]
+#[cfg(feature = "alloc")]
+fn derive_zeroize_on_drop_generic() {
+ #[derive(ZeroizeOnDrop)]
+ struct Y<T: Zeroize>(Box<T>);
+
+ #[derive(ZeroizeOnDrop)]
+ struct Z<T: Zeroize>(Vec<T>);
+}