2
$\begingroup$

The keyspace of XTS is $2^{512}$ due to its use of two distinct keys, and the most effective attack (a meet-in-the-middle attack) brings this down to $2^{384}$. This implies that knowledge of either the main key or the tweak key does not significantly reduce security. What confuses me is the idea that the scheme is still secure even if the main key is known and only the tweak key is kept secret. This idea I got from an answer to another question which notes that an attack revealing the main key but not the tweak key is not a fatal attack, leaving the scheme with a remaining $2^{256}$ keyspace. Looking at a diagram of XEX mode and trying to imagine how it would remain secure when $K_1$ is known, I could not think of any possible way it'd be true:

XEX mode

$K_1$ is the main key and $K_2$ is the tweak key.

XTS mode, sans ciphertext stealing, is defined as:

$$C_{ij} = E_{K_1}(P_{ij} \oplus (E_{K_2}(i) \otimes \alpha^j)) \oplus (E_{K_2}(i) \otimes \alpha^j)$$

Here, $i$ is the sector number and $j$ is the block number within the sector. For the purpose of this question, only one sector matters so $i$ can be considered a constant. Since this makes it such that $E_{K_2}(i)$ is a secret value that never changes, we can define $K^\prime = E_{K_2}(i)$, giving us:

$$C_{j} = E_{K_1}(P_{j} \oplus (K^\prime \otimes \alpha^j)) \oplus (K^\prime \otimes \alpha^j)$$

Because $K_1$ is not secret for our purposes, we can model $E_{K_1}$ as a public PRP $\pi$:

$$C_{j} = \pi(P_{j} \oplus (K^\prime \otimes \alpha^j)) \oplus (K^\prime \otimes \alpha^j)$$

If we simplify things and look at a single $j$, we can say $K^{\prime\prime} = K^\prime \otimes \alpha^j$. Now we have:

$$C = \pi(P \oplus K^{\prime\prime}) \oplus K^{\prime\prime}$$

This can't possibly provide data-at-rest security! It looks to me that knowledge of $K_1$ allows an attacker with a plaintext/ciphertext pair to easily derive $K_2$, which, according to the above-linked answer, is not true. Where is the error in my logic?

$\endgroup$
  • $\begingroup$ Wait. I noticed $K_1$ and $K_2$ in the equations are opposite of what is in the picture. Did that cause a mix up? We are talking about inner key being known and the outer key unknown. "Inner" meaning the key used for the E in XEX. "Outer" meaning the key used to derive value used for the two XORs before and after the inner layer block encryption. $\endgroup$ – Future Security Jun 27 '18 at 4:56
  • $\begingroup$ I was referring to $K_1$ as the tweak key and $K_2$ as the main key. I didn't actually notice that the diagram showed the reverse. I originally had XTS defined with $T_{ij} = E_{K_1}(i) \otimes \alpha^j$ on the first line instead of including the tweak $T_{ij}$ inline. I've edited it now so the question and image do not contradict each other. $K_1$ is now the main key and $K_2$ is now the tweak. $\endgroup$ – forest Jun 27 '18 at 5:24
5
$\begingroup$

Actually, you can't remove the $E_{k_2}$ as you did. You had:

$$C_{j} = E_{K_2}(P_{j} \oplus (K^\prime \otimes \alpha^j)) \oplus (K^\prime \otimes \alpha^j)$$

Let me replace the term $(K^\prime \otimes \alpha^j)$ with $K^{\prime\prime}$ and eliminate the $j$ to makes things easier to read. The result is:

$$C = E_{K_2}(P \oplus K^{\prime\prime}) \oplus K^{\prime\prime}$$

This form is that of a type of Even-Mansour cipher. It is a block cipher formed with a public (pseudo-random) permutation $\pi$ and one or more keys with a length equal to the block length. It looks like:

$$C = \pi(P \oplus K_a) \oplus K_b$$

XEX mode uses the same construction to make a tweakable block cipher. In XEX the permutation used is not public. (It is a block cipher with a secret key.) For an EM block cipher the permutation does not need to be secret. (Therefore you can use a block cipher with a non-secret key.) Its security claims just depend on the block size, the assumption that $\pi$ is a pseudo-random permutation, and that the keys are unpredictable and from a uniform distribution.

You cannot eliminate the $\pi$ as you did.

$$\pi(P \oplus K_a) \oplus K_b \neq (P \oplus {K_a}^\prime) \oplus {K_b}^\prime$$


Given plaintext ciphertext pairs:

If you omit $K_a$ then you can trivially recover $K_b$. $$C = \pi(P) \oplus K_b$$ $$C \oplus \pi(P) = K_b$$

If you omit $K_b$ then you can trivially recover $K_a$. $$C = \pi(P \oplus K_a)$$ $$\pi^{-1}(C) = P \oplus K_a$$ $$\pi^{-1}(C) \oplus P = K_a$$

If both keys are present, then the best attacks on a generic single round*EM cipher require about $D$ plaintext/ciphertext pairs (D for data) and $T$ evaluations of $\pi$ (T for time) such that $DT \geq 2^n$ where $n$ is the block size.

As for the question "So in essence, the output of $\pi$ will necessarily not be known because of the [correction: $K_a$] added to the input?"

Yes, basically. The exact behavior is a bit subtle and I don't want to cause confusion. So actually either $K_a$ or $K_b$ being unknown is sufficient to make the ciphertext impossible for the adversary to predict IF no plaintext/ciphertext pairs are known.

I actually mean $K_a$ added to the input of $\pi$ makes the new output of $\pi$, that is $\pi(x \oplus K_a)$, impossible for the adversary to calculate because the "real" input, that is $x \oplus K_a$, is not known by him.

If you skip the second XOR ($K_b$) then from one pair you can recover $K_a$ as described above using the inverse of $\pi$.

Similarly if have secret $K_b$ the adversary can compute $\pi^{-1}(x)$ but not $\pi^{-1}(x \oplus K_b)$. The adversary needs to know the difference between $E^{-1}(C) = K_a \oplus \pi^{-1}(C \oplus K_b)$ and $\pi^{-1}(C \oplus K_b)$ to recover $K_a$.

So you can't recover the pre-key ($K_a$) efficiently without knowing the post-key ($K_b$). You can't recover the post-key easily without knowing the pre-key. Both are essential. One protects the other from being recovered.

I hope that makes sense. I struggled to phrase it in a way that made sense without resorting to formal arguments. I will look for references later.

The claim that an EM cipher is secure may not pass the smell test, though. And that's because I forgot to emphasize that you can't actually make a claim to that their security level is equal to their key-size. $|K_a| + |K_b| = 2n$ but the worst case security level is $O(n / 2$) if measured in terms of $min(D + T)$. And you don't limit $D$.

It's better to use larger block ciphers or permutations for that reason. I recall reading using more rounds brings the security level closer to $n$ bits.

(If for some reason we lost the ability to use typical block ciphers we would be perfectly fine using only one round EM ciphers with a "standard" block size of 256 bits instead of 128. We also wouldn't need double the key bulk if we did this. The different subkeys can be generated by KDF. For the single round version there is no loss in security on the generic construct if the pre- and post-keys are equal.)

Also the symmetry of the construct makes informal reasoning a bit easier. Whatever logic applies to encryption or the forward public permutation function also applies to decryption and the inverse permutation function. ie.

$$E_1(P, K_a, K_b) \text{ corresponds to:}\\ \begin{align} X &= P \oplus K_a; \\ Y &= \pi(X); \\ C &= Y \oplus K_b \end{align}$$

$$E_2(P, K_b, K_a) \text{ corresponds to:}\\ \begin{align} X &= P \oplus K_b; \\ Y &= \pi^{-1}(X); \\ C &= Y \oplus K_a \end{align}$$

* Rounds in the context of EM ciphers refers to the number of times $\pi$ is used. One round is XOR → permute → XOR. Two is XOR → permute → XOR → permute → XOR. And so on.

$\endgroup$
  • $\begingroup$ But if $\pi$ is a function that can be computed by an adversary, e.g. $\pi(m) = E_{K_2}(m)$ where $K_2$ is known, then why can't it be eliminated? The output can be computed by an attacker. $\endgroup$ – forest Jun 27 '18 at 4:30
  • 2
    $\begingroup$ An adversary can compute $\pi(m)$ but not $\pi(m \oplus k)$ where k is secret. (The XOR at the end means you cannot simply invert $\pi$ and recover $K_a$. The symmetry of the structure implies you cannot recover $k_b$ either. The adversary can also compute $\pi^{-1}(x)$ but not $\pi^{-1}(x \oplus K_b)$.) $\endgroup$ – Future Security Jun 27 '18 at 4:55
  • $\begingroup$ I've added $\pi$ to my question which I had meant (and forgotten) to add and doesn't really change the problem, since it is public and that seems to have thrown me off. So in essence, the output of $\pi$ will necessarily not be known because of the $K_b$ added to the input? $\endgroup$ – forest Jun 27 '18 at 5:17
  • $\begingroup$ $K_a = K_b$ since both are $K^{\prime\prime}$, right? I was (incorrectly) assuming that $\pi$ was there only to prevent $C = (P \oplus K^{\prime\prime}) \oplus K^{\prime\prime}$ from being reduced to $C = P \oplus K^{\prime\prime} \oplus K^{\prime\prime}$ and then $C = P$. $\endgroup$ – forest Jun 28 '18 at 1:54
  • $\begingroup$ I've edited my question to simplify the equation by removing $j$ to get $C = \pi(P \oplus K^{\prime\prime}) \oplus K^{\prime\prime}$ as you have done in your answer. That does indeed make it more readable. $\endgroup$ – forest Jun 28 '18 at 2:07

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.