pub enum EncString {
AesCbc256_B64 {
iv: [u8; 16],
data: Vec<u8>,
},
AesCbc128_HmacSha256_B64 {
iv: [u8; 16],
mac: [u8; 32],
data: Vec<u8>,
},
AesCbc256_HmacSha256_B64 {
iv: [u8; 16],
mac: [u8; 32],
data: Vec<u8>,
},
}
Expand description
§Encrypted string primitive
EncString is a Bitwarden specific primitive that represents a symmetrically encrypted string. They are are used together with the KeyDecryptable and KeyEncryptable traits to encrypt and decrypt data using SymmetricCryptoKeys.
The flexibility of the EncString type allows for different encryption algorithms to be used which is represented by the different variants of the enum.
§Note
For backwards compatibility we will rarely if ever be able to remove support for decrypting old variants, but we should be opinionated in which variants are used for encrypting.
§Variants
§Serialization
EncString implements Display and FromStr to allow for easy serialization and uses a custom scheme to represent the different variants.
The scheme is one of the following schemes:
[type].[iv]|[data]
[type].[iv]|[data]|[mac]
Where:
[type]
: is a digit number representing the variant.[iv]
: (optional) is the initialization vector used for encryption.[data]
: is the encrypted data.[mac]
: (optional) is the MAC used to validate the integrity of the data.
Variants§
Implementations§
Source§impl EncString
impl EncString
Sourcepub fn try_from_optional(
s: Option<String>,
) -> Result<Option<EncString>, CryptoError>
pub fn try_from_optional( s: Option<String>, ) -> Result<Option<EncString>, CryptoError>
Synthetic sugar for mapping Option<String>
to Result<Option<EncString>>
pub fn from_buffer(buf: &[u8]) -> Result<Self, CryptoError>
pub fn to_buffer(&self) -> Result<Vec<u8>, CryptoError>
Trait Implementations§
Source§impl Debug for EncString
To avoid printing sensitive information, EncString debug prints to EncString
.
impl Debug for EncString
To avoid printing sensitive information, EncString debug prints to EncString
.
Source§impl<'de> Deserialize<'de> for EncString
impl<'de> Deserialize<'de> for EncString
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl JsonSchema for EncString
Usually we wouldn’t want to expose EncStrings in the API or the schemas.
But during the transition phase we will expose endpoints using the EncString type.
impl JsonSchema for EncString
Usually we wouldn’t want to expose EncStrings in the API or the schemas. But during the transition phase we will expose endpoints using the EncString type.
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read moreSource§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 &[u8]
impl KeyEncryptable<PinKey, EncString> for &[u8]
fn encrypt_with_key(self, key: &PinKey) -> Result<EncString, CryptoError>
Source§impl KeyEncryptable<PinKey, EncString> for String
impl KeyEncryptable<PinKey, EncString> for String
fn encrypt_with_key(self, key: &PinKey) -> Result<EncString, 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 LocateKey for EncString
impl LocateKey for EncString
fn locate_key<'a>( &self, enc: &'a dyn KeyContainer, org_id: &Option<Uuid>, ) -> Result<&'a SymmetricCryptoKey, CryptoError>
impl StructuralPartialEq for EncString
Auto Trait Implementations§
impl Freeze for EncString
impl RefUnwindSafe for EncString
impl Send for EncString
impl Sync for EncString
impl Unpin for EncString
impl UnwindSafe for EncString
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,
§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
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
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>
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