comparison libtomcrypt/src/mac/pmac/pmac_process.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_process.c 14 @file pmac_process.c
15 PMAC implementation, process data, by Tom St Denis 15 PMAC implementation, process data, by Tom St Denis
16 */ 16 */
17 17
18 18
19 #ifdef PMAC 19 #ifdef LTC_PMAC
20 20
21 /** 21 /**
22 Process data in a PMAC stream 22 Process data in a PMAC stream
23 @param pmac The PMAC state 23 @param pmac The PMAC state
24 @param in The data to send through PMAC 24 @param in The data to send through PMAC
48 for (x = 0; x < (inlen - 16); x += 16) { 48 for (x = 0; x < (inlen - 16); x += 16) {
49 pmac_shift_xor(pmac); 49 pmac_shift_xor(pmac);
50 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) { 50 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) {
51 *((LTC_FAST_TYPE*)(&Z[y])) = *((LTC_FAST_TYPE*)(&in[y])) ^ *((LTC_FAST_TYPE*)(&pmac->Li[y])); 51 *((LTC_FAST_TYPE*)(&Z[y])) = *((LTC_FAST_TYPE*)(&in[y])) ^ *((LTC_FAST_TYPE*)(&pmac->Li[y]));
52 } 52 }
53 cipher_descriptor[pmac->cipher_idx].ecb_encrypt(Z, Z, &pmac->key); 53 if ((err = cipher_descriptor[pmac->cipher_idx].ecb_encrypt(Z, Z, &pmac->key)) != CRYPT_OK) {
54 return err;
55 }
54 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) { 56 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) {
55 *((LTC_FAST_TYPE*)(&pmac->checksum[y])) ^= *((LTC_FAST_TYPE*)(&Z[y])); 57 *((LTC_FAST_TYPE*)(&pmac->checksum[y])) ^= *((LTC_FAST_TYPE*)(&Z[y]));
56 } 58 }
57 in += 16; 59 in += 16;
58 } 60 }
65 if (pmac->buflen == pmac->block_len) { 67 if (pmac->buflen == pmac->block_len) {
66 pmac_shift_xor(pmac); 68 pmac_shift_xor(pmac);
67 for (x = 0; x < (unsigned long)pmac->block_len; x++) { 69 for (x = 0; x < (unsigned long)pmac->block_len; x++) {
68 Z[x] = pmac->Li[x] ^ pmac->block[x]; 70 Z[x] = pmac->Li[x] ^ pmac->block[x];
69 } 71 }
70 cipher_descriptor[pmac->cipher_idx].ecb_encrypt(Z, Z, &pmac->key); 72 if ((err = cipher_descriptor[pmac->cipher_idx].ecb_encrypt(Z, Z, &pmac->key)) != CRYPT_OK) {
73 return err;
74 }
71 for (x = 0; x < (unsigned long)pmac->block_len; x++) { 75 for (x = 0; x < (unsigned long)pmac->block_len; x++) {
72 pmac->checksum[x] ^= Z[x]; 76 pmac->checksum[x] ^= Z[x];
73 } 77 }
74 pmac->buflen = 0; 78 pmac->buflen = 0;
75 } 79 }
90 } 94 }
91 95
92 #endif 96 #endif
93 97
94 /* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_process.c,v $ */ 98 /* $Source: /cvs/libtom/libtomcrypt/src/mac/pmac/pmac_process.c,v $ */
95 /* $Revision: 1.5 $ */ 99 /* $Revision: 1.8 $ */
96 /* $Date: 2005/05/05 14:35:59 $ */ 100 /* $Date: 2006/11/03 00:39:49 $ */