#[non_exhaustive]pub enum EncryptionAlgorithm {
NoPadding,
Pkcs7,
Unknown(u8),
}Expand description
The encryption algorithm used to encrypt the message.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
NoPadding
AES-GCM, using no padding
Pkcs7
AES-GCM, using PKCS7 padding
Unknown(u8)
Unknwon encryption version
Implementations§
Source§impl EncryptionAlgorithm
impl EncryptionAlgorithm
Sourcepub const fn is_no_padding(&self) -> bool
Available on crate feature encryption only.
pub const fn is_no_padding(&self) -> bool
encryption only.Returns true if this value is of type NoPadding. Returns false otherwise
Sourcepub const fn is_pkcs_7(&self) -> bool
Available on crate feature encryption only.
pub const fn is_pkcs_7(&self) -> bool
encryption only.Returns true if this value is of type Pkcs7. Returns false otherwise
Sourcepub const fn is_unknown(&self) -> bool
Available on crate feature encryption only.
pub const fn is_unknown(&self) -> bool
encryption only.Returns true if this value is of type Unknown. Returns false otherwise
Source§impl EncryptionAlgorithm
impl EncryptionAlgorithm
Sourcepub const fn nonce_size(&self) -> usize
Available on crate feature encryption only.
pub const fn nonce_size(&self) -> usize
encryption only.Returns the nonce size of the encryption algorithm
Sourcepub fn write_nonce(dst: &mut impl BufMut) -> [u8; 12]
Available on crate feature encryption only.
pub fn write_nonce(dst: &mut impl BufMut) -> [u8; 12]
encryption only.Writes the nonce to the buffer, returning the random generated nonce
Sourcepub fn random_nonce() -> [u8; 12]
Available on crate feature encryption only.
pub fn random_nonce() -> [u8; 12]
encryption only.Generates a random nonce
Sourcepub fn read_nonce(src: &mut impl Buf) -> [u8; 12]
Available on crate feature encryption only.
pub fn read_nonce(src: &mut impl Buf) -> [u8; 12]
encryption only.Reads the nonce from the buffer
Sourcepub fn encrypt<B>(
&self,
pk: SecretKey,
nonce: [u8; 12],
auth_data: &[u8],
buf: &mut B,
) -> Result<(), EncryptionError>where
B: Buffer,
Available on crate feature encryption only.
pub fn encrypt<B>(
&self,
pk: SecretKey,
nonce: [u8; 12],
auth_data: &[u8],
buf: &mut B,
) -> Result<(), EncryptionError>where
B: Buffer,
encryption only.Encrypts the data using the provided secret key, nonce, and the authentication data
Sourcepub fn decrypt(
&self,
key: &SecretKey,
nonce: &[u8],
auth_data: &[u8],
dst: &mut impl Buffer,
) -> Result<(), EncryptionError>
Available on crate feature encryption only.
pub fn decrypt( &self, key: &SecretKey, nonce: &[u8], auth_data: &[u8], dst: &mut impl Buffer, ) -> Result<(), EncryptionError>
encryption only.Decrypts the data using the provided secret key, nonce, and the authentication data
Sourcepub const fn encrypted_suffix_len(&self, inp: usize) -> usize
Available on crate feature encryption only.
pub const fn encrypted_suffix_len(&self, inp: usize) -> usize
encryption only.Returns the encrypted suffix length of the input size
Trait Implementations§
Source§impl Arbitrary for EncryptionAlgorithm
impl Arbitrary for EncryptionAlgorithm
Source§impl<'a> Arbitrary<'a> for EncryptionAlgorithm
Available on crate feature encryption only.
impl<'a> Arbitrary<'a> for EncryptionAlgorithm
Available on crate feature
encryption only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<EncryptionAlgorithm, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<EncryptionAlgorithm, Error>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§impl Clone for EncryptionAlgorithm
impl Clone for EncryptionAlgorithm
Source§fn clone(&self) -> EncryptionAlgorithm
fn clone(&self) -> EncryptionAlgorithm
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for EncryptionAlgorithm
Source§impl Debug for EncryptionAlgorithm
impl Debug for EncryptionAlgorithm
Source§impl Default for EncryptionAlgorithm
impl Default for EncryptionAlgorithm
Source§fn default() -> EncryptionAlgorithm
fn default() -> EncryptionAlgorithm
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for EncryptionAlgorithm
impl<'de> Deserialize<'de> for EncryptionAlgorithm
Source§fn deserialize<D>(
deserializer: D,
) -> Result<EncryptionAlgorithm, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<EncryptionAlgorithm, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for EncryptionAlgorithm
impl Display for EncryptionAlgorithm
impl Eq for EncryptionAlgorithm
Source§impl From<u8> for EncryptionAlgorithm
impl From<u8> for EncryptionAlgorithm
Source§fn from(value: u8) -> EncryptionAlgorithm
fn from(value: u8) -> EncryptionAlgorithm
Converts to this type from the input type.
Source§impl FromStr for EncryptionAlgorithm
impl FromStr for EncryptionAlgorithm
Source§type Err = ParseEncryptionAlgorithmError
type Err = ParseEncryptionAlgorithmError
The associated error which can be returned from parsing.
Source§fn from_str(
s: &str,
) -> Result<EncryptionAlgorithm, <EncryptionAlgorithm as FromStr>::Err>
fn from_str( s: &str, ) -> Result<EncryptionAlgorithm, <EncryptionAlgorithm as FromStr>::Err>
Parses a string
s to return a value of this type. Read moreSource§impl Hash for EncryptionAlgorithm
impl Hash for EncryptionAlgorithm
Source§impl PartialEq for EncryptionAlgorithm
impl PartialEq for EncryptionAlgorithm
Source§fn eq(&self, other: &EncryptionAlgorithm) -> bool
fn eq(&self, other: &EncryptionAlgorithm) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for EncryptionAlgorithm
impl Serialize for EncryptionAlgorithm
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for EncryptionAlgorithm
Auto Trait Implementations§
impl Freeze for EncryptionAlgorithm
impl RefUnwindSafe for EncryptionAlgorithm
impl Send for EncryptionAlgorithm
impl Sync for EncryptionAlgorithm
impl Unpin for EncryptionAlgorithm
impl UnsafeUnpin for EncryptionAlgorithm
impl UnwindSafe for EncryptionAlgorithm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more