Debian Codegraph @

src/libtom/tomcrypt_custom.h

raw symbols SCIP
1 #ifndef TOMCRYPT_CUSTOM_H_
2 #define TOMCRYPT_CUSTOM_H_
3
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
9 #define XMALLOC malloc
10 #endif
11 #ifndef XREALLOC
12 #ifdef realloc
13 #define LTC_NO_PROTOTYPES
14 #endif
15 #define XREALLOC realloc
16 #endif
17 #ifndef XCALLOC
18 #ifdef calloc
19 #define LTC_NO_PROTOTYPES
20 #endif
21 #define XCALLOC calloc
22 #endif
23 #ifndef XFREE
24 #ifdef free
25 #define LTC_NO_PROTOTYPES
26 #endif
27 #define XFREE free
28 #endif
29
30 #ifndef XMEMSET
31 #ifdef memset
32 #define LTC_NO_PROTOTYPES
33 #endif
34 #define XMEMSET memset
35 #endif
36 #ifndef XMEMCPY
37 #ifdef memcpy
38 #define LTC_NO_PROTOTYPES
39 #endif
40 #define XMEMCPY memcpy
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
56 #define XCLOCK clock
57 #endif
58 #ifndef XCLOCKS_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 LTC_RIJNDAEL
73 #define LTC_BLOWFISH
74 #define LTC_DES
75 #define LTC_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 LTC_SHA1
84 #define LTC_SHA512
85 #define LTC_SHA384
86 #define LTC_SHA256
87 #define LTC_SHA224
88
89 #define LTC_NO_MACS
90 #define LTC_HMAC
91 #define LTC_OMAC
92 #define LTC_CCM_MODE
93
94 #define LTC_NO_PRNGS
95 #define LTC_SPRNG
96 #define LTC_YARROW
97 #define LTC_DEVRANDOM
98 #define TRY_URANDOM_FIRST
99
100 #define LTC_NO_PK
101 #define LTC_MRSA
102 #define LTC_MECC
103 #endif
104
105 /* Use small code where possible */
106 /* #define LTC_SMALL_CODE */
107
108 /* Enable self-test test vector checking */
109 #ifndef LTC_NO_TEST
110 #define LTC_TEST
111 #endif
112
113 /* clean the stack of functions which put private information on stack */
114 /* #define LTC_CLEAN_STACK */
115
116 /* disable all file related functions */
117 /* #define LTC_NO_FILE */
118
119 /* disable all forms of ASM */
120 /* #define LTC_NO_ASM */
121
122 /* disable FAST mode */
123 /* #define LTC_NO_FAST */
124
125 /* disable BSWAP on x86 */
126 /* #define LTC_NO_BSWAP */
127
128 /* ---> Symmetric Block Ciphers <--- */
129 #ifndef LTC_NO_CIPHERS
130
131 #define LTC_BLOWFISH
132 #define LTC_RC2
133 #define LTC_RC5
134 #define LTC_RC6
135 #define LTC_SAFERP
136 #define LTC_RIJNDAEL
137 #define LTC_XTEA
138 /* _TABLES tells it to use tables during setup, _SMALL means to use the smaller scheduled key format
139 * (saves 4KB of ram), _ALL_TABLES enables all tables during setup */
140 #define LTC_TWOFISH
141 #ifndef LTC_NO_TABLES
142 #define LTC_TWOFISH_TABLES
143 /* #define LTC_TWOFISH_ALL_TABLES */
144 #else
145 #define LTC_TWOFISH_SMALL
146 #endif
147 /* #define LTC_TWOFISH_SMALL */
148 /* LTC_DES includes EDE triple-LTC_DES */
149 #define LTC_DES
150 #define LTC_CAST5
151 #define LTC_NOEKEON
152 #define LTC_SKIPJACK
153 #define LTC_SAFER
154 #define LTC_KHAZAD
155 #define LTC_ANUBIS
156 #define LTC_ANUBIS_TWEAK
157 #define LTC_KSEED
158 #define LTC_KASUMI
159
160 #endif /* LTC_NO_CIPHERS */
161
162
163 /* ---> Block Cipher Modes of Operation <--- */
164 #ifndef LTC_NO_MODES
165
166 #define LTC_CFB_MODE
167 #define LTC_OFB_MODE
168 #define LTC_ECB_MODE
169 #define LTC_CBC_MODE
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
183
184 /* XTS mode */
185 #define LTC_XTS_MODE
186
187 #endif /* LTC_NO_MODES */
188
189 /* ---> One-Way Hash Functions <--- */
190 #ifndef LTC_NO_HASHES
191
192 #define LTC_CHC_HASH
193 #define LTC_WHIRLPOOL
194 #define LTC_SHA512
195 #define LTC_SHA384
196 #define LTC_SHA256
197 #define LTC_SHA224
198 #define LTC_TIGER
199 #define LTC_SHA1
200 #define LTC_MD5
201 #define LTC_MD4
202 #define LTC_MD2
203 #define LTC_RIPEMD128
204 #define LTC_RIPEMD160
205 #define LTC_RIPEMD256
206 #define LTC_RIPEMD320
207
208 #endif /* LTC_NO_HASHES */
209
210 /* ---> MAC functions <--- */
211 #ifndef LTC_NO_MACS
212
213 #define LTC_HMAC
214 #define LTC_OMAC
215 #define LTC_PMAC
216 #define LTC_XCBC
217 #define LTC_F9_MODE
218 #define LTC_PELICAN
219
220 #if defined(LTC_PELICAN) && !defined(LTC_RIJNDAEL)
221 #error Pelican-MAC requires LTC_RIJNDAEL
222 #endif
223
224 /* ---> Encrypt + Authenticate Modes <--- */
225
226 #define LTC_EAX_MODE
227 #if defined(LTC_EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(LTC_OMAC))
228 #error LTC_EAX_MODE requires CTR and LTC_OMAC mode
229 #endif
230
231 #define LTC_OCB_MODE
232 #define LTC_CCM_MODE
233 #define LTC_GCM_MODE
234
235 /* Use 64KiB tables */
236 #ifndef LTC_NO_TABLES
237 #define LTC_GCM_TABLES
238 #endif
239
240 /* USE SSE2? requires GCC works on x86_32 and x86_64*/
241 #ifdef LTC_GCM_TABLES
242 /* #define LTC_GCM_TABLES_SSE2 */
243 #endif
244
245 #endif /* LTC_NO_MACS */
246
247 /* Various tidbits of modern neatoness */
248 #define LTC_BASE64
249
250 /* --> Pseudo Random Number Generators <--- */
251 #ifndef LTC_NO_PRNGS
252
253 /* Yarrow */
254 #define LTC_YARROW
255 /* which descriptor of AES to use? */
256 /* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */
257 #define LTC_YARROW_AES 0
258
259 #if defined(LTC_YARROW) && !defined(LTC_CTR_MODE)
260 #error LTC_YARROW requires LTC_CTR_MODE chaining mode to be defined!
261 #endif
262
263 /* a PRNG that simply reads from an available system source */
264 #define LTC_SPRNG
265
266 /* The LTC_RC4 stream cipher */
267 #define LTC_RC4
268
269 /* Fortuna PRNG */
270 #define LTC_FORTUNA
271 /* reseed every N calls to the read function */
272 #define LTC_FORTUNA_WD 10
273 /* number of pools (4..32) can save a bit of ram by lowering the count */
274 #define LTC_FORTUNA_POOLS 32
275
276 /* Greg's LTC_SOBER128 PRNG ;-0 */
277 #define LTC_SOBER128
278
279 /* the *nix style /dev/random device */
280 #define LTC_DEVRANDOM
281 /* try /dev/urandom before trying /dev/random */
282 #define TRY_URANDOM_FIRST
283
284 #endif /* LTC_NO_PRNGS */
285
286 /* ---> math provider? <--- */
287 #ifndef LTC_NO_MATH
288
289 /* LibTomMath */
290 /* #define LTM_LTC_DESC */
291
292 /* TomsFastMath */
293 /* #define TFM_LTC_DESC */
294
295 #endif /* LTC_NO_MATH */
296
297 /* ---> Public Key Crypto <--- */
298 #ifndef LTC_NO_PK
299
300 /* Include RSA support */
301 #define LTC_MRSA
302
303 /* Include Katja (a Rabin variant like RSA) */
304 /* #define MKAT */
305
306 /* Digital Signature Algorithm */
307 #define LTC_MDSA
308
309 /* ECC */
310 #define LTC_MECC
311
312 /* use Shamir's trick for point mul (speeds up signature verification) */
313 #define LTC_ECC_SHAMIR
314
315 #if defined(TFM_LTC_DESC) && defined(LTC_MECC)
316 #define LTC_MECC_ACCEL
317 #endif
318
319 /* do we want fixed point ECC */
320 /* #define LTC_MECC_FP */
321
322 /* Timing Resistant? */
323 /* #define LTC_ECC_TIMING_RESISTANT */
324
325 #endif /* LTC_NO_PK */
326
327 /* LTC_PKCS #1 (RSA) and #5 (Password Handling) stuff */
328 #ifndef LTC_NO_PKCS
329
330 #define LTC_PKCS_1
331 #define LTC_PKCS_5
332
333 /* Include ASN.1 DER (required by DSA/RSA) */
334 #define LTC_DER
335
336 #endif /* LTC_NO_PKCS */
337
338 /* cleanup */
339
340 #ifdef LTC_MECC
341 /* Supported ECC Key Sizes */
342 #ifndef LTC_NO_CURVES
343 #define ECC112
344 #define ECC128
345 #define ECC160
346 #define ECC192
347 #define ECC224
348 #define ECC256
349 #define ECC384
350 #define ECC521
351 #endif
352 #endif
353
354 #if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(MKATJA)
355 /* Include the MPI functionality? (required by the PK algorithms) */
356 #define MPI
357 #endif
358
359 #ifdef LTC_MRSA
360 #define LTC_PKCS_1
361 #endif
362
363 #if defined(LTC_DER) && !defined(MPI)
364 #error ASN.1 DER requires MPI functionality
365 #endif
366
367 #if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(MKATJA)) && !defined(LTC_DER)
368 #error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled
369 #endif
370
371 /* THREAD management */
372 #ifdef LTC_PTHREAD
373
374 #include <pthread.h>
375
376 #define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
377 #define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x;
378 #define LTC_MUTEX_TYPE(x) pthread_mutex_t x;
379 #define LTC_MUTEX_INIT(x) pthread_mutex_init(x, NULL);
380 #define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x);
381 #define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x);
382
383 #else
384
385 /* default no functions */
386 #define LTC_MUTEX_GLOBAL(x)
387 #define LTC_MUTEX_PROTO(x)
388 #define LTC_MUTEX_TYPE(x)
389 #define LTC_MUTEX_INIT(x)
390 #define LTC_MUTEX_LOCK(x)
391 #define LTC_MUTEX_UNLOCK(x)
392
393 #endif
394
395 /* Debuggers */
396
397 /* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and LTC_RC4 work (see the code) */
398 /* #define LTC_VALGRIND */
399
400 #endif
401
402
403
404 /* $Source$ */
405 /* $Revision$ */
406 /* $Date$ */