pub struct Nonce(pub [u8; 24]);
Expand description
Nonce
for asymmetric authenticated encryption
Tuple Fields§
§0: [u8; 24]
Implementations§
Source§impl Nonce
impl Nonce
Sourcepub fn from_slice(bs: &[u8]) -> Option<Nonce>
pub fn from_slice(bs: &[u8]) -> Option<Nonce>
from_slice()
creates an object from a byte slice
This function will fail and return None
if the length of
the byte-slice isn’t equal to the length of the object
Sourcepub fn increment_le(&self) -> Nonce
pub fn increment_le(&self) -> Nonce
increment_le()
treats the nonce as an unsigned little-endian number and
returns an incremented version of it.
WARNING: this method does not check for arithmetic overflow. It is the callers responsibility to ensure that any given nonce value is only used once. If the caller does not do that the cryptographic primitives in sodiumoxide will not uphold any security guarantees (i.e. they will break)
Sourcepub fn increment_le_inplace(&mut self)
pub fn increment_le_inplace(&mut self)
increment_le_inplace()
treats the nonce as an unsigned little-endian number
and increments it.
WARNING: this method does not check for arithmetic overflow. It is the callers responsibility to ensure that any given nonce value is only used once. If the caller does not do that the cryptographic primitives in sodiumoxide will not uphold any security guarantees.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Nonce
impl<'de> Deserialize<'de> for Nonce
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Nonce, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Nonce, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Index<Range<usize>> for Nonce
Allows a user to access the byte contents of an object as a slice.
impl Index<Range<usize>> for Nonce
Allows a user to access the byte contents of an object as a slice.
WARNING: it might be tempting to do comparisons on objects
by using x[a..b] == y[a..b]
. This will open up for timing attacks
when comparing for example authenticator tags. Because of this only
use the comparison functions exposed by the sodiumoxide API.
Source§impl Index<RangeFrom<usize>> for Nonce
Allows a user to access the byte contents of an object as a slice.
impl Index<RangeFrom<usize>> for Nonce
Allows a user to access the byte contents of an object as a slice.
WARNING: it might be tempting to do comparisons on objects
by using x[a..] == y[a..]
. This will open up for timing attacks
when comparing for example authenticator tags. Because of this only
use the comparison functions exposed by the sodiumoxide API.
Source§impl Index<RangeFull> for Nonce
Allows a user to access the byte contents of an object as a slice.
impl Index<RangeFull> for Nonce
Allows a user to access the byte contents of an object as a slice.
WARNING: it might be tempting to do comparisons on objects
by using x[] == y[]
. This will open up for timing attacks
when comparing for example authenticator tags. Because of this only
use the comparison functions exposed by the sodiumoxide API.
Source§impl Index<RangeTo<usize>> for Nonce
Allows a user to access the byte contents of an object as a slice.
impl Index<RangeTo<usize>> for Nonce
Allows a user to access the byte contents of an object as a slice.
WARNING: it might be tempting to do comparisons on objects
by using x[..b] == y[..b]
. This will open up for timing attacks
when comparing for example authenticator tags. Because of this only
use the comparison functions exposed by the sodiumoxide API.