21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

modes such as CWC and CCM are starting to appear, both of which perform<br />

encryption and message integrity checking together, and they are still secure (such<br />

modes are compared in Recipe 5.4, and CWC is discussed in Recipe 5.10). However,<br />

if you’re not willing to use one of those encryption modes, follow these guidelines<br />

to ensure security:<br />

• Use two separate keys, one for encryption and one for MAC’ing.<br />

• Encrypt first, then MAC the ciphertext.<br />

We recommend encrypting, then MAC’ing the ciphertext (the encrypt-then-authenticate<br />

paradigm; see Figure 6-4) because other approaches aren’t always secure.<br />

Figure 6-4. The encrypt-then-authenticate paradigm<br />

M<br />

Encryption<br />

C Tag<br />

MAC<br />

Output<br />

For example, if you’re using a stream-based mode such as CTR (discussed in Recipe<br />

5.9), or if you’re using CBC mode (Recipe 5.6), you will still have a good design if<br />

you use a MAC to authenticate the plaintext, then encrypt both the plaintext and the<br />

MAC tag (the authenticate-then-encrypt paradigm; see Figure 6-5). But if you fail to<br />

encrypt the MAC tag (this is actually called the authenticate-and-encrypt paradigm,<br />

because the two operations could happen in parallel with the same results; see<br />

Figure 6-6), or if you use an encryption mode with bad security properties (such as<br />

ECB mode), you might have something significant to worry about.<br />

Another advantage of encrypting first is that if you’re careful, your servers can reject<br />

bogus messages before decrypting them, which can help improve resistance to denial<br />

of service attacks. We consider this of minor interest at best.<br />

The one significant reason you might want to encrypt first is to give extra protection<br />

for message authentication, assuming your MAC is cryptographically broken. The<br />

hope is that if the privacy component isn’t broken, the MAC may still be secure,<br />

which may or may not be the case, depending on the nature of the attack.<br />

In practice, if you’re using a well-designed system—a dual-use scheme such as CWC<br />

mode—the correct functioning of authentication and encryption both assume the<br />

correct functioning of an underlying cipher such as AES. If this is broken, we consider<br />

all bets to be off anyway!<br />

Making Encryption and Message Integrity Work Together | 299<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!