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.

authentication in a straightforward manner using a hash function, and they believe<br />

they would be better off doing this than using an off-the-shelf solution. Basically,<br />

they think they can do something less complex and faster with just a hash function.<br />

Other people think that creating some sort of “encryption with redundancy” scheme<br />

is a good idea, even though many such schemes are known to be bad.<br />

OMAC, HMAC, CMAC, and MAC127, which we compare in Recipe 6.4, are all<br />

simple and efficient, and there are proofs that those constructions are secure with<br />

some reasonable assumptions. Will that be the case for anything you put together<br />

manually?<br />

See Also<br />

Recipe 6.4<br />

6.20 Encrypting with a Hash Function<br />

<strong>Problem</strong><br />

You want to encrypt with a hash function, possibly because you want only a single<br />

cryptographic primitive and to use a hash function instead of a block cipher.<br />

Solution<br />

Use a hash-based MAC in counter mode.<br />

Discussion<br />

Use a separate key from the one you use to authenticate, and don’t<br />

forget to use the MAC for message authentication as well!<br />

You can turn any MAC into a stream cipher essentially by using the MAC in counter<br />

(CTR) mode. You should not use a hash function by itself, because it’s difficult to<br />

ensure that you’re doing so securely. Basically, if you have a MAC built on a hash<br />

function that is known to be a secure MAC, it will be secure for encryption in CTR<br />

mode.<br />

There is no point in using any MAC that uses a block cipher in any way, such as<br />

OMAC, CMAC, or MAC127 (see Recipe 6.4 for a discussion of MAC solutions).<br />

Instead, just use the underlying block cipher in CTR mode, which will produce the<br />

same results. This recipe should be used only when you don’t want to use a block<br />

cipher.<br />

Encrypting with a Hash Function | 301<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!