comparison libtomcrypt/src/mac/pmac/pmac_init.c @ 415:8b9aba1d5fa4 channel-fix

merge of '73fe066c5d9e2395354ba74756124d45c978a04d' and 'f5014cc84558f1e8eba42dbecf9f72f94bfe6134'
author Matt Johnston <matt@ucc.asn.au>
date Tue, 06 Feb 2007 16:00:18 +0000
parents 0cbe8f6dbf9e
children f849a5ca2efc
comparison
equal deleted inserted replaced
414:c53a26c430e5 415:8b9aba1d5fa4
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 $ */