.links: Drop obsolete `lib-config.in' file.
[u/mdw/catacomb] / rijndael-base.h
CommitLineData
8b3d7f30 1/* -*-c-*-
2 *
b817bfc6 3 * $Id: rijndael-base.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
8b3d7f30 4 *
5 * Internal header for Rijndael implementation
6 *
7 * (c) 2001 Straylight/Edgeware
8 */
9
45c0fd36 10/*----- Licensing notice --------------------------------------------------*
8b3d7f30 11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
45c0fd36 18 *
8b3d7f30 19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
45c0fd36 23 *
8b3d7f30 24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
8b3d7f30 30#ifndef CATACOMB_RIJNDAEL_BASE_H
31#define CATACOMB_RIJNDAEL_BASE_H
32
33#ifdef __cplusplus
34 extern "C" {
35#endif
36
37/*----- Header files ------------------------------------------------------*/
38
39#include <mLib/bits.h>
40
41/*----- Constant tables ---------------------------------------------------*/
42
43extern const octet rijndael_s[256];
44extern const octet rijndael_si[256];
45extern const uint32 rijndael_t[4][256];
46extern const uint32 rijndael_ti[4][256];
47extern const uint32 rijndael_u[4][256];
48extern const octet rijndael_rcon[];
49
50#define S rijndael_s
51#define SI rijndael_si
52#define T rijndael_t
53#define TI rijndael_ti
54#define U rijndael_u
55#define RCON rijndael_rcon
56
57/*----- Handy macros ------------------------------------------------------*/
58
59#define SUB(s, a, b, c, d) \
38333dc2 60 (s[U8((a) >> 24)] << 24 | s[U8((b) >> 16)] << 16 | \
45c0fd36 61 s[U8((c) >> 8)] << 8 | s[U8((d) >> 0)] << 0)
8b3d7f30 62
63#define MIX(t, a, b, c, d) \
38333dc2
MW
64 (t[0][U8((a) >> 24)] ^ t[1][U8((b) >> 16)] ^ \
65 t[2][U8((c) >> 8)] ^ t[3][U8((d) >> 0)])
8b3d7f30 66
67/*----- That's all, folks -------------------------------------------------*/
68
69#ifdef __cplusplus
70 }
71#endif
72
73#endif