Ben Lindstrom | 0256e8b | 2001-08-06 21:24:11 +0000 | [diff] [blame] | 1 | /* $OpenBSD: rijndael.h,v 1.9 2001/07/30 16:23:30 stevesk Exp $ */ |
Ben Lindstrom | b22c2b8 | 2001-03-05 06:50:47 +0000 | [diff] [blame] | 2 | |
| 3 | /* This is an independent implementation of the encryption algorithm: */ |
| 4 | /* */ |
| 5 | /* RIJNDAEL by Joan Daemen and Vincent Rijmen */ |
| 6 | /* */ |
| 7 | /* which is a candidate algorithm in the Advanced Encryption Standard */ |
| 8 | /* programme of the US National Institute of Standards and Technology. */ |
Ben Lindstrom | 0256e8b | 2001-08-06 21:24:11 +0000 | [diff] [blame] | 9 | |
| 10 | /* |
| 11 | ----------------------------------------------------------------------- |
| 12 | Copyright (c) 2001 Dr Brian Gladman <brg@gladman.uk.net>, Worcester, UK |
| 13 | |
| 14 | TERMS |
| 15 | |
| 16 | Redistribution and use in source and binary forms, with or without |
| 17 | modification, are permitted provided that the following conditions |
| 18 | are met: |
| 19 | 1. Redistributions of source code must retain the above copyright |
| 20 | notice, this list of conditions and the following disclaimer. |
| 21 | 2. Redistributions in binary form must reproduce the above copyright |
| 22 | notice, this list of conditions and the following disclaimer in the |
| 23 | documentation and/or other materials provided with the distribution. |
| 24 | |
| 25 | This software is provided 'as is' with no guarantees of correctness or |
| 26 | fitness for purpose. |
| 27 | ----------------------------------------------------------------------- |
| 28 | */ |
Ben Lindstrom | 36579d3 | 2001-01-29 07:39:26 +0000 | [diff] [blame] | 29 | |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 30 | #ifndef _RIJNDAEL_H_ |
| 31 | #define _RIJNDAEL_H_ |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 32 | |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 33 | #include "config.h" |
Damien Miller | 5993935 | 2000-10-15 12:21:32 +1100 | [diff] [blame] | 34 | |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 35 | /* 1. Standard types for AES cryptography source code */ |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 36 | |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 37 | typedef u_int8_t u1byte; /* an 8 bit unsigned character type */ |
| 38 | typedef u_int16_t u2byte; /* a 16 bit unsigned integer type */ |
| 39 | typedef u_int32_t u4byte; /* a 32 bit unsigned integer type */ |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 40 | |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 41 | typedef int8_t s1byte; /* an 8 bit signed character type */ |
| 42 | typedef int16_t s2byte; /* a 16 bit signed integer type */ |
| 43 | typedef int32_t s4byte; /* a 32 bit signed integer type */ |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 44 | |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 45 | typedef struct _rijndael_ctx { |
| 46 | u4byte k_len; |
| 47 | int decrypt; |
| 48 | u4byte e_key[64]; |
| 49 | u4byte d_key[64]; |
| 50 | } rijndael_ctx; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 51 | |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 52 | |
| 53 | /* 2. Standard interface for AES cryptographic routines */ |
| 54 | |
| 55 | /* These are all based on 32 bit unsigned values and will therefore */ |
| 56 | /* require endian conversions for big-endian architectures */ |
| 57 | |
Ben Lindstrom | ddb4f24 | 2001-05-10 23:26:11 +0000 | [diff] [blame] | 58 | rijndael_ctx * |
| 59 | rijndael_set_key __P((rijndael_ctx *, const u4byte *, const u4byte, int)); |
Ben Lindstrom | fa1b3d0 | 2000-12-10 01:55:37 +0000 | [diff] [blame] | 60 | void rijndael_encrypt __P((rijndael_ctx *, const u4byte *, u4byte *)); |
| 61 | void rijndael_decrypt __P((rijndael_ctx *, const u4byte *, u4byte *)); |
| 62 | |
| 63 | #endif /* _RIJNDAEL_H_ */ |