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§
- Content
Key - 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_blocks16-byte blocks, then leaveskip_blocksblocks clear, repeating across a protected range.Pattern::NONE(crypt_blocks == 0) means full-region encryption — used bycenc/cbc1and for audio undercens/cbcs. - Subsample
- A contiguous run within a sample:
clearplaintext bytes followed byprotectedbytes to encrypt.
Enums§
- Protection
System - A DRM protection system a
psshbox can be generated for. - Scheme
- A CENC protection scheme (the
schmscheme_type).