3 * Internal header for Rijndael implementation
5 * (c) 2001 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of Catacomb.
12 * Catacomb is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * Catacomb is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with Catacomb; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 #ifndef CATACOMB_RIJNDAEL_BASE_H
29 #define CATACOMB_RIJNDAEL_BASE_H
35 /*----- Header files ------------------------------------------------------*/
37 #include <mLib/bits.h>
39 /*----- Constant tables ---------------------------------------------------*/
41 extern const octet rijndael_s[256];
42 extern const octet rijndael_si[256];
43 extern const uint32 rijndael_t[4][256];
44 extern const uint32 rijndael_ti[4][256];
45 extern const uint32 rijndael_u[4][256];
46 extern const octet rijndael_rcon[];
49 #define SI rijndael_si
51 #define TI rijndael_ti
53 #define RCON rijndael_rcon
55 /*----- Handy macros ------------------------------------------------------*/
57 #define SUB(s, a, b, c, d) \
58 (s[U8((a) >> 24)] << 24 | s[U8((b) >> 16)] << 16 | \
59 s[U8((c) >> 8)] << 8 | s[U8((d) >> 0)] << 0)
61 #define MIX(t, a, b, c, d) \
62 (t[0][U8((a) >> 24)] ^ t[1][U8((b) >> 16)] ^ \
63 t[2][U8((c) >> 8)] ^ t[3][U8((d) >> 0)])
65 /*----- That's all, folks -------------------------------------------------*/