From c211ce7f6646d1ed93bed53155ae2812ad9c66b6 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Thu, 1 May 2014 15:44:09 +0200 Subject: [PATCH] omac: fix accidentally reverted patch introduced in 6816ac3f3fae776adb1372dbffd0441062006109 reverted in 8e7777b5545e46ab545bd51f7fcde7957134ade2 --- src/mac/omac/omac_process.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/mac/omac/omac_process.c b/src/mac/omac/omac_process.c index 2bd08a9..8ecac0d 100644 --- a/src/mac/omac/omac_process.c +++ b/src/mac/omac/omac_process.c @@ -27,7 +27,7 @@ */ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen) { - unsigned long n, x, blklen; + unsigned long n, x; int err; LTC_ARGCHK(omac != NULL); @@ -42,20 +42,23 @@ int omac_process(omac_state *omac, const unsigned char *in, unsigned long inlen) } #ifdef LTC_FAST - blklen = cipher_descriptor[omac->cipher_idx].block_length; - if (omac->buflen == 0 && inlen > blklen) { - unsigned long y; - for (x = 0; x < (inlen - blklen); x += blklen) { - for (y = 0; y < blklen; y += sizeof(LTC_FAST_TYPE)) { - *((LTC_FAST_TYPE*)(&omac->prev[y])) ^= *((LTC_FAST_TYPE*)(&in[y])); - } - in += blklen; - if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) { - return err; - } - } - inlen -= x; - } + { + unsigned long blklen = cipher_descriptor[omac->cipher_idx].block_length; + + if (omac->buflen == 0 && inlen > blklen) { + unsigned long y; + for (x = 0; x < (inlen - blklen); x += blklen) { + for (y = 0; y < blklen; y += sizeof(LTC_FAST_TYPE)) { + *((LTC_FAST_TYPE*)(&omac->prev[y])) ^= *((LTC_FAST_TYPE*)(&in[y])); + } + in += blklen; + if ((err = cipher_descriptor[omac->cipher_idx].ecb_encrypt(omac->prev, omac->prev, &omac->key)) != CRYPT_OK) { + return err; + } + } + inlen -= x; + } + } #endif while (inlen != 0) {