3 * $Id: rijndael-base.h,v 1.2 2004/04/08 01:36:15 mdw Exp $
5 * Internal header for Rijndael implementation
7 * (c) 2001 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of Catacomb.
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.
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.
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,
30 #ifndef CATACOMB_RIJNDAEL_BASE_H
31 #define CATACOMB_RIJNDAEL_BASE_H
37 /*----- Header files ------------------------------------------------------*/
39 #include <mLib/bits.h>
41 /*----- Constant tables ---------------------------------------------------*/
43 extern const octet rijndael_s[256];
44 extern const octet rijndael_si[256];
45 extern const uint32 rijndael_t[4][256];
46 extern const uint32 rijndael_ti[4][256];
47 extern const uint32 rijndael_u[4][256];
48 extern const octet rijndael_rcon[];
51 #define SI rijndael_si
53 #define TI rijndael_ti
55 #define RCON rijndael_rcon
57 /*----- Handy macros ------------------------------------------------------*/
59 #define SUB(s, a, b, c, d) \
60 (s[U8((a) >> 24)] << 24 | s[U8((b) >> 16)] << 16 | \
61 s[U8((c) >> 8)] << 8 | s[U8((d) >> 0)] << 0)
63 #define MIX(t, a, b, c, d) \
64 (t[0][U8((a) >> 24)] ^ t[1][U8((b) >> 16)] ^ \
65 t[2][U8((c) >> 8)] ^ t[3][U8((d) >> 0)])
67 /*----- That's all, folks -------------------------------------------------*/