pub struct Strobe { /* private fields */ }
Expand description
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
- For streaming purposes. Specifies whether you’re trying to add more input / get more output to/from the previous operation. For example:
s.ad(b"hello world", false);
is equivalent to
s.ad(b"hello ", false);
s.ad(b"world", true);
NOTE: If you try to set the more
flag for an operation that is not preceded by the same
operation (e.g., if you try ad
followed by send_enc
with more=true
), then the function
will panic, since that is an invalid use of the more
flag.
Finally, ratchet
and meta_ratchet
take a usize
argument instead of bytes. These functions
are individually commented below.
Implementations
sourceimpl Strobe
impl Strobe
sourcepub fn new(proto: &[u8], sec: SecParam) -> Strobe
pub fn new(proto: &[u8], sec: SecParam) -> Strobe
Makes a new Strobe
object with a given protocol byte string and security parameter.
sourcepub fn version_str(&self) -> String
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.
sourcepub fn recv_mac(&mut self, data: &mut [u8]) -> Result<(), AuthError>
pub fn recv_mac(&mut self, data: &mut [u8]) -> Result<(), 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.
sourcepub fn meta_recv_mac(&mut self, data: &mut [u8]) -> Result<(), AuthError>
pub fn meta_recv_mac(&mut self, data: &mut [u8]) -> Result<(), 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.
sourcepub fn ratchet(&mut self, num_bytes_to_zero: usize, more: bool)
pub fn ratchet(&mut self, num_bytes_to_zero: usize, more: bool)
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.
sourcepub fn meta_ratchet(&mut self, num_bytes_to_zero: usize, more: bool)
pub fn meta_ratchet(&mut self, num_bytes_to_zero: usize, more: bool)
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.
sourcepub fn send_mac(&mut self, data: &mut [u8], more: bool)
pub fn send_mac(&mut self, data: &mut [u8], more: bool)
Sends a MAC of the internal state. The output is independent of the initial contents of the input buffer.
sourcepub fn meta_send_mac(&mut self, data: &mut [u8], more: bool)
pub fn meta_send_mac(&mut self, data: &mut [u8], more: bool)
Sends a MAC of the internal state. The output is independent of the initial contents of the input buffer.
sourcepub fn prf(&mut self, data: &mut [u8], more: bool)
pub fn prf(&mut self, data: &mut [u8], more: bool)
Extracts pseudorandom data as a function of the internal state. The output is independent of the initial contents of the input buffer.
sourcepub fn meta_prf(&mut self, data: &mut [u8], more: bool)
pub fn meta_prf(&mut self, data: &mut [u8], more: bool)
Extracts pseudorandom data as a function of the internal state. The output is independent of the initial contents of the input buffer.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Strobe
impl Send for Strobe
impl Sync for Strobe
impl Unpin for Strobe
impl UnwindSafe for Strobe
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more