*/
-#include "silcincludes.h"
+#include "silc.h"
+#include "twofish_internal.h"
#include "twofish.h"
/*
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);
SILC_CIPHER_API_ENCRYPT_CBC(twofish)
{
- uint32 tiv[4];
+ SilcUInt32 tiv[4];
int i;
SILC_CBC_GET_IV(tiv, iv);
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);
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;