Skip to main content

Module secret

Module secret 

Source
Expand description

Secret bytes and the zeroize helpers.

This module is the one import path for zeroization in libxmtp:

  • Secret owns secret bytes in a struct field, a return value or a long-lived binding. It is wiped on drop and its Debug shows only the length.
  • Zeroizing wraps a transient buffer (a serialization output, a to_vec(), an FFI argument) at the point where it is created. Its Debug prints the inner value, so never format one.
  • Zeroize and ZeroizeOnDrop are for hand-written secret holders.

With the test-utils feature, heap_canary provides the test allocator that proves a secret is wiped before its heap block is freed.

Structs§

Secret
Owned secret bytes. Wiped on drop; Debug shows only the length.
Zeroizing
Zeroizing is a wrapper for any Z: Zeroize type which implements a Drop handler which zeroizes dropped values.

Traits§

Zeroize
Trait for securely erasing values from memory.
ZeroizeOnDrop
Marker trait signifying that this type will Zeroize::zeroize itself on Drop.

Functions§

deserialize_seq
Read a Secret stored as a sequence of u8, the serde shape of a Vec<u8>, into a wiping buffer. For a type whose shape another crate owns, such as OpenMLS’s SignatureKeyPair.

Derive Macros§

Zeroize
Derive the Zeroize trait.
ZeroizeOnDrop
Derive the ZeroizeOnDrop trait.