X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..192053f16dc688ff9d73d42b52bf35f39948c0e9:/symm/twofish-mktab.c diff --git a/symm/twofish-mktab.c b/symm/twofish-mktab.c index 4453fbe..f461a7d 100644 --- a/symm/twofish-mktab.c +++ b/symm/twofish-mktab.c @@ -150,16 +150,16 @@ static void printq(const q_tab *q, const char *name) int j; printf("\ -#define TWOFISH_%s { \\\n\ +const octet twofish_%s[256] = {\n\ ", name); j = 0; for (i = 0; i < 256; i++) { printf("0x%02x", q->q[i]); j = (j + 1) & 7; if (i == 255) - fputs(" \\\n}\n\n", stdout); + fputs("\n};\n\n", stdout); else if (j == 0) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } @@ -260,19 +260,19 @@ static void qmds(void) * bytes through appropriate @q@ tables and the MDS matrix.\n\ */\n\ \n\ -#define TWOFISH_QMDS { \\"); +const uint32 twofish_qmds[4][256] = {\ +"); for (i = 0; i < 4; i++) { fputs(" { ", stdout); for (j = 0; j < 256; j++) { printf("0x%08lx", (unsigned long)t[i][j]); if (j == 255) { if (i == 3) - puts(" } \\\n}"); + puts(" }\n};"); else - puts(" }, \\\n\ - \\"); + puts(" },\n"); } else if (j % 4 == 3) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } @@ -320,29 +320,29 @@ static void rslog(void) * The Reed-Solomon multiplies are accelerated by using log tables.\n\ */\n\ \n\ -#define TWOFISH_RSLOG { \\\n\ +const octet twofish_rslog[256] = {\n\ ", stdout); for (i = 0; i < 256; i++) { printf("0x%02x", rslog[i]); if (i == 255) - puts(" \\\n}\n"); + puts("\n};\n"); else if (i % 8 == 7) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } - fputs("\ -#define TWOFISH_RSEXP { \\\n\ - ", stdout); + printf("\ +const octet twofish_rsexp[%d] = {\n\ + ", 255 + x + 1); for (i = 0; i < 255 + x + 1; i++) { printf("0x%02x", rsexp[i % 255]); if (i == 255 + x) - puts(" \\\n}\n"); + puts("\n};\n"); else if (i % 8 == 7) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } @@ -350,15 +350,15 @@ static void rslog(void) fputs("\ /* --- Reed-Solomon matrix with log entries --- */\n\ \n\ -#define TWOFISH_RS { \\\n\ +const octet twofish_rs[32] = {\n\ ", stdout); for (i = 0; i < 32; i++) { printf("0x%02x", rslog[rs[i]]); if (i == 31) - puts(" \\\n}\n"); + puts("\n};"); else if (i % 8 == 7) - fputs(", \\\n ", stdout); + fputs(",\n ", stdout); else fputs(", ", stdout); } @@ -376,8 +376,7 @@ int main(void) * Twofish q tables [generated]\n\ */\n\ \n\ -#ifndef CATACOMB_TWOFISH_TAB_H\n\ -#define CATACOMB_TWOFISH_TAB_H\n\ +#include \n\ \n\ ", stdout); @@ -388,8 +387,8 @@ int main(void) "); mkq(&q0, &qt0, "qt0"); mkq(&q1, &qt1, "qt1"); - printq(&q0, "Q0"); - printq(&q1, "Q1"); + printq(&q0, "q0"); + printq(&q1, "q1"); /* --- The MDS/q tables --- */ @@ -398,8 +397,6 @@ int main(void) /* --- Done --- */ - puts("#endif"); - if (fclose(stdout)) { fprintf(stderr, "error writing data\n"); exit(EXIT_FAILURE);