Skip to main content

Crate redactor

Crate redactor 

Source
Expand description

Shared #![no_std] in-process redaction and hashing utilities for network identifiers (MAC addresses, BSSIDs, and SSIDs).

This crate is #![no_std] so that platform-agnostic base crates such as net-types and ieee80211 can implement Redactable directly and share a single process-global Redactor state machine.

Responsibilities are split in two:

By default (such as on eng builds, in unit tests, and in host tools), no global redactor is installed and fmt_dispatch writes the raw value.

When initialized at component startup on user and userdebug builds:

  • set_masking_redactor synchronously installs MaskingRedactor, which preserves the first 3 OUI octets of a MAC and zeroes everything else, before the per-boot salt arrives.
  • set_salted_redactor transitions the global redactor to SaltedRedactor, which preserves the first 3 OUI octets of a MAC/BSSID and replaces the last 3 octets (and the SSID) with a salted SHA-256 digest keyed by a 32-byte per-boot random salt.

Macros§

impl_debug_via_redactable
Implements core::fmt::Debug for a type that implements Redactable by delegating to Redactable::fmt_dispatch, so {:?} produces the same (possibly redacted) output as {}.
impl_display_via_redactable
Implements core::fmt::Display for a type that implements Redactable by delegating to Redactable::fmt_dispatch.

Structs§

MaskingRedactor
A Redactor that preserves the first 3 OUI vendor octets of a MAC and zeroes the remaining 3 octets, and zeroes SSID digests. Used in the window between component startup and the per-boot salt becoming available.
SaltedRedactor
A Redactor that hashes identifiers using a 32-byte per-boot secret salt.
SetRedactorError
Error returned when attempting to install a final global Redactor after one has already been installed.
Unredacted
A Display adapter that always formats a Redactable value in its raw, unredacted form, bypassing the global redactor.

Constants§

MAC_LEN
Length in bytes of an IEEE 802.3 / 802.11 MAC address or BSSID.
REDACTED_MARKER
Suffix that Redactable::fmt_redacted implementations append so a redacted identifier is distinguishable at a glance from a raw one (e.g. 00:1a:2b:9f:3e:c1*). Shared so every crate emits the same marker and cross-component correlation keeps working.
SALT_LEN
Length in bytes of the per-boot random salt.
SSID_DIGEST_LEN
Length in bytes of the digest a Redactor produces for an SSID.

Traits§

Redactable
Trait implemented by identifier types (such as MAC addresses, BSSIDs, and SSIDs) whose Display and Debug representations support redaction via the global Redactor.
Redactor
Strategy for obscuring MAC addresses, BSSIDs, and SSIDs.

Functions§

set_masking_redactor
Synchronously transitions the global redactor from Uninitialized to MaskingRedactor while the per-boot salt is being fetched asynchronously.
set_salted_redactor
Installs a SaltedRedactor with the given salt as the global redactor.