Lesson
The theory โ Encrypting One Block in Ten (CENC cbcs)
Common Encryption (ISO/IEC 23001-7) lets one set of encrypted files serve several DRM systems. It encrypts media samples with AES-128 and keeps their structure readable: each coded video slice is split into a clear part, the NAL unit's length, header and slice header, and a protected range after it. The cenc scheme runs AES in counter mode over every byte of that range. The cbcs scheme runs AES in CBC mode over a pattern of whole 16-byte blocks, one encrypted and nine left clear, repeated to the end of the range, and a partial block at the end stays clear.
What each symbol means
L- the slice, one coded-slice NAL unit, in bytes
h- the clear header: length prefix, NAL header and slice header, which subsample encryption leaves readable
B- whole 16-byte blocks in the protected range P = L โ h; cbcs encrypts โB/10โ of them
- Assumes
- One slice size for the whole stream. A real encoder writes large slices for the pictures others are predicted from and small ones for the rest, so the per-slice figures hold slice by slice and the stream figures describe a stream of equal slices. The clear header is 32 bytes by default because that is the one length a specification fixes: Apple's SAMPLE-AES leaves the NAL type byte and the 31 bytes after it clear. A CENC packager clears exactly the headers, which vary from slice to slice. Parameter sets, SEI messages and the MP4 boxes around the samples are clear and are left out, so a real file's ciphertext share is a little lower. Audio is AAC-LC at 48 kHz, 1024 samples a frame, and encrypted; a service that leaves its audio clear takes the audio out of the work as well.
- Breaks when
- As a way to hide anything but the pictures. The clear headers are there to be read, and they give away the type of every slice, the size of every frame and the timing of the whole stream to anyone holding the file, with the key or without it.
Problem solved in full
-
The most a 1:9 pattern can over-encrypt 3 steps
How far above a tenth can a slice go? Press One slice per macroblock row: 306 bytes, 10.46% ciphertext. The page prints one slice at a time. Find the largest share cbcs can encrypt of any slice of at least 1,000 bytes with a 32-byte header, and how that worst case shrinks as slices grow.
-
The share is 16โB/10โ/L. While โB/10โ holds still it only falls as L grows, so the worst sizes are the ones where a new encrypted block has just begun: a protected range of exactly 10k + 1 whole blocks, with k + 1 of them encrypted.
-
At those sizes L = h + 16(10k + 1). Divide, and split off the tenth: what remains is the excess over 10%, a fixed number of bytes over L.
-
With h = 32 the excess is 11.2 bytes over L. The first worst size at or above 1,000 bytes is k = 6: 61 whole blocks, 7 of them encrypted, in a slice of 1,008 bytes.
Answer
112 bytes of 1,008, 11.11%, and nothing of 1,000 bytes or more does worse. The excess falls as 1/L: the worst slice of 10,000 bytes or more is 10,128 bytes at 10.11%, the top of the band the first insight quotes. The formula also says which header ends the over-encryption. The excess is 16 โ (h + 16)/10 bytes, which is zero at h = 144, and a slice whose clear header is 144 bytes or longer never has more than a tenth of itself encrypted, at any size.
-
References (3)
- The standard itself. Paywalled; the publisher's preview is openly readable and carries the introduction, the scope and the table of contents, which is where the page's two quotations come from: ISO/IEC 23001-7:2023, Information technology โ MPEG systems technologies โ Part 7: Common encryption in ISO base media file format files. 4th edition. Preview via iTeh Standards.
- The cbcs rules as a working decryptor applies them, with the standard's ยง9.6.1 and ยง10.4.2 quoted in its comments: the pattern over whole blocks, the partial block left clear, and a 0:0 pattern meaning every block: The Chromium Authors, media/cdm/cbcs_decryptor.cc, Chromium source tree (BSD licence).
- HLS's transport-stream format, SAMPLE-AES, which uses the same one-block-in-ten pattern with a fixed 32-byte clear leader. RFC 8216 names it as the format for non-fMP4 segments and 'cbcs' for fMP4 ones: Apple Inc., "MPEG-2 Stream Encryption Format for HTTP Live Streaming", ยง2.2 H.264 Video Streams and ยง2.3 Audio Streams. Documentation Archive, updated 2015-10-29.