Struct strobe_rs::Strobe [−][src]
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. Some inputs are not
meaningful in some contexts. Again, see the specification for more info. The arguments are
data
- The input data to the operation.metadata
- An optional tuple containing meta-operation flags and metadata info. See spec for more info.more
- Whether or not you want to add more input to the previous operation. For example:
s.ad(b"hello world".to_vec(), None, false);
is equivalent to
s.ad(b"hello ".to_vec(), None, false); s.ad(b"world".to_vec(), None, 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
Methods
impl Strobe
[src]
impl Strobe
pub fn new(proto: Vec<u8>, sec: SecParam) -> Strobe
[src]
pub fn new(proto: Vec<u8>, sec: SecParam) -> Strobe
Makes a new Strobe
object with a given protocol byte string and security parameter.
pub fn version_str(&self) -> String
[src]
pub fn version_str(&self) -> String
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: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Result<Option<Vec<u8>>, AuthError>
[src]
pub fn recv_mac(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Result<Option<Vec<u8>>, AuthError>
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,
bytes_to_zero: usize,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Option<Vec<u8>>
[src]
pub fn ratchet(
&mut self,
bytes_to_zero: usize,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Option<Vec<u8>>
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_clr(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
[src]
pub fn send_clr(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
Sends a plaintext message.
pub fn recv_clr(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
[src]
pub fn recv_clr(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
Receives a plaintext message.
pub fn send_enc(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
[src]
pub fn send_enc(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
Sends an encrypted message.
pub fn recv_enc(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
[src]
pub fn recv_enc(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
Receives an encrypted message.
pub fn send_mac(
&mut self,
output_len: usize,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
[src]
pub fn send_mac(
&mut self,
output_len: usize,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
Sends a MAC of the internal state.
Takes a usize
argument instead of bytes. This specifies the number of bytes the user
wants as output.
pub fn prf(
&mut self,
output_len: usize,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
[src]
pub fn prf(
&mut self,
output_len: usize,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Vec<u8>
Extracts pseudorandom data as a function of the internal state.
Takes a usize
argument instead of bytes. This specifies the number of bytes the user
wants as output.
pub fn ad(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Option<Vec<u8>>
[src]
pub fn ad(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Option<Vec<u8>>
Mixes associated data into the internal state.
Takes input as normal. This will return a value if and only if metadata is supplied in the input.
pub fn key(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Option<Vec<u8>>
[src]
pub fn key(
&mut self,
data: Vec<u8>,
metadata: Option<(OpFlags, Vec<u8>)>,
more: bool
) -> Option<Vec<u8>>
Sets a symmetric cipher key.
Takes input as normal. This will return a value if and only if metadata is supplied in the input.