X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/3a65506d4df316377c9b838ef5954b5d856215ee..2685767a6125c1620719c7de6234aedf41857b7e:/rijndael-mktab.c diff --git a/rijndael-mktab.c b/rijndael-mktab.c index f5df965..f5a73b8 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.3 2000/10/14 17:13:19 mdw Exp $ * * Build precomputed tables for the Rijndael block cipher * @@ -30,6 +30,12 @@ /*----- Revision history --------------------------------------------------* * * $Log: rijndael-mktab.c,v $ + * Revision 1.3 2000/10/14 17:13:19 mdw + * Fix some compile errors. + * + * Revision 1.2 2000/06/18 23:12:15 mdw + * Change typesetting of Galois Field names. + * * Revision 1.1 2000/06/17 11:56:07 mdw * New cipher. * @@ -54,7 +60,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 +89,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 +221,7 @@ static void ubox(void) /* --- Round constants --- */ -void rcon(void) +static void rcon(void) { unsigned r = 1; int i; @@ -285,7 +291,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 +311,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 +336,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);