LibLogicalAccess
2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
plugins
logicalaccess
plugins
crypto
tomcrypt_custom.h
Go to the documentation of this file.
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
#define LTC_MULTI2
160
#define LTC_CAMELLIA
161
162
#endif
/* LTC_NO_CIPHERS */
163
164
/* ---> Block Cipher Modes of Operation <--- */
165
#ifndef LTC_NO_MODES
166
167
#define LTC_CFB_MODE
168
#define LTC_OFB_MODE
169
#define LTC_ECB_MODE
170
#define LTC_CBC_MODE
171
#define LTC_CTR_MODE
172
173
/* F8 chaining mode */
174
#define LTC_F8_MODE
175
176
/* LRW mode */
177
#define LTC_LRW_MODE
178
#ifndef LTC_NO_TABLES
179
/* like GCM mode this will enable 16 8x128 tables [64KB] that make
180
* seeking very fast.
181
*/
182
#define LRW_TABLES
183
#endif
184
185
/* XTS mode */
186
#define LTC_XTS_MODE
187
188
#endif
/* LTC_NO_MODES */
189
190
/* ---> One-Way Hash Functions <--- */
191
#ifndef LTC_NO_HASHES
192
193
#define LTC_CHC_HASH
194
#define LTC_WHIRLPOOL
195
#define LTC_SHA512
196
#define LTC_SHA384
197
#define LTC_SHA256
198
#define LTC_SHA224
199
#define LTC_TIGER
200
#define LTC_SHA1
201
#define LTC_MD5
202
#define LTC_MD4
203
#define LTC_MD2
204
#define LTC_RIPEMD128
205
#define LTC_RIPEMD160
206
#define LTC_RIPEMD256
207
#define LTC_RIPEMD320
208
209
#endif
/* LTC_NO_HASHES */
210
211
/* ---> MAC functions <--- */
212
#ifndef LTC_NO_MACS
213
214
#define LTC_HMAC
215
#define LTC_OMAC
216
#define LTC_PMAC
217
#define LTC_XCBC
218
#define LTC_F9_MODE
219
#define LTC_PELICAN
220
221
#if defined(LTC_PELICAN) && !defined(LTC_RIJNDAEL)
222
#error Pelican-MAC requires LTC_RIJNDAEL
223
#endif
224
225
/* ---> Encrypt + Authenticate Modes <--- */
226
227
#define LTC_EAX_MODE
228
#if defined(LTC_EAX_MODE) && !(defined(LTC_CTR_MODE) && defined(LTC_OMAC))
229
#error LTC_EAX_MODE requires CTR and LTC_OMAC mode
230
#endif
231
232
#define LTC_OCB_MODE
233
#define LTC_CCM_MODE
234
#define LTC_GCM_MODE
235
236
/* Use 64KiB tables */
237
#ifndef LTC_NO_TABLES
238
#define LTC_GCM_TABLES
239
#endif
240
241
/* USE SSE2? requires GCC works on x86_32 and x86_64*/
242
#ifdef LTC_GCM_TABLES
243
/* #define LTC_GCM_TABLES_SSE2 */
244
#endif
245
246
#endif
/* LTC_NO_MACS */
247
248
/* Various tidbits of modern neatoness */
249
#define LTC_BASE64
250
251
/* --> Pseudo Random Number Generators <--- */
252
#ifndef LTC_NO_PRNGS
253
254
/* Yarrow */
255
#define LTC_YARROW
256
/* which descriptor of AES to use? */
257
/* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */
258
#define LTC_YARROW_AES 0
259
260
#if defined(LTC_YARROW) && !defined(LTC_CTR_MODE)
261
#error LTC_YARROW requires LTC_CTR_MODE chaining mode to be defined!
262
#endif
263
264
/* a PRNG that simply reads from an available system source */
265
#define LTC_SPRNG
266
267
/* The LTC_RC4 stream cipher */
268
#define LTC_RC4
269
270
/* Fortuna PRNG */
271
#define LTC_FORTUNA
272
/* reseed every N calls to the read function */
273
#define LTC_FORTUNA_WD 10
274
/* number of pools (4..32) can save a bit of ram by lowering the count */
275
#define LTC_FORTUNA_POOLS 32
276
277
/* Greg's LTC_SOBER128 PRNG ;-0 */
278
#define LTC_SOBER128
279
280
/* the *nix style /dev/random device */
281
#define LTC_DEVRANDOM
282
/* try /dev/urandom before trying /dev/random */
283
#define TRY_URANDOM_FIRST
284
285
#endif
/* LTC_NO_PRNGS */
286
287
/* ---> math provider? <--- */
288
#ifndef LTC_NO_MATH
289
290
/* LibTomMath */
291
/* #define LTM_DESC */
292
293
/* TomsFastMath */
294
/* #define TFM_DESC */
295
296
#endif
/* LTC_NO_MATH */
297
298
/* ---> Public Key Crypto <--- */
299
#ifndef LTC_NO_PK
300
301
/* Include RSA support */
302
#define LTC_MRSA
303
304
/* Enable RSA blinding when doing private key operations? */
305
/* #define LTC_RSA_BLINDING */
306
307
/* Include Diffie-Hellman support */
308
#ifndef GPM_DESC
309
/* is_prime fails for GPM */
310
#define MDH
311
/* Supported Key Sizes */
312
#define DH768
313
#define DH1024
314
#define DH1280
315
#define DH1536
316
#define DH1792
317
#define DH2048
318
319
#ifndef TFM_DESC
320
/* tfm has a problem in fp_isprime for larger key sizes */
321
#define DH2560
322
#define DH3072
323
#define DH4096
324
#endif
325
#endif
326
327
/* Include Katja (a Rabin variant like RSA) */
328
/* #define MKAT */
329
330
/* Digital Signature Algorithm */
331
#define LTC_MDSA
332
333
/* ECC */
334
#define LTC_MECC
335
336
/* use Shamir's trick for point mul (speeds up signature verification) */
337
#define LTC_ECC_SHAMIR
338
339
#if defined(TFM_LTC_DESC) && defined(LTC_MECC)
340
#define LTC_MECC_ACCEL
341
#endif
342
343
/* do we want fixed point ECC */
344
/* #define LTC_MECC_FP */
345
346
/* Timing Resistant? */
347
/* #define LTC_ECC_TIMING_RESISTANT */
348
349
#endif
/* LTC_NO_PK */
350
351
/* LTC_PKCS #1 (RSA) and #5 (Password Handling) stuff */
352
#ifndef LTC_NO_PKCS
353
354
#define LTC_PKCS_1
355
#define LTC_PKCS_5
356
357
/* Include ASN.1 DER (required by DSA/RSA) */
358
#define LTC_DER
359
360
#endif
/* LTC_NO_PKCS */
361
362
/* cleanup */
363
364
#ifdef LTC_MECC
365
/* Supported ECC Key Sizes */
366
#ifndef LTC_NO_CURVES
367
#define ECC112
368
#define ECC128
369
#define ECC160
370
#define ECC192
371
#define ECC224
372
#define ECC256
373
#define ECC384
374
#define ECC521
375
#endif
376
#endif
377
378
#if defined(LTC_MECC) || defined(LTC_MRSA) || defined(LTC_MDSA) || defined(MKATJA)
379
/* Include the MPI functionality? (required by the PK algorithms) */
380
#define MPI
381
#endif
382
383
#ifdef LTC_MRSA
384
#define LTC_PKCS_1
385
#endif
386
387
#if defined(TFM_DESC) && defined(LTC_RSA_BLINDING)
388
#warning RSA blinding currently not supported in combination with TFM
389
#undef LTC_RSA_BLINDING
390
#endif
391
392
#if defined(LTC_DER) && !defined(MPI)
393
#error ASN.1 DER requires MPI functionality
394
#endif
395
396
#if (defined(LTC_MDSA) || defined(LTC_MRSA) || defined(LTC_MECC) || defined(MKATJA)) && !defined(LTC_DER)
397
#error PK requires ASN.1 DER functionality, make sure LTC_DER is enabled
398
#endif
399
400
/* THREAD management */
401
#ifdef LTC_PTHREAD
402
403
#include <pthread.h>
404
405
#define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
406
#define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x;
407
#define LTC_MUTEX_TYPE(x) pthread_mutex_t x;
408
#define LTC_MUTEX_INIT(x) pthread_mutex_init(x, NULL);
409
#define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x);
410
#define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x);
411
412
#else
413
414
/* default no functions */
415
#define LTC_MUTEX_GLOBAL(x)
416
#define LTC_MUTEX_PROTO(x)
417
#define LTC_MUTEX_TYPE(x)
418
#define LTC_MUTEX_INIT(x)
419
#define LTC_MUTEX_LOCK(x)
420
#define LTC_MUTEX_UNLOCK(x)
421
422
#endif
423
424
/* Debuggers */
425
426
/* define this if you use Valgrind, note: it CHANGES the way SOBER-128 and LTC_RC4 work (see the code) */
427
/* #define LTC_VALGRIND */
428
429
#endif
430
431
/* $Source$ */
432
/* $Revision$ */
433
/* $Date$ */
Generated on Wed Mar 29 2023 13:50:38 for LibLogicalAccess by
1.9.6