1*753c7e08SAugustin Cavalier /* $KAME: rijndael.h,v 1.6 2003/08/28 08:36:32 itojun Exp $ */ 2*753c7e08SAugustin Cavalier /* $FreeBSD$ */ 3*753c7e08SAugustin Cavalier 4*753c7e08SAugustin Cavalier /** 5*753c7e08SAugustin Cavalier * rijndael-alg-fst.h 6*753c7e08SAugustin Cavalier * 7*753c7e08SAugustin Cavalier * @version 3.0 (December 2000) 8*753c7e08SAugustin Cavalier * 9*753c7e08SAugustin Cavalier * Optimised ANSI C code for the Rijndael cipher (now AES) 10*753c7e08SAugustin Cavalier * 11*753c7e08SAugustin Cavalier * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> 12*753c7e08SAugustin Cavalier * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> 13*753c7e08SAugustin Cavalier * @author Paulo Barreto <paulo.barreto@terra.com.br> 14*753c7e08SAugustin Cavalier * 15*753c7e08SAugustin Cavalier * This code is hereby placed in the public domain. 16*753c7e08SAugustin Cavalier * 17*753c7e08SAugustin Cavalier * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 18*753c7e08SAugustin Cavalier * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19*753c7e08SAugustin Cavalier * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*753c7e08SAugustin Cavalier * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 21*753c7e08SAugustin Cavalier * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22*753c7e08SAugustin Cavalier * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23*753c7e08SAugustin Cavalier * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24*753c7e08SAugustin Cavalier * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25*753c7e08SAugustin Cavalier * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26*753c7e08SAugustin Cavalier * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27*753c7e08SAugustin Cavalier * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28*753c7e08SAugustin Cavalier */ 29*753c7e08SAugustin Cavalier 30*753c7e08SAugustin Cavalier #ifndef __RIJNDAEL_H 31*753c7e08SAugustin Cavalier #define __RIJNDAEL_H 32*753c7e08SAugustin Cavalier 33*753c7e08SAugustin Cavalier #define RIJNDAEL_MAXKC (256/32) 34*753c7e08SAugustin Cavalier #define RIJNDAEL_MAXKB (256/8) 35*753c7e08SAugustin Cavalier #define RIJNDAEL_MAXNR 14 36*753c7e08SAugustin Cavalier 37*753c7e08SAugustin Cavalier typedef struct { 38*753c7e08SAugustin Cavalier int decrypt; 39*753c7e08SAugustin Cavalier int Nr; /* key-length-dependent number of rounds */ 40*753c7e08SAugustin Cavalier uint32_t ek[4 * (RIJNDAEL_MAXNR + 1)]; /* encrypt key schedule */ 41*753c7e08SAugustin Cavalier uint32_t dk[4 * (RIJNDAEL_MAXNR + 1)]; /* decrypt key schedule */ 42*753c7e08SAugustin Cavalier } rijndael_ctx; 43*753c7e08SAugustin Cavalier 44*753c7e08SAugustin Cavalier void rijndael_set_key(rijndael_ctx *, const u_char *, int); 45*753c7e08SAugustin Cavalier void rijndael_decrypt(const rijndael_ctx *, const u_char *, u_char *); 46*753c7e08SAugustin Cavalier void rijndael_encrypt(const rijndael_ctx *, const u_char *, u_char *); 47*753c7e08SAugustin Cavalier 48*753c7e08SAugustin Cavalier int rijndaelKeySetupEnc(u_int32_t [/*4*(Nr+1)*/], const u_int8_t [], int); 49*753c7e08SAugustin Cavalier int rijndaelKeySetupDec(u_int32_t [/*4*(Nr+1)*/], const u_int8_t [], int); 50*753c7e08SAugustin Cavalier void rijndaelEncrypt(const u_int32_t [/*4*(Nr+1)*/], int, 51*753c7e08SAugustin Cavalier const u_int8_t[16], u_int8_t [16]); 52*753c7e08SAugustin Cavalier void rijndaelDecrypt(const u_int32_t [/*4*(Nr+1)*/], int, 53*753c7e08SAugustin Cavalier const u_int8_t [16], u_int8_t [16]); 54*753c7e08SAugustin Cavalier 55*753c7e08SAugustin Cavalier #endif /* __RIJNDAEL_H */ 56