comparison libtomcrypt/src/mac/omac/omac_init.c @ 435:337c45621e81

merge of 'a9b0496634cdd25647b65e585cc3240f3fa699ee' and 'c22be8b8f570b48e9662dac32c7b3e7148a42206'
author Matt Johnston <matt@ucc.asn.au>
date Thu, 22 Feb 2007 14:53:49 +0000
parents 0cbe8f6dbf9e
children f849a5ca2efc
comparison
equal deleted inserted replaced
434:0aaaf68e97dc 435:337c45621e81
4 * algorithms in a highly modular and flexible manner. 4 * algorithms in a highly modular and flexible manner.
5 * 5 *
6 * The library is free for all purposes without any express 6 * The library is free for all purposes without any express
7 * guarantee it works. 7 * guarantee it works.
8 * 8 *
9 * Tom St Denis, [email protected], http://libtomcrypt.org 9 * Tom St Denis, [email protected], http://libtomcrypt.com
10 */ 10 */
11 #include "tomcrypt.h" 11 #include "tomcrypt.h"
12 12
13 /** 13 /**
14 @file omac_init.c 14 @file omac_init.c
15 OMAC1 support, initialize state, by Tom St Denis 15 OMAC1 support, initialize state, by Tom St Denis
16 */ 16 */
17 17
18 18
19 #ifdef OMAC 19 #ifdef LTC_OMAC
20 20
21 /** 21 /**
22 Initialize an OMAC state 22 Initialize an OMAC state
23 @param omac The OMAC state to initialize 23 @param omac The OMAC state to initialize
24 @param cipher The index of the desired cipher 24 @param cipher The index of the desired cipher
61 61
62 /* ok now we need Lu and Lu^2 [calc one from the other] */ 62 /* ok now we need Lu and Lu^2 [calc one from the other] */
63 63
64 /* first calc L which is Ek(0) */ 64 /* first calc L which is Ek(0) */
65 zeromem(omac->Lu[0], cipher_descriptor[cipher].block_length); 65 zeromem(omac->Lu[0], cipher_descriptor[cipher].block_length);
66 cipher_descriptor[cipher].ecb_encrypt(omac->Lu[0], omac->Lu[0], &omac->key); 66 if ((err = cipher_descriptor[cipher].ecb_encrypt(omac->Lu[0], omac->Lu[0], &omac->key)) != CRYPT_OK) {
67 return err;
68 }
67 69
68 /* now do the mults, whoopy! */ 70 /* now do the mults, whoopy! */
69 for (x = 0; x < 2; x++) { 71 for (x = 0; x < 2; x++) {
70 /* if msb(L * u^(x+1)) = 0 then just shift, otherwise shift and xor constant mask */ 72 /* if msb(L * u^(x+1)) = 0 then just shift, otherwise shift and xor constant mask */
71 msb = omac->Lu[x][0] >> 7; 73 msb = omac->Lu[x][0] >> 7;
93 } 95 }
94 96
95 #endif 97 #endif
96 98
97 /* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_init.c,v $ */ 99 /* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_init.c,v $ */
98 /* $Revision: 1.5 $ */ 100 /* $Revision: 1.10 $ */
99 /* $Date: 2005/06/06 10:22:44 $ */ 101 /* $Date: 2006/11/03 00:39:49 $ */