1 /* $OpenBSD: rijndael.h,v 1.13 2008/06/09 07:49:45 djm Exp $ */
6 * @version 3.0 (December 2000)
8 * Optimised ANSI C code for the Rijndael cipher (now AES)
10 * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be>
11 * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be>
12 * @author Paulo Barreto <paulo.barreto@terra.com.br>
14 * This code is hereby placed in the public domain.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
17 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #define WITH_AES_DECRYPT 1
34 #define AES_MAXKEYBITS (256)
35 #define AES_MAXKEYBYTES (AES_MAXKEYBITS>>3)
36 /* for 256-bit keys we need 14 rounds for a 128 we only need 10 round */
37 #define AES_MAXROUNDS 14
39 /* bergmann: to avoid conflicts with typedefs from certain Contiki platforms,
40 * the following type names have been prefixed with "aes_": */
41 typedef unsigned char u_char;
42 typedef uint8_t aes_u8;
43 typedef uint16_t aes_u16;
44 typedef uint32_t aes_u32;
46 /* The structure for key information */
48 #ifdef WITH_AES_DECRYPT
49 int enc_only; /* context contains only encrypt schedule */
51 int Nr; /* key-length-dependent number of rounds */
52 aes_u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */
53 #ifdef WITH_AES_DECRYPT
54 aes_u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */
58 int rijndael_set_key(rijndael_ctx *, const u_char *, int);
59 int rijndael_set_key_enc_only(rijndael_ctx *, const u_char *, int);
60 void rijndael_decrypt(rijndael_ctx *, const u_char *, u_char *);
61 void rijndael_encrypt(rijndael_ctx *, const u_char *, u_char *);
63 int rijndaelKeySetupEnc(aes_u32 rk[/*4*(Nr + 1)*/], const aes_u8 cipherKey[], int keyBits);
64 int rijndaelKeySetupDec(aes_u32 rk[/*4*(Nr + 1)*/], const aes_u8 cipherKey[], int keyBits);
65 void rijndaelEncrypt(const aes_u32 rk[/*4*(Nr + 1)*/], int Nr, const aes_u8 pt[16], aes_u8 ct[16]);
67 #endif /* __RIJNDAEL_H */