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.

Solution<br />

In most cases, instead of using a standalone MAC, we recommend that you use a<br />

dual-use mode that provides both authentication and encryption all at once (such as<br />

CWC mode, discussed in Recipe 5.10). Dual-use modes can also be used for authentication<br />

when encryption is not required.<br />

If a dual-use mode does not suit your needs, the best solution depends on your particular<br />

requirements. In general, HMAC is a popular and well-supported alternative<br />

based on hash functions (it’s good for compatibility), and OMAC is a good solution<br />

based on a block cipher (which we see as a strong advantage). If you care about maximizing<br />

efficiency, a hash127-based MAC is a reasonable solution (though it has<br />

some limitations, so CMAC may be better in such cases; see Recipes 6.13 and 6.14).<br />

We recommend against using RMAC and UMAC, for reasons discussed in the following<br />

section.<br />

Discussion<br />

Do not use the same key for encryption that you use in a MAC. See<br />

Recipe 4.11 for how to overcome this restriction.<br />

As with hash functions, there are a large number of available algorithms for performing<br />

message authentication, each with its own advantages and drawbacks. Besides<br />

algorithms designed explicitly for message authentication, some encryption modes<br />

such as CWC provide message authentication as a side effect. (See Recipe 5.4 for an<br />

overview of several such modes, and Recipe 6.10 for a discussion of CWC.) Such<br />

dual-use modes are designed for general-purpose needs, and they are high-level<br />

enough that it is far more difficult to use these modes in an insecure manner than<br />

regular cryptography.<br />

Table 6-2 lists interesting message authentication functions, all with provable security<br />

properties assuming the security of the underlying primitive upon which they<br />

were based. This table also compares important properties of those functions. When<br />

comparing speeds, we used an x86-based machine and unoptimized implementations<br />

for testing. Results will vary depending on platform and other operating conditions.<br />

Speeds are measured in cycles per byte; lower numbers are better.<br />

Table 6-2. MACs and their properties<br />

Small message<br />

speed (64<br />

MAC Built upon<br />

bytes) a<br />

Large<br />

Patent<br />

message Appropriate restricParallel- speed (8K) for hardware tionsizable CMAC A universal hash and AES ~18 cpb ~18 cpb Yes No Yes<br />

HMAC-<br />

SHA1<br />

Message digest function 90 cpb 20 cpb Yes No No<br />

Choosing a Message Authentication Code | 259<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!