Module dryoc::dryocsecretbox::protected
source · Available on crate feature
nightly
only.Expand description
Protected memory type aliases for DryocSecretBox
This mod provides re-exports of type aliases for protected memory usage
with DryocSecretBox
. These type aliases are provided for
convenience.
Example
use dryoc::dryocsecretbox::protected::*;
use dryoc::dryocsecretbox::DryocSecretBox;
// Generate a random secret key, lock it, protect memory as read-only
let secret_key = Key::gen_readonly_locked().expect("key failed");
// Generate a random secret key, lock it, protect memory as read-only
let nonce = Nonce::gen_readonly_locked().expect("nonce failed");
// Load a message, lock it, protect memory as read-only
let message =
HeapBytes::from_slice_into_readonly_locked(b"Secret message from the tooth fairy")
.expect("message failed");
// Encrypt the message, placing the result into locked memory
let dryocsecretbox: LockedBox = DryocSecretBox::encrypt(&message, &nonce, &secret_key);
// Decrypt the message, placing the result into locked memory
let decrypted: LockedBytes = dryocsecretbox
.decrypt(&nonce, &secret_key)
.expect("decrypt failed");
assert_eq!(message.as_slice(), decrypted.as_slice());
Re-exports
Type Definitions
- Heap-allocated, page-aligned secret for authenticated secret box, for use with protected memory.
- Locked
DryocSecretBox
, provided as a type alias for convenience. - Heap-allocated, page-aligned secret box message authentication code, for use with protected memory.
- Heap-allocated, page-aligned nonce for authenticated secret box, for use with protected memory.