Expand description
Crate zerodds-security-rtps. Safety classification: SAFE (a pure wire-format adapter; the actual crypto delegates to a [CryptographicPlugin]).
Secure submessage wrapper (OMG DDS-Security 1.1 §7.3.6) + RTPS header AAD codec (§9.5).
§Layer position
Layer 4 — Core Services. Consumes zerodds-security (SPI) +
zerodds-rtps (RTPS submessage layout). Used by the DCPS runtime via
Box<dyn CryptographicPlugin> and the inbound/outbound datapath.
§Public API (as of 1.0.0-rc.1)
Takes one or more plain RTPS submessages (as opaque bytes) and wraps them into:
SEC_PREFIX | SEC_BODY (ciphertext) | SEC_POSTFIXOn the receiver side decode_secured_submessage does the step
in reverse: extract SEC_BODY, send it through the crypto plugin,
return the plaintext.
- Submessage IDs + flags per spec §7.3.6.
encode_secured_submessage+decode_secured_submessagewith a&mut dyn CryptographicPlugincallback — so AES-GCM, HMAC, or future backends are interchangeable.- SRTPS wrap (§9.5 RTPS message protection):
SRTPS_PREFIX+SRTPS_POSTFIXcodec. - Receiver-specific MAC list in the POSTFIX (
MAX_RECEIVER_MACS): one 16-byte MAC per remote reader; single-receiver paths leave the list empty (spec §7.3.6.3 allows that). - Little-endian submessage header (
0x01flag).
§Non-goals
- Big-endian submessage header — the spec allows both; all vendors use LE by default. Re-add additively in major-2.0.
Re-exports§
pub use header_aad::build_rtps_header_aad;pub use header_aad::build_submessage_aad;
Modules§
- header_
aad - RTPS header AAD for SRTPS wrapping — DDS-Security 1.2 §7.4.6.6 + §8.1.
Enums§
- Security
Rtps Error - Error on encode/decode.
Constants§
- MAX_
RECEIVER_ MACS - DoS cap for the MAC list in the SEC_POSTFIX. Each MAC is 20 bytes; 256 MACs = 5 KiB — enough for heterogeneous deployments with hundreds of readers per writer, but far below the RAM-attack threshold.
- PRE_
SHARED_ KEY_ FLAG PreSharedKeyFlagim SRTPS_PREFIX-Submessage-Header — Spec DDS-Security 1.2 §10.9.1.- RTPS_
HEADER_ LEN - RTPS header size (spec §8.3.3.1).
- SEC_
BODY - SEC_BODY submessage ID (spec §7.3.6.4).
- SEC_
POSTFIX - SEC_POSTFIX submessage ID (spec §7.3.6.3).
- SEC_
PREFIX - SEC_PREFIX submessage ID (spec §7.3.6.2).
- SRTPS_
POSTFIX - SRTPS_POSTFIX submessage ID (spec §7.3.6.6).
- SRTPS_
PREFIX - SRTPS_PREFIX submessage ID (spec §7.3.6.5).
Functions§
- decode_
secured_ rtps_ message - Unwraps a whole RTPS message. Expects the same format as
encode_secured_rtps_message. Returns the reconstructed plaintext message ([header | body]). - decode_
secured_ submessage - Decodes a secure-submessage sequence and returns the plaintext.
- decode_
secured_ submessage_ multi - Decodes a secure-submessage sequence WITH a multi-MAC SEC_POSTFIX and returns the plaintext.
- encode_
secured_ rtps_ message - Protects a whole RTPS message. The first 20 bytes (header) stay plaintext; everything after it (the submessage stream) is encrypted + authenticated. Output:
- encode_
secured_ rtps_ message_ psk - Like
encode_secured_rtps_message, but additionally sets thePreSharedKeyFlagin the SRTPS_PREFIX (spec §10.9.1) — for the PSK crypto path. - encode_
secured_ submessage - Encodes a plain submessage blob as a secured submessage sequence (SEC_PREFIX + SEC_BODY + SEC_POSTFIX).
- encode_
secured_ submessage_ multi - Encodes a plain submessage blob as a secured sequence WITH receiver-specific MACs in the SEC_POSTFIX (spec §7.3.6.3).
- srtps_
psk_ flag - Reads the
PreSharedKeyFlagbit from the SRTPS_PREFIX of a secured RTPS message. ReturnsNoneif the wire is not a valid SRTPS wrapping.