void TigerHash::update(const void* data, size_t length) { size_t tmppos = (uint32_t)(pos & (BLOCK_SIZE - 1)); #ifdef TIGER_BIG_ENDIAN uint8_t buf[BLOCK_SIZE]; int j; #endif const uint8_t* str = (const uint8_t*)data; // First empty tmp buffer if possible if (tmppos > 0) { const size_t n = min(length, BLOCK_SIZE - tmppos); memcpy(tmp + tmppos, str, n); str += n; pos += n; length -= n; if ((tmppos + n) == BLOCK_SIZE) { #ifdef TIGER_BIG_ENDIAN for (j = 0; j < BLOCK_SIZE; j++) buf[j ^ 7] = ((uint8_t*)tmp)[j]; tiger_compress_macro(((uint64_t*)buf), res); #else tiger_compress_macro(((uint64_t*)tmp), res); #endif tmppos = 0; } } // So, now either tmp is empty or all data has been consumed... dcassert(length == 0 || tmppos == 0); // Process the bulk of data while (length >= BLOCK_SIZE) { #ifdef TIGER_BIG_ENDIAN for (j = 0; j < BLOCK_SIZE; j++) buf[j ^ 7] = ((uint8_t*)str)[j]; tiger_compress_macro(((uint64_t*)buf), res); #else tiger_compress_macro(((uint64_t*)str), res); // [5] https://www.box.net/shared/56e20a1bb6bfd4f2433f #endif str += BLOCK_SIZE; pos += BLOCK_SIZE; length -= BLOCK_SIZE; } // Copy the rest to the tmp buffer memcpy(tmp, str, length); pos += length; }
uint8_t* TigerHash::finalize() { size_t tmppos = (size_t)(pos & BLOCK_SIZE - 1); #ifdef TIGER_BIG_ENDIAN uint8_t buf[BLOCK_SIZE]; int j; #endif // Tmp buffer always has at least one pos, otherwise it would have // been processed in update() tmp[tmppos++] = 0x01; if (tmppos > (BLOCK_SIZE - sizeof(uint64_t))) { memzero(tmp + tmppos, BLOCK_SIZE - tmppos); #ifdef TIGER_BIG_ENDIAN for (j = 0; j < BLOCK_SIZE; j++) buf[j ^ 7] = ((uint8_t*)tmp)[j]; tiger_compress_macro(((uint64_t*)buf), res); #else tiger_compress_macro(((uint64_t*)tmp), res); #endif memzero(tmp, BLOCK_SIZE); } else { memzero(tmp + tmppos, BLOCK_SIZE - tmppos - sizeof(uint64_t)); #ifdef TIGER_BIG_ENDIAN for (j = 0; j < BLOCK_SIZE; j++) buf[j ^ 7] = ((uint8_t*)tmp)[j]; memcpy(tmp, buf, BLOCK_SIZE); #endif } ((uint64_t*)(&(tmp[56])))[0] = pos << 3; tiger_compress_macro(((uint64_t*)tmp), res); #ifdef TIGER_BIG_ENDIAN for (j = 0; j < BYTES; j++) buf[j ^ 7] = ((uint8_t*)res)[j]; memcpy(res, buf, BYTES); #endif return getResult(); }
/* The compress function is a function. Requires smaller cache? */ void tiger_compress(word64 *str, word64 state[3], word32 passes) { tiger_compress_macro(((word64*)str), ((word64*)state), passes); }
/* The compress function is a function. Requires smaller cache? */ void tiger_compress(word64 *str, word64 state[3]) { tiger_compress_macro(((word64*)str), ((word64*)state)); }
/* The compress function is a function. Requires smaller cache? */ static G_GNUC_HOT void tiger_compress(const guint64 *data, guint64 state[3]) { tiger_compress_macro(data, state); }
/* The compress function is a function. Requires smaller cache? */ static void tiger_compress(uint64_t *str, uint64_t state[3]) { tiger_compress_macro(((uint64_t*)str), ((uint64_t*)state)); }
/* The compress function is a function. Requires smaller cache? */ void TigerHash::tigerCompress(const uint64_t *str, uint64_t state[3]) { tiger_compress_macro(((const uint64_t*)str), ((uint64_t*)state)); }
void ADCLIB::TigerHash::tigerCompress( const unsigned long long * str, unsigned long long state[3] ) { tiger_compress_macro( ( ( const unsigned long long * ) str ), ( ( unsigned long long * ) state ) ); }