diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/aesGladman/aes.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/aesGladman/aes.h | 274 |
1 files changed, 137 insertions, 137 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/aes.h b/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/aes.h index 127c886..5e4c596 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/aes.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/aesGladman/aes.h | |||
@@ -1,137 +1,137 @@ | |||
1 | /* | 1 | /* |
2 | --------------------------------------------------------------------------- | 2 | --------------------------------------------------------------------------- |
3 | Copyright (c) 2003, Dr Brian Gladman < >, Worcester, UK. | 3 | Copyright (c) 2003, Dr Brian Gladman < >, Worcester, UK. |
4 | All rights reserved. | 4 | All rights reserved. |
5 | 5 | ||
6 | LICENSE TERMS | 6 | LICENSE TERMS |
7 | 7 | ||
8 | The free distribution and use of this software in both source and binary | 8 | The free distribution and use of this software in both source and binary |
9 | form is allowed (with or without changes) provided that: | 9 | form is allowed (with or without changes) provided that: |
10 | 10 | ||
11 | 1. distributions of this source code include the above copyright | 11 | 1. distributions of this source code include the above copyright |
12 | notice, this list of conditions and the following disclaimer; | 12 | notice, this list of conditions and the following disclaimer; |
13 | 13 | ||
14 | 2. distributions in binary form include the above copyright | 14 | 2. distributions in binary form include the above copyright |
15 | notice, this list of conditions and the following disclaimer | 15 | notice, this list of conditions and the following disclaimer |
16 | in the documentation and/or other associated materials; | 16 | in the documentation and/or other associated materials; |
17 | 17 | ||
18 | 3. the copyright holder's name is not used to endorse products | 18 | 3. the copyright holder's name is not used to endorse products |
19 | built using this software without specific written permission. | 19 | built using this software without specific written permission. |
20 | 20 | ||
21 | ALTERNATIVELY, provided that this notice is retained in full, this product | 21 | ALTERNATIVELY, provided that this notice is retained in full, this product |
22 | may be distributed under the terms of the GNU General Public License (GPL), | 22 | may be distributed under the terms of the GNU General Public License (GPL), |
23 | in which case the provisions of the GPL apply INSTEAD OF those given above. | 23 | in which case the provisions of the GPL apply INSTEAD OF those given above. |
24 | 24 | ||
25 | DISCLAIMER | 25 | DISCLAIMER |
26 | 26 | ||
27 | This software is provided 'as is' with no explicit or implied warranties | 27 | This software is provided 'as is' with no explicit or implied warranties |
28 | in respect of its properties, including, but not limited to, correctness | 28 | in respect of its properties, including, but not limited to, correctness |
29 | and/or fitness for purpose. | 29 | and/or fitness for purpose. |
30 | --------------------------------------------------------------------------- | 30 | --------------------------------------------------------------------------- |
31 | Issue Date: 26/08/2003 | 31 | Issue Date: 26/08/2003 |
32 | 32 | ||
33 | This file contains the definitions required to use AES in C. See aesopt.h | 33 | This file contains the definitions required to use AES in C. See aesopt.h |
34 | for optimisation details. | 34 | for optimisation details. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #ifndef _AES_H | 37 | #ifndef _AES_H |
38 | #define _AES_H | 38 | #define _AES_H |
39 | 39 | ||
40 | #include "irrMath.h" | 40 | #include "irrMath.h" |
41 | 41 | ||
42 | #define AES_128 /* define if AES with 128 bit keys is needed */ | 42 | #define AES_128 /* define if AES with 128 bit keys is needed */ |
43 | #define AES_192 /* define if AES with 192 bit keys is needed */ | 43 | #define AES_192 /* define if AES with 192 bit keys is needed */ |
44 | #define AES_256 /* define if AES with 256 bit keys is needed */ | 44 | #define AES_256 /* define if AES with 256 bit keys is needed */ |
45 | #define AES_VAR /* define if a variable key size is needed */ | 45 | #define AES_VAR /* define if a variable key size is needed */ |
46 | 46 | ||
47 | /* The following must also be set in assembler files if being used */ | 47 | /* The following must also be set in assembler files if being used */ |
48 | 48 | ||
49 | #define AES_ENCRYPT /* if support for encryption is needed */ | 49 | #define AES_ENCRYPT /* if support for encryption is needed */ |
50 | #define AES_DECRYPT /* if support for decryption is needed */ | 50 | #define AES_DECRYPT /* if support for decryption is needed */ |
51 | #define AES_ERR_CHK /* for parameter checks & error return codes */ | 51 | #define AES_ERR_CHK /* for parameter checks & error return codes */ |
52 | 52 | ||
53 | typedef irr::u8 aes_08t; | 53 | typedef irr::u8 aes_08t; |
54 | typedef irr::u32 aes_32t; | 54 | typedef irr::u32 aes_32t; |
55 | 55 | ||
56 | #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ | 56 | #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ |
57 | #define N_COLS 4 /* the number of columns in the state */ | 57 | #define N_COLS 4 /* the number of columns in the state */ |
58 | 58 | ||
59 | /* a maximum of 60 32-bit words are needed for the key schedule */ | 59 | /* a maximum of 60 32-bit words are needed for the key schedule */ |
60 | #define KS_LENGTH 64 | 60 | #define KS_LENGTH 64 |
61 | 61 | ||
62 | #ifdef AES_ERR_CHK | 62 | #ifdef AES_ERR_CHK |
63 | #define aes_ret int | 63 | #define aes_ret int |
64 | #define aes_good 0 | 64 | #define aes_good 0 |
65 | #define aes_error -1 | 65 | #define aes_error -1 |
66 | #else | 66 | #else |
67 | #define aes_ret void | 67 | #define aes_ret void |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | #ifndef AES_DLL /* implement normal/DLL functions */ | 70 | #ifndef AES_DLL /* implement normal/DLL functions */ |
71 | #define aes_rval aes_ret | 71 | #define aes_rval aes_ret |
72 | #else | 72 | #else |
73 | #define aes_rval aes_ret __declspec(dllexport) _stdcall | 73 | #define aes_rval aes_ret __declspec(dllexport) _stdcall |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | /* This routine must be called before first use if non-static */ | 76 | /* This routine must be called before first use if non-static */ |
77 | /* tables are being used */ | 77 | /* tables are being used */ |
78 | 78 | ||
79 | void gen_tabs(void); | 79 | void gen_tabs(void); |
80 | 80 | ||
81 | /* The key length (klen) is input in bytes when it is in the range */ | 81 | /* The key length (klen) is input in bytes when it is in the range */ |
82 | /* 16 <= klen <= 32 or in bits when in the range 128 <= klen <= 256 */ | 82 | /* 16 <= klen <= 32 or in bits when in the range 128 <= klen <= 256 */ |
83 | 83 | ||
84 | #ifdef AES_ENCRYPT | 84 | #ifdef AES_ENCRYPT |
85 | 85 | ||
86 | typedef struct | 86 | typedef struct |
87 | { | 87 | { |
88 | aes_32t ks[KS_LENGTH]; | 88 | aes_32t ks[KS_LENGTH]; |
89 | } aes_encrypt_ctx; | 89 | } aes_encrypt_ctx; |
90 | 90 | ||
91 | #if defined(AES_128) || defined(AES_VAR) | 91 | #if defined(AES_128) || defined(AES_VAR) |
92 | aes_rval aes_encrypt_key128(const void *in_key, aes_encrypt_ctx cx[1]); | 92 | aes_rval aes_encrypt_key128(const void *in_key, aes_encrypt_ctx cx[1]); |
93 | #endif | 93 | #endif |
94 | 94 | ||
95 | #if defined(AES_192) || defined(AES_VAR) | 95 | #if defined(AES_192) || defined(AES_VAR) |
96 | aes_rval aes_encrypt_key192(const void *in_key, aes_encrypt_ctx cx[1]); | 96 | aes_rval aes_encrypt_key192(const void *in_key, aes_encrypt_ctx cx[1]); |
97 | #endif | 97 | #endif |
98 | 98 | ||
99 | #if defined(AES_256) || defined(AES_VAR) | 99 | #if defined(AES_256) || defined(AES_VAR) |
100 | aes_rval aes_encrypt_key256(const void *in_key, aes_encrypt_ctx cx[1]); | 100 | aes_rval aes_encrypt_key256(const void *in_key, aes_encrypt_ctx cx[1]); |
101 | #endif | 101 | #endif |
102 | 102 | ||
103 | #if defined(AES_VAR) | 103 | #if defined(AES_VAR) |
104 | aes_rval aes_encrypt_key(const void *in_key, int key_len, aes_encrypt_ctx cx[1]); | 104 | aes_rval aes_encrypt_key(const void *in_key, int key_len, aes_encrypt_ctx cx[1]); |
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | aes_rval aes_encrypt(const void *in_blk, void *out_blk, const aes_encrypt_ctx cx[1]); | 107 | aes_rval aes_encrypt(const void *in_blk, void *out_blk, const aes_encrypt_ctx cx[1]); |
108 | #endif | 108 | #endif |
109 | 109 | ||
110 | #ifdef AES_DECRYPT | 110 | #ifdef AES_DECRYPT |
111 | 111 | ||
112 | typedef struct | 112 | typedef struct |
113 | { | 113 | { |
114 | aes_32t ks[KS_LENGTH]; | 114 | aes_32t ks[KS_LENGTH]; |
115 | } aes_decrypt_ctx; | 115 | } aes_decrypt_ctx; |
116 | 116 | ||
117 | #if defined(AES_128) || defined(AES_VAR) | 117 | #if defined(AES_128) || defined(AES_VAR) |
118 | aes_rval aes_decrypt_key128(const void *in_key, aes_decrypt_ctx cx[1]); | 118 | aes_rval aes_decrypt_key128(const void *in_key, aes_decrypt_ctx cx[1]); |
119 | #endif | 119 | #endif |
120 | 120 | ||
121 | #if defined(AES_192) || defined(AES_VAR) | 121 | #if defined(AES_192) || defined(AES_VAR) |
122 | aes_rval aes_decrypt_key192(const void *in_key, aes_decrypt_ctx cx[1]); | 122 | aes_rval aes_decrypt_key192(const void *in_key, aes_decrypt_ctx cx[1]); |
123 | #endif | 123 | #endif |
124 | 124 | ||
125 | #if defined(AES_256) || defined(AES_VAR) | 125 | #if defined(AES_256) || defined(AES_VAR) |
126 | aes_rval aes_decrypt_key256(const void *in_key, aes_decrypt_ctx cx[1]); | 126 | aes_rval aes_decrypt_key256(const void *in_key, aes_decrypt_ctx cx[1]); |
127 | #endif | 127 | #endif |
128 | 128 | ||
129 | #if defined(AES_VAR) | 129 | #if defined(AES_VAR) |
130 | aes_rval aes_decrypt_key(const void *in_key, int key_len, aes_decrypt_ctx cx[1]); | 130 | aes_rval aes_decrypt_key(const void *in_key, int key_len, aes_decrypt_ctx cx[1]); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | aes_rval aes_decrypt(const void *in_blk, void *out_blk, const aes_decrypt_ctx cx[1]); | 133 | aes_rval aes_decrypt(const void *in_blk, void *out_blk, const aes_decrypt_ctx cx[1]); |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | #endif | 136 | #endif |
137 | 137 | ||