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.

Figure 6-2. The Mayas-Meyer-Oseas construct<br />

MDC-2 is based on Matyas-Meyer-Oseas. There are two internal states instead of<br />

one, and each is initialized with a different value. Each block of input is copied, and<br />

the two copies go through one round of Matyas-Meyer-Oseas separately. Then,<br />

before the next block of input is processed, the two internal states are shuffled a bit;<br />

the lower halves of the two states are swapped. This is all illustrated for one block of<br />

the message in Figure 6-3.<br />

L i–1<br />

Figure 6-3. The MDC-2 construct<br />

IV i-1<br />

MMO<br />

A B<br />

A D<br />

L i<br />

expand<br />

P i<br />

Clearly, input needs to be padded to the block size of the cipher. We do this internally<br />

to our implementation by adding a 1 bit to the end of the input, then as many<br />

zeros as are necessary to make the resulting string block-aligned.<br />

One important thing to note about MDC-2 (as well as Matyas-Meyer-Oseas) is that<br />

there are ways to extend a message to get the same hash as a result, unless you do<br />

something to improve the function. The typical solution is to use MD-strengthening,<br />

which involves adding to the end of the input a block that encodes the length of the<br />

input. We do that in the code presented later in this section.<br />

Using a Block Cipher to Build a Full-Strength Hash Function | 295<br />

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

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.<br />

P i<br />

E<br />

IV i<br />

MMO<br />

C D<br />

C B<br />

R i<br />

R i–1

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

Saved successfully!

Ooh no, something went wrong!