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