pub enum AsymmetricEncString {
Rsa2048_OaepSha256_B64 {
data: Vec<u8>,
},
Rsa2048_OaepSha1_B64 {
data: Vec<u8>,
},
Rsa2048_OaepSha256_HmacSha256_B64 {
data: Vec<u8>,
mac: Vec<u8>,
},
Rsa2048_OaepSha1_HmacSha256_B64 {
data: Vec<u8>,
mac: Vec<u8>,
},
}
Expand description
§Encrypted string primitive
AsymmetricEncString is a Bitwarden specific primitive that represents an asymmetrically encrypted string. They are used together with the KeyDecryptable and KeyEncryptable traits to encrypt and decrypt data using crate::AsymmetricCryptoKeys.
The flexibility of the AsymmetricEncString 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
AsymmetricEncString implements std::fmt::Display and std::str::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].[data]
Where:
[type]
: is a digit number representing the variant.[data]
: is the encrypted data.
Variants§
Rsa2048_OaepSha256_B64
3
Rsa2048_OaepSha1_B64
4
Rsa2048_OaepSha256_HmacSha256_B64
5
Rsa2048_OaepSha1_HmacSha256_B64
6
Implementations§
Source§impl AsymmetricEncString
impl AsymmetricEncString
Sourcepub fn encrypt_rsa2048_oaep_sha1(
data_dec: &[u8],
key: &dyn AsymmetricEncryptable,
) -> Result<AsymmetricEncString, CryptoError>
pub fn encrypt_rsa2048_oaep_sha1( data_dec: &[u8], key: &dyn AsymmetricEncryptable, ) -> Result<AsymmetricEncString, CryptoError>
Encrypt and produce a AsymmetricEncString::Rsa2048_OaepSha1_B64 variant.
Sourceconst fn enc_type(&self) -> u8
const fn enc_type(&self) -> u8
The numerical representation of the encryption type of the AsymmetricEncString.
Trait Implementations§
Source§impl Clone for AsymmetricEncString
impl Clone for AsymmetricEncString
Source§fn clone(&self) -> AsymmetricEncString
fn clone(&self) -> AsymmetricEncString
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for AsymmetricEncString
To avoid printing sensitive information, AsymmetricEncString debug prints to
AsymmetricEncString
.
impl Debug for AsymmetricEncString
To avoid printing sensitive information, AsymmetricEncString debug prints to
AsymmetricEncString
.
Source§impl<'de> Deserialize<'de> for AsymmetricEncString
impl<'de> Deserialize<'de> for AsymmetricEncString
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 Display for AsymmetricEncString
impl Display for AsymmetricEncString
Source§impl Drop for AsymmetricEncString
impl Drop for AsymmetricEncString
Source§impl FromStr for AsymmetricEncString
Deserializes an AsymmetricEncString from a string.
impl FromStr for AsymmetricEncString
Deserializes an AsymmetricEncString from a string.
Source§impl JsonSchema for AsymmetricEncString
Usually we wouldn’t want to expose AsymmetricEncStrings in the API or the schemas.
But during the transition phase we will expose endpoints using the AsymmetricEncString type.
impl JsonSchema for AsymmetricEncString
Usually we wouldn’t want to expose AsymmetricEncStrings in the API or the schemas. But during the transition phase we will expose endpoints using the AsymmetricEncString 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<AsymmetricCryptoKey, String> for AsymmetricEncString
impl KeyDecryptable<AsymmetricCryptoKey, String> for AsymmetricEncString
fn decrypt_with_key( &self, key: &AsymmetricCryptoKey, ) -> Result<String, CryptoError>
Source§impl KeyDecryptable<AsymmetricCryptoKey, Vec<u8>> for AsymmetricEncString
impl KeyDecryptable<AsymmetricCryptoKey, Vec<u8>> for AsymmetricEncString
fn decrypt_with_key( &self, key: &AsymmetricCryptoKey, ) -> Result<Vec<u8>, CryptoError>
Auto Trait Implementations§
impl Freeze for AsymmetricEncString
impl RefUnwindSafe for AsymmetricEncString
impl Send for AsymmetricEncString
impl Sync for AsymmetricEncString
impl Unpin for AsymmetricEncString
impl UnwindSafe for AsymmetricEncString
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