dvb-csa
Pure-Rust implementation of the DVB Common Scrambling Algorithm (CSA2) — the cipher underneath conditional access on DVB-S, DVB-T, and DVB-C.
Status: oracle-validated, not spec-cited
DVB-CSA has no public normative specification — the algorithm was confidential and licensed through ETSI. Every open implementation is reverse-engineered. Correctness is established by byte-exact agreement with libdvbcsa 1.1.0 (VideoLAN's reference free implementation): 11 golden vectors (184-byte TS payloads) plus inline multi-size vectors (8 B, 16 B, 32 B, 64 B).
Algorithm overview
DVB-CSA2 combines a block cipher and a stream cipher, both keyed by the same 8-byte control word:
- Block cipher — 56-round substitution/permutation network on 8-byte blocks, applied in a CBC-like chained mode across all complete blocks.
- Stream cipher — LFSR-based byte-stream generator seeded from the nibble-swapped control word and the encrypted first block as IV, XOR'd with bytes 8..end.
Encrypt = block CBC then stream XOR; decrypt = stream XOR then block CBC undo. Payloads shorter than 8 bytes pass through unchanged.
Usage
use ;
let cw = from_bytes;
let mut payload = vec!;
scramble;
descramble;
// payload is back to all 0xAA
For TS-packet-level operation (extracts the payload, respects the adaptation field):
use ;
let cw = from_bytes;
let mut packet = ;
// ... fill packet ...
let _ = scramble_ts_packet;
Features
| Feature | Default | What it does |
|---|---|---|
std |
yes | Enables std::error::Error on Error |
Builds no_std without default features.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.