Enum SymmetricCryptoKey
pub enum SymmetricCryptoKey {
Aes256CbcKey(Aes256CbcKey),
Aes256CbcHmacKey(Aes256CbcHmacKey),
XChaCha20Poly1305Key(XChaCha20Poly1305Key),
Aes256GcmKey(Aes256GcmKey),
XAes256GcmKey(XAes256GcmKey),
}Expand description
Variants§
Aes256CbcKey(Aes256CbcKey)
Aes256CbcHmacKey(Aes256CbcHmacKey)
XChaCha20Poly1305Key(XChaCha20Poly1305Key)
Data encrypted by XChaCha20Poly1305Key keys has type
Cose_Encrypt0_B64
Aes256GcmKey(Aes256GcmKey)
FIPS-approved AES-256-GCM key, used as the content-encryption key for FIPS
DataEnvelopes. Encoded as a COSE key.
XAes256GcmKey(XAes256GcmKey)
Extended-nonce AES-256-GCM key. Encoded as a COSE key and used with type-7 EncStrings.
Implementations§
§impl SymmetricCryptoKey
impl SymmetricCryptoKey
pub fn make(algorithm: SymmetricKeyAlgorithm) -> SymmetricCryptoKey
pub fn make(algorithm: SymmetricKeyAlgorithm) -> SymmetricCryptoKey
Make a new SymmetricCryptoKey for the specified algorithm
pub fn to_encoded(&self) -> Bytes<BitwardenLegacyKeyContentFormat>
pub fn to_encoded(&self) -> Bytes<BitwardenLegacyKeyContentFormat>
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. COSE-serialized variants are 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
pub fn key_id(&self) -> Option<KeyId>
pub fn key_id(&self) -> Option<KeyId>
Returns the key ID of the key, if it has one. Every authenticated key variant has a key ID;
only the unauthenticated SymmetricCryptoKey::Aes256CbcKey does not.
SymmetricCryptoKey::Aes256CbcHmacKey has no field to store a key ID in, and derives one
from its key material instead: its RFC 9679 thumbprint, truncated to the key ID length. Two
such keys with identical key material therefore share an ID.
Trait Implementations§
§impl Clone for SymmetricCryptoKey
impl Clone for SymmetricCryptoKey
§fn clone(&self) -> SymmetricCryptoKey
fn clone(&self) -> SymmetricCryptoKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl ConstantTimeEq for SymmetricCryptoKey
impl ConstantTimeEq for SymmetricCryptoKey
§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.
§impl CoseKeyThumbprintExt for SymmetricCryptoKey
impl CoseKeyThumbprintExt for SymmetricCryptoKey
§fn thumbprint(&self) -> Result<CoseKeyThumbprint, CryptoError>
fn thumbprint(&self) -> Result<CoseKeyThumbprint, CryptoError>
Computes the RFC 9679 thumbprint of this symmetric key.
Returns an error for the unauthenticated legacy AES-CBC key, which is not representable as a COSE key.
impl CryptoKey for SymmetricCryptoKey
§impl Debug for SymmetricCryptoKey
impl Debug for SymmetricCryptoKey
§impl<'de> Deserialize<'de> for SymmetricCryptoKey
impl<'de> Deserialize<'de> for SymmetricCryptoKey
§fn deserialize<D>(
deserializer: D,
) -> Result<SymmetricCryptoKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SymmetricCryptoKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
§impl Drop for SymmetricCryptoKey
impl Drop for SymmetricCryptoKey
§impl FromStr for SymmetricCryptoKey
impl FromStr for SymmetricCryptoKey
§impl KeyEncryptable<PinKey, EncString> for &SymmetricCryptoKey
impl KeyEncryptable<PinKey, EncString> for &SymmetricCryptoKey
§fn encrypt_with_key(self, key: &PinKey) -> Result<EncString, CryptoError>
fn encrypt_with_key(self, key: &PinKey) -> Result<EncString, CryptoError>
§impl PartialEq for SymmetricCryptoKey
impl PartialEq for SymmetricCryptoKey
§impl Serialize for SymmetricCryptoKey
impl Serialize for SymmetricCryptoKey
§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,
§impl TryFrom<&Bytes<BitwardenLegacyKeyContentFormat>> for SymmetricCryptoKey
impl TryFrom<&Bytes<BitwardenLegacyKeyContentFormat>> for SymmetricCryptoKey
§fn try_from(
value: &Bytes<BitwardenLegacyKeyContentFormat>,
) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<&Bytes<BitwardenLegacyKeyContentFormat>>>::Error>
fn try_from( value: &Bytes<BitwardenLegacyKeyContentFormat>, ) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<&Bytes<BitwardenLegacyKeyContentFormat>>>::Error>
§impl TryFrom<&CoseKey> for SymmetricCryptoKey
impl TryFrom<&CoseKey> for SymmetricCryptoKey
§fn try_from(
cose_key: &CoseKey,
) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<&CoseKey>>::Error>
fn try_from( cose_key: &CoseKey, ) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<&CoseKey>>::Error>
§impl TryFrom<B64> for SymmetricCryptoKey
impl TryFrom<B64> for SymmetricCryptoKey
§fn try_from(
value: B64,
) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<B64>>::Error>
fn try_from( value: B64, ) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<B64>>::Error>
§impl TryFrom<EncodedSymmetricKey> for SymmetricCryptoKey
impl TryFrom<EncodedSymmetricKey> for SymmetricCryptoKey
§fn try_from(
value: EncodedSymmetricKey,
) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<EncodedSymmetricKey>>::Error>
fn try_from( value: EncodedSymmetricKey, ) -> Result<SymmetricCryptoKey, <SymmetricCryptoKey as TryFrom<EncodedSymmetricKey>>::Error>
§impl TryFrom<String> for SymmetricCryptoKey
impl TryFrom<String> 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 UnsafeUnpin for SymmetricCryptoKey
impl UnwindSafe for SymmetricCryptoKey
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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