Skip to main content

PrivateSecret

Struct PrivateSecret 

Source
pub struct PrivateSecret { /* private fields */ }
Expand description

A per-run shared secret. Never printed; compare with verify only.

Implementations§

Source§

impl PrivateSecret

Source

pub fn generate() -> Result<Self, SecretError>

A fresh secret from the OS random source.

Source

pub fn from_hex(text: &str) -> Result<Self, SecretError>

Parse the text form (exactly SECRET_HEX_LEN lowercase hex digits; no surrounding whitespace).

Source

pub fn expose(&self) -> &str

The text form, for putting in a frame or on a pipe. Do not log it.

Source

pub fn verify(&self, presented: &str) -> bool

Constant-time check of a presented secret. The comparison always runs over the full fixed-length buffer, and a presented value of the wrong length fails without an early return, so neither content nor length-prefix match leaks through timing.

Source

pub fn read_from(reader: &mut impl BufRead) -> Result<Self, SecretError>

Read the secret from the first line of reader, at most SECRET_HEX_LEN plus a line ending long. For the child’s stdin; the generic form exists for tests.

Source

pub fn read_from_stdin() -> Result<Self, SecretError>

Read the secret from this process’s stdin. Call it once, first, before anything else reads stdin; later reads (see watch_stdin_eof) continue after the secret line.

Trait Implementations§

Source§

impl Clone for PrivateSecret

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PrivateSecret

Source§

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

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

impl Drop for PrivateSecret

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.