3 Galois counter mode, specified by NIST,
4 http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf
6 Generation of fixed multiplication tables.
8 Copyright (C) 2011 Niels Möller
10 This file is part of GNU Nettle.
12 GNU Nettle is free software: you can redistribute it and/or
13 modify it under the terms of either:
15 * the GNU Lesser General Public License as published by the Free
16 Software Foundation; either version 3 of the License, or (at your
17 option) any later version.
21 * the GNU General Public License as published by the Free
22 Software Foundation; either version 2 of the License, or (at your
23 option) any later version.
25 or both in parallel, as here.
27 GNU Nettle is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 General Public License for more details.
32 You should have received copies of the GNU General Public License and
33 the GNU Lesser General Public License along with this program. If
34 not, see http://www.gnu.org/licenses/.
40 #define GHASH_POLYNOMIAL 0xE1
43 /* When x is shifted out over the block edge, add multiples of the
44 defining polynomial to eliminate each bit. */
48 unsigned p = GHASH_POLYNOMIAL << 1;
50 for (; x; x >>= 1, p <<= 1)
57 main(int argc, char **argv)
60 printf("4-bit table:\n");
62 for (i = 0; i<16; i++)
69 printf("W(%02x,%02x),", x >> 8, x & 0xff);
72 printf("8-bit table:\n");
73 for (i = 0; i<256; i++)
80 printf("W(%02x,%02x),", x >> 8, x & 0xff);