X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/7246869f7bf4069fd46eaa78fde65d0879dbfdcd..8b3d7f307a1f99d461898af5422a960cd8080e72:/rijndael-base.h diff --git a/rijndael-base.h b/rijndael-base.h new file mode 100644 index 0000000..1c17fdf --- /dev/null +++ b/rijndael-base.h @@ -0,0 +1,81 @@ +/* -*-c-*- + * + * $Id: rijndael-base.h,v 1.1 2001/05/07 17:31:37 mdw Exp $ + * + * Internal header for Rijndael implementation + * + * (c) 2001 Straylight/Edgeware + */ + +/*----- Licensing notice --------------------------------------------------* + * + * This file is part of Catacomb. + * + * Catacomb is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * Catacomb is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with Catacomb; if not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, + * MA 02111-1307, USA. + */ + +/*----- Revision history --------------------------------------------------* + * + * $Log: rijndael-base.h,v $ + * Revision 1.1 2001/05/07 17:31:37 mdw + * Centralize Rijndael tables and key scheduling. + * + */ + +#ifndef CATACOMB_RIJNDAEL_BASE_H +#define CATACOMB_RIJNDAEL_BASE_H + +#ifdef __cplusplus + extern "C" { +#endif + +/*----- Header files ------------------------------------------------------*/ + +#include + +/*----- Constant tables ---------------------------------------------------*/ + +extern const octet rijndael_s[256]; +extern const octet rijndael_si[256]; +extern const uint32 rijndael_t[4][256]; +extern const uint32 rijndael_ti[4][256]; +extern const uint32 rijndael_u[4][256]; +extern const octet rijndael_rcon[]; + +#define S rijndael_s +#define SI rijndael_si +#define T rijndael_t +#define TI rijndael_ti +#define U rijndael_u +#define RCON rijndael_rcon + +/*----- Handy macros ------------------------------------------------------*/ + +#define SUB(s, a, b, c, d) \ + (s[U8((a) >> 0)] << 0 | s[U8((b) >> 8)] << 8 | \ + s[U8((c) >> 16)] << 16 | s[U8((d) >> 24)] << 24) + +#define MIX(t, a, b, c, d) \ + (t[0][U8((a) >> 0)] ^ t[1][U8((b) >> 8)] ^ \ + t[2][U8((c) >> 16)] ^ t[3][U8((d) >> 24)]) + +/*----- That's all, folks -------------------------------------------------*/ + +#ifdef __cplusplus + } +#endif + +#endif