Mercurial > dropbear
comparison libtomcrypt/src/mac/pmac/pmac_init.c @ 382:0cbe8f6dbf9e
propagate from branch 'au.asn.ucc.matt.ltc.dropbear' (head 2af22fb4e878750b88f80f90d439b316d229796f)
to branch 'au.asn.ucc.matt.dropbear' (head 02c413252c90e9de8e03d91e9939dde3029f5c0a)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:41:05 +0000 |
parents | 1b9e69c058d2 |
children | f849a5ca2efc |
comparison
equal
deleted
inserted
replaced
379:b66a00272a90 | 382:0cbe8f6dbf9e |
---|---|
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 pmac_init.c | 14 @file pmac_init.c |
15 PMAC implementation, initialize state, by Tom St Denis | 15 PMAC implementation, initialize state, by Tom St Denis |
16 */ | 16 */ |
17 | 17 |
18 #ifdef PMAC | 18 #ifdef LTC_PMAC |
19 | 19 |
20 static const struct { | 20 static const struct { |
21 int len; | 21 int len; |
22 unsigned char poly_div[MAXBLOCKSIZE], | 22 unsigned char poly_div[MAXBLOCKSIZE], |
23 poly_mul[MAXBLOCKSIZE]; | 23 poly_mul[MAXBLOCKSIZE]; |
85 return CRYPT_MEM; | 85 return CRYPT_MEM; |
86 } | 86 } |
87 | 87 |
88 /* find L = E[0] */ | 88 /* find L = E[0] */ |
89 zeromem(L, pmac->block_len); | 89 zeromem(L, pmac->block_len); |
90 cipher_descriptor[cipher].ecb_encrypt(L, L, &pmac->key); | 90 if ((err = cipher_descriptor[cipher].ecb_encrypt(L, L, &pmac->key)) != CRYPT_OK) { |
91 goto error; | |
92 } | |
91 | 93 |
92 /* find Ls[i] = L << i for i == 0..31 */ | 94 /* find Ls[i] = L << i for i == 0..31 */ |
93 XMEMCPY(pmac->Ls[0], L, pmac->block_len); | 95 XMEMCPY(pmac->Ls[0], L, pmac->block_len); |
94 for (x = 1; x < 32; x++) { | 96 for (x = 1; x < 32; x++) { |
95 m = pmac->Ls[x-1][0] >> 7; | 97 m = pmac->Ls[x-1][0] >> 7; |
125 pmac->cipher_idx = cipher; | 127 pmac->cipher_idx = cipher; |
126 pmac->buflen = 0; | 128 pmac->buflen = 0; |
127 zeromem(pmac->block, sizeof(pmac->block)); | 129 zeromem(pmac->block, sizeof(pmac->block)); |
128 zeromem(pmac->Li, sizeof(pmac->Li)); | 130 zeromem(pmac->Li, sizeof(pmac->Li)); |
129 zeromem(pmac->checksum, sizeof(pmac->checksum)); | 131 zeromem(pmac->checksum, sizeof(pmac->checksum)); |
130 | 132 err = CRYPT_OK; |
133 error: | |
131 #ifdef LTC_CLEAN_STACK | 134 #ifdef LTC_CLEAN_STACK |
132 zeromem(L, pmac->block_len); | 135 zeromem(L, pmac->block_len); |
133 #endif | 136 #endif |
134 | 137 |
135 XFREE(L); | 138 XFREE(L); |
136 | 139 |
137 return CRYPT_OK; | 140 return err; |
138 } | 141 } |
139 | 142 |
140 #endif | 143 #endif |
141 | 144 |
142 /* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_init.c,v $ */ | 145 /* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_init.c,v $ */ |
143 /* $Revision: 1.4 $ */ | 146 /* $Revision: 1.7 $ */ |
144 /* $Date: 2005/05/05 14:35:59 $ */ | 147 /* $Date: 2006/11/03 00:39:49 $ */ |