[][src]Struct strobe_rs::Strobe

pub struct Strobe {
    pub sec: SecParam,
    pub rate: usize,
    // some fields omitted
}

The main Strobe object. This is currently limited to using Keccak-f[1600] as the internal permutation function. For more information on this object, the protocol specification is a great resource.

Description of method input

Most operations exposed by Strobe take the same set of inputs. The arguments are

  • data - The input data to the operation.
  • more - Whether or not you want to add more input to the previous operation. For example:
s.ad(b"hello world", false);

is equivalent to

s.ad(b"hello ", false);
s.ad(b"world", true);

Some methods take a usize argument instead of bytes. These functions are individually commented below.

Fields

sec: SecParam

Security parameter (128 or 256)

rate: usize

This is the R parameter in the Strobe spec

Implementations

impl Strobe[src]

pub fn new(proto: &[u8], sec: SecParam) -> Strobe[src]

Makes a new Strobe object with a given protocol byte string and security parameter.

pub fn version_str(&self) -> String[src]

Returns a string of the form Strobe-Keccak-<sec>/<b>v<ver> where sec is the bits of security (128 or 256), b is the block size (in bits) of the Keccak permutation function, and ver is the protocol version.

pub fn recv_mac(&mut self, data: &mut [u8], more: bool) -> Result<(), AuthError>[src]

Attempts to authenticate the current state against the given MAC. On failure, it returns an AuthError. It behooves the user of this library to check this return value and overreact on error.

pub fn meta_recv_mac(
    &mut self,
    data: &mut [u8],
    more: bool
) -> Result<(), AuthError>
[src]

Attempts to authenticate the current state against the given MAC. On failure, it returns an AuthError. It behooves the user of this library to check this return value and overreact on error.

pub fn ratchet(&mut self, num_bytes_to_zero: usize, more: bool)[src]

Ratchets the internal state forward in an irreversible way by zeroing bytes.

Takes a usize argument specifying the number of bytes of public state to zero. If the size exceeds self.rate, Keccak-f will be called before more bytes are zeroed.

pub fn meta_ratchet(&mut self, num_bytes_to_zero: usize, more: bool)[src]

Ratchets the internal state forward in an irreversible way by zeroing bytes.

Takes a usize argument specifying the number of bytes of public state to zero. If the size exceeds self.rate, Keccak-f will be called before more bytes are zeroed.

pub fn send_enc(&mut self, data: &mut [u8], more: bool)[src]

Sends an encrypted message.

pub fn meta_send_enc(&mut self, data: &mut [u8], more: bool)[src]

Sends an encrypted message.

pub fn recv_enc(&mut self, data: &mut [u8], more: bool)[src]

Receives an encrypted message.

pub fn meta_recv_enc(&mut self, data: &mut [u8], more: bool)[src]

Receives an encrypted message.

pub fn send_mac(&mut self, data: &mut [u8], more: bool)[src]

Sends a MAC of the internal state. The output is independent of the initial contents of the input buffer.

pub fn meta_send_mac(&mut self, data: &mut [u8], more: bool)[src]

Sends a MAC of the internal state. The output is independent of the initial contents of the input buffer.

pub fn prf(&mut self, data: &mut [u8], more: bool)[src]

Extracts pseudorandom data as a function of the internal state. The output is independent of the initial contents of the input buffer.

pub fn meta_prf(&mut self, data: &mut [u8], more: bool)[src]

Extracts pseudorandom data as a function of the internal state. The output is independent of the initial contents of the input buffer.

pub fn send_clr(&mut self, data: &[u8], more: bool)[src]

Sends a plaintext message.

pub fn meta_send_clr(&mut self, data: &[u8], more: bool)[src]

Sends a plaintext message.

pub fn recv_clr(&mut self, data: &[u8], more: bool)[src]

Receives a plaintext message.

pub fn meta_recv_clr(&mut self, data: &[u8], more: bool)[src]

Receives a plaintext message.

pub fn ad(&mut self, data: &[u8], more: bool)[src]

Mixes associated data into the internal state.

pub fn meta_ad(&mut self, data: &[u8], more: bool)[src]

Mixes associated data into the internal state.

pub fn key(&mut self, data: &[u8], more: bool)[src]

Sets a symmetric cipher key.

pub fn meta_key(&mut self, data: &[u8], more: bool)[src]

Sets a symmetric cipher key.

Trait Implementations

impl Clone for Strobe[src]

Auto Trait Implementations

impl Send for Strobe

impl Sync for Strobe

impl Unpin for Strobe

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.