| Crates.io | ma_proper |
| lib.rs | ma_proper |
| version | 1.0.0 |
| created_at | 2019-01-21 00:20:21.362398+00 |
| updated_at | 2019-11-23 18:20:45.58705+00 |
| description | A securely overwriting memory allocator |
| homepage | |
| repository | https://github.com/KizzyCode/ma_proper |
| max_upload_size | |
| id | 109743 |
| size | 26,411 |
This crate provides the securely overwriting memory allocator MAProper ๐งน
MAProperMAProper 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.
MAProperMAProper 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.
MAProper as global allocator (example)#[global_allocator]
static MA_PROPER: ma_proper::MAProper = ma_proper::MAProper;
fn main() {
// This `Vec` will allocate memory through `MA_PROPER` above
let mut v = Vec::new();
v.push(1);
}
Please note that MAProper only erases memory that is deallocated properly. This especially means
that:
MAProper::erase_slice and MAProper::erase_ptr<T> so that you can erase them manually if
necessaryRc/Arc use (retain-cycles), the destructor (and thus
the deallocator) may never be called