hopr_crypto_types::utils

Struct SecretValue

Source
pub struct SecretValue<L: ArrayLength<u8>>(/* private fields */);
Expand description

Represents a secret value of a fixed length that is zeroized on drop. Secret values are always compared in constant time. The default value is all zeroes.

Implementations§

Source§

impl<L: ArrayLength<u8>> SecretValue<L>

Source

pub const LENGTH: usize = L::USIZE

Length of the secret value in bytes.

Source

pub fn random() -> Self

Generates cryptographically strong random secret value.

Trait Implementations§

Source§

impl<L: ArrayLength<u8>> AsMut<[u8]> for SecretValue<L>

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<L: ArrayLength<u8>> AsRef<[u8]> for SecretValue<L>

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<L: Clone + ArrayLength<u8>> Clone for SecretValue<L>

Source§

fn clone(&self) -> SecretValue<L>

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<L: ArrayLength<u8>> ConstantTimeEq for SecretValue<L>

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl<L: ArrayLength<u8>> Default for SecretValue<L>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<L: ArrayLength<u8>> Drop for SecretValue<L>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'a, L: ArrayLength<u8>> From<&'a SecretValue<L>> for &'a GenericArray<u8, L>

Source§

fn from(value: &'a SecretValue<L>) -> Self

Converts to this type from the input type.
Source§

impl<L: ArrayLength<u8>> From<GenericArray<u8, L>> for SecretValue<L>

Source§

fn from(value: GenericArray<u8, L>) -> Self

Converts to this type from the input type.
Source§

impl<L: ArrayLength<u8>> From<SecretValue<L>> for Box<[u8]>

Source§

fn from(value: SecretValue<L>) -> Self

Converts to this type from the input type.
Source§

impl<L: ArrayLength<u8>> TryFrom<&[u8]> for SecretValue<L>

Source§

type Error = CryptoError

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

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<L: ArrayLength<u8>> Zeroize for SecretValue<L>

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.

Auto Trait Implementations§

§

impl<L> Freeze for SecretValue<L>
where <L as ArrayLength<u8>>::ArrayType: Freeze,

§

impl<L> RefUnwindSafe for SecretValue<L>
where <L as ArrayLength<u8>>::ArrayType: RefUnwindSafe,

§

impl<L> Send for SecretValue<L>

§

impl<L> Sync for SecretValue<L>

§

impl<L> Unpin for SecretValue<L>
where <L as ArrayLength<u8>>::ArrayType: Unpin,

§

impl<L> UnwindSafe for SecretValue<L>
where <L as ArrayLength<u8>>::ArrayType: UnwindSafe,

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
§

impl<T, U> AsByteSlice<T> for U
where T: ToByteSlice, U: AsRef<[T]> + ?Sized,

§

fn as_byte_slice(&self) -> &[u8]

§

impl<T, U> AsMutByteSlice<T> for U
where T: ToMutByteSlice, U: AsMut<[T]> + ?Sized,

§

fn as_mut_byte_slice(&mut self) -> &mut [u8]

§

impl<U> AsMutSliceOf for U
where U: AsMut<[u8]> + ?Sized,

§

fn as_mut_slice_of<T>(&mut self) -> Result<&mut [T], Error>
where T: FromByteSlice,

§

impl<U> AsSliceOf for U
where U: AsRef<[u8]> + ?Sized,

§

fn as_slice_of<T>(&self) -> Result<&[T], Error>
where T: FromByteSlice,

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToHex for T
where T: AsRef<[u8]>,

Source§

fn encode_hex<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca)
Source§

fn encode_hex_upper<U>(&self) -> U
where U: FromIterator<char>,

Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA)
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, 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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> JsonSchemaMaybe for T