From 0f3cd09568673957181edf36dabaeda7110f6ce0 Mon Sep 17 00:00:00 2001 From: Radu Marias Date: Tue, 4 Jun 2024 01:55:28 +0300 Subject: [PATCH] examples, docs, version --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- examples/lock_and_zeroize.py | 2 ++ examples/zeroize_before_fork.py | 6 +++--- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b183ae0..26c4811 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -366,7 +366,7 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "zeroize" -version = "0.1.6" +version = "0.1.7" dependencies = [ "numpy", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index b293b7a..4330cad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "zeroize" -version = "0.1.6" +version = "0.1.7" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/README.md b/README.md index ba5129e..be4aace 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,8 @@ It uses [zeroize](https://crates.io/crates/zeroize) crate under the hood. It can work with `bytearray` and `numpy array`. > [!WARNING] -> **In the case of [Copy-on-write fork](https://en.wikipedia.org/wiki/Copy-on-write) you should zeroize the memory before fork the child process, see example below. -> Also by itself it doesn't work if memory is moved or moved to swap file. You can use `crypes` with `libc.mlock()` to lock the memory, see example below.** +> **In the case of [Copy-on-write fork](https://en.wikipedia.org/wiki/Copy-on-write) you need to zeroize the memory before forking the child process, see example below. +> Also by itself it doesn't work if memory is moved or moved to swap. You can use `crypes` with `libc.mlock()` to lock the memory, see example below.** # Examples diff --git a/examples/lock_and_zeroize.py b/examples/lock_and_zeroize.py index 38c1e26..6302ad2 100644 --- a/examples/lock_and_zeroize.py +++ b/examples/lock_and_zeroize.py @@ -1,3 +1,5 @@ +"""By itself it doesn't work if memory is moved or moved to swap. You can use `crypes` with `libc.mlock()` to lock the memory""" + from zeroize import zeroize1, zeroize_np import numpy as np import ctypes diff --git a/examples/zeroize_before_fork.py b/examples/zeroize_before_fork.py index b5c7db1..ccfcdb4 100644 --- a/examples/zeroize_before_fork.py +++ b/examples/zeroize_before_fork.py @@ -1,6 +1,7 @@ +""" In the case of [Copy-on-write fork](https://en.wikipedia.org/wiki/Copy-on-write) you need to zeroize the memory before forking the child process. """ + import os -from zeroize import zeroize1, zeroize_np -import numpy as np +from zeroize import zeroize1 import ctypes @@ -51,4 +52,3 @@ def unlock_memory(buffer): # Unlock the memory print("unlocking memory") unlock_memory(sensitive_data) - \ No newline at end of file