4
$\begingroup$

ECB is considered to be insecure when used for confidentiality because identical plaintext result with identical ciphertext. But what if we use ECB for authentication?

Assume A wants to transmit an authenticated message X to B. A and B have a shared key. What if A encrypts the plaintext X using AES-ECB and outputs Y as the ciphertext and appends it next to the plaintext X as a MAC? Would that be secure?

Confidentiality is not of importance here. We only need to authenticate the data.

$\endgroup$
3
  • $\begingroup$ What is "Y" here? The ciphertext? $\endgroup$
    – Thomas
    Sep 3, 2014 at 15:03
  • $\begingroup$ Yes. Let me edit it to make it more clear $\endgroup$
    – BlaX
    Sep 3, 2014 at 15:04
  • $\begingroup$ Similar question on Information Security (not with ECB, but with a slightly more complex mode that exhibits a similar problem) $\endgroup$ Sep 3, 2014 at 15:19

2 Answers 2

10
$\begingroup$

It is not secure, because an attacker can "mix and match" the output blocks from different authentication tags on different input messages, or repeat output blocks for repeated input blocks.

For example, if the attacker knows the tag $F_k(m)$ for a one-block message $m$, then it can forge the correct tag $F_k(m) \mid F_k(m)$ for the two-block message $m \mid m$.

Another attack: suppose the attacker learns the tag $F_k(m_1) \mid F_k(m_2)$ for the message $m=m_1 \mid m_2$, and the tag $F_k(n_1) \mid F_k(n_2)$ for the message $n=n_1 \mid n_2$. Then it can forge the correct tag $F_k(m_1) \mid F_k(n_2)$ for the message $m_1 \mid n_2$. More generally, it can forge a correct tag for any message that is made by arbitrarily concatenating blocks from $m$ and $n$.

$\endgroup$
9
$\begingroup$

The other answer is correct in general. However, if your messages are all exactly one block long (or all one block after padding), ECB is a secure MAC.

A PRP looks like a PRF up to half its bit length, i.e. up to $2^{64}$ blocks for AES. A secure PRF is a secure MAC of the same size. Thus, AES ECB used on 128-bit messages is a secure MAC as long as you use a key for (significantly) fewer than $2^{64}$ messages.

$\endgroup$
1
  • 2
    $\begingroup$ These are good points. In fact, ECB on single-block messages is equivalent to CBC-MAC (on single-block messages), which is a secure MAC on messages of any fixed number of blocks. $\endgroup$ Sep 3, 2014 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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