pub struct SymmetricCryptoKey {
pub(crate) key: Pin<Box<GenericArray<u8, U32>>>,
pub(crate) mac_key: Option<Pin<Box<GenericArray<u8, U32>>>>,
}
Expand description
A symmetric encryption key. Used to encrypt and decrypt EncString
Fields§
§key: Pin<Box<GenericArray<u8, U32>>>
§mac_key: Option<Pin<Box<GenericArray<u8, U32>>>>
Implementations§
Source§impl SymmetricCryptoKey
impl SymmetricCryptoKey
const KEY_LEN: usize = 32usize
const MAC_LEN: usize = 32usize
Sourcepub fn generate(rng: impl RngCore) -> Self
pub fn generate(rng: impl RngCore) -> Self
Generate a new random SymmetricCryptoKey
pub(crate) fn new( key: Pin<Box<GenericArray<u8, U32>>>, mac_key: Option<Pin<Box<GenericArray<u8, U32>>>>, ) -> Self
fn total_len(&self) -> usize
pub fn to_base64(&self) -> String
pub fn to_vec(&self) -> Vec<u8> ⓘ
Trait Implementations§
Source§impl Clone for SymmetricCryptoKey
impl Clone for SymmetricCryptoKey
Source§fn clone(&self) -> SymmetricCryptoKey
fn clone(&self) -> SymmetricCryptoKey
Returns a copy 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 SymmetricCryptoKey
impl Debug for SymmetricCryptoKey
Source§impl Drop for SymmetricCryptoKey
impl Drop for SymmetricCryptoKey
Source§impl KeyDecryptable<SymmetricCryptoKey, String> for EncString
impl KeyDecryptable<SymmetricCryptoKey, String> for EncString
fn decrypt_with_key( &self, key: &SymmetricCryptoKey, ) -> Result<String, CryptoError>
Source§impl KeyDecryptable<SymmetricCryptoKey, Vec<u8>> for EncString
impl KeyDecryptable<SymmetricCryptoKey, Vec<u8>> for EncString
fn decrypt_with_key( &self, key: &SymmetricCryptoKey, ) -> Result<Vec<u8>, CryptoError>
Source§impl KeyEncryptable<SymmetricCryptoKey, EncString> for &[u8]
impl KeyEncryptable<SymmetricCryptoKey, EncString> for &[u8]
fn encrypt_with_key( self, key: &SymmetricCryptoKey, ) -> Result<EncString, CryptoError>
Source§impl KeyEncryptable<SymmetricCryptoKey, EncString> for &str
impl KeyEncryptable<SymmetricCryptoKey, EncString> for &str
fn encrypt_with_key( self, key: &SymmetricCryptoKey, ) -> Result<EncString, CryptoError>
Source§impl KeyEncryptable<SymmetricCryptoKey, EncString> for String
impl KeyEncryptable<SymmetricCryptoKey, EncString> for String
fn encrypt_with_key( self, key: &SymmetricCryptoKey, ) -> Result<EncString, CryptoError>
Source§impl TryFrom<&mut [u8]> for SymmetricCryptoKey
impl TryFrom<&mut [u8]> for SymmetricCryptoKey
Source§fn try_from(value: &mut [u8]) -> Result<Self, Self::Error>
fn try_from(value: &mut [u8]) -> Result<Self, Self::Error>
Note: This function takes the byte slice by mutable reference and will zero out all the data in it. This is to prevent the key from being left in memory.
Source§type Error = CryptoError
type Error = CryptoError
The type returned in the event of a conversion error.
Source§impl TryFrom<String> for SymmetricCryptoKey
impl TryFrom<String> for SymmetricCryptoKey
impl CryptoKey for SymmetricCryptoKey
impl ZeroizeOnDrop for SymmetricCryptoKey
Auto Trait Implementations§
impl Freeze for SymmetricCryptoKey
impl RefUnwindSafe for SymmetricCryptoKey
impl Send for SymmetricCryptoKey
impl Sync for SymmetricCryptoKey
impl Unpin for SymmetricCryptoKey
impl UnwindSafe for SymmetricCryptoKey
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> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
Create a new handle for an Arc value Read more
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
Clone a handle Read more
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Consume a handle, getting back the initial
Arc<>
Read moreSource§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