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:
- A
Redactoronly obscures data: it maps the 6 octets of a MAC/BSSID to 6 octets safe to display, and an SSID to a fixed-size digest. It never decides how those bytes are rendered. - A
Redactabletype owns its string representation. It provides its raw formatting inRedactable::fmt_unredactedand formats the bytes returned by aRedactorinRedactable::fmt_redacted; itsDisplay/Debugimpls (seeimpl_display_via_redactable!) callRedactable::fmt_dispatch, which picks one depending on whether a global redactor has been installed.
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_redactorsynchronously installsMaskingRedactor, which preserves the first 3 OUI octets of a MAC and zeroes everything else, before the per-boot salt arrives.set_salted_redactortransitions the global redactor toSaltedRedactor, 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::Debugfor a type that implementsRedactableby delegating toRedactable::fmt_dispatch, so{:?}produces the same (possibly redacted) output as{}. - impl_
display_ via_ redactable - Implements
core::fmt::Displayfor a type that implementsRedactableby delegating toRedactable::fmt_dispatch.
Structs§
- Masking
Redactor - A
Redactorthat 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. - Salted
Redactor - A
Redactorthat hashes identifiers using a 32-byte per-boot secret salt. - SetRedactor
Error - Error returned when attempting to install a final global
Redactorafter one has already been installed. - Unredacted
- A
Displayadapter that always formats aRedactablevalue 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_redactedimplementations 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
Redactorproduces for an SSID.
Traits§
- Redactable
- Trait implemented by identifier types (such as MAC addresses, BSSIDs, and
SSIDs) whose
DisplayandDebugrepresentations support redaction via the globalRedactor. - Redactor
- Strategy for obscuring MAC addresses, BSSIDs, and SSIDs.
Functions§
- set_
masking_ redactor - Synchronously transitions the global redactor from
UninitializedtoMaskingRedactorwhile the per-boot salt is being fetched asynchronously. - set_
salted_ redactor - Installs a
SaltedRedactorwith the givensaltas the global redactor.