Damien Miller | ec0b67e | 2014-05-15 13:45:26 +1000 | [diff] [blame] | 1 | /* $OpenBSD: rijndael.h,v 1.14 2014/04/29 15:42:07 markus Exp $ */ |
Ben Lindstrom | d5e1c04 | 2001-09-14 23:09:29 +0000 | [diff] [blame] | 2 | |
Ben Lindstrom | 319fc73 | 2001-09-14 02:47:33 +0000 | [diff] [blame] | 3 | /** |
| 4 | * rijndael-alg-fst.h |
| 5 | * |
| 6 | * @version 3.0 (December 2000) |
| 7 | * |
| 8 | * Optimised ANSI C code for the Rijndael cipher (now AES) |
| 9 | * |
| 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> |
| 13 | * |
| 14 | * This code is hereby placed in the public domain. |
| 15 | * |
| 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. |
| 27 | */ |
Damien Miller | ec0b67e | 2014-05-15 13:45:26 +1000 | [diff] [blame] | 28 | #ifndef _PRIVATE_RIJNDAEL_H |
| 29 | #define _PRIVATE_RIJNDAEL_H |
Ben Lindstrom | b22c2b8 | 2001-03-05 06:50:47 +0000 | [diff] [blame] | 30 | |
Damien Miller | ec0b67e | 2014-05-15 13:45:26 +1000 | [diff] [blame] | 31 | #define AES_MAXKEYBITS (256) |
| 32 | #define AES_MAXKEYBYTES (AES_MAXKEYBITS/8) |
| 33 | /* for 256-bit keys, fewer for less */ |
| 34 | #define AES_MAXROUNDS 14 |
Ben Lindstrom | 0256e8b | 2001-08-06 21:24:11 +0000 | [diff] [blame] | 35 | |
Damien Miller | 9f0f5c6 | 2001-12-21 14:45:46 +1100 | [diff] [blame] | 36 | typedef unsigned char u8; |
| 37 | typedef unsigned short u16; |
Ben Lindstrom | 319fc73 | 2001-09-14 02:47:33 +0000 | [diff] [blame] | 38 | typedef unsigned int u32; |
Ben Lindstrom | 0256e8b | 2001-08-06 21:24:11 +0000 | [diff] [blame] | 39 | |
Damien Miller | ec0b67e | 2014-05-15 13:45:26 +1000 | [diff] [blame] | 40 | int rijndaelKeySetupEnc(unsigned int [], const unsigned char [], int); |
| 41 | void rijndaelEncrypt(const unsigned int [], int, const unsigned char [], |
| 42 | unsigned char []); |
| 43 | |
Ben Lindstrom | 319fc73 | 2001-09-14 02:47:33 +0000 | [diff] [blame] | 44 | /* The structure for key information */ |
| 45 | typedef struct { |
| 46 | int decrypt; |
Damien Miller | ec0b67e | 2014-05-15 13:45:26 +1000 | [diff] [blame] | 47 | int Nr; /* key-length-dependent number of rounds */ |
| 48 | u32 ek[4*(AES_MAXROUNDS + 1)]; /* encrypt key schedule */ |
| 49 | u32 dk[4*(AES_MAXROUNDS + 1)]; /* decrypt key schedule */ |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 50 | } rijndael_ctx; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 51 | |
Ben Lindstrom | 319fc73 | 2001-09-14 02:47:33 +0000 | [diff] [blame] | 52 | void rijndael_set_key(rijndael_ctx *, u_char *, int, int); |
| 53 | void rijndael_decrypt(rijndael_ctx *, u_char *, u_char *); |
| 54 | void rijndael_encrypt(rijndael_ctx *, u_char *, u_char *); |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 55 | |
Damien Miller | ec0b67e | 2014-05-15 13:45:26 +1000 | [diff] [blame] | 56 | #endif /* _PRIVATE_RIJNDAEL_H */ |