1*5458353dSdjm /* $OpenBSD: rijndael.h,v 1.13 2008/06/09 07:49:45 djm Exp $ */ 2b3f26ac6Smarkus 38875bbf2Smarkus /** 48875bbf2Smarkus * rijndael-alg-fst.h 58875bbf2Smarkus * 68875bbf2Smarkus * @version 3.0 (December 2000) 78875bbf2Smarkus * 88875bbf2Smarkus * Optimised ANSI C code for the Rijndael cipher (now AES) 98875bbf2Smarkus * 108875bbf2Smarkus * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> 118875bbf2Smarkus * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> 128875bbf2Smarkus * @author Paulo Barreto <paulo.barreto@terra.com.br> 138875bbf2Smarkus * 148875bbf2Smarkus * This code is hereby placed in the public domain. 158875bbf2Smarkus * 168875bbf2Smarkus * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS 178875bbf2Smarkus * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 188875bbf2Smarkus * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 198875bbf2Smarkus * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE 208875bbf2Smarkus * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 218875bbf2Smarkus * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 228875bbf2Smarkus * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 238875bbf2Smarkus * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 248875bbf2Smarkus * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 258875bbf2Smarkus * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 268875bbf2Smarkus * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2706ed33c6Sstevesk */ 288875bbf2Smarkus #ifndef __RIJNDAEL_H 298875bbf2Smarkus #define __RIJNDAEL_H 305df83cf4Sderaadt 31aed7ccbfStedu #define AES_MAXKEYBITS (256) 32aed7ccbfStedu #define AES_MAXKEYBYTES (AES_MAXKEYBITS/8) 33aed7ccbfStedu /* for 256-bit keys, fewer for less */ 34aed7ccbfStedu #define AES_MAXROUNDS 14 356b24b8a0Sprovos 368875bbf2Smarkus typedef unsigned char u8; 378875bbf2Smarkus typedef unsigned short u16; 388875bbf2Smarkus typedef unsigned int u32; 396b24b8a0Sprovos 408875bbf2Smarkus /* The structure for key information */ 418875bbf2Smarkus typedef struct { 425076b47dSmarkus int enc_only; /* context contains only encrypt schedule */ 438875bbf2Smarkus int Nr; /* key-length-dependent number of rounds */ 44aed7ccbfStedu u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */ 45aed7ccbfStedu u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */ 466b24b8a0Sprovos } rijndael_ctx; 476b24b8a0Sprovos 48*5458353dSdjm int rijndael_set_key(rijndael_ctx *, const u_char *, int); 49*5458353dSdjm int rijndael_set_key_enc_only(rijndael_ctx *, const u_char *, int); 50*5458353dSdjm void rijndael_decrypt(rijndael_ctx *, const u_char *, u_char *); 51*5458353dSdjm void rijndael_encrypt(rijndael_ctx *, const u_char *, u_char *); 526b24b8a0Sprovos 5312605d87Sderaadt int rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int); 5412605d87Sderaadt int rijndaelKeySetupDec(unsigned int [], const unsigned char [], int); 558264d0c5Smarkus void rijndaelEncrypt(const unsigned int [], int, const unsigned char [], 568264d0c5Smarkus unsigned char []); 5712605d87Sderaadt 588875bbf2Smarkus #endif /* __RIJNDAEL_H */ 59