tomcrypt_custom.h
Upload User: xuxiaoled
Upload Date: 2018-04-29
Package Size: 2115k
Code Size: 5k
Development Platform:

Visual C++

  1. #ifndef TOMCRYPT_CUSTOM_H_
  2. #define TOMCRYPT_CUSTOM_H_
  3. /* macros for various libc functions you can change for embedded targets */
  4. #define XMALLOC  malloc
  5. #define XREALLOC realloc
  6. #define XCALLOC  calloc
  7. #define XFREE    free
  8. #define XMEMSET  memset
  9. #define XMEMCPY  memcpy
  10. #define XCLOCK   clock
  11. #define XCLOCKS_PER_SEC CLOCKS_PER_SEC
  12. /* Use small code where possible */
  13. /* #define LTC_SMALL_CODE */
  14. /* Enable self-test test vector checking */
  15. #ifndef LTC_NO_TEST
  16.    #define LTC_TEST
  17. #endif
  18. /* clean the stack of functions which put private information on stack */
  19. /* #define LTC_CLEAN_STACK */
  20. /* disable all file related functions */
  21. /* #define LTC_NO_FILE */
  22. /* disable all forms of ASM */
  23. /* #define LTC_NO_ASM */
  24. /* disable FAST mode */
  25. /* #define LTC_NO_FAST */
  26. /* disable BSWAP on x86 */
  27. /* #define LTC_NO_BSWAP */
  28. /* ---> Symmetric Block Ciphers <--- */
  29. #ifndef LTC_NO_CIPHERS
  30. #define BLOWFISH
  31. #define RC2
  32. #define RC5
  33. #define RC6
  34. #define SAFERP
  35. #define RIJNDAEL
  36. #define XTEA
  37. /* _TABLES tells it to use tables during setup, _SMALL means to use the smaller scheduled key format
  38.  * (saves 4KB of ram), _ALL_TABLES enables all tables during setup */
  39. #define TWOFISH
  40. #ifndef LTC_NO_TABLES
  41.    #define TWOFISH_TABLES
  42.    /* #define TWOFISH_ALL_TABLES */
  43. #else
  44.    #define TWOFISH_SMALL
  45. #endif
  46. /* #define TWOFISH_SMALL */
  47. /* DES includes EDE triple-DES */
  48. #define DES
  49. #define CAST5
  50. #define NOEKEON
  51. #define SKIPJACK
  52. #define SAFER
  53. #define KHAZAD
  54. #define ANUBIS
  55. #define ANUBIS_TWEAK
  56. #endif /* LTC_NO_CIPHERS */
  57. /* ---> Block Cipher Modes of Operation <--- */
  58. #ifndef LTC_NO_MODES
  59. #define CFB
  60. #define OFB
  61. #define ECB
  62. #define CBC
  63. #define CTR
  64. #endif /* LTC_NO_MODES */
  65. /* ---> One-Way Hash Functions <--- */
  66. #ifndef LTC_NO_HASHES 
  67. #define CHC_HASH
  68. #define WHIRLPOOL
  69. #define SHA512
  70. #define SHA384
  71. #define SHA256
  72. #define SHA224
  73. #define TIGER
  74. #define SHA1
  75. #define MD5
  76. #define MD4
  77. #define MD2
  78. #define RIPEMD128
  79. #define RIPEMD160
  80. #endif /* LTC_NO_HASHES */
  81. /* ---> MAC functions <--- */
  82. #ifndef LTC_NO_MACS
  83. #define HMAC
  84. #define OMAC
  85. #define PMAC
  86. #define PELICAN
  87. #if defined(PELICAN) && !defined(RIJNDAEL)
  88.    #error Pelican-MAC requires RIJNDAEL
  89. #endif
  90. /* ---> Encrypt + Authenticate Modes <--- */
  91. #define EAX_MODE
  92. #if defined(EAX_MODE) && !(defined(CTR) && defined(OMAC))
  93.    #error EAX_MODE requires CTR and OMAC mode
  94. #endif
  95. #define OCB_MODE
  96. #define CCM_MODE
  97. #define GCM_MODE
  98. /* Use 64KiB tables */
  99. #ifndef LTC_NO_TABLES
  100.    #define GCM_TABLES 
  101. #endif
  102. #endif /* LTC_NO_MACS */
  103. /* Various tidbits of modern neatoness */
  104. #define BASE64
  105. /* --> Pseudo Random Number Generators <--- */
  106. #ifndef LTC_NO_PRNGS
  107. /* Yarrow */
  108. #define YARROW
  109. /* which descriptor of AES to use?  */
  110. /* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */
  111. #define YARROW_AES 0
  112. #if defined(YARROW) && !defined(CTR)
  113.    #error YARROW requires CTR chaining mode to be defined!
  114. #endif
  115. /* a PRNG that simply reads from an available system source */
  116. #define SPRNG
  117. /* The RC4 stream cipher */
  118. #define RC4
  119. /* Fortuna PRNG */
  120. #define FORTUNA
  121. /* reseed every N calls to the read function */
  122. #define FORTUNA_WD    10
  123. /* number of pools (4..32) can save a bit of ram by lowering the count */
  124. #define FORTUNA_POOLS 32
  125. /* Greg's SOBER128 PRNG ;-0 */
  126. #define SOBER128
  127. /* the *nix style /dev/random device */
  128. #define DEVRANDOM
  129. /* try /dev/urandom before trying /dev/random */
  130. #define TRY_URANDOM_FIRST
  131. #endif /* LTC_NO_PRNGS */
  132. /* ---> Public Key Crypto <--- */
  133. #ifndef LTC_NO_PK
  134. #define MRSA
  135. /* Digital Signature Algorithm */
  136. #define MDSA
  137. /* Max diff between group and modulus size in bytes */
  138. #define MDSA_DELTA     512
  139. /* Max DSA group size in bytes (default allows 4k-bit groups) */
  140. #define MDSA_MAX_GROUP 512
  141. /* Diffie-Hellman */
  142. #define MDH
  143. /* Supported Key Sizes */
  144. #define DH768
  145. #define DH1024
  146. #define DH1280
  147. #define DH1536
  148. #define DH1792
  149. #define DH2048
  150. #define DH2560
  151. #define DH3072
  152. #define DH4096
  153. /* ECC */
  154. #define MECC
  155. /* Supported Key Sizes */
  156. #define ECC192
  157. #define ECC224
  158. #define ECC256
  159. #define ECC384
  160. #define ECC521
  161. /* Include the MPI functionality?  (required by the PK algorithms) */
  162. #define MPI
  163. #endif /* LTC_NO_PK */
  164. /* PKCS #1 (RSA) and #5 (Password Handling) stuff */
  165. #ifndef LTC_NO_PKCS
  166. #define PKCS_1
  167. #define PKCS_5
  168. /* Include ASN.1 DER (required by DSA/RSA) */
  169. #define LTC_DER
  170. #if defined(LTC_DER) && !defined(MPI) 
  171.    #error ASN.1 DER requires MPI functionality
  172. #endif
  173. #if (defined(MDSA) || defined(MRSA)) && !defined(LTC_DER)
  174.    #error RSA/DSA requires ASN.1 DER functionality, make sure LTC_DER is enabled
  175. #endif
  176. #endif /* LTC_NO_PKCS */
  177. #endif
  178. /* THREAD management */
  179. #ifdef LTC_PTHREAD
  180. #include <pthread.h>
  181. #define LTC_MUTEX_GLOBAL(x)   pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
  182. #define LTC_MUTEX_PROTO(x)    extern pthread_mutex_t x;
  183. #define LTC_MUTEX_LOCK(x)     pthread_mutex_lock(x);
  184. #define LTC_MUTEX_UNLOCK(x)   pthread_mutex_unlock(x);
  185. #else 
  186. /* default no functions */
  187. #define LTC_MUTEX_GLOBAL(x)
  188. #define LTC_MUTEX_PROTO(x)
  189. #define LTC_MUTEX_LOCK(x)
  190. #define LTC_MUTEX_UNLOCK(x)
  191. #endif
  192. /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_custom.h,v $ */
  193. /* $Revision: 1.17 $ */
  194. /* $Date: 2005/06/19 18:00:28 $ */