From: bg Date: Wed, 9 Jul 2008 07:00:42 +0000 (+0000) Subject: skipjack testvectors seem broken X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=f6e331f76599dbb9b3bb82fb9600bbc4410b77bb;p=avr-crypto-lib.git skipjack testvectors seem broken --- diff --git a/skipjack.c b/skipjack.c index 3a610fc..2b4019e 100644 --- a/skipjack.c +++ b/skipjack.c @@ -30,6 +30,14 @@ #include #include +#define SKIPJACK_CNT_BIG + +#ifdef SKIPJACK_CNT_BIG + #define SKIPJACK_CNT_SHIFT <<8 +#else + #define SKIPJACK_CNT_SHIFT +#endif + /*****************************************************************************/ uint8_t skipjack_ftable[] PROGMEM ={ @@ -102,7 +110,7 @@ void skipjack_a(uint16_t* w, uint8_t k, uint8_t* key){ w[3] = w[2]; w[2] = w[1]; w[1] = skipjack_g(w[0],k-1,key); - w[0] = t ^ w[1] ^ k<<8; + w[0] = t ^ w[1] ^ (((uint16_t)k)SKIPJACK_CNT_SHIFT); } /*****************************************************************************/ @@ -113,7 +121,7 @@ void skipjack_a_inv(uint16_t* w, uint8_t k, uint8_t* key){ w[0] = skipjack_g_inv(w[1],k-1,key); w[1] = w[2]; w[2] = w[3]; - w[3] = t ^ k<<8; + w[3] = t ^ (((uint16_t)k)SKIPJACK_CNT_SHIFT); } /*****************************************************************************/ @@ -123,7 +131,7 @@ void skipjack_b(uint16_t* w, uint8_t k, uint8_t* key){ t = w[0]; w[0] = w[3]; w[3] = w[2]; - w[2] = t ^ k<<8 ^ w[1]; + w[2] = t ^ (((uint16_t)k)SKIPJACK_CNT_SHIFT) ^ w[1]; w[1] = skipjack_g(t,k-1,key); } @@ -135,7 +143,7 @@ void skipjack_b_inv(uint16_t* w, uint8_t k, uint8_t* key){ w[2] = w[3]; w[3] = w[0]; w[0] = skipjack_g_inv(w[1],k-1,key); - w[1] = w[0] ^ t ^ k<<8; + w[1] = w[0] ^ t ^ (((uint16_t)k)SKIPJACK_CNT_SHIFT); } /*****************************************************************************/