4 * The One-key CBC MAC (OMAC) message authentication code,
\r
5 * designed by T. Iwata and K. Kurosawa.
\r
7 * @author Paulo S. L. M. Barreto
\r
11 * This software is hereby placed in the public domain.
\r
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
\r
14 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
\r
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
\r
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
\r
17 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
\r
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
\r
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
\r
20 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
\r
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
\r
22 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
23 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
28 #include "BlockCipher.h"
\r
32 typedef unsigned char byte;
\r
33 typedef unsigned long uint; /* assuming sizeof(uint) == 4 */
\r
34 #endif /* USUAL_TYPES */
\r
36 #define OMAC_MAXBLOCKSIZE 16
\r
46 * Start computing an OMAC tag by selecting the underlying block cipher.
\r
48 * @param E block cipher underlying OMAC computation.
\r
49 * CAVEAT: in the current implementation the block size
\r
50 * must be either 16 or 8.
\r
52 void init(BlockCipher* E);
\r
55 * Update the OMAC tag computation with a message chunk.
\r
57 * @param M message chunk
\r
58 * @param m its length in bytes
\r
60 void update(const byte* M, uint m);
\r
63 * Complete the computation of the OMAC tag, or simply
\r
64 * get the finished OMAC tag if available.
\r
66 * @return the OMAC tag.
\r
68 void final(byte *tag);
\r
71 * Get the default tag size for the underlying block cipher.
\r
73 * @return the default tag size in bytes.
\r
80 BlockCipher *_E; // block cipher context
\r
82 uint t; // remaining space on T, in bytes
\r
85 byte L[OMAC_MAXBLOCKSIZE]; // OMAC padding (block_size bytes): B = 2L, P = 4L
\r
86 byte T[OMAC_MAXBLOCKSIZE]; // OMAC tag (block_size bytes)
\r
89 #endif /* __OMAC_H */
\r