Skip to main content

Module payload

Module payload 

Source
Expand description

Payload serialization, compression, and file embedding.

The payload format wraps the plaintext before encryption:

[1 byte ] flags
[M bytes] inner payload (raw or Brotli-compressed depending on flags)

The inner payload (after decompression) uses a 0x00 separator:

[text bytes]     UTF-8 message (may be empty)
[0x00]           separator (only present if files follow)
[file entry]*    zero or more file entries

File entry format:

[1 byte ] filename_len (1–255)
[N bytes] filename (UTF-8)
[4 bytes] content_len (u32 BE)
[M bytes] file content

Structs§

FileEntry
A file entry embedded in the payload.
PayloadData
Decoded payload containing text and optional files.

Constants§

MAX_RAW_FILE_SIZE
Maximum raw file size before compression (hard reject).

Functions§

compressed_payload_size
Compute the compressed payload size (in bytes) for the given text and files.
decode_payload
Decode a payload from decrypted bytes.
encode_payload
Encode a payload (text + optional files) into bytes ready for encryption.