3 * $Id: rijndael-base.h,v 1.1 2001/05/07 17:31:37 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 /*----- Revision history --------------------------------------------------*
32 * $Log: rijndael-base.h,v $
33 * Revision 1.1 2001/05/07 17:31:37 mdw
34 * Centralize Rijndael tables and key scheduling.
38 #ifndef CATACOMB_RIJNDAEL_BASE_H
39 #define CATACOMB_RIJNDAEL_BASE_H
45 /*----- Header files ------------------------------------------------------*/
47 #include <mLib/bits.h>
49 /*----- Constant tables ---------------------------------------------------*/
51 extern const octet rijndael_s
[256];
52 extern const octet rijndael_si
[256];
53 extern const uint32 rijndael_t
[4][256];
54 extern const uint32 rijndael_ti
[4][256];
55 extern const uint32 rijndael_u
[4][256];
56 extern const octet rijndael_rcon
[];
59 #define SI rijndael_si
61 #define TI rijndael_ti
63 #define RCON rijndael_rcon
65 /*----- Handy macros ------------------------------------------------------*/
67 #define SUB(s, a, b, c, d) \
68 (s[U8((a) >> 0)] << 0 | s[U8((b) >> 8)] << 8 | \
69 s[U8((c) >> 16)] << 16 | s[U8((d) >> 24)] << 24)
71 #define MIX(t, a, b, c, d) \
72 (t[0][U8((a) >> 0)] ^ t[1][U8((b) >> 8)] ^ \
73 t[2][U8((c) >> 16)] ^ t[3][U8((d) >> 24)])
75 /*----- That's all, folks -------------------------------------------------*/