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.

spc_mdc2_oneblock(c, c->bf);<br />

memcpy(output, c->h1, SPC_BLOCK_SZ);<br />

memcpy(output+SPC_BLOCK_SZ, c->h2, SPC_BLOCK_SZ);<br />

}<br />

6.17 Using Smaller MAC Tags<br />

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

You want to trade off security for smaller authentication tags.<br />

Solution<br />

Truncate the least significant bytes of the MAC, but make sure to retain adequate<br />

security.<br />

Discussion<br />

Normal software environments should not have a need for smaller MACs because<br />

space is not at a premium. However, if you’re working in a space-constrained<br />

embedded environment, it’s acceptable to truncate MAC tags if space is a requirement.<br />

Note that doing so will not reduce computation costs. In addition, keep in<br />

mind that security goes down as the tag size decreases, particularly if you are not<br />

using a nonce (or are using a small nonce).<br />

6.18 Making Encryption and Message Integrity<br />

Work Together<br />

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

You need to encrypt data and ensure the integrity of your data at the same time.<br />

Solution<br />

Use either an encryption mode that performs both encryption and message integrity<br />

checking, such as CWC mode, or encrypt data with one secret key and use a second<br />

key to MAC the encrypted data.<br />

Discussion<br />

Unbelievably, many subtle things can go wrong when you try to perform encryption<br />

and message integrity checking in tandem. This is part of the reason encryption<br />

298 | Chapter 6: Hashes and Message Authentication<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!