X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..HEAD:/symm/whirlpool-mktab.c diff --git a/symm/whirlpool-mktab.c b/symm/whirlpool-mktab.c index cac72bf9..402c15c1 100644 --- a/symm/whirlpool-mktab.c +++ b/symm/whirlpool-mktab.c @@ -106,8 +106,12 @@ int main(void) * Whirlpool tables [generated]\n\ */\n\ \n\ -#ifndef CATACOMB_WHIRLPOOL_TAB_H\n\ -#define CATACOMB_WHIRLPOOL_TAB_H\n\ +#include \n\ +\n\ +#if defined(HAVE_UINT64)\n\ +# define USE64\n\ +#endif\n\ +\n\ "); /* --- Write out the S-box --- */ @@ -117,14 +121,14 @@ int main(void) fputs("\ /* --- The byte substitution --- */\n\ \n\ -#define WHIRLPOOL_S { \\\n\ +const octet whirlpool_s[256] = {\n\ ", stdout); for (i = 0; i < 256; i++) { printf("0x%02x", S[i]); if (i == 255) - fputs(" \\\n}\n\n", stdout); + fputs("\n};\n\n", stdout); else if (i % 8 == 7) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } @@ -134,16 +138,16 @@ int main(void) fputs("\ /* --- The key generation constants --- */\n\ \n\ -#define WHIRLPOOL_C { \\\n\ +const kludge64 whirlpool_c[10] = {\n\ ", stdout); for (i = 0; i < 10; i++) { printf("X64(%08lx, %08lx)", (unsigned long)LOAD32_L(&S[i * 8 + 4]), (unsigned long)LOAD32_L(&S[i * 8 + 0])); if (i == 9) - fputs(" \\\n}\n\n", stdout); + fputs("\n};\n\n", stdout); else if (i % 2 == 1) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } @@ -151,22 +155,22 @@ int main(void) /* --- Write out the big T tables --- */ fputs("\ +#ifdef USE64\n\ +\n\ /* --- The 64-bit big round tables --- */\n\ \n\ -#define WHIRLPOOL_T { \\\n\ +const kludge64 whirlpool_t[8][256] = {\n\ { ", stdout); for (j = 0; j < 8; j++) { for (i = 0; i < 256; i++) { printf("X64(%08lx, %08lx)", w32(j, i, 0), w32(j, i, 1)); if (i == 255) { if (j == 7) - fputs(" } \\\n}\n\n", stdout); + fputs(" }\n};\n\n", stdout); else - fputs(" }, \\\n\ - \\\n\ - { ", stdout); + fputs(" },\n\n { ", stdout); } else if (i % 2 == 1) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } @@ -175,42 +179,40 @@ int main(void) /* --- Write out the smaller U and V tables --- */ fputs("\ +#else\n\ +\n\ /* --- The 32-bit round tables --- */\n\ \n\ -#define WHIRLPOOL_U { \\\n\ +const uint32 whirlpool_u[4][256] = {\n\ { ", stdout); for (j = 0; j < 4; j++) { for (i = 0; i < 256; i++) { printf("0x%08lx", w32(j, i, 1)); if (i == 255) { if (j == 3) - fputs(" } \\\n}\n\n", stdout); + fputs(" }\n};\n\n", stdout); else - fputs(" }, \\\n\ - \\\n\ - { ", stdout); + fputs(" },\n\n { ", stdout); } else if (i % 4 == 3) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } } fputs("\ -#define WHIRLPOOL_V { \\\n\ +const uint32 whirlpool_v[4][256] = {\n\ { ", stdout); for (j = 0; j < 4; j++) { for (i = 0; i < 256; i++) { printf("0x%08lx", w32(j, i, 0)); if (i == 255) { if (j == 3) - fputs(" } \\\n}\n\n", stdout); + fputs(" }\n};\n\n", stdout); else - fputs(" }, \\\n\ - \\\n\ - { ", stdout); + fputs(" },\n\n { ", stdout); } else if (i % 4 == 3) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); }