diff --git a/src/headers/tomcrypt_private.h b/src/headers/tomcrypt_private.h index 8c6d8a7ba..ecf90c1d3 100644 --- a/src/headers/tomcrypt_private.h +++ b/src/headers/tomcrypt_private.h @@ -168,6 +168,7 @@ int func_name (hash_state * md, const unsigned char *in, unsigned long inlen) int ocb3_int_ntz(unsigned long x); void ocb3_int_xor_blocks(unsigned char *out, const unsigned char *block_a, const unsigned char *block_b, unsigned long block_len); +int omac_vprocess(omac_state *omac, const unsigned char *in, unsigned long inlen, va_list args); /* tomcrypt_math.h */ diff --git a/src/mac/omac/omac_memory_multi.c b/src/mac/omac/omac_memory_multi.c index 4f3b708ea..1cceecbe9 100644 --- a/src/mac/omac/omac_memory_multi.c +++ b/src/mac/omac/omac_memory_multi.c @@ -10,6 +10,31 @@ #ifdef LTC_OMAC +static LTC_INLINE int s_omac_vprocess(omac_state *omac, const unsigned char *in, unsigned long inlen, va_list args) +{ + const unsigned char * curptr = in; + unsigned long curlen = inlen; + int err; + for (;;) { + /* process buf */ + if ((err = omac_process(omac, curptr, curlen)) != CRYPT_OK) { + return err; + } + /* step to next */ + curptr = va_arg(args, const unsigned char*); + if (curptr == NULL) { + break; + } + curlen = va_arg(args, unsigned long); + } + return CRYPT_OK; +} + +int omac_vprocess(omac_state *omac, const unsigned char *in, unsigned long inlen, va_list args) +{ + return s_omac_vprocess(omac, in, inlen, args); +} + /** OMAC multiple blocks of memory @param cipher The index of the desired cipher @@ -30,8 +55,6 @@ int omac_memory_multi(int cipher, int err; omac_state *omac; va_list args; - const unsigned char *curptr; - unsigned long curlen; LTC_ARGCHK(key != NULL); LTC_ARGCHK(in != NULL); @@ -49,24 +72,11 @@ int omac_memory_multi(int cipher, goto LBL_ERR; } va_start(args, inlen); - curptr = in; - curlen = inlen; - for (;;) { - /* process buf */ - if ((err = omac_process(omac, curptr, curlen)) != CRYPT_OK) { - goto LBL_ERR; - } - /* step to next */ - curptr = va_arg(args, const unsigned char*); - if (curptr == NULL) { - break; - } - curlen = va_arg(args, unsigned long); - } - if ((err = omac_done(omac, out, outlen)) != CRYPT_OK) { + if ((err = s_omac_vprocess(omac, in, inlen, args)) != CRYPT_OK) { goto LBL_ERR; } LBL_ERR: + err = omac_done(omac, out, outlen); #ifdef LTC_CLEAN_STACK zeromem(omac, sizeof(omac_state)); #endif