Struct lioness::Lioness

source ·
pub struct Lioness<H, SC>{ /* private fields */ }
Expand description

Lioness implemented generically over a Digest and StreamCipher

Implementations§

source§

impl<H, SC> Lioness<H, SC>

source

pub fn encrypt(&self, block: &mut [u8]) -> Result<(), LionessError>

encrypt a block

§Arguments
  • block - a mutable byte slice of data to encrypt
§Errors
  • LionessError::BlockSizeError - returned if block size is too small
§Example
extern crate blake2;
extern crate chacha;
extern crate lioness;
extern crate hex;
use self::lioness::{Lioness, RAW_KEY_SIZE};
use chacha::ChaCha;
use blake2::VarBlake2b;

let key = hex::decode(
    "e98e0e3f28311995e8448e6dc1de73159e800c8184a7846418347f4490f063e372\
     6eebda84e02f2cc218bd6c6e9a9b801e8d8899e8f5b6dcd23bf7ca7f11641c584cd9568f045e9\
     ad92c59275f67b9bed7f02bb23e28c0b8e56fbb634d60a6d1eae7145e53a4442dda40ae37b2e2\
     e1f97ae495c8ce0166605d4f1ea91f139159229f208c69362095d8d8e00d7b4c9ca5603dc8b87\
     50b0eb500670858ca7983a8760be307ff3e5c05f22799cb60d7c57fe3fc8b980aa65e89e3ac0a\
     c147af7deb").unwrap();

const PLAINTEXT: &'static [u8] = b"Open, secure and reliable
connectivity is necessary (although not sufficient) to
excercise the human rights such as freedom of expression and
freedom of association [FOC], as defined in the Universal
Declaration of Human Rights [UDHR]. The purpose of the
Internet to be a global network of networks that provides
unfettered connectivity to all users and for any content
[RFC1958]. This objective of stimulating global connectivity
contributes to the Internet's role as an enabler of human
rights.";

let mut block: Vec<u8> = PLAINTEXT.to_owned();
let cipher = Lioness::<VarBlake2b,ChaCha>::new_raw(array_ref!(key, 0, RAW_KEY_SIZE));
cipher.encrypt(&mut block).unwrap();
}
source

pub fn decrypt(&self, block: &mut [u8]) -> Result<(), LionessError>

decrypt a block

§Arguments
  • block - a mutable byte slice of data to decrypt
§Errors
  • LionessError::BlockSizeError - returned if block size is too small
source

pub fn new_raw(key: &[u8; 192]) -> Lioness<H, SC>

Given a key, create a new Lioness cipher

Auto Trait Implementations§

§

impl<H, SC> Freeze for Lioness<H, SC>

§

impl<H, SC> RefUnwindSafe for Lioness<H, SC>

§

impl<H, SC> Send for Lioness<H, SC>
where H: Send, SC: Send,

§

impl<H, SC> Sync for Lioness<H, SC>
where H: Sync, SC: Sync,

§

impl<H, SC> Unpin for Lioness<H, SC>
where H: Unpin, SC: Unpin,

§

impl<H, SC> UnwindSafe for Lioness<H, SC>
where H: UnwindSafe, SC: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.