pub struct Session<SessionKey: ByteArray<CRYPTO_KX_SESSIONKEYBYTES>> { /* 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>> Session<SessionKey>
impl<SessionKey: NewByteArray<CRYPTO_KX_SESSIONKEYBYTES>> Session<SessionKey>
sourcepub fn new_client<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>(
client_keypair: &KeyPair<PublicKey, SecretKey>,
server_public_key: &PublicKey
) -> Result<Self, Error>
pub fn new_client<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>( 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.
sourcepub fn new_server<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>(
server_keypair: &KeyPair<PublicKey, SecretKey>,
client_public_key: &PublicKey
) -> Result<Self, Error>
pub fn new_server<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>( 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>
impl Session<SessionKey>
sourcepub fn new_client_with_defaults<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>(
client_keypair: &KeyPair<PublicKey, SecretKey>,
server_public_key: &PublicKey
) -> Result<Self, Error>
pub fn new_client_with_defaults<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>( 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.
sourcepub fn new_server_with_defaults<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>(
server_keypair: &KeyPair<PublicKey, SecretKey>,
client_public_key: &PublicKey
) -> Result<Self, Error>
pub fn new_server_with_defaults<PublicKey: ByteArray<CRYPTO_KX_PUBLICKEYBYTES>, SecretKey: ByteArray<CRYPTO_KX_SECRETKEYBYTES>>( 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>> Session<SessionKey>
impl<SessionKey: ByteArray<CRYPTO_KX_SESSIONKEYBYTES>> Session<SessionKey>
sourcepub fn into_parts(self) -> (SessionKey, SessionKey)
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)
.
sourcepub fn rx_as_slice(&self) -> &[u8] ⓘ
pub fn rx_as_slice(&self) -> &[u8] ⓘ
Returns a reference to a slice of the Rx session key.
sourcepub fn tx_as_slice(&self) -> &[u8] ⓘ
pub fn tx_as_slice(&self) -> &[u8] ⓘ
Returns a reference to a slice of the Tx session key.
sourcepub fn rx_as_array(&self) -> &[u8; 32]
pub fn rx_as_array(&self) -> &[u8; 32]
Returns a reference to an array of the Rx session key.
sourcepub fn tx_as_array(&self) -> &[u8; 32]
pub fn tx_as_array(&self) -> &[u8; 32]
Returns a reference to an array of the Tx session key.