pub enum SymmetricCryptoKey {
Aes256CbcKey(Aes256CbcKey),
Aes256CbcHmacKey(Aes256CbcHmacKey),
XChaCha20Poly1305Key(XChaCha20Poly1305Key),
}Expand description
A symmetric encryption key. Used to encrypt and decrypt EncString
Variants§
Aes256CbcKey(Aes256CbcKey)
Aes256CbcHmacKey(Aes256CbcHmacKey)
XChaCha20Poly1305Key(XChaCha20Poly1305Key)
Data encrypted by XChaCha20Poly1305Key keys has type
Cose_Encrypt0_B64
Implementations§
Source§impl SymmetricCryptoKey
impl SymmetricCryptoKey
Sourcepub fn make(algorithm: SymmetricKeyAlgorithm) -> Self
pub fn make(algorithm: SymmetricKeyAlgorithm) -> Self
Make a new SymmetricCryptoKey for the specified algorithm
Sourcepub fn make_aes256_cbc_hmac_key() -> Self
pub fn make_aes256_cbc_hmac_key() -> Self
Generate a new random AES256_CBC_HMAC SymmetricCryptoKey
Sourcepub fn make_xchacha20_poly1305_key() -> Self
pub fn make_xchacha20_poly1305_key() -> Self
Generate a new random XChaCha20Poly1305 SymmetricCryptoKey
Sourcepub fn to_encoded(&self) -> BitwardenLegacyKeyBytes
pub fn to_encoded(&self) -> BitwardenLegacyKeyBytes
Encodes the key to a byte array representation, that is separated by size. SymmetricCryptoKey::Aes256CbcHmacKey and SymmetricCryptoKey::Aes256CbcKey are encoded as 64 and 32 bytes respectively. SymmetricCryptoKey::XChaCha20Poly1305Key is encoded as at least 65 bytes, using padding.
This can be used for storage and transmission in the old byte array format. When the wrapping key is a COSE key, and the wrapped key is a COSE key, then this should not use the byte representation but instead use the COSE key representation.
pub fn to_base64(&self) -> B64
Trait Implementations§
Source§impl Clone for SymmetricCryptoKey
impl Clone for SymmetricCryptoKey
Source§fn clone(&self) -> SymmetricCryptoKey
fn clone(&self) -> SymmetricCryptoKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConstantTimeEq for SymmetricCryptoKey
impl ConstantTimeEq for SymmetricCryptoKey
Source§fn ct_eq(&self, other: &SymmetricCryptoKey) -> Choice
fn ct_eq(&self, other: &SymmetricCryptoKey) -> Choice
Note: This is constant time with respect to comparing two keys of the same type, but not constant type with respect to the fact that different keys are compared. If two types of different keys are compared, then this does have different timing.
Source§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<PinKey, EncString> for &SymmetricCryptoKey
impl KeyEncryptable<PinKey, EncString> for &SymmetricCryptoKey
Source§fn encrypt_with_key(self, key: &PinKey) -> Result<EncString, CryptoError>
fn encrypt_with_key(self, key: &PinKey) -> Result<EncString, CryptoError>
Source§impl<T: ConstContentFormat> KeyEncryptable<SymmetricCryptoKey, EncString> for &Bytes<T>
impl<T: ConstContentFormat> KeyEncryptable<SymmetricCryptoKey, EncString> for &Bytes<T>
Source§fn encrypt_with_key(
self,
key: &SymmetricCryptoKey,
) -> Result<EncString, CryptoError>
fn encrypt_with_key( self, key: &SymmetricCryptoKey, ) -> Result<EncString, CryptoError>
Source§impl KeyEncryptable<SymmetricCryptoKey, EncString> for &str
impl KeyEncryptable<SymmetricCryptoKey, EncString> for &str
Source§fn encrypt_with_key(
self,
key: &SymmetricCryptoKey,
) -> Result<EncString, CryptoError>
fn encrypt_with_key( self, key: &SymmetricCryptoKey, ) -> Result<EncString, CryptoError>
Source§impl KeyEncryptable<SymmetricCryptoKey, EncString> for String
impl KeyEncryptable<SymmetricCryptoKey, EncString> for String
Source§fn encrypt_with_key(
self,
key: &SymmetricCryptoKey,
) -> Result<EncString, CryptoError>
fn encrypt_with_key( self, key: &SymmetricCryptoKey, ) -> Result<EncString, CryptoError>
Source§impl PartialEq for SymmetricCryptoKey
impl PartialEq for SymmetricCryptoKey
Source§impl TryFrom<&Bytes<BitwardenLegacyKeyContentFormat>> for SymmetricCryptoKey
impl TryFrom<&Bytes<BitwardenLegacyKeyContentFormat>> for SymmetricCryptoKey
Source§type Error = CryptoError
type Error = CryptoError
Source§impl TryFrom<&CoseKey> for SymmetricCryptoKey
impl TryFrom<&CoseKey> for SymmetricCryptoKey
Source§impl TryFrom<&SymmetricCryptoKey> for MasterKey
impl TryFrom<&SymmetricCryptoKey> for MasterKey
Source§type Error = CryptoError
type Error = CryptoError
Source§fn try_from(value: &SymmetricCryptoKey) -> Result<Self, CryptoError>
fn try_from(value: &SymmetricCryptoKey) -> Result<Self, CryptoError>
Source§impl TryFrom<B64> for SymmetricCryptoKey
impl TryFrom<B64> for SymmetricCryptoKey
Source§impl TryFrom<EncodedSymmetricKey> for SymmetricCryptoKey
impl TryFrom<EncodedSymmetricKey> for SymmetricCryptoKey
Source§type Error = CryptoError
type Error = CryptoError
Source§impl TryFrom<String> for SymmetricCryptoKey
impl TryFrom<String> for SymmetricCryptoKey
impl CryptoKey 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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