comparison src/mac/omac/omac_process.c @ 381:999a5eb4ed10 libtomcrypt-dropbear

propagate from branch 'au.asn.ucc.matt.ltc.orig' (head 52840647ac7f5c707c3bd158d119a15734a7ef28) to branch 'au.asn.ucc.matt.ltc.dropbear' (head 20dccfc09627970a312d77fb41dc2970b62689c3)
author Matt Johnston <matt@ucc.asn.au>
date Thu, 11 Jan 2007 02:39:21 +0000
parents d5faf4814ddb
children
comparison
equal deleted inserted replaced
281:997e6f7dc01e 381:999a5eb4ed10
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_process.c 14 @file omac_process.c
15 OMAC1 support, process data, Tom St Denis 15 OMAC1 support, process data, Tom St Denis
16 */ 16 */
17 17
18 18
19 #ifdef OMAC 19 #ifdef LTC_OMAC
20 20
21 /** 21 /**
22 Process data through OMAC 22 Process data through OMAC
23 @param omac The OMAC state 23 @param omac The OMAC state
24 @param in The input data to send through OMAC 24 @param in The input data to send through OMAC
47 for (x = 0; x < (inlen - 16); x += 16) { 47 for (x = 0; x < (inlen - 16); x += 16) {
48 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) { 48 for (y = 0; y < 16; y += sizeof(LTC_FAST_TYPE)) {
49 *((LTC_FAST_TYPE*)(&omac->prev[y])) ^= *((LTC_FAST_TYPE*)(&in[y])); 49 *((LTC_FAST_TYPE*)(&omac->prev[y])) ^= *((LTC_FAST_TYPE*)(&in[y]));
50 } 50 }
51 in += 16; 51 in += 16;
52 cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key); 52 if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) {
53 return err;
54 }
53 } 55 }
54 inlen -= x; 56 inlen -= x;
55 } 57 }
56 #endif 58 #endif
57 59
59 /* ok if the block is full we xor in prev, encrypt and replace prev */ 61 /* ok if the block is full we xor in prev, encrypt and replace prev */
60 if (omac->buflen == omac->blklen) { 62 if (omac->buflen == omac->blklen) {
61 for (x = 0; x < (unsigned long)omac->blklen; x++) { 63 for (x = 0; x < (unsigned long)omac->blklen; x++) {
62 omac->block[x] ^= omac->prev[x]; 64 omac->block[x] ^= omac->prev[x];
63 } 65 }
64 cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->block, omac->prev, &omac->key); 66 if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->block, omac->prev, &omac->key)) != CRYPT_OK) {
67 return err;
68 }
65 omac->buflen = 0; 69 omac->buflen = 0;
66 } 70 }
67 71
68 /* add bytes */ 72 /* add bytes */
69 n = MIN(inlen, (unsigned long)(omac->blklen - omac->buflen)); 73 n = MIN(inlen, (unsigned long)(omac->blklen - omac->buflen));
78 82
79 #endif 83 #endif
80 84
81 85
82 /* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_process.c,v $ */ 86 /* $Source: /cvs/libtom/libtomcrypt/src/mac/omac/omac_process.c,v $ */
83 /* $Revision: 1.6 $ */ 87 /* $Revision: 1.9 $ */
84 /* $Date: 2005/05/05 14:35:58 $ */ 88 /* $Date: 2006/11/03 00:39:49 $ */