diff libtomcrypt/src/hashes/tiger.c @ 1471:6dba84798cd5

Update to libtomcrypt 1.18.1, merged with Dropbear changes
author Matt Johnston <matt@ucc.asn.au>
date Fri, 09 Feb 2018 21:44:05 +0800
parents f849a5ca2efc
children
line wrap: on
line diff
--- a/libtomcrypt/src/hashes/tiger.c	Thu Feb 08 23:11:40 2018 +0800
+++ b/libtomcrypt/src/hashes/tiger.c	Fri Feb 09 21:44:05 2018 +0800
@@ -5,8 +5,6 @@
  *
  * The library is free for all purposes without any express
  * guarantee it works.
- *
- * Tom St Denis, [email protected], http://libtom.org
  */
 
 #include "tomcrypt.h"
@@ -558,16 +556,16 @@
 #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 @@
 /* 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 @@
 
     /* 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 @@
 /**
   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 @@
       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 @@
 
 
 
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref:         $Format:%D$ */
+/* git commit:  $Format:%H$ */
+/* commit time: $Format:%ai$ */