pub struct DryocStream<Mode> { /* private fields */ }Expand description
Secret-key authenticated encrypted streams
Implementations§
Source§impl<M> DryocStream<M>
impl<M> DryocStream<M>
Sourcepub fn rekey(&mut self)
pub fn rekey(&mut self)
Manually rekeys the stream. Both the push and pull sides of the stream must rekey at the same position.
Automatic rekeying normally makes manual rekeying unnecessary.
Refer to the libsodium docs for details.
Source§impl DryocStream<Push>
impl DryocStream<Push>
Sourcepub fn init_push<Key: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES>, Header: NewByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES>>(
key: &Key,
) -> (Self, Header)
pub fn init_push<Key: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES>, Header: NewByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES>>( key: &Key, ) -> (Self, Header)
Returns a new push stream, initialized from key.
Sourcepub fn push<Input: Bytes, Output: NewBytes + ResizableBytes>(
&mut self,
message: &Input,
associated_data: Option<&Input>,
tag: Tag,
) -> Result<Output, Error>
pub fn push<Input: Bytes, Output: NewBytes + ResizableBytes>( &mut self, message: &Input, associated_data: Option<&Input>, tag: Tag, ) -> Result<Output, Error>
Encrypts message for this stream with associated_data and tag,
returning the ciphertext.
§Errors
Returns an error if tag contains unknown bits, the message exceeds the
stream’s maximum message length, or the output storage does not resize
to exactly the required ciphertext length.
Sourcepub fn push_to_vec<Input: Bytes>(
&mut self,
message: &Input,
associated_data: Option<&Input>,
tag: Tag,
) -> Result<Vec<u8>, Error>
pub fn push_to_vec<Input: Bytes>( &mut self, message: &Input, associated_data: Option<&Input>, tag: Tag, ) -> Result<Vec<u8>, Error>
Encrypts message for this stream with associated_data and tag,
returning the ciphertext.
§Errors
Returns an error if tag contains unknown bits or the message exceeds
the stream’s maximum message length.
Source§impl DryocStream<Pull>
impl DryocStream<Pull>
Sourcepub fn init_pull<Key: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES>, Header: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES>>(
key: &Key,
header: &Header,
) -> Self
pub fn init_pull<Key: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_KEYBYTES>, Header: ByteArray<CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES>>( key: &Key, header: &Header, ) -> Self
Returns a new pull stream, initialized from key and header.
Sourcepub fn pull<Input: Bytes, Output: MutBytes + Default + ResizableBytes>(
&mut self,
ciphertext: &Input,
associated_data: Option<&Input>,
) -> Result<(Output, Tag), Error>
pub fn pull<Input: Bytes, Output: MutBytes + Default + ResizableBytes>( &mut self, ciphertext: &Input, associated_data: Option<&Input>, ) -> Result<(Output, Tag), Error>
Decrypts ciphertext for this stream with associated_data, returning
the decrypted message and tag.
§Errors
Returns an error if the ciphertext is too short or too long, the output storage cannot hold the plaintext, or authentication fails. Authentication fails for a wrong key or header, mismatched associated data, modified ciphertext, or messages processed out of order. Authenticated tag values containing unknown bits are also rejected without advancing the stream.
Sourcepub fn pull_to_vec<Input: Bytes>(
&mut self,
ciphertext: &Input,
associated_data: Option<&Input>,
) -> Result<(Vec<u8>, Tag), Error>
pub fn pull_to_vec<Input: Bytes>( &mut self, ciphertext: &Input, associated_data: Option<&Input>, ) -> Result<(Vec<u8>, Tag), Error>
Decrypts ciphertext for this stream with associated_data, returning
the decrypted message and tag into a Vec.
§Errors
Returns an error if the ciphertext is too short or too long, or authentication fails because the key, header, associated data, stream position, or ciphertext does not match. Authenticated tag values containing unknown bits are also rejected without advancing the stream.
Trait Implementations§
Source§impl<Mode: Clone> Clone for DryocStream<Mode>
impl<Mode: Clone> Clone for DryocStream<Mode>
Source§fn clone(&self) -> DryocStream<Mode>
fn clone(&self) -> DryocStream<Mode>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more