X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/3a65506d4df316377c9b838ef5954b5d856215ee..578a86d91941a0f722b87973d88e84ec2cf9a608:/rijndael-mktab.c diff --git a/rijndael-mktab.c b/rijndael-mktab.c index f5df965..4360f20 100644 --- a/rijndael-mktab.c +++ b/rijndael-mktab.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: rijndael-mktab.c,v 1.1 2000/06/17 11:56:07 mdw Exp $ + * $Id: rijndael-mktab.c,v 1.4 2004/04/08 01:36:15 mdw Exp $ * * Build precomputed tables for the Rijndael block cipher * @@ -27,14 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: rijndael-mktab.c,v $ - * Revision 1.1 2000/06/17 11:56:07 mdw - * New cipher. - * - */ - /*----- Header files ------------------------------------------------------*/ #include @@ -54,7 +46,7 @@ static octet rc[32]; /* --- @mul@ --- * * - * Arguments: @unsigned x, y@ = polynomials over %$\mathrm{GF}(2^8)$% + * Arguments: @unsigned x, y@ = polynomials over %$\gf{2^8}$% * @unsigned m@ = modulus * * Returns: The product of two polynomials. @@ -83,10 +75,10 @@ static unsigned mul(unsigned x, unsigned y, unsigned m) * * Build the S-box. * - * This is built from multiplicative inversion in the group - * %$\mathrm{GF}(2^8)[x]/p(x)$%, where %$p(x) = x^8 + x^4 + x^3 + x + 1$%, - * followed by an affine transformation treating inputs as vectors over - * %$\mathrm{GF}(2)$%. The result is a horrible function. + * This is built from inversion in the multiplicative group of + * %$\gf{2^8}[x]/(p(x))$%, where %$p(x) = x^8 + x^4 + x^3 + x + 1$%, followed + * by an affine transformation treating inputs as vectors over %$\gf{2}$%. + * The result is a horrible function. * * The inversion is done slightly sneakily, by building log and antilog * tables. Let %$a$% be an element of the finite field. If the inverse of @@ -215,7 +207,7 @@ static void ubox(void) /* --- Round constants --- */ -void rcon(void) +static void rcon(void) { unsigned r = 1; int i; @@ -285,7 +277,7 @@ int main(void) { ", stdout); for (j = 0; j < 4; j++) { for (i = 0; i < 256; i++) { - printf("0x%08x", t[j][i]); + printf("0x%08lx", (unsigned long)t[j][i]); if (i == 255) { if (j == 3) fputs(" } \\\n}\n\n", stdout); @@ -305,7 +297,7 @@ int main(void) { ", stdout); for (j = 0; j < 4; j++) { for (i = 0; i < 256; i++) { - printf("0x%08x", ti[j][i]); + printf("0x%08lx", (unsigned long)ti[j][i]); if (i == 255) { if (j == 3) fputs(" } \\\n}\n\n", stdout); @@ -330,7 +322,7 @@ int main(void) { ", stdout); for (j = 0; j < 4; j++) { for (i = 0; i < 256; i++) { - printf("0x%08x", u[j][i]); + printf("0x%08lx", (unsigned long)u[j][i]); if (i == 255) { if (j == 3) fputs(" } \\\n}\n\n", stdout);