1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
6
* The library is free for all purposes without any express
9
* Tom St Denis, tomstdenis@gmail.com, http://libtomcrypt.com
15
XCBC Support, process blocks with XCBC
20
/** Process data through XCBC-MAC
21
@param xcbc The XCBC-MAC state
22
@param in Input data to process
23
@param inlen Length of input in octets
24
Return CRYPT_OK on success
26
int xcbc_process(xcbc_state *xcbc, const unsigned char *in, unsigned long inlen)
33
LTC_ARGCHK(xcbc != NULL);
34
LTC_ARGCHK(in != NULL);
37
if ((err = cipher_is_valid(xcbc->cipher)) != CRYPT_OK) {
41
if ((xcbc->blocksize > cipher_descriptor[xcbc->cipher].block_length) || (xcbc->blocksize < 0) ||
42
(xcbc->buflen > xcbc->blocksize) || (xcbc->buflen < 0)) {
43
return CRYPT_INVALID_ARG;
47
if (xcbc->buflen == 0) {
48
while (inlen > (unsigned long)xcbc->blocksize) {
49
for (x = 0; x < xcbc->blocksize; x += sizeof(LTC_FAST_TYPE)) {
50
*((LTC_FAST_TYPE*)&(xcbc->IV[x])) ^= *((LTC_FAST_TYPE*)&(in[x]));
52
cipher_descriptor[xcbc->cipher].ecb_encrypt(xcbc->IV, xcbc->IV, &xcbc->key);
53
in += xcbc->blocksize;
54
inlen -= xcbc->blocksize;
60
if (xcbc->buflen == xcbc->blocksize) {
61
cipher_descriptor[xcbc->cipher].ecb_encrypt(xcbc->IV, xcbc->IV, &xcbc->key);
64
xcbc->IV[xcbc->buflen++] ^= *in++;
72
/* $Source: /cvs/libtom/libtomcrypt/src/mac/xcbc/xcbc_process.c,v $ */
73
/* $Revision: 1.9 $ */
74
/* $Date: 2006/11/09 22:43:52 $ */