Skip to main content

pamoja_session_seal

Function pamoja_session_seal 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn pamoja_session_seal( session: *mut PamojaSession, buf: *mut u8, len: usize, aad: *const u8, aad_len: usize, out_sealed: *mut PamojaSealed, ) -> PamojaStatus
Expand description

Seals a message for the peer, encrypting it in place.

The associated data is authenticated but not encrypted, so it stays readable on the wire yet cannot be altered: a device identifier or a routing header belongs there. On success buf holds the ciphertext and out_sealed holds the counter and tag to send with it.

§Arguments

  • session - the session.
  • buf - the plaintext, replaced by the ciphertext of equal length.
  • len - the length of buf.
  • aad - associated data to authenticate alongside the message.
  • aad_len - the length of aad.
  • out_sealed - receives the counter and tag.

§Returns

PamojaStatus::Ok on success.

§Safety

session must be a live handle from pamoja_session_establish, buf must point to at least len readable and writable bytes or be null when len is 0, aad must point to at least aad_len readable bytes or be null when aad_len is 0, and out_sealed must be writable.