From: bg Date: Thu, 11 Dec 2008 00:15:23 +0000 (+0000) Subject: oops some imortant thigs were commented out X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=0896c282ff85cedfa7205695420c916eb08eafed;p=avr-crypto-lib.git oops some imortant thigs were commented out --- diff --git a/seed-stub.c b/seed-stub.c index ff64489..fa3b75c 100644 --- a/seed-stub.c +++ b/seed-stub.c @@ -28,10 +28,29 @@ #include #include #include -#include "seed_sbox.h" #include "uart.h" #include "debug.h" +/* key constants */ +uint32_t seed_kc[16] PROGMEM ={ + 0xb979379e, + 0x73f36e3c, + 0xe6e6dd78, + 0xcccdbbf1, + 0x999b77e3, + 0x3337efc6, + 0x676ede8d, + 0xcfdcbc1b, + 0x9eb97937, + 0x3c73f36e, + 0x78e6e6dd, + 0xf1cccdbb, + 0xe3999b77, + 0xc63337ef, + 0x8d676ede, + 0x1bcfdcbc +}; + static uint64_t f_function(uint64_t a, uint32_t k0, uint32_t k1); uint32_t g_function(uint32_t x); @@ -83,39 +102,7 @@ uint64_t f_function(uint64_t a, uint32_t k0, uint32_t k1){ return a; } -/******************************************************************************/ -#if 0 -#define M0 0xfc -#define M1 0xf3 -#define M2 0xcf -#define M3 0x3f - -#define X3 (((uint8_t*)(&x))[0]) -#define X2 (((uint8_t*)(&x))[1]) -#define X1 (((uint8_t*)(&x))[2]) -#define X0 (((uint8_t*)(&x))[3]) - -#define Z3 (((uint8_t*)(&z))[0]) -#define Z2 (((uint8_t*)(&z))[1]) -#define Z1 (((uint8_t*)(&z))[2]) -#define Z0 (((uint8_t*)(&z))[3]) -static -uint32_t g_function(uint32_t x){ - uint32_t z; - /* sbox substitution */ - X3 = pgm_read_byte(&(seed_sbox2[X3])); - X2 = pgm_read_byte(&(seed_sbox1[X2])); - X1 = pgm_read_byte(&(seed_sbox2[X1])); - X0 = pgm_read_byte(&(seed_sbox1[X0])); - /* now the permutation */ - Z0 = (X0 & M0) ^ (X1 & M1) ^ (X2 & M2) ^ (X3 & M3); - Z1 = (X0 & M1) ^ (X1 & M2) ^ (X2 & M3) ^ (X3 & M0); - Z2 = (X0 & M2) ^ (X1 & M3) ^ (X2 & M0) ^ (X3 & M1); - Z3 = (X0 & M3) ^ (X1 & M0) ^ (X2 & M1) ^ (X3 & M2); - return z; -} -#endif /******************************************************************************/ typedef struct { uint32_t k0, k1; diff --git a/seed_C.c b/seed_C.c index f055e7f..2f9b8d0 100644 --- a/seed_C.c +++ b/seed_C.c @@ -32,6 +32,9 @@ #include "uart.h" #include "debug.h" + +static +uint32_t g_function(uint32_t x); /******************************************************************************/ static diff --git a/seed_sbox.h b/seed_sbox.h index 91ce4c6..eafecc6 100644 --- a/seed_sbox.h +++ b/seed_sbox.h @@ -31,7 +31,7 @@ #include #include -/* + uint8_t seed_sbox1[256] PROGMEM ={ 169, 133, 214, 211, 84, 29, 172, 37, 93, 67, 24, 30, 81, 252, 202, 99, @@ -101,7 +101,7 @@ uint8_t seed_sbox2[256] PROGMEM ={ 55, 231, 36, 164, 203, 83, 10, 135, 217, 76, 131, 143, 206, 59, 74, 183 }; -*/ + /* key constants */ uint32_t seed_kc[16] PROGMEM ={ 0xb979379e,