Available on crate feature
nightly
only.Expand description
Protected memory type aliases for DryocBox
This mod provides re-exports of type aliases for protected memory usage
with DryocBox
. These type aliases are provided for convenience.
Example
use dryoc::dryocbox::protected::*;
use dryoc::dryocbox::DryocBox;
// Generate a random sender and recipient keypair, into locked, readonly
// memory.
let sender_keypair = LockedROKeyPair::gen_readonly_locked_keypair().expect("keypair");
let recipient_keypair = LockedROKeyPair::gen_readonly_locked_keypair().expect("keypair");
// Generate a random nonce, into locked, readonly memory.
let nonce = Nonce::gen_readonly_locked().expect("nonce failed");
// Read message into locked, readonly memory.
let message = HeapBytes::from_slice_into_readonly_locked(b"Secret message from Santa Claus")
.expect("message failed");
// Encrypt message into a locked box.
let dryocbox: LockedBox = DryocBox::encrypt(
&message,
&nonce,
&recipient_keypair.public_key,
&sender_keypair.secret_key,
)
.expect("encrypt failed");
// Decrypt message into locked bytes.
let decrypted: LockedBytes = dryocbox
.decrypt(
&nonce,
&sender_keypair.public_key,
&recipient_keypair.secret_key,
)
.expect("decrypt failed");
assert_eq!(message.as_slice(), decrypted.as_slice());
Re-exports
pub use crate::protected::*;
Type Aliases
- Locked DryocBox, provided as a type alias for convenience.
- Heap-allocated, page-aligned public/secret keypair for authenticated public-key boxes, for use with protected memory.
- Heap-allocated, page-aligned public/secret keypair for authenticated public-key boxes, for use with protected memory.
- Heap-allocated, page-aligned message authentication code for authenticated public-key boxes, for use with protected memory.
- Heap-allocated, page-aligned nonce for authenticated public-key boxes, for use with protected memory.
- Heap-allocated, page-aligned public key for authenticated public-key boxes, for use with protected memory.
- Heap-allocated, page-aligned secret key for authenticated public-key boxes, for use with protected memory.