bitwarden_crypto::enc_string::asymmetric::internal

Enum AsymmetricEncString

Source
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

Fields

§data: Vec<u8>
§

Rsa2048_OaepSha1_B64

4

Fields

§data: Vec<u8>
§

Rsa2048_OaepSha256_HmacSha256_B64

👎Deprecated

5

Fields

§data: Vec<u8>
👎Deprecated
§mac: Vec<u8>
👎Deprecated
§

Rsa2048_OaepSha1_HmacSha256_B64

👎Deprecated

6

Fields

§data: Vec<u8>
👎Deprecated
§mac: Vec<u8>
👎Deprecated

Implementations§

Source§

impl AsymmetricEncString

Source

pub fn encrypt_rsa2048_oaep_sha1( data_dec: &[u8], key: &dyn AsymmetricEncryptable, ) -> Result<AsymmetricEncString, CryptoError>

Encrypt and produce a AsymmetricEncString::Rsa2048_OaepSha1_B64 variant.

Source

const fn enc_type(&self) -> u8

The numerical representation of the encryption type of the AsymmetricEncString.

Trait Implementations§

Source§

impl Clone for AsymmetricEncString

Source§

fn clone(&self) -> AsymmetricEncString

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AsymmetricEncString

To avoid printing sensitive information, AsymmetricEncString debug prints to AsymmetricEncString.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AsymmetricEncString

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for AsymmetricEncString

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for AsymmetricEncString

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl FromStr for AsymmetricEncString

Deserializes an AsymmetricEncString from a string.

Source§

type Err = CryptoError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
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.

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl KeyDecryptable<AsymmetricCryptoKey, String> for AsymmetricEncString

Source§

impl KeyDecryptable<AsymmetricCryptoKey, Vec<u8>> for AsymmetricEncString

Source§

impl Serialize for AsymmetricEncString

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,