Mercurial > dropbear
comparison src/mac/omac/omac_init.c @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16
Update to LibTomCrypt 1.16
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:22:00 +0000 |
parents | 59400faa4b44 |
children |
comparison
equal
deleted
inserted
replaced
280:59400faa4b44 | 380:d5faf4814ddb |
---|---|
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 $ */ |