5 releases

โœ“ Uses Rust 2018 edition

0.1.4 Mar 9, 2019
0.1.3 Mar 9, 2019
0.1.2 Mar 9, 2019
0.1.1 Jan 21, 2019
0.1.0 Jan 21, 2019

#29 in Memory management

Download history 18/week @ 2019-01-16 12/week @ 2019-01-23 1/week @ 2019-01-30 1/week @ 2019-02-20 10/week @ 2019-02-27 34/week @ 2019-03-06 13/week @ 2019-03-13 55/week @ 2019-03-20 13/week @ 2019-03-27 8/week @ 2019-04-03 20/week @ 2019-04-10 12/week @ 2019-04-17 8/week @ 2019-04-24

52 downloads per month
Used in 1 crate

BSD-2-Clause OR MIT

16KB
182 lines

BSD-2-Clause License MIT License Travis CI Appveyor CI

MAProper

This crate provides the securely overwriting memory allocator MAProper ๐Ÿงน

What is MAProper

MAProper is an extension around std::alloc::System which ensures that the allocated memory is always erased before it is deallocated by using one of memset_s/SecureZeroMemory/explicit_bzero/explicit_memset.

Whats the purpose of MAProper

MAProper becomes handy if you're dealing with a lot of sensitive data: because the memory management of dynamically allocating types like Vec or String is opaque, you basically have no real chance to reliably trace and erase their sensitive contents.

However they all use the global allocator โ€“ so all ways lead to Rome (or in this case to the global allocator's alloc and dealloc functions) โ€“ which is where MAProper is sitting and waiting to take care of the discarded memory.

Using MAProper as global allocator (example)

#[global_allocator]
static MA_PROPER: MAProper = MAProper;

fn main() {
	// This `Vec` will allocate memory through `MA_PROPER` above
	let mut v = Vec::new();
	v.push(1);
}

Important

Please note that MAProper only erases memory that is deallocated properly. This especially means that:

  • stack items are not overwritten by this allocator โ€“ to erase stack memory, we expose MAProper::erase_slice and MAProper::erase_ptr<T> so that you can erase them manually if necessary
  • depending on your panic-policy and your Rc/Arc use (retain-cycles), the destructor (and thus the deallocator) may never be called

โš ๏ธ Beta-Warning โš ๏ธ

This crate is in an beta state; so be careful if you use it!

No runtime deps

~112KB