3 * $Id: rijndael.h,v 1.2 2000/10/08 15:48:58 mdw Exp $
5 * The Rijndael block cipher
7 * (c) 2000 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.h,v $
33 * Revision 1.2 2000/10/08 15:48:58 mdw
34 * Update comments now that AES has been chosen.
36 * Revision 1.1 2000/06/17 11:56:07 mdw
41 /*----- Notes on the Rijndael block cipher --------------------------------*
43 * Invented by Joan Daemen and Vincent Rijmen, Rijndael is a fast, elegant
44 * and relatively simple 128-bit block cipher. It was chosen by NIST to be
45 * the new Advanced Encryption Standard (AES) algorithm.
47 * Rijnadel appears to have a low security margin. I recommend waiting
48 * before using Rijndael for any sensitive applications.
51 #ifndef CATACOMB_RIJNDAEL_H
52 #define CATACOMB_RIJNDAEL_H
58 /*----- Header files ------------------------------------------------------*/
62 #include <mLib/bits.h>
64 /*----- Magical numbers ---------------------------------------------------*/
66 #define RIJNDAEL_BLKSZ 16
67 #define RIJNDAEL_KEYSZ 32
68 #define RIJNDAEL_CLASS (N, L, 128)
70 extern const octet rijndael_keysz
[];
72 /*----- Data structures ---------------------------------------------------*/
74 #define RIJNDAEL_MAXROUNDS 32
75 #define RIJNDAEL_KWORDS ((RIJNDAEL_MAXROUNDS + 1) * (RIJNDAEL_BLKSZ / 4))
77 typedef struct rijndael_ctx
{
79 uint32 w
[RIJNDAEL_KWORDS
];
80 uint32 wi
[RIJNDAEL_KWORDS
];
83 /*----- Functions provided ------------------------------------------------*/
85 /* --- @rijndael_init@ --- *
87 * Arguments: @rijndael_ctx *k@ = pointer to context to initialize
88 * @const void *buf@ = pointer to buffer of key material
89 * @size_t sz@ = size of the key material
93 * Use: Initializes a Rijndael context with a particular key. This
94 * implementation of Rijndael doesn't impose any particular
95 * limits on the key size except that it must be multiple of 4
96 * bytes long. 256 bits seems sensible, though.
99 extern void rijndael_init(rijndael_ctx */
*k*/
,
100 const void */
*buf*/
, size_t /*sz*/);
102 /* --- @rijndael_eblk@, @rijndael_dblk@ --- *
104 * Arguments: @const rijndael_ctx *k@ = pointer to Rijndael context
105 * @const uint32 s[4]@ = pointer to source block
106 * @uint32 d[4]@ = pointer to destination block
110 * Use: Low-level block encryption and decryption.
113 extern void rijndael_eblk(const rijndael_ctx */
*k*/
,
114 const uint32 */
*s*/
, uint32 */
*dst*/
);
115 extern void rijndael_dblk(const rijndael_ctx */
*k*/
,
116 const uint32 */
*s*/
, uint32 */
*dst*/
);
118 /*----- That's all, folks -------------------------------------------------*/