Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The CSS Cipher

The Content Scramble System (CSS) is the encryption that protected movies on commercial DVD-Video discs. It was introduced around 1996, when DVDs first went on sale. It’s a stream cipher built from two LFSRs, one with 17 bits and one with 25 bits, seeded from a 40-bit key.

A DVD player doesn’t just hold one key. Each licensed player has its own player key. The player uses it to unlock a disc key stored on the disc, uses the disc key to unlock title keys, and uses those to unscramble the video. Each of these steps uses the same cipher, built from two LFSRs.

What makes CSS interesting is how it combines the two LFSRs. On the previous page you saw that LFSRsum, which combines two LFSRs with XOR, falls to a system of linear equations. CSS combines them with addition with carry instead, so the key bits no longer satisfy linear equations.

Addition with Carry

XOR is addition without carrying (see Binary Operations). CSS uses ordinary addition, carries included:

babyCSS

To see how this works, we’ll use a small version called babyCSS. It uses exactly the same LFSRs and key as the LFSRsum example:

  • LFSR-B: bits b3 b2 b1 b0b_3\, b_2\, b_1\, b_0, taps b1b_1 and b0b_0 (characteristic polynomial x4+x+1x^4 + x + 1).

  • LFSR-C: bits c4 c3 c2 c1 c0c_4\, c_3\, c_2\, c_1\, c_0, taps c2c_2 and c0c_0 (characteristic polynomial x5+x2+1x^5 + x^2 + 1).

  • Key: 7 bits, k1⋯k7k_1 \cdots k_7. The seeds are k1 k2 k3 1k_1\, k_2\, k_3\, 1 for LFSR-B and k4 k5 k6 k7 1k_4\, k_5\, k_6\, k_7\, 1 for LFSR-C.

The only difference from LFSRsum is step 2: the outputs are added with carry, not XOR-ed.

Example of babyCSS

You receive the ciphertext 11111100 00001110, enciphered with babyCSS and the key 0011001. Decipher it.

Solution: The key gives the same seeds as the LFSRsum example, 0011 and 10011, so the registers produce the same output streams:

LFSR-B output:   11000100 11010111
LFSR-C output:   11001111 10001101

Add the first pair of bytes. In decimal this is 196+207=403196 + 207 = 403, which needs 9 bits:

11000100+ 110011111 10010011\begin{array}{r} \texttt{11000100} \\ +\text{ } \texttt{11001111} \\ \hline \texttt{1}\,\texttt{10010011} \end{array}

The first keystream byte is 10010011, and the carry out bit, 1, moves on to the next pair. Add the second pair of bytes, plus that carry: 215+141+1=357215 + 141 + 1 = 357.

1101011110001101+ 11 01100101\begin{array}{r} \texttt{11010111} \\ \texttt{10001101} \\ +\text{ } \texttt{1} \\ \hline \texttt{1}\,\texttt{01100101} \end{array}

The second keystream byte is 01100101. (Its carry out would go into a third byte, if the message were longer.) Finally, XOR the ciphertext with the keystream:

   ciphertext:   11111100 00001110
    keystream: ⊕ 10010011 01100101
                 -----------------
    plaintext:   01101111 01101011    ('ok')

The plaintext is ok. Compare this with the LFSRsum example, where the same key and plaintext gave the keystream 00001011 01011010. The registers are the same, but the carries change 9 of the 16 keystream bits.

babyCSS in Python

The function below follows the steps above. It splits each LFSR’s output into bytes, adds them one pair at a time, and carries into the next pair. Since enciphering and deciphering are the same XOR, one function does both.

['10010011', '01100101']
'\xfc\x0e'
ok
'\xfc\x0e'

Why the Carry Makes the System Nonlinear

When you add two bits xx and yy, there is a carry only when both are 1. So the carry is x⋅yx \cdot y, a product. In LFSRsum every keystream bit was a sum of key bits. With addition with carry, products of key bits appear.

To see this, write the output bits of both registers in terms of the key, using the tables on the LFSR Sum page. The first byte of keystream comes from ticks 1 to 8, and tick 8 gives its right-most bit. Work from the right-most bit to the left, since tick 8 is the only bit with no carry coming in:

  • Tick 8. LFSR-B outputs 1+k1+k31 + k_1 + k_3 and LFSR-C outputs k4+k6k_4 + k_6. The keystream bit is their sum, 1+k1+k3+k4+k61 + k_1 + k_3 + k_4 + k_6, a linear equation just like in LFSRsum. But the carry out is their product:

    (1+k1+k3)(k4+k6)=k4+k6+k1k4+k1k6+k3k4+k3k6.(1 + k_1 + k_3)(k_4 + k_6) = k_4 + k_6 + k_1k_4 + k_1k_6 + k_3k_4 + k_3k_6.
  • Tick 7. LFSR-B outputs k1+k2k_1 + k_2, LFSR-C outputs k5+k7k_5 + k_7, and the carry from tick 8 comes in. The keystream bit is the sum of all three:

    k1+k2+k4+k5+k6+k7+k1k4+k1k6+k3k4+k3k6,k_1 + k_2 + k_4 + k_5 + k_6 + k_7 + k_1k_4 + k_1k_6 + k_3k_4 + k_3k_6,

    which contains products of key bits. That is a nonlinear equation. In LFSRsum, the same keystream bit was simply k1+k2+k5+k7k_1 + k_2 + k_5 + k_7.

  • Tick 6. The carry out of three bits is 1 when at least two of them are 1, so the products pile up. The keystream bit for tick 6 has 28 terms, some of them products of three key bits.

Each step to the left adds a longer carry. By tick 1, the keystream bit has 29 terms, and one of them is the product of all seven key bits. You can check the equations above with the key 0011001 and the keystream byte 10010011: tick 8 gives 1+0+1+1+0≡11 + 0 + 1 + 1 + 0 \equiv 1, and tick 7 gives 0+0+1+0+0+1+0+0+1+0≡10 + 0 + 1 + 0 + 0 + 1 + 0 + 0 + 1 + 0 \equiv 1.

Row reduction only solves linear systems. There is no comparably fast general method for nonlinear systems like this one, so the attack that broke LFSRsum no longer works.

Breaking babyCSS

So what options remain to break babyCSS? With a 7-bit key, there are only 27=1282^7 = 128 keys, so an attacker who knows the plaintext starts with ok can simply try them all:

0011001

There’s an even faster way, and it’s the idea behind one of the real attacks on CSS. Instead of guessing the whole key, guess only LFSR-B’s 3 key bits. For each guess:

Only 8 guesses are needed instead of 128:

000 10000 False
001 10011 True
010 00111 False
011 01101 False
100 11111 False
101 11101 False
110 01011 False
111 00101 False

Only the guess 001 works, and it gives LFSR-C’s seed 10011. So the key is 001 followed by 1001: 0011001.

Breaking the Real CSS

The real CSS uses the same ideas at a larger size:

  • Two LFSRs, with 17 and 25 bits.

  • A 40-bit key. Two bytes (16 bits) seed the 17-bit LFSR and three bytes (24 bits) seed the 25-bit LFSR. Each register also gets one bit fixed at 1, so it can never be all 0’s, just like babyCSS.

  • The output bytes are combined by 8-bit addition with carry, with the carry going into the next byte.

That gives 240=1,099,511,627,7762^{40} = 1{,}099{,}511{,}627{,}776 keys. Why only 40 bits? At the time CSS was designed, US export rules limited the encryption in products sold abroad to 40-bit keys. The limit was on export: using stronger encryption inside the US was legal. Since DVD players were sold around the world, CSS was built to fit the export limit.

CSS fell anyway, in two ways.

  • The design didn’t stay secret. The CSS algorithm was only shared with licensed manufacturers. In October 1999, a program called DeCSS appeared on the internet. It used a player key taken from a software DVD player whose maker hadn’t protected it, and soon the whole algorithm was public. This is Kerckhoffs’s principle in action: a cipher whose security depends on keeping the design secret is not secure.

  • The design was weak. In November 1999, the cryptographer Frank Stevenson published an analysis of CSS with attacks far faster than trying all 240 keys. One attack is the guess-one-register idea above: with 6 known output bytes, guess the 16 unknown seed bits of the 17-bit register (only 216=65,5362^{16} = 65{,}536 guesses), subtract to get the 25-bit register’s output, and check. Another recovers a disc key from information stored on the disc with about 225 steps, which took less than 18 seconds on a 450 MHz Pentium III computer of the time.

The carry did make CSS nonlinear, and that does stop the attack that broke LFSRsum. But the small key, the secret design and the guess-one-register attack each broke it anyway. A cipher is only as strong as its weakest part.

Check Your Understanding