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.

Generally, you should prefer an encryption mode like CWC that provides both<br />

encryption and message integrity to one of these constructions. Using a MAC, you<br />

can get message integrity without encryption, which is sometimes useful.<br />

MACs aren’t useful for software distribution, because the key itself must remain<br />

secret and can’t be public knowledge. Another limitation is that if there are two parties<br />

in the system, Alice and Bob, Alice cannot prove that Bob sent a message by<br />

showing the MAC value sent by Bob (i.e., non-repudiation). The problem is that<br />

Alice and Bob share a key; Alice could have forged the message and produced the correct<br />

MAC value. Digital signature schemes (discussed in Chapter 7) can circumvent<br />

these problems, but they have limitations of their own—the primary one is efficiency.<br />

Attacks against one-way constructs<br />

There are numerous classes of problems that you need to worry about when you’re<br />

using a cryptographic hash function or a MAC. Generally, if an attacker can find collisions<br />

for a hash function (two inputs that give the same output), that can be turned<br />

into a real attack.<br />

The most basic collision attack is this: given a known hash function {input, output}<br />

pair, somehow produce another input that gives the same output. To see how this<br />

can be a real attack, consider a public key–based digital signature scheme where the<br />

message to “sign” gets cryptographically hashed, and the hash gets encrypted with<br />

the private key of the signer. In such a scenario, anyone who has the associated public<br />

key can validate the signature, and no one can forge it. (We’ll discuss such<br />

schemes further in Chapter 7.)<br />

Suppose that an attacker sees the message being signed. From that, he can determine<br />

the hash value computed. If he can find another message that gives the same<br />

hash value, he can claim that a different message is being signed from the one that<br />

actually was. For example, an attacker could get someone to sign a benign document,<br />

then substitute a contract that is beneficial to the attacker.<br />

Of course, we assume that if an attacker has a way to force collisions in a reasonably<br />

efficient manner, he can force the second plaintext to be a message of his choice,<br />

more or less. (This isn’t always the case, but it is generally a good assumption, particularly<br />

because it applies for the most basic brute-force attacks.)<br />

To illustrate, let’s say that an attacker uses a hash function that is cryptographically<br />

strong but outputs only a 16-bit hash. Given a message and a digest, an attacker<br />

should be able to generate a collision after generating, on average, 32,768 messages.<br />

An attacker could identify 16 places where a one-bit change could be made without<br />

significantly changing the content (e.g., 16 places where you could put an extra space<br />

after a period, or refrain from doing so).<br />

If the attacker can control both messages, collisions are far easier to find. For example,<br />

if an attacker can give the target a message of his choosing and get the target to<br />

sign it, there is an attack that will find a collision after 256 attempts, on average.<br />

Understanding the Basics of Hashes and MACs | 251<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!