SshkdfBuilder

Struct SshkdfBuilder 

Source
pub struct SshkdfBuilder<'a> { /* private fields */ }
Expand description

SSH key-derivation builder (RFC 4253 §7.2).

let iv = SshkdfBuilder::new(&sha256, &shared_secret, &exchange_hash, &session_id,
                            SshkdfKeyType::InitialIvClientToServer)
    .derive_to_vec(16)?;

Implementations§

Source§

impl<'a> SshkdfBuilder<'a>

Source

pub fn new( digest: &'a DigestAlg, key: &'a [u8], xcghash: &'a [u8], session_id: &'a [u8], key_type: SshkdfKeyType, ) -> Self

Create an SSH-KDF builder.

  • digest — hash algorithm (e.g. SHA-256).
  • key — the shared secret K from the Diffie-Hellman exchange.
  • xcghash — exchange hash H.
  • session_id — the session identifier (= first H for the session).
  • key_type — which key/IV component to derive (A–F).
Source

pub fn derive(self, out: &mut [u8]) -> Result<(), ErrorStack>

Derive key material, writing into out.

§Errors
Source

pub fn derive_to_vec(self, len: usize) -> Result<Vec<u8>, ErrorStack>

Derive len bytes, returning them in a freshly allocated Vec<u8>.

§Errors

Auto Trait Implementations§

§

impl<'a> Freeze for SshkdfBuilder<'a>

§

impl<'a> RefUnwindSafe for SshkdfBuilder<'a>

§

impl<'a> Send for SshkdfBuilder<'a>

§

impl<'a> Sync for SshkdfBuilder<'a>

§

impl<'a> Unpin for SshkdfBuilder<'a>

§

impl<'a> UnwindSafe for SshkdfBuilder<'a>

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> 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, 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.