Mercurial > dropbear
comparison src/headers/tomcrypt_custom.h @ 380:d5faf4814ddb libtomcrypt-orig libtomcrypt-1.16
Update to LibTomCrypt 1.16
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 11 Jan 2007 02:22:00 +0000 |
parents | 59400faa4b44 |
children | 999a5eb4ed10 |
comparison
equal
deleted
inserted
replaced
280:59400faa4b44 | 380:d5faf4814ddb |
---|---|
1 #ifndef TOMCRYPT_CUSTOM_H_ | 1 #ifndef TOMCRYPT_CUSTOM_H_ |
2 #define TOMCRYPT_CUSTOM_H_ | 2 #define TOMCRYPT_CUSTOM_H_ |
3 | 3 |
4 /* macros for various libc functions you can change for embedded targets */ | 4 /* macros for various libc functions you can change for embedded targets */ |
5 #ifndef XMALLOC | |
6 #ifdef malloc | |
7 #define LTC_NO_PROTOTYPES | |
8 #endif | |
5 #define XMALLOC malloc | 9 #define XMALLOC malloc |
10 #endif | |
11 #ifndef XREALLOC | |
12 #ifdef realloc | |
13 #define LTC_NO_PROTOTYPES | |
14 #endif | |
6 #define XREALLOC realloc | 15 #define XREALLOC realloc |
16 #endif | |
17 #ifndef XCALLOC | |
18 #ifdef calloc | |
19 #define LTC_NO_PROTOTYPES | |
20 #endif | |
7 #define XCALLOC calloc | 21 #define XCALLOC calloc |
22 #endif | |
23 #ifndef XFREE | |
24 #ifdef free | |
25 #define LTC_NO_PROTOTYPES | |
26 #endif | |
8 #define XFREE free | 27 #define XFREE free |
9 | 28 #endif |
29 | |
30 #ifndef XMEMSET | |
31 #ifdef memset | |
32 #define LTC_NO_PROTOTYPES | |
33 #endif | |
10 #define XMEMSET memset | 34 #define XMEMSET memset |
35 #endif | |
36 #ifndef XMEMCPY | |
37 #ifdef memcpy | |
38 #define LTC_NO_PROTOTYPES | |
39 #endif | |
11 #define XMEMCPY memcpy | 40 #define XMEMCPY memcpy |
12 | 41 #endif |
42 #ifndef XMEMCMP | |
43 #ifdef memcmp | |
44 #define LTC_NO_PROTOTYPES | |
45 #endif | |
46 #define XMEMCMP memcmp | |
47 #endif | |
48 #ifndef XSTRCMP | |
49 #ifdef strcmp | |
50 #define LTC_NO_PROTOTYPES | |
51 #endif | |
52 #define XSTRCMP strcmp | |
53 #endif | |
54 | |
55 #ifndef XCLOCK | |
13 #define XCLOCK clock | 56 #define XCLOCK clock |
57 #endif | |
58 #ifndef XCLOCKS_PER_SEC | |
14 #define XCLOCKS_PER_SEC CLOCKS_PER_SEC | 59 #define XCLOCKS_PER_SEC CLOCKS_PER_SEC |
60 #endif | |
61 | |
62 #ifndef XQSORT | |
63 #ifdef qsort | |
64 #define LTC_NO_PROTOTYPES | |
65 #endif | |
66 #define XQSORT qsort | |
67 #endif | |
68 | |
69 /* Easy button? */ | |
70 #ifdef LTC_EASY | |
71 #define LTC_NO_CIPHERS | |
72 #define RIJNDAEL | |
73 #define BLOWFISH | |
74 #define DES | |
75 #define CAST5 | |
76 | |
77 #define LTC_NO_MODES | |
78 #define LTC_ECB_MODE | |
79 #define LTC_CBC_MODE | |
80 #define LTC_CTR_MODE | |
81 | |
82 #define LTC_NO_HASHES | |
83 #define SHA1 | |
84 #define SHA512 | |
85 #define SHA384 | |
86 #define SHA256 | |
87 #define SHA224 | |
88 | |
89 #define LTC_NO_MACS | |
90 #define HMAC | |
91 #define OMAC | |
92 #define CCM_MODE | |
93 | |
94 #define LTC_NO_PRNGS | |
95 #define SPRNG | |
96 #define YARROW | |
97 #define DEVRANDOM | |
98 #define TRY_URANDOM_FIRST | |
99 | |
100 #define LTC_NO_PK | |
101 #define MRSA | |
102 #define MECC | |
103 #endif | |
15 | 104 |
16 /* Use small code where possible */ | 105 /* Use small code where possible */ |
17 /* #define LTC_SMALL_CODE */ | 106 /* #define LTC_SMALL_CODE */ |
18 | 107 |
19 /* Enable self-test test vector checking */ | 108 /* Enable self-test test vector checking */ |
63 #define SKIPJACK | 152 #define SKIPJACK |
64 #define SAFER | 153 #define SAFER |
65 #define KHAZAD | 154 #define KHAZAD |
66 #define ANUBIS | 155 #define ANUBIS |
67 #define ANUBIS_TWEAK | 156 #define ANUBIS_TWEAK |
157 #define KSEED | |
158 #define LTC_KASUMI | |
68 | 159 |
69 #endif /* LTC_NO_CIPHERS */ | 160 #endif /* LTC_NO_CIPHERS */ |
70 | 161 |
71 | 162 |
72 /* ---> Block Cipher Modes of Operation <--- */ | 163 /* ---> Block Cipher Modes of Operation <--- */ |
73 #ifndef LTC_NO_MODES | 164 #ifndef LTC_NO_MODES |
74 | 165 |
75 #define CFB | 166 #define LTC_CFB_MODE |
76 #define OFB | 167 #define LTC_OFB_MODE |
77 #define ECB | 168 #define LTC_ECB_MODE |
78 #define CBC | 169 #define LTC_CBC_MODE |
79 #define CTR | 170 #define LTC_CTR_MODE |
171 | |
172 /* F8 chaining mode */ | |
173 #define LTC_F8_MODE | |
174 | |
175 /* LRW mode */ | |
176 #define LTC_LRW_MODE | |
177 #ifndef LTC_NO_TABLES | |
178 /* like GCM mode this will enable 16 8x128 tables [64KB] that make | |
179 * seeking very fast. | |
180 */ | |
181 #define LRW_TABLES | |
182 #endif | |
80 | 183 |
81 #endif /* LTC_NO_MODES */ | 184 #endif /* LTC_NO_MODES */ |
82 | 185 |
83 /* ---> One-Way Hash Functions <--- */ | 186 /* ---> One-Way Hash Functions <--- */ |
84 #ifndef LTC_NO_HASHES | 187 #ifndef LTC_NO_HASHES |
94 #define MD5 | 197 #define MD5 |
95 #define MD4 | 198 #define MD4 |
96 #define MD2 | 199 #define MD2 |
97 #define RIPEMD128 | 200 #define RIPEMD128 |
98 #define RIPEMD160 | 201 #define RIPEMD160 |
202 #define RIPEMD256 | |
203 #define RIPEMD320 | |
99 | 204 |
100 #endif /* LTC_NO_HASHES */ | 205 #endif /* LTC_NO_HASHES */ |
101 | 206 |
102 /* ---> MAC functions <--- */ | 207 /* ---> MAC functions <--- */ |
103 #ifndef LTC_NO_MACS | 208 #ifndef LTC_NO_MACS |
104 | 209 |
105 #define HMAC | 210 #define LTC_HMAC |
106 #define OMAC | 211 #define LTC_OMAC |
107 #define PMAC | 212 #define LTC_PMAC |
213 #define LTC_XCBC | |
214 #define LTC_F9_MODE | |
108 #define PELICAN | 215 #define PELICAN |
109 | 216 |
110 #if defined(PELICAN) && !defined(RIJNDAEL) | 217 #if defined(PELICAN) && !defined(RIJNDAEL) |
111 #error Pelican-MAC requires RIJNDAEL | 218 #error Pelican-MAC requires RIJNDAEL |
112 #endif | 219 #endif |
113 | 220 |
114 /* ---> Encrypt + Authenticate Modes <--- */ | 221 /* ---> Encrypt + Authenticate Modes <--- */ |
115 | 222 |
116 #define EAX_MODE | 223 #define EAX_MODE |
117 #if defined(EAX_MODE) && !(defined(CTR) && defined(OMAC)) | 224 #if defined(EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(LTC_OMAC)) |
118 #error EAX_MODE requires CTR and OMAC mode | 225 #error EAX_MODE requires CTR and OMAC mode |
119 #endif | 226 #endif |
120 | 227 |
121 #define OCB_MODE | 228 #define OCB_MODE |
122 #define CCM_MODE | 229 #define CCM_MODE |
123 | |
124 #define GCM_MODE | 230 #define GCM_MODE |
125 | 231 |
126 /* Use 64KiB tables */ | 232 /* Use 64KiB tables */ |
127 #ifndef LTC_NO_TABLES | 233 #ifndef LTC_NO_TABLES |
128 #define GCM_TABLES | 234 #define GCM_TABLES |
235 #endif | |
236 | |
237 /* USE SSE2? requires GCC works on x86_32 and x86_64*/ | |
238 #ifdef GCM_TABLES | |
239 /* #define GCM_TABLES_SSE2 */ | |
129 #endif | 240 #endif |
130 | 241 |
131 #endif /* LTC_NO_MACS */ | 242 #endif /* LTC_NO_MACS */ |
132 | 243 |
133 /* Various tidbits of modern neatoness */ | 244 /* Various tidbits of modern neatoness */ |
140 #define YARROW | 251 #define YARROW |
141 /* which descriptor of AES to use? */ | 252 /* which descriptor of AES to use? */ |
142 /* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */ | 253 /* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */ |
143 #define YARROW_AES 0 | 254 #define YARROW_AES 0 |
144 | 255 |
145 #if defined(YARROW) && !defined(CTR) | 256 #if defined(YARROW) && !defined(LTC_CTR_MODE) |
146 #error YARROW requires CTR chaining mode to be defined! | 257 #error YARROW requires LTC_CTR_MODE chaining mode to be defined! |
147 #endif | 258 #endif |
148 | 259 |
149 /* a PRNG that simply reads from an available system source */ | 260 /* a PRNG that simply reads from an available system source */ |
150 #define SPRNG | 261 #define SPRNG |
151 | 262 |
167 /* try /dev/urandom before trying /dev/random */ | 278 /* try /dev/urandom before trying /dev/random */ |
168 #define TRY_URANDOM_FIRST | 279 #define TRY_URANDOM_FIRST |
169 | 280 |
170 #endif /* LTC_NO_PRNGS */ | 281 #endif /* LTC_NO_PRNGS */ |
171 | 282 |
283 /* ---> math provider? <--- */ | |
284 #ifndef LTC_NO_MATH | |
285 | |
286 /* LibTomMath */ | |
287 /* #define LTM_DESC */ | |
288 | |
289 /* TomsFastMath */ | |
290 /* #define TFM_DESC */ | |
291 | |
292 #endif /* LTC_NO_MATH */ | |
293 | |
172 /* ---> Public Key Crypto <--- */ | 294 /* ---> Public Key Crypto <--- */ |
173 #ifndef LTC_NO_PK | 295 #ifndef LTC_NO_PK |
174 | 296 |
297 /* Include RSA support */ | |
175 #define MRSA | 298 #define MRSA |
299 | |
300 /* Include Katja (a Rabin variant like RSA) */ | |
301 /* #define MKAT */ | |
176 | 302 |
177 /* Digital Signature Algorithm */ | 303 /* Digital Signature Algorithm */ |
178 #define MDSA | 304 #define MDSA |
179 /* Max diff between group and modulus size in bytes */ | |
180 #define MDSA_DELTA 512 | |
181 /* Max DSA group size in bytes (default allows 4k-bit groups) */ | |
182 #define MDSA_MAX_GROUP 512 | |
183 | |
184 /* Diffie-Hellman */ | |
185 #define MDH | |
186 /* Supported Key Sizes */ | |
187 #define DH768 | |
188 #define DH1024 | |
189 #define DH1280 | |
190 #define DH1536 | |
191 #define DH1792 | |
192 #define DH2048 | |
193 #define DH2560 | |
194 #define DH3072 | |
195 #define DH4096 | |
196 | 305 |
197 /* ECC */ | 306 /* ECC */ |
198 #define MECC | 307 #define MECC |
199 /* Supported Key Sizes */ | 308 |
200 #define ECC192 | 309 /* use Shamir's trick for point mul (speeds up signature verification) */ |
201 #define ECC224 | 310 #define LTC_ECC_SHAMIR |
202 #define ECC256 | 311 |
203 #define ECC384 | 312 #if defined(TFM_DESC) && defined(MECC) |
204 #define ECC521 | 313 #define MECC_ACCEL |
205 | 314 #endif |
206 /* Include the MPI functionality? (required by the PK algorithms) */ | 315 |
207 #define MPI | 316 /* do we want fixed point ECC */ |
317 /* #define MECC_FP */ | |
318 | |
319 /* Timing Resistant? */ | |
320 /* #define LTC_ECC_TIMING_RESISTANT */ | |
208 | 321 |
209 #endif /* LTC_NO_PK */ | 322 #endif /* LTC_NO_PK */ |
210 | 323 |
211 /* PKCS #1 (RSA) and #5 (Password Handling) stuff */ | 324 /* PKCS #1 (RSA) and #5 (Password Handling) stuff */ |
212 #ifndef LTC_NO_PKCS | 325 #ifndef LTC_NO_PKCS |
214 #define PKCS_1 | 327 #define PKCS_1 |
215 #define PKCS_5 | 328 #define PKCS_5 |
216 | 329 |
217 /* Include ASN.1 DER (required by DSA/RSA) */ | 330 /* Include ASN.1 DER (required by DSA/RSA) */ |
218 #define LTC_DER | 331 #define LTC_DER |
332 | |
333 #endif /* LTC_NO_PKCS */ | |
334 | |
335 /* cleanup */ | |
336 | |
337 #ifdef MECC | |
338 /* Supported ECC Key Sizes */ | |
339 #ifndef LTC_NO_CURVES | |
340 #define ECC112 | |
341 #define ECC128 | |
342 #define ECC160 | |
343 #define ECC192 | |
344 #define ECC224 | |
345 #define ECC256 | |
346 #define ECC384 | |
347 #define ECC521 | |
348 #endif | |
349 #endif | |
350 | |
351 #if defined(MECC) || defined(MRSA) || defined(MDSA) || defined(MKATJA) | |
352 /* Include the MPI functionality? (required by the PK algorithms) */ | |
353 #define MPI | |
354 #endif | |
355 | |
356 #ifdef MRSA | |
357 #define PKCS_1 | |
358 #endif | |
359 | |
219 #if defined(LTC_DER) && !defined(MPI) | 360 #if defined(LTC_DER) && !defined(MPI) |
220 #error ASN.1 DER requires MPI functionality | 361 #error ASN.1 DER requires MPI functionality |
221 #endif | 362 #endif |
222 | 363 |
223 #if (defined(MDSA) || defined(MRSA)) && !defined(LTC_DER) | 364 #if (defined(MDSA) || defined(MRSA) || defined(MECC) || defined(MKATJA)) && !defined(LTC_DER) |
224 #error RSA/DSA requires ASN.1 DER functionality, make sure LTC_DER is enabled | 365 #error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled |
225 #endif | 366 #endif |
226 | |
227 #endif /* LTC_NO_PKCS */ | |
228 | |
229 #endif | |
230 | |
231 | 367 |
232 /* THREAD management */ | 368 /* THREAD management */ |
233 | |
234 #ifdef LTC_PTHREAD | 369 #ifdef LTC_PTHREAD |
235 | 370 |
236 #include <pthread.h> | 371 #include <pthread.h> |
237 | 372 |
238 #define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER; | 373 #define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER; |
239 #define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x; | 374 #define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x; |
375 #define LTC_MUTEX_TYPE(x) pthread_mutex_t x; | |
376 #define LTC_MUTEX_INIT(x) pthread_mutex_init(x, NULL); | |
240 #define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x); | 377 #define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x); |
241 #define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x); | 378 #define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x); |
242 | 379 |
243 #else | 380 #else |
244 | 381 |
245 /* default no functions */ | 382 /* default no functions */ |
246 #define LTC_MUTEX_GLOBAL(x) | 383 #define LTC_MUTEX_GLOBAL(x) |
247 #define LTC_MUTEX_PROTO(x) | 384 #define LTC_MUTEX_PROTO(x) |
385 #define LTC_MUTEX_TYPE(x) | |
386 #define LTC_MUTEX_INIT(x) | |
248 #define LTC_MUTEX_LOCK(x) | 387 #define LTC_MUTEX_LOCK(x) |
249 #define LTC_MUTEX_UNLOCK(x) | 388 #define LTC_MUTEX_UNLOCK(x) |
250 | 389 |
251 #endif | 390 #endif |
252 | 391 |
392 /* Debuggers */ | |
393 | |
394 /* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and RC4 work (see the code) */ | |
395 /* #define LTC_VALGRIND */ | |
396 | |
397 #endif | |
398 | |
399 | |
253 | 400 |
254 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_custom.h,v $ */ | 401 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_custom.h,v $ */ |
255 /* $Revision: 1.17 $ */ | 402 /* $Revision: 1.66 $ */ |
256 /* $Date: 2005/06/19 18:00:28 $ */ | 403 /* $Date: 2006/12/04 02:50:11 $ */ |