Skip to main content

Module open_org_invite_crypto

Module open_org_invite_crypto 

Source
Expand description

§open_org_invite_crypto

Open-organization-invite registration crossing.

The app seals an open org invite context on registration-start submit and unseals it on the accept open-org-invite component after a successful registration-finish. This module owns the versioned plaintext payload (data_v1), the domain types and crypto operations (open_org_invite), their wire encoding (serialization), and the FFI-facing client methods (client).

Two envelopes protect the invite: a fresh CEK encrypts the plaintext, and a fresh 256-bit HighEntropySecret encrypts that CEK. The paired envelopes travel together as SealedOpenOrgInviteData; the HighEntropySecret is returned separately to the caller and kept client-side. Both halves are required to unseal.

§Key-protection diagram

  • Audience: engineers touching this module.
  • Intent: show which key protects what.
  • Scope: the two envelopes composing SealedOpenOrgInviteData (excludes app flow, wire encoding, and FFI).
flowchart LR
    HES["HighEntropySecret<br/>(kept client-side)"]
    CEK[CEK]
    Plain["OpenOrgInvite<br/>{ organization_id, invite_link_code, invite_secret }"]
    HES -->|"SecretProtectedKeyEnvelope<br/>(key_envelope)"| CEK
    CEK -->|"DataEnvelope<br/>(data_envelope)"| Plain
  • HighEntropySecret -> SecretProtectedKeyEnvelope -> CEK (key_envelope): the CEK sealed under a fresh 32-byte HighEntropySecret returned to the caller and kept client-side.
  • CEK -> DataEnvelope -> OpenOrgInvite (data_envelope): the versioned invite plaintext sealed under the fresh CEK. AES-GCM’s auth tag at each layer is the substitution defense.

Re-exports§

pub use client::SealedOpenOrgInvite;
pub use open_org_invite::OpenOrgInvite;
pub use open_org_invite::SealedOpenOrgInviteData;
pub use serialization::SealedOpenOrgInviteDataError;

Modules§

client 🔒
FFI-facing seal/unseal. The RegistrationClient methods are thin wrappers over SealedOpenOrgInviteData::seal / SealedOpenOrgInviteData::unseal; SealedOpenOrgInvite bundles both halves of the seal output as one WASM return type.
data_v1 🔒
Version 1 of the open-org-invite plaintext payload — the innermost thing sealed by the [bitwarden_crypto::safe::DataEnvelope]. Not to be confused with the sealed opaque blob (super::SealedOpenOrgInviteData) or the outbound JSON (super::SealedOpenOrgInvite); this file describes only the cleartext shape that gets CBOR-encoded and encrypted.
open_org_invite 🔒
OpenOrgInvite and its sealed form SealedOpenOrgInviteData, and the seal/unseal operations between them. Seal returns the sealed blob paired with a HighEntropySecret.
serialization 🔒
Wire encoding for SealedOpenOrgInviteData. Its two internal envelopes are packed with CBOR (compact binary format) then base64url-wrapped so it crosses every boundary as one opaque string — via serde on the Rust side and the WASM ABI (wasm-bindgen’s Rust↔JS conversion layer) into TypeScript.

Enums§

RegistrationOpenOrgInviteData 🔒