Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / nettle / gcmdata.c
blobd431e03a15ef1d9ed65cbccdcaea7a5627570647
1 /* gcmdata.c
3 * Galois counter mode, specified by NIST,
4 * http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf
6 */
8 /* Generation of fixed multiplication tables. */
10 /* nettle, low-level cryptographics library
12 * Copyright (C) 2011 Niels Möller
14 * The nettle library is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published by
16 * the Free Software Foundation; either version 2.1 of the License, or (at your
17 * option) any later version.
19 * The nettle library is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
22 * License for more details.
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with the nettle library; see the file COPYING.LIB. If not, write to
26 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 * MA 02111-1301, USA.
30 #include <stdio.h>
31 #include <stdlib.h>
33 #define GHASH_POLYNOMIAL 0xE1
36 /* When x is shifted out over the block edge, add multiples of the
37 defining polynomial to eliminate each bit. */
38 static unsigned
39 reduce(unsigned x)
41 unsigned p = GHASH_POLYNOMIAL << 1;
42 unsigned y = 0;
43 for (; x; x >>= 1, p <<= 1)
44 if (x & 1)
45 y ^= p;
46 return y;
49 int
50 main(int argc, char **argv)
52 unsigned i;
53 printf("4-bit table:\n");
55 for (i = 0; i<16; i++)
57 unsigned x;
58 if (i && !(i%8))
59 printf("\n");
61 x = reduce(i << 4);
62 printf("W(%02x,%02x),", x >> 8, x & 0xff);
64 printf("\n\n");
65 printf("8-bit table:\n");
66 for (i = 0; i<256; i++)
68 unsigned x;
69 if (i && !(i%8))
70 printf("\n");
72 x = reduce(i);
73 printf("W(%02x,%02x),", x >> 8, x & 0xff);
75 printf("\n");
76 return EXIT_SUCCESS;