13
$\begingroup$

This question was asked in comments on my answer to Should we MAC-then-encrypt or encrypt-then-MAC? I think posing the question as a separate entity is best, so:

The general advice for applying MACs seems to be that we should encrypt first, then MAC. However, the general advice for signatures appears to be diametrically opposed.

Why is this the case? Aren't these the same ideas? If so why are they so opposite?

I have answered this myself but feel free to improve upon this answer.

$\endgroup$
1
  • 1
    $\begingroup$ We should sign followed by authenticated encryption. $\endgroup$ Apr 10, 2014 at 8:33

1 Answer 1

13
$\begingroup$

Okay. So first up, let's eliminate encrypt-then-sign. Why is this a problem? The idea behind a signature is to prove that a message came from me even in the presence of malicious actors. If a malicious actor changes the ciphertext under the signature, clearly this invalidates the signature as per expectations, however, that is only one possible attack scenario. The other is that the attacker could claim ownership of a message simply by stripping off the existing signature and adding their own - this is trivial, since the ciphertext (not the plaintext) is signed.

So relying on the signature to identify the recipient in this case could be fatal. D.W. gives an example of this in his/her answer.

The alternative approach to this is sign then encrypt. Clearly a malicious adversary cannot modify this in flight, but again the purpose of the signatures is to indisputedly identify the sender. A malicious recipient could forward the signed plaintext encrypted and it would appear to come from the original sender, defeating the goal of signatures.

D.W. gives one approach for resolving the issue. Others are sign-encrypt-sign, encrypt-sign-encrypt etc.

In the MAC case, our goal is different. We want to know whether or not the ciphertext has been modified on the wire or not, and whether or not we should decrypt it (to prevent the creation of an oracle, for example) or reject it as corrupted. We are not attempting to identify who the plaintext came from, simply that it has not been modified in flight.

So you might ask, okay, what happens if an attacker strip off a MAC block from a ciphertext and replace it with their own? Since we have exchanged MAC keys and we assume these keys are still secure, the recipient will identify an invalid ciphertext and reject it.

It is also worth reviewing Thomas' answer for some additional items. Specifically, not all cryptographers agree that encrypt-then-mac is the most ideal approach.

Secondly, Thomas highlights that MACs provide automatic protection against chosen ciphertext attacks. D.W. has recommended in his/her answer that an IND-CCA2 cipher should be used - that is, one provably secure under adaptive chosen ciphertext attacks.

Although it is not entirely accurate, I would say that the requirement for MACs and IND-CCA2 to defeat chosen ciphertext attacks is a closer parallel than comparing MACs and Signatures, although at first glance it looks like MACs and signatures are doing the same thing.

$\endgroup$
4
  • 2
    $\begingroup$ I'm having a hard time understanding this paragraph: "the purpose of the signatures is to indisputedly identify the recipient. A malicious recipient could forward the signed plaintext encrypted and it would appear to come from the original sender, defeating the goal of signatures." I'm missing how the goal of signatures is defeated. If all the malicious recipient is doing is forwarding something you signed, where's the problem? $\endgroup$
    – jnm2
    Mar 4, 2017 at 3:41
  • $\begingroup$ I dont understand the following part: "The idea behind a signature is to prove that a message came from me even in the presence of malicious actors. If a malicious actor changes the ciphertext under the signature, clearly this invalidates the signature as per expectations, however, that is only one possible attack scenario." It invalidated the signature. That's what we want right? After the "however" there is no argument why this would be bad? $\endgroup$
    – efie
    Mar 5, 2017 at 22:01
  • $\begingroup$ @user46, Re "could forward the signed plaintext encrypted and it would appear to come from the original sender", but since its a forward, then didn't it not come from the original sender? $\endgroup$
    – Pacerier
    Oct 24, 2017 at 8:35
  • 1
    $\begingroup$ @jnm2 I'm pretty sure it's a typo and this phrase meant to read "the purpose of the signatures is to indisputedly identify the sender" $\endgroup$
    – ScumCoder
    Feb 28, 2020 at 15:32

Your Answer

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