[]Struct themis::secure_cell::SecureCell

pub struct SecureCell { /* fields omitted */ }

Basic Secure Cell.

This is modeless, basic cell. First you provide the master key to a new SecureCell object then you select the desired operation mode and your Secure Cell is ready to go.

Methods

impl SecureCell

pub fn with_key(master_key: impl AsRef<[u8]>) -> Result<Self>

Constructs a new cell secured by a master key.

Examples

A master key may be provided as anything convertible to a byte slice: a byte slice or an array, a Vec<u8>, or a String.

Note that it is actually a password. It is not required to be an actual key generated by one of the keygen functions (though you definitely can use those keys as well). The master key cannot be empty.

use themis::secure_cell::SecureCell;

assert!(SecureCell::with_key(b"byte string").is_ok());
assert!(SecureCell::with_key(&[1, 2, 3, 4, 5]).is_ok());
assert!(SecureCell::with_key(vec![6, 7, 8, 9]).is_ok());
assert!(SecureCell::with_key(format!("owned string")).is_ok());

assert!(SecureCell::with_key(b"").is_err());

pub fn seal(self) -> SecureCellSeal

Switches this Secure Cell to the sealing operation mode.

pub fn token_protect(self) -> SecureCellTokenProtect

Switches this Secure Cell to the token protect operation mode.

pub fn context_imprint(self) -> SecureCellContextImprint

Switches this Secure Cell to the context imprint operation mode.

Trait Implementations

impl Debug for SecureCell

Auto Trait Implementations

impl Send for SecureCell

impl Sync for SecureCell

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.