Skip to main content

pamoja_session_establish

Function pamoja_session_establish 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_session_establish( local: *const PamojaAgreementKey, peer_public_key: *const u8, salt: *const u8, salt_len: usize, role: PamojaSessionRole, ) -> *mut PamojaSession
Expand description

Establishes a session with a peer.

Both devices call this with the same salt and opposite roles, and arrive at the same key without either sending it. The salt is a fresh per-session value exchanged in the clear; reusing one with the same pair of keys reuses the session key, so it must change each session.

§Arguments

  • local - this device key-agreement secret.
  • peer_public_key - the PAMOJA_SESSION_KEY_LEN-byte public key of the peer, already authenticated by pinning or by a signature.
  • salt - the fresh per-session salt both sides share.
  • salt_len - the length of salt.
  • role - whether this device opens the session or answers.

§Returns

A handle the caller must release with pamoja_session_free, or null on failure.

§Safety

local must be a live agreement key handle, peer_public_key must point to at least PAMOJA_SESSION_KEY_LEN readable bytes, and salt must point to at least salt_len readable bytes, or be null when salt_len is 0.