diff options
Diffstat (limited to 'rijndael.h')
-rw-r--r-- | rijndael.h | 106 |
1 files changed, 46 insertions, 60 deletions
diff --git a/rijndael.h b/rijndael.h index db33805ec..242bf9a66 100644 --- a/rijndael.h +++ b/rijndael.h | |||
@@ -1,63 +1,49 @@ | |||
1 | /* $OpenBSD: rijndael.h,v 1.9 2001/07/30 16:23:30 stevesk Exp $ */ | 1 | /** |
2 | 2 | * rijndael-alg-fst.h | |
3 | /* This is an independent implementation of the encryption algorithm: */ | 3 | * |
4 | /* */ | 4 | * @version 3.0 (December 2000) |
5 | /* RIJNDAEL by Joan Daemen and Vincent Rijmen */ | 5 | * |
6 | /* */ | 6 | * Optimised ANSI C code for the Rijndael cipher (now AES) |
7 | /* which is a candidate algorithm in the Advanced Encryption Standard */ | 7 | * |
8 | /* programme of the US National Institute of Standards and Technology. */ | 8 | * @author Vincent Rijmen <vincent.rijmen@esat.kuleuven.ac.be> |
9 | 9 | * @author Antoon Bosselaers <antoon.bosselaers@esat.kuleuven.ac.be> | |
10 | /* | 10 | * @author Paulo Barreto <paulo.barreto@terra.com.br> |
11 | ----------------------------------------------------------------------- | 11 | * |
12 | Copyright (c) 2001 Dr Brian Gladman <brg@gladman.uk.net>, Worcester, UK | 12 | * This code is hereby placed in the public domain. |
13 | 13 | * | |
14 | TERMS | 14 | * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS |
15 | 15 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
16 | Redistribution and use in source and binary forms, with or without | 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
17 | modification, are permitted provided that the following conditions | 17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE |
18 | are met: | 18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
19 | 1. Redistributions of source code must retain the above copyright | 19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
20 | notice, this list of conditions and the following disclaimer. | 20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
21 | 2. Redistributions in binary form must reproduce the above copyright | 21 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
22 | notice, this list of conditions and the following disclaimer in the | 22 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
23 | documentation and/or other materials provided with the distribution. | 23 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
24 | 24 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
25 | This software is provided 'as is' with no guarantees of correctness or | 25 | */ |
26 | fitness for purpose. | 26 | #ifndef __RIJNDAEL_H |
27 | ----------------------------------------------------------------------- | 27 | #define __RIJNDAEL_H |
28 | */ | 28 | |
29 | 29 | #define MAXKC (256/32) | |
30 | #ifndef _RIJNDAEL_H_ | 30 | #define MAXKB (256/8) |
31 | #define _RIJNDAEL_H_ | 31 | #define MAXNR 14 |
32 | 32 | ||
33 | #include "config.h" | 33 | typedef unsigned char u8; |
34 | 34 | typedef unsigned short u16; | |
35 | /* 1. Standard types for AES cryptography source code */ | 35 | typedef unsigned int u32; |
36 | 36 | ||
37 | typedef u_int8_t u1byte; /* an 8 bit unsigned character type */ | 37 | /* The structure for key information */ |
38 | typedef u_int16_t u2byte; /* a 16 bit unsigned integer type */ | 38 | typedef struct { |
39 | typedef u_int32_t u4byte; /* a 32 bit unsigned integer type */ | 39 | int decrypt; |
40 | 40 | int Nr; /* key-length-dependent number of rounds */ | |
41 | typedef int8_t s1byte; /* an 8 bit signed character type */ | 41 | u32 ek[4*(MAXNR + 1)]; /* encrypt key schedule */ |
42 | typedef int16_t s2byte; /* a 16 bit signed integer type */ | 42 | u32 dk[4*(MAXNR + 1)]; /* decrypt key schedule */ |
43 | typedef int32_t s4byte; /* a 32 bit signed integer type */ | ||
44 | |||
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; | 43 | } rijndael_ctx; |
51 | 44 | ||
45 | void rijndael_set_key(rijndael_ctx *, u_char *, int, int); | ||
46 | void rijndael_decrypt(rijndael_ctx *, u_char *, u_char *); | ||
47 | void rijndael_encrypt(rijndael_ctx *, u_char *, u_char *); | ||
52 | 48 | ||
53 | /* 2. Standard interface for AES cryptographic routines */ | 49 | #endif /* __RIJNDAEL_H */ |
54 | |||
55 | /* These are all based on 32 bit unsigned values and will therefore */ | ||
56 | /* require endian conversions for big-endian architectures */ | ||
57 | |||
58 | rijndael_ctx * | ||
59 | rijndael_set_key __P((rijndael_ctx *, const u4byte *, const u4byte, int)); | ||
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_ */ | ||