Skip to content

Commit

Permalink
Remove std feature in favor of alloc; MSRV 1.36+
Browse files Browse the repository at this point in the history
Previously the `std` feature gated `Zeroize` impls on `Box`, `String`,
and `Vec`.

Now that the `alloc` crate is stable, if we go MSRV 1.36+, we can always
source these types from there, and thereby eliminate the `std` feature.
  • Loading branch information
tony-iqlusion committed Aug 19, 2019
1 parent bd22cba commit 28e134a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 24 deletions.
3 changes: 1 addition & 2 deletions zeroize/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ travis-ci = { repository = "iqlusioninc/crates", branch = "develop" }
zeroize_derive = { version = "0.9", path = "../zeroize_derive", optional = true }

[features]
default = ["std", "zeroize_derive"]
default = ["alloc", "zeroize_derive"]
alloc = []
std = ["alloc"]
11 changes: 5 additions & 6 deletions zeroize/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
[![Crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
![Apache 2.0/MIT Licensed][license-image]
![Rust 1.35+][rustc-image]
![MSRV][rustc-image]
[![Build Status][build-image]][build-link]
[![Gitter Chat][gitter-image]][gitter-link]

Securely zero memory while avoiding compiler optimizations.

This crate provides a safe<sup>†</sup>, portable access to cross-platform
intrinsics for securely zeroing memory which are specifically documented as
guaranteeing they won't be "optimized away".
This crate implements a portable approach to securely zeroing memory using
techniques which guarantee they won't be "optimized away" by the compiler.

The [`Zeroize` trait] is the crate's primary API.

Expand All @@ -37,7 +36,7 @@ thereof, implemented in pure Rust with no usage of FFI or assembly.

## Requirements

- Rust 1.35+
- Rust **1.36+**

## License

Expand All @@ -60,7 +59,7 @@ 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.35+-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.36+-blue.svg
[build-image]: https://travis-ci.com/iqlusioninc/crates.svg?branch=develop
[build-link]: https://travis-ci.com/iqlusioninc/crates/
[gitter-image]: https://badges.gitter.im/iqlusioninc/community.svg
Expand Down
17 changes: 4 additions & 13 deletions zeroize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,9 @@
#![deny(warnings, missing_docs, trivial_casts, unused_qualifications)]
#![doc(html_root_url = "https://docs.rs/zeroize/0.9.3")]

#[cfg(all(feature = "alloc", not(feature = "std")))]
#[allow(unused_imports)] // rustc bug?
#[macro_use]
extern crate alloc;

#[cfg(any(feature = "std", test))]
#[cfg(feature = "alloc")]
#[cfg_attr(test, macro_use)]
extern crate std;
extern crate alloc;

#[cfg(feature = "zeroize_derive")]
#[allow(unused_imports)]
Expand All @@ -213,10 +208,8 @@ pub use zeroize_derive::*;

use core::{ops, ptr, slice::IterMut, sync::atomic};

#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(feature = "alloc")]
use alloc::{string::String, vec::Vec};
#[cfg(feature = "std")]
use std::{string::String, vec::Vec};

/// Trait for securely erasing types from memory
pub trait Zeroize {
Expand Down Expand Up @@ -414,10 +407,8 @@ fn volatile_set<T: Copy + Sized>(dst: &mut [T], src: T) {
#[cfg(test)]
mod tests {
use super::*;
#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(feature = "alloc")]
use alloc::boxed::Box;
#[cfg(feature = "std")]
use std::boxed::Box;

#[test]
fn zeroize_byte_arrays() {
Expand Down
6 changes: 3 additions & 3 deletions zeroize_derive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Crate][crate-image]][crate-link]
![Apache 2.0 Licensed/MIT][license-image]
![Rust 1.35+][rustc-image]
![MSRV][rustc-image]
[![Build Status][build-image]][build-link]

Custom derive support for [zeroize]: a crate for securely zeroing memory
Expand All @@ -13,7 +13,7 @@ See [zeroize] crate for documentation.

## Requirements

- Rust 1.35+
- Rust **1.36+**

## License

Expand All @@ -34,7 +34,7 @@ without any additional terms or conditions.
[crate-image]: https://img.shields.io/crates/v/zeroize_derive.svg
[crate-link]: https://crates.io/crates/zeroize_derive
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.35+-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.36+-blue.svg
[build-image]: https://travis-ci.com/iqlusioninc/crates.svg?branch=develop
[build-link]: https://travis-ci.com/iqlusioninc/crates/

Expand Down

0 comments on commit 28e134a

Please sign in to comment.