21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

OMAC has been explicitly specified for AES, and it is easy to adapt to any 128-bit<br />

block cipher. It is possible, but a bit more work, to get it working with ciphers with<br />

64-bit blocks. In this section, we only cover using OMAC with AES.<br />

The basic idea behind using CBC mode as a MAC is to encrypt a message in CBC<br />

mode and throw away everything except the very last block of output. That’s not<br />

generally secure, though. It only works when all messages you might possibly process<br />

are a particular size.<br />

Besides OMAC, there are several MACs that try to fix the CBC-MAC problem,<br />

including XCBC-MAC, TMAC, and RMAC:<br />

RMAC<br />

RMAC (the R stands for randomized) has security issues in the general case, and<br />

is not favored by the cryptographic community. *<br />

XCBC-MAC<br />

XCBC-MAC (eXtended CBC-MAC) is the foundation for TMAC and OMAC,<br />

but it uses three different keys.<br />

TMAC<br />

TMAC uses two keys (thus the T in the name).<br />

OMAC is the first good CBC-MAC derivative that uses a single key. OMAC works<br />

the same way CBC-MAC does until the last block, where it XORs the state with an<br />

additional value before encrypting. That additional value is derived from the result of<br />

encrypting all zeros, and it can be performed at key setup time. That is, the additional<br />

value is key-dependent, not message-dependent.<br />

OMAC is actually the name of a family of MAC algorithms. There are two concrete<br />

versions, OMAC1 and OMAC2, which are slightly different but equally secure.<br />

OMAC1 is slightly preferable because its key setup can be done a few cycles more<br />

quickly than OMAC2’s key setup. NIST is expected to standardize on OMAC1.<br />

First, we provide an incremental API for using OMAC. This code requires linking<br />

against an AES implementation, and also that the macros developed in Recipe 5.5 be<br />

defined (they bridge the API of your AES implementation with this book’s API). The<br />

secure memory function spc_memset( ) from Recipe 13.2 is also required.<br />

To use this API, you must instantiate an SPC_OMAC_CTX object and pass it to the various<br />

API functions. To initialize the context, call either spc_omac1_init( ) or spc_<br />

omac2_init( ), depending on whether you want to use OMAC1 or OMAC2. The initialization<br />

functions always return success unless the key length is invalid, in which<br />

case they return 0. Successful initialization is indicated by a return value of 1.<br />

* Most importantly, RMAC requires the underlying block cipher to protect against related-key attacks, where<br />

other constructs do not. Related-key attacks are not well studied, so it’s best to prefer constructs that can<br />

avoid them when possible.<br />

Using OMAC (a Simple Block Cipher–Based MAC) | 281<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!