void tiger_t(const word64 *str, word64 length, word64 res[3]) { register word64 i; #ifdef BIG_ENDIAN register word64 j = 0; unsigned char temp[64]; #endif /* * res[0]=0x0123456789ABCDEFLL; * res[1]=0xFEDCBA9876543210LL; * res[2]=0xF096A5B4C3B2E187LL; */ for(i=length; i>=64; i-=64) { #ifdef BIG_ENDIAN for(j=0; j<64; j++) temp[j^7] = ((sh_byte*)str)[j]; tiger_compress(((word64*)temp), res); #else tiger_compress(str, res); #endif str += 8; } }
void TIGERUpdate(tiger_context_t *tp, const uint8_t *data, size_t len) { const uint64_t *str = (const uint64_t *)data; uint64_t i; uint64_t j; uint8_t temp[64]; for (i = len; i >= 64; i -= 64) { #ifdef WORDS_BIGENDIAN for (j = 0; j < 64; j++) { temp[j ^ 7] = ((uint8_t *) str)[j]; } tiger_compress(((const uint64_t *) temp), tp->ctx); #else tiger_compress(str, tp->ctx); #endif str += 8; } #ifdef WORDS_BIGENDIAN for (j = 0; j < i; j++) { temp[j ^ 7] = ((uint8_t *) str)[j]; } temp[j ^ 7] = 0x01; j++; for (; j & 7; j++) { temp[j ^ 7] = 0; } #else for (j = 0; j < i; j++) { temp[j] = ((const uint8_t *) str)[j]; } temp[j++] = 0x01; for (; j & 7; j++) { temp[j] = 0; } #endif if (j > 56) { for (; j < 64; j++) { temp[j] = 0; } tiger_compress(((uint64_t *) temp), tp->ctx); j = 0; } for (; j < 56; j++) { temp[j] = 0; } ((uint64_t *) (&(temp[56])))[0] = ((uint64_t) len) << 3; tiger_compress(((uint64_t *) temp), tp->ctx); tp->first_time = 0; }
void tiger(word64 *str, word64 length, word64 res[3], word32 passes) { register word64 i, j; unsigned char temp[64]; res[0]=0x0123456789ABCDEFLL; res[1]=0xFEDCBA9876543210LL; res[2]=0xF096A5B4C3B2E187LL; for(i=length; i>=64; i-=64) { #ifdef BIG_ENDIAN for(j=0; j<64; j++) temp[j^7] = ((byte*)str)[j]; tiger_compress(((word64*)temp), res, passes); #else tiger_compress(str, res, passes); #endif str += 8; } #ifdef BIG_ENDIAN for(j=0; j<i; j++) temp[j^7] = ((byte*)str)[j]; temp[j^7] = 0x01; j++; for(; j&7; j++) temp[j^7] = 0; #else for(j=0; j<i; j++) temp[j] = ((byte*)str)[j]; temp[j++] = 0x01; for(; j&7; j++) temp[j] = 0; #endif if(j>56) { for(; j<64; j++) temp[j] = 0; tiger_compress(((word64*)temp), res, passes); j=0; } for(; j<56; j++) temp[j] = 0; ((word64*)(&(temp[56])))[0] = ((word64)length)<<3; tiger_compress(((word64*)temp), res, passes); }
void tiger_update(tiger_state_t *ctx, uint8_t *str, uint32_t length) { uint32_t i, j; uint8_t temp[64]; uint64_t *dat; ctx->len += length; for(i=length; i>=64; i-=64) { #ifdef WORDS_BIGENDIAN for(j=0; j<64; j++) temp[j^7] = str[j]; dat = (uint64_t *)temp; #else dat = (uint64_t *)str; #endif tiger_compress(dat, ctx->state); str += 8 * sizeof(uint64_t); } if (i) { memcpy(ctx->rembuf, str, i); ctx->remlen = i; ctx->len -= i; } }
int tiger_final(tiger_state_t *ctx, uint8_t *result) { uint32_t i, j; uint8_t temp[64]; uint64_t *dat; #ifdef WORDS_BIGENDIAN for(j=0; j<ctx->remlen; j++) temp[j^7] = ctx->rembuf[j]; temp[j^7] = 0x01; j++; for(; j&7; j++) temp[j^7] = 0; #else for(j=0; j<ctx->remlen; j++) temp[j] = ctx->rembuf[j]; temp[j++] = 0x01; for(; j&7; j++) temp[j] = 0; #endif if(j>56) { for(; j<64; j++) temp[j] = 0; tiger_compress(((uint64_t*)temp), ctx->state); j=0; } ctx->len += ctx->remlen; for(; j<56; j++) temp[j] = 0; ((uint64_t*)(&(temp[56])))[0] = ((uint64_t)ctx->len)<<3; tiger_compress(((uint64_t*)temp), ctx->state); memcpy(result, ctx->state, sizeof(ctx->state)); return 1; }
void tiger(gconstpointer data, guint64 length, char hash[24]) { guint64 i, j, res[3]; const guint8 *data_u8 = data; union { guint64 u64[8]; guint8 u8[64]; } temp; res[0] = U64_FROM_2xU32(0x01234567UL, 0x89ABCDEFUL); res[1] = U64_FROM_2xU32(0xFEDCBA98UL, 0x76543210UL); res[2] = U64_FROM_2xU32(0xF096A5B4UL, 0xC3B2E187UL); #if G_BYTE_ORDER == G_BIG_ENDIAN for (i = length; i >= 64; i -= 64) { for (j = 0; j < 64; j++) { temp.u8[j ^ 7] = data_u8[j]; } tiger_compress(temp.u64, res); data_u8 += 64; } #else /* !BIG ENDIAN */ if ((gulong) data & 7) { for (i = length; i >= 64; i -= 64) { memcpy(temp.u64, data_u8, 64); tiger_compress(temp.u64, res); data_u8 += 64; } } else { for (i = length; i >= 64; i -= 64) { tiger_compress((gconstpointer) data_u8, res); data_u8 += 64; } } #endif /* BIG ENDIAN */ #if G_BYTE_ORDER == G_BIG_ENDIAN for (j = 0; j < i; j++) { temp.u8[j ^ 7] = data_u8[j]; } temp.u8[j ^ 7] = 0x01; j++; for (; j & 7; j++) { temp.u8[j ^ 7] = 0; } #else for(j = 0; j < i; j++) { temp.u8[j] = data_u8[j]; } temp.u8[j++] = 0x01; for (; j & 7; j++) { temp.u8[j] = 0; } #endif if (j > 56) { for (; j < 64; j++) { temp.u8[j] = 0; } tiger_compress(temp.u64, res); j = 0; } for (; j < 56; j++) { temp.u8[j] = 0; } temp.u64[7] = length << 3; tiger_compress(temp.u64, res); for (i = 0; i < 3; i++) { poke_le64(&hash[i * 8], res[i]); } }
void tiger(const word64 *str, word64 length, word64 res[3]) { register word64 i; register word64 j = 0; unsigned char temp[64]; /* * res[0]=0x0123456789ABCDEFLL; * res[1]=0xFEDCBA9876543210LL; * res[2]=0xF096A5B4C3B2E187LL; */ for(i=length; i>=64; i-=64) { #ifdef BIG_ENDIAN for(j=0; j<64; j++) temp[j^7] = ((sh_byte*)str)[j]; tiger_compress(((word64*)temp), res); #else tiger_compress(str, res); #endif str += 8; } #ifdef BIG_ENDIAN for(j=0; j<i; j++) temp[j^7] = ((sh_byte*)str)[j]; temp[j^7] = 0x01; j++; for(; j&7; j++) temp[j^7] = 0; #else #ifndef USE_MEMSET for(j=0; j<i; j++) temp[j] = ((sh_byte*)str)[j]; #else memcpy( temp, str, j=i ); #endif temp[j++] = 0x01; for(; j&7; j++) temp[j] = 0; #endif if(j>56) { #ifndef USE_MEMSET for(; j<64; j++) temp[j] = 0; #else memset( temp+j, 0, 64-j); #endif tiger_compress(((word64*)temp), res); j=0; } #ifndef USE_MEMSET for(; j<56; j++) temp[j] = 0; #else memset( temp+j, 0, 56-j); #endif ((word64*)(&(temp[56])))[0] = ((word64)length)<<3; tiger_compress(((word64*)temp), res); }