#[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
pub const fn is_no_padding(&self) -> bool
Returns true if this value is of type NoPadding. Returns false otherwise
Sourcepub const fn is_pkcs_7(&self) -> bool
pub const fn is_pkcs_7(&self) -> bool
Returns true if this value is of type Pkcs7. Returns false otherwise
Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns true if this value is of type Unknown. Returns false otherwise
Source§impl EncryptionAlgorithm
impl EncryptionAlgorithm
Sourcepub const fn nonce_size(&self) -> usize
pub const fn nonce_size(&self) -> usize
Returns the nonce size of the encryption algorithm
Sourcepub fn write_nonce(dst: &mut impl BufMut) -> [u8; 12]
pub fn write_nonce(dst: &mut impl BufMut) -> [u8; 12]
Writes the nonce to the buffer, returning the random generated nonce
Sourcepub fn random_nonce() -> [u8; 12]
pub fn random_nonce() -> [u8; 12]
Generates a random nonce
Sourcepub fn read_nonce(src: &mut impl Buf) -> [u8; 12]
pub fn read_nonce(src: &mut impl Buf) -> [u8; 12]
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,
pub fn encrypt<B>(
&self,
pk: SecretKey,
nonce: [u8; 12],
auth_data: &[u8],
buf: &mut B,
) -> Result<(), EncryptionError>where
B: Buffer,
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>
pub fn decrypt( &self, key: &SecretKey, nonce: &[u8], auth_data: &[u8], dst: &mut impl Buffer, ) -> Result<(), EncryptionError>
Decrypts the data using the provided secret key, nonce, and the authentication data
Sourcepub const fn encrypted_suffix_len(&self, inp: usize) -> usize
pub const fn encrypted_suffix_len(&self, inp: usize) -> usize
Returns the encrypted suffix length of the input size
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for EncryptionAlgorithm
impl<'a> Arbitrary<'a> for EncryptionAlgorithm
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 Arbitrary for EncryptionAlgorithm
impl Arbitrary for EncryptionAlgorithm
Source§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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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
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§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 Copy for EncryptionAlgorithm
impl Eq for EncryptionAlgorithm
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 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,
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