[][src]Struct lib3h_sodium::secbuf::SecBuf

pub struct SecBuf { /* fields omitted */ }

A SecBuf is a memory buffer for use with libsodium functions. It can be backed by insecure (raw) memory for things like public keys, or secure (mlocked / mprotected) memory for things like private keys.

Methods

impl SecBuf[src]

pub fn with_insecure(s: usize) -> Self[src]

create a new SecBuf backed by insecure memory (for things like public keys)

pub fn with_secure(s: usize) -> Self[src]

create a new SecBuf backed by secure memory (for things like private keys) warning: funky sizes may result in mis-alignment

pub fn with_insecure_from_string(s: String) -> Self[src]

pub fn protect_state(&self) -> ProtectState[src]

what is the current memory protection state of this SecBuf?

pub fn len(&self) -> usize[src]

should be able to get size without messing with mem protection

pub fn readable(&mut self)[src]

make this SecBuf readable

pub fn writable(&mut self)[src]

make this SecBuf writable

pub fn noaccess(&mut self)[src]

secure this SecBuf against reading or writing

pub fn read_lock(&mut self) -> Locker[src]

make this SecBuf readable, and return a locker object that will secure this SecBuf automatically when it goes out of scope.

pub fn write_lock(&mut self) -> Locker[src]

make this SecBuf writable, and return a locker object that will secure this SecBuf automatically when it goes out of scope.

pub fn write(&mut self, offset: usize, data: &[u8]) -> Result<(), CryptoError>[src]

helper for writing data to our internal buffer

impl SecBuf[src]

pub fn randomize(&mut self)[src]

randomize the provided SecBuf

impl SecBuf[src]

pub fn zero(&mut self)[src]

Zero all memory

pub fn increment(&mut self)[src]

Increments all memory by 1

pub fn compare(&mut self, b: &mut SecBuf) -> i32[src]

Compares two SecBuf Return : | if a > b; return 1 | if a < b; return -1 | if a == b; return 0

pub fn from_array(&mut self, data: &[u8]) -> Result<(), CryptoError>[src]

Load the u8 into the SecBuf

Trait Implementations

impl Clone for SecBuf[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Deref for SecBuf[src]

type Target = [u8]

The resulting type after dereferencing.

impl DerefMut for SecBuf[src]

impl Debug for SecBuf[src]

Auto Trait Implementations

impl Send for SecBuf

impl Unpin for SecBuf

impl !Sync for SecBuf

impl !UnwindSafe for SecBuf

impl !RefUnwindSafe for SecBuf

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]