Struct bitwarden_crypto::Sensitive
source · pub struct Sensitive<V: Zeroize> { /* private fields */ }Expand description
Wrapper for sensitive values which makes a best effort to enforce zeroization of the inner value
on drop. The inner value exposes a Sensitive::expose method which returns a reference to the
inner value. Care must be taken to avoid accidentally exposing the inner value through copying
or cloning.
Internally Sensitive contains a Box which ensures the value is placed on the heap. It
implements the Drop trait which calls zeroize on the inner value.
Implementations§
source§impl<V: Zeroize> Sensitive<V>
impl<V: Zeroize> Sensitive<V>
sourcepub fn expose(&self) -> &V
pub fn expose(&self) -> &V
Expose the inner value. By exposing the inner value, you take responsibility for ensuring that any copy of the value is zeroized.
sourcepub fn expose_mut(&mut self) -> &mut V
pub fn expose_mut(&mut self) -> &mut V
Expose the inner value mutable. By exposing the inner value, you take responsibility for ensuring that any copy of the value is zeroized.
source§impl Sensitive<String>
impl Sensitive<String>
pub fn decode_base64<T: Engine>( self, engine: T ) -> Result<SensitiveVec, CryptoError>
source§impl Sensitive<Vec<u8>>
impl Sensitive<Vec<u8>>
pub fn encode_base64<T: Engine>(self, engine: T) -> SensitiveString
source§impl<V: Zeroize> Sensitive<V>
impl<V: Zeroize> Sensitive<V>
pub fn test<T: ?Sized>(value: &'static T) -> Selfwhere
&'static T: Into<V>,
Trait Implementations§
source§impl<'de, V: Zeroize + Deserialize<'de>> Deserialize<'de> for Sensitive<V>
impl<'de, V: Zeroize + Deserialize<'de>> Deserialize<'de> for Sensitive<V>
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
source§impl<const N: usize> From<Sensitive<[u8; N]>> for SensitiveVec
impl<const N: usize> From<Sensitive<[u8; N]>> for SensitiveVec
Helper to convert a Sensitive<[u8, N]> to a SensitiveVec.
source§impl From<Sensitive<String>> for SensitiveVec
impl From<Sensitive<String>> for SensitiveVec
source§fn from(s: SensitiveString) -> Self
fn from(s: SensitiveString) -> Self
source§impl<V: Zeroize + JsonSchema> JsonSchema for Sensitive<V>
impl<V: Zeroize + JsonSchema> JsonSchema for Sensitive<V>
Transparently expose the inner value for serialization
source§fn schema_name() -> String
fn schema_name() -> String
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moresource§impl<V: PartialEq + Zeroize> PartialEq for Sensitive<V>
impl<V: PartialEq + Zeroize> PartialEq for Sensitive<V>
source§impl<V: Zeroize + Serialize> Serialize for Sensitive<V>
impl<V: Zeroize + Serialize> Serialize for Sensitive<V>
Unfortunately once we serialize a SensitiveString we can’t control the future memory.
source§impl TryFrom<Sensitive<String>> for DeviceKey
impl TryFrom<Sensitive<String>> for DeviceKey
§type Error = CryptoError
type Error = CryptoError
source§impl TryFrom<Sensitive<String>> for SymmetricCryptoKey
impl TryFrom<Sensitive<String>> for SymmetricCryptoKey
§type Error = CryptoError
type Error = CryptoError
source§impl TryFrom<Sensitive<Vec<u8>>> for SensitiveString
impl TryFrom<Sensitive<Vec<u8>>> for SensitiveString
Helper to convert a Sensitive<Vec<u8>> to a Sensitive<String>, care is taken to ensure any
intermediate copies are zeroed to avoid leaking sensitive data.
§type Error = CryptoError
type Error = CryptoError
source§fn try_from(v: SensitiveVec) -> Result<Self, CryptoError>
fn try_from(v: SensitiveVec) -> Result<Self, CryptoError>
source§impl TryFrom<Sensitive<Vec<u8>>> for SymmetricCryptoKey
impl TryFrom<Sensitive<Vec<u8>>> for SymmetricCryptoKey
§type Error = CryptoError
type Error = CryptoError
impl<V: Zeroize> StructuralPartialEq for Sensitive<V>
Auto Trait Implementations§
impl<V> Freeze for Sensitive<V>
impl<V> RefUnwindSafe for Sensitive<V>where
V: RefUnwindSafe,
impl<V> Send for Sensitive<V>where
V: Send,
impl<V> Sync for Sensitive<V>where
V: Sync,
impl<V> Unpin for Sensitive<V>
impl<V> UnwindSafe for Sensitive<V>where
V: UnwindSafe,
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> 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