Added SILC Server library.
[silc.git] / lib / silccrypt / twofish.c
index 1dadee2595b146fdda33728a0c80037f1fc8f409..ebfc19a4749cf05137d61ab59112174cb3991db0 100644 (file)
@@ -39,7 +39,8 @@ Mean:          378 cycles =    67.8 mbits/sec
 
 */
 
-#include "silcincludes.h"
+#include "silc.h"
+#include "twofish_internal.h"
 #include "twofish.h"
 
 /* 
@@ -50,7 +51,7 @@ Mean:          378 cycles =    67.8 mbits/sec
 
 SILC_CIPHER_API_SET_KEY(twofish)
 {
-  uint32 k[8];
+  SilcUInt32 k[8];
 
   SILC_GET_WORD_KEY(key, k, keylen);
   twofish_set_key((TwofishContext *)context, k, keylen);
@@ -78,7 +79,7 @@ SILC_CIPHER_API_CONTEXT_LEN(twofish)
 
 SILC_CIPHER_API_ENCRYPT_CBC(twofish)
 {
-  uint32 tiv[4];
+  SilcUInt32 tiv[4];
   int i;
 
   SILC_CBC_GET_IV(tiv, iv);
@@ -103,7 +104,7 @@ SILC_CIPHER_API_ENCRYPT_CBC(twofish)
 
 SILC_CIPHER_API_DECRYPT_CBC(twofish)
 {
-  uint32 tmp[4], tmp2[4], tiv[4];
+  SilcUInt32 tmp[4], tmp2[4], tiv[4];
   int i;
 
   SILC_CBC_GET_IV(tiv, iv);
@@ -420,27 +421,27 @@ u4byte mds_rem(u4byte p0, u4byte p1)
 
     for(i = 0; i < 8; ++i)
     {
-        t = p1 >> 24;   // get most significant coefficient
+        t = p1 >> 24;   /* get most significant coefficient */
         
-        p1 = (p1 << 8) | (p0 >> 24); p0 <<= 8;  // shift others up
+        p1 = (p1 << 8) | (p0 >> 24); p0 <<= 8;  /* shift others up */
             
-        // multiply t by a (the primitive element - i.e. left shift)
+        /* multiply t by a (the primitive element - i.e. left shift) */
 
         u = (t << 1); 
         
-        if(t & 0x80)            // subtract modular polynomial on overflow
+        if(t & 0x80)            /* subtract modular polynomial on overflow */
         
             u ^= G_MOD; 
 
-        p1 ^= t ^ (u << 16);    // remove t * (a * x^2 + 1)  
+        p1 ^= t ^ (u << 16);    /* remove t * (a * x^2 + 1) */
 
-        u ^= (t >> 1);          // form u = a * t + t / a = t * (a + 1 / a); 
+        u ^= (t >> 1);          /* form u = a * t + t / a = t * (a + 1 / a); */
         
-        if(t & 0x01)            // add the modular polynomial on underflow
+        if(t & 0x01)            /* add the modular polynomial on underflow */
         
             u ^= G_MOD >> 1;
 
-        p1 ^= (u << 24) | (u << 8); // remove t * (a + 1/a) * (x^3 + x)
+        p1 ^= (u << 24) | (u << 8); /* remove t * (a + 1/a) * (x^3 + x) */
     }
 
     return p1;