Struct dryoc::kx::Session

source ·
pub struct Session<SessionKey: ByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize> { /* private fields */ }
Expand description

Key derivation implemantation based on Curve25519, Diffie-Hellman, and Blake2b. Compatible with libsodium’s crypto_kx_* functions.

Implementations§

source§

impl<SessionKey: NewByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize> Session<SessionKey>

source

pub fn new_client<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES> + Zeroize>( client_keypair: &KeyPair<PublicKey, SecretKey>, server_public_key: &PublicKey ) -> Result<Self, Error>

Computes client session keys, given client_keypair and server_public_key, returning a new session upon success.

source

pub fn new_server<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES> + Zeroize>( server_keypair: &KeyPair<PublicKey, SecretKey>, client_public_key: &PublicKey ) -> Result<Self, Error>

Computes server session keys, given server_keypair and client_public_key, returning a new session upon success.

source§

impl Session<SessionKey>

source

pub fn new_client_with_defaults<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES> + Zeroize>( client_keypair: &KeyPair<PublicKey, SecretKey>, server_public_key: &PublicKey ) -> Result<Self, Error>

Returns a new client session upon success using the default types for the given client_keypair and server_public_key. Wraps Session::new_client, provided for convenience.

source

pub fn new_server_with_defaults<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES> + Zeroize, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES> + Zeroize>( server_keypair: &KeyPair<PublicKey, SecretKey>, client_public_key: &PublicKey ) -> Result<Self, Error>

Returns a new server session upon success using the default types for the given server_keypair and client_public_key. Wraps Session::new_server, provided for convenience.

source§

impl<SessionKey: ByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize> Session<SessionKey>

source

pub fn into_parts(self) -> (SessionKey, SessionKey)

Moves the rx_key and tx_key out of this instance, returning them as a tuple with (rx_key, tx_key).

source

pub fn rx_as_slice(&self) -> &[u8]

Returns a reference to a slice of the Rx session key.

source

pub fn tx_as_slice(&self) -> &[u8]

Returns a reference to a slice of the Tx session key.

source

pub fn rx_as_array(&self) -> &[u8; 32]

Returns a reference to an array of the Rx session key.

source

pub fn tx_as_array(&self) -> &[u8; 32]

Returns a reference to an array of the Tx session key.

Trait Implementations§

source§

impl<SessionKey: Clone + ByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize> Clone for Session<SessionKey>

source§

fn clone(&self) -> Session<SessionKey>

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<SessionKey: Debug + ByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize> Debug for Session<SessionKey>

source§

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

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

impl<'de, SessionKey> Deserialize<'de> for Session<SessionKey>
where SessionKey: Deserialize<'de> + ByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize,

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<SessionKey> Serialize for Session<SessionKey>
where SessionKey: Serialize + ByteArray<CRYPTO_KX_SESSIONKEYBYTES> + Zeroize,

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

impl<SessionKey> Zeroize for Session<SessionKey>
where SessionKey: Zeroize + ByteArray<CRYPTO_KX_SESSIONKEYBYTES>,

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<SessionKey> Freeze for Session<SessionKey>
where SessionKey: ByteArray<32> + Bytes + Freeze,

§

impl<SessionKey> RefUnwindSafe for Session<SessionKey>
where SessionKey: ByteArray<32> + Bytes + RefUnwindSafe,

§

impl<SessionKey> Send for Session<SessionKey>
where SessionKey: ByteArray<32> + Bytes + Send,

§

impl<SessionKey> Sync for Session<SessionKey>
where SessionKey: ByteArray<32> + Bytes + Sync,

§

impl<SessionKey> Unpin for Session<SessionKey>
where SessionKey: ByteArray<32> + Bytes + Unpin,

§

impl<SessionKey> UnwindSafe for Session<SessionKey>
where SessionKey: ByteArray<32> + Bytes + 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
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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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

§

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.
source§

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