]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - twister_tables.h
now comes twister-512
[avr-crypto-lib.git] / twister_tables.h
index 96686a149a4bbfe1554abecc1e5259eac1c984ba..b0f145cf84ac7565a5e44f935d861a6986b71db6 100644 (file)
@@ -4,6 +4,7 @@
  *
  *******************************************************************/
 
+#include "config.h"
 #include <stdint.h>
 #include <avr/pgmspace.h>
 
@@ -42,6 +43,7 @@ static const uint8_t twister_sbox[256] PROGMEM = {
     0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16
 };
 
+#ifndef TWISTER_MUL_TABLE
   
   
 /* Twister MDS matrix */
@@ -56,9 +58,30 @@ static const uint8_t twister_mds[8][8] PROGMEM = {
   {1, 1, 5, 7, 8, 6, 1, 2}
 };
   
-/*  
+#else
+
+#define S1 0
+#define S2 1
+#define S3 X
+#define S4 X
+#define S5 2
+#define S6 3
+#define S7 4
+#define S8 5
+
+static const uint8_t twister_mds[8][8] PROGMEM = {
+  {S2, S1, S1, S5, S7, S8, S6, S1},
+  {S1, S2, S1, S1, S5, S7, S8, S6},
+  {S6, S1, S2, S1, S1, S5, S7, S8},
+  {S8, S6, S1, S2, S1, S1, S5, S7},
+  {S7, S8, S6, S1, S2, S1, S1, S5},
+  {S5, S7, S8, S6, S1, S2, S1, S1},
+  {S1, S5, S7, S8, S6, S1, S2, S1},
+  {S1, S1, S5, S7, S8, S6, S1, S2}
+};
+
 static const uint8_t twister_multab[8][256] PROGMEM = {
-  {
+  { /* 1 */
     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
     16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
@@ -76,7 +99,7 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
     224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
     240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
   },
-  {
+  { /* 2 */
     0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30,
     32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62,
     64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94,
@@ -94,7 +117,7 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
     141, 143, 137, 139, 133, 135, 129, 131, 157, 159, 153, 155, 149, 151, 145, 147,
     173, 175, 169, 171, 165, 167, 161, 163, 189, 191, 185, 187, 181, 183, 177, 179
   },
-  {
+/*  { / * 3 * /
     0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17,
     48, 51, 54, 53, 60, 63, 58, 57, 40, 43, 46, 45, 36, 39, 34, 33,
     96, 99, 102, 101, 108, 111, 106, 105, 120, 123, 126, 125, 116, 119, 114, 113,
@@ -112,7 +135,7 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
     109, 110, 107, 104, 97, 98, 103, 100, 117, 118, 115, 112, 121, 122, 127, 124,
     93, 94, 91, 88, 81, 82, 87, 84, 69, 70, 67, 64, 73, 74, 79, 76
   },
-  {
+  { / * 4 * /
     0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60,
     64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124,
     128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188,
@@ -130,7 +153,7 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
     87, 83, 95, 91, 71, 67, 79, 75, 119, 115, 127, 123, 103, 99, 111, 107,
     23, 19, 31, 27, 7, 3, 15, 11, 55, 51, 63, 59, 39, 35, 47, 43
   },
-  {
+*/  { /* 5 */
     0, 5, 10, 15, 20, 17, 30, 27, 40, 45, 34, 39, 60, 57, 54, 51,
     80, 85, 90, 95, 68, 65, 78, 75, 120, 125, 114, 119, 108, 105, 102, 99,
     160, 165, 170, 175, 180, 177, 190, 187, 136, 141, 130, 135, 156, 153, 150, 147,
@@ -148,7 +171,7 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
     183, 178, 189, 184, 163, 166, 169, 172, 159, 154, 149, 144, 139, 142, 129, 132,
     231, 226, 237, 232, 243, 246, 249, 252, 207, 202, 197, 192, 219, 222, 209, 212
   },
-  {
+  { /* 6 */
     0, 6, 12, 10, 24, 30, 20, 18, 48, 54, 60, 58, 40, 46, 36, 34,
     96, 102, 108, 106, 120, 126, 116, 114, 80, 86, 92, 90, 72, 78, 68, 66,
     192, 198, 204, 202, 216, 222, 212, 210, 240, 246, 252, 250, 232, 238, 228, 226,
@@ -166,7 +189,7 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
     218, 220, 214, 208, 194, 196, 206, 200, 234, 236, 230, 224, 242, 244, 254, 248,
     186, 188, 182, 176, 162, 164, 174, 168, 138, 140, 134, 128, 146, 148, 158, 152
   },
-  {
+  { /* 7 */
     0, 7, 14, 9, 28, 27, 18, 21, 56, 63, 54, 49, 36, 35, 42, 45,
     112, 119, 126, 121, 108, 107, 98, 101, 72, 79, 70, 65, 84, 83, 90, 93,
     224, 231, 238, 233, 252, 251, 242, 245, 216, 223, 214, 209, 196, 195, 202, 205,
@@ -184,7 +207,7 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
     58, 61, 52, 51, 38, 33, 40, 47, 2, 5, 12, 11, 30, 25, 16, 23,
     74, 77, 68, 67, 86, 81, 88, 95, 114, 117, 124, 123, 110, 105, 96, 103
   },
-  {
+  { /* 8 */
     0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120,
     128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248,
     77, 69, 93, 85, 109, 101, 125, 117, 13, 5, 29, 21, 45, 37, 61, 53,
@@ -204,4 +227,6 @@ static const uint8_t twister_multab[8][256] PROGMEM = {
   }
 };
     
-*/    
+#endif
+
+