Skip to main content

Crate sheathe_crypto

Crate sheathe_crypto 

Source
Expand description

Common Encryption (ISO/IEC 23001-7) for sheathe.

Mirrors Shaka Packager’s media/crypto: the four CENC protection schemes plus a sample Encryptor that applies them, all on top of a pure-Rust AES-128 block cipher.

  • cenc — AES-128 CTR, full-region. The keystream runs continuously across a sample’s protected byte ranges (clear ranges do not advance the counter).
  • cens — AES-128 CTR with pattern encryption: only the crypt-phase blocks consume keystream; skipped blocks pass through clear, the counter continuing across them.
  • cbc1 — AES-128 CBC, full-region. CBC chaining runs continuously across the sample (clear ranges are skipped); a trailing partial block (< 16 bytes) of each protected range is left in the clear.
  • cbcs — AES-128 CBC with pattern encryption, chaining reset to the constant IV at the start of each subsample; trailing partial blocks clear.

Pattern encryption (cens/cbcs) is, by convention, applied to video only; audio uses Pattern::NONE (full-region) even under those schemes. The caller decides the per-track pattern and the NAL-aware clear/protected split via the Subsample list, so this crate stays format-agnostic.

Structs§

ContentKey
A content key plus its 16-byte Key ID (KID).
Encryptor
An AES-128 sample encryptor bound to one content key.
Pattern
A crypt/skip block pattern (ISO/IEC 23001-7 §9.6): encrypt crypt_blocks 16-byte blocks, then leave skip_blocks blocks clear, repeating across a protected range. Pattern::NONE (crypt_blocks == 0) means full-region encryption — used by cenc/cbc1 and for audio under cens/cbcs.
Subsample
A contiguous run within a sample: clear plaintext bytes followed by protected bytes to encrypt.

Enums§

ProtectionSystem
A DRM protection system a pssh box can be generated for.
Scheme
A CENC protection scheme (the schm scheme_type).