Trait hard::BufferMut[][src]

pub trait BufferMut: Buffer where
    Self: Sized
{ type NoAccess: BufferNoAccess; type ReadOnly: BufferReadOnly; fn zero(&mut self);
fn try_clone(&self) -> Result<Self, HardError>;
fn into_noaccess(self) -> Result<Self::NoAccess, HardError>;
fn into_readonly(self) -> Result<Self::ReadOnly, HardError>; }
Expand description

Trait implemented by any buffer type with mutable contents.

Associated Types

The variant of this buffer that is locked such that its contents cannot be accessed.

The variant of this buffer that is locked such that its contents cannot be mutated, although they can be read.

Required methods

Overwrite the contents of the buffer with zeros, in such a way that will not be optimised away by the compiler.

Buffers are automatically zeroed on drop, you should not need to call this method yourself unless you want to set a buffer to zero for initialisation purposes.

Attempt to clone this buffer.

This will allocate a new region of memory, and copy the contents of this buffer into it.

mprotect the region of memory pointed to by this buffer, so that it cannot be accessed.

This function uses the operating system’s memory protection tools to mark the region of memory backing this buffer as inaccessible. This is used as a hardening measure, to protect the region of memory so that it can’t be accessed by anything while we don’t need it.

If there is no mprotect (or equivalent) syscall on this platform, this function will return an error.

mprotect the region of memory pointed to by this buffer, so that it cannot be mutated, although it can still be read.

This function uses the operating system’s memory protection tools to mark the region of memory backing this buffer as read-only. This is used as a hardening measure, to protect the region of memory so that it can’t be altered by anything. This would be well suited to, for example, secure a key after key generation, since there is no need to modify a key once we’ve generated it in most cases.

If there is no mprotect (or equivalent) syscall on this platform, this function will return an error.

Implementors