summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/src/hashes/tiger.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2018-02-09 21:44:05 +0800
committerMatt Johnston <matt@ucc.asn.au>2018-02-09 21:44:05 +0800
commit4f2eb1914bdac3ed3ee504ad86061281dbe0d074 (patch)
tree078293375c3f3ee2d485cf9559a08d65d460786a /libtomcrypt/src/hashes/tiger.c
parentd72f50ff3284e15124a0f233c26339229fe305ac (diff)
Update to libtomcrypt 1.18.1, merged with Dropbear changes
Diffstat (limited to 'libtomcrypt/src/hashes/tiger.c')
-rw-r--r--libtomcrypt/src/hashes/tiger.c80
1 files changed, 39 insertions, 41 deletions
diff --git a/libtomcrypt/src/hashes/tiger.c b/libtomcrypt/src/hashes/tiger.c
index 4d8c659..863f7fa 100644
--- a/libtomcrypt/src/hashes/tiger.c
+++ b/libtomcrypt/src/hashes/tiger.c
@@ -5,8 +5,6 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
#include "tomcrypt.h"
@@ -558,16 +556,16 @@ static const ulong64 table[4*256] = {
#ifdef _MSC_VER
#define INLINE __inline
#else
- #define INLINE
-#endif
+ #define INLINE
+#endif
/* one round of the hash function */
INLINE static void tiger_round(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, int mul)
{
ulong64 tmp;
- tmp = (*c ^= x);
- *a -= t1[byte(tmp, 0)] ^ t2[byte(tmp, 2)] ^ t3[byte(tmp, 4)] ^ t4[byte(tmp, 6)];
- tmp = (*b += t4[byte(tmp, 1)] ^ t3[byte(tmp, 3)] ^ t2[byte(tmp,5)] ^ t1[byte(tmp,7)]);
+ tmp = (*c ^= x);
+ *a -= t1[byte(tmp, 0)] ^ t2[byte(tmp, 2)] ^ t3[byte(tmp, 4)] ^ t4[byte(tmp, 6)];
+ tmp = (*b += t4[byte(tmp, 1)] ^ t3[byte(tmp, 3)] ^ t2[byte(tmp,5)] ^ t1[byte(tmp,7)]);
switch (mul) {
case 5: *b = (tmp << 2) + tmp; break;
case 7: *b = (tmp << 3) - tmp; break;
@@ -578,36 +576,36 @@ INLINE static void tiger_round(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 x, in
/* one complete pass */
static void pass(ulong64 *a, ulong64 *b, ulong64 *c, ulong64 *x, int mul)
{
- tiger_round(a,b,c,x[0],mul);
- tiger_round(b,c,a,x[1],mul);
- tiger_round(c,a,b,x[2],mul);
- tiger_round(a,b,c,x[3],mul);
- tiger_round(b,c,a,x[4],mul);
- tiger_round(c,a,b,x[5],mul);
- tiger_round(a,b,c,x[6],mul);
- tiger_round(b,c,a,x[7],mul);
-}
+ tiger_round(a,b,c,x[0],mul);
+ tiger_round(b,c,a,x[1],mul);
+ tiger_round(c,a,b,x[2],mul);
+ tiger_round(a,b,c,x[3],mul);
+ tiger_round(b,c,a,x[4],mul);
+ tiger_round(c,a,b,x[5],mul);
+ tiger_round(a,b,c,x[6],mul);
+ tiger_round(b,c,a,x[7],mul);
+}
/* The key mixing schedule */
-static void key_schedule(ulong64 *x)
+static void key_schedule(ulong64 *x)
{
- x[0] -= x[7] ^ CONST64(0xA5A5A5A5A5A5A5A5);
- x[1] ^= x[0];
- x[2] += x[1];
- x[3] -= x[2] ^ ((~x[1])<<19);
- x[4] ^= x[3];
- x[5] += x[4];
- x[6] -= x[5] ^ ((~x[4])>>23);
- x[7] ^= x[6];
- x[0] += x[7];
- x[1] -= x[0] ^ ((~x[7])<<19);
- x[2] ^= x[1];
- x[3] += x[2];
- x[4] -= x[3] ^ ((~x[2])>>23);
- x[5] ^= x[4];
- x[6] += x[5];
+ x[0] -= x[7] ^ CONST64(0xA5A5A5A5A5A5A5A5);
+ x[1] ^= x[0];
+ x[2] += x[1];
+ x[3] -= x[2] ^ ((~x[1])<<19);
+ x[4] ^= x[3];
+ x[5] += x[4];
+ x[6] -= x[5] ^ ((~x[4])>>23);
+ x[7] ^= x[6];
+ x[0] += x[7];
+ x[1] -= x[0] ^ ((~x[7])<<19);
+ x[2] ^= x[1];
+ x[3] += x[2];
+ x[4] -= x[3] ^ ((~x[2])>>23);
+ x[5] ^= x[4];
+ x[6] += x[5];
x[7] -= x[6] ^ CONST64(0x0123456789ABCDEF);
-}
+}
#ifdef LTC_CLEAN_STACK
static int _tiger_compress(hash_state *md, unsigned char *buf)
@@ -709,7 +707,7 @@ int tiger_done(hash_state * md, unsigned char *out)
/* pad upto 56 bytes of zeroes */
while (md->tiger.curlen < 56) {
- md->tiger.buf[md->tiger.curlen++] = (unsigned char)0;
+ md->tiger.buf[md->tiger.curlen++] = (unsigned char)0;
}
/* store length */
@@ -730,14 +728,14 @@ int tiger_done(hash_state * md, unsigned char *out)
/**
Self-test the hash
@return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled
-*/
+*/
int tiger_test(void)
{
#ifndef LTC_TEST
return CRYPT_NOP;
- #else
+ #else
static const struct {
- char *msg;
+ const char *msg;
unsigned char hash[24];
} tests[] = {
{ "",
@@ -775,7 +773,7 @@ int tiger_test(void)
tiger_init(&md);
tiger_process(&md, (unsigned char *)tests[i].msg, (unsigned long)strlen(tests[i].msg));
tiger_done(&md, tmp);
- if (XMEMCMP(tmp, tests[i].hash, 24) != 0) {
+ if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "TIGER", i)) {
return CRYPT_FAIL_TESTVECTOR;
}
}
@@ -809,6 +807,6 @@ Hash of "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-ABCDEFG
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */