comparison src/headers/tomcrypt_custom.h @ 209:39d5d58461d6 libtomcrypt-orig LTC_1.05

Import of libtomcrypt 1.05
author Matt Johnston <matt@ucc.asn.au>
date Wed, 06 Jul 2005 03:53:40 +0000
parents 1c15b283127b
children 4768b55c5240
comparison
equal deleted inserted replaced
191:1c15b283127b 209:39d5d58461d6
1 /* This header is meant to be included before mycrypt.h in projects where
2 * you don't want to throw all the defines in a makefile.
3 */
4 #ifndef TOMCRYPT_CUSTOM_H_ 1 #ifndef TOMCRYPT_CUSTOM_H_
5 #define TOMCRYPT_CUSTOM_H_ 2 #define TOMCRYPT_CUSTOM_H_
6 3
7 /* macros for various libc functions you can change for embedded targets */ 4 /* macros for various libc functions you can change for embedded targets */
8 #define XMALLOC malloc 5 #define XMALLOC malloc
18 15
19 /* Use small code where possible */ 16 /* Use small code where possible */
20 /* #define LTC_SMALL_CODE */ 17 /* #define LTC_SMALL_CODE */
21 18
22 /* Enable self-test test vector checking */ 19 /* Enable self-test test vector checking */
23 #define LTC_TEST 20 #ifndef LTC_NO_TEST
21 #define LTC_TEST
22 #endif
24 23
25 /* clean the stack of functions which put private information on stack */ 24 /* clean the stack of functions which put private information on stack */
26 /* #define LTC_CLEAN_STACK */ 25 /* #define LTC_CLEAN_STACK */
27 26
28 /* disable all file related functions */ 27 /* disable all file related functions */
36 35
37 /* disable BSWAP on x86 */ 36 /* disable BSWAP on x86 */
38 /* #define LTC_NO_BSWAP */ 37 /* #define LTC_NO_BSWAP */
39 38
40 /* ---> Symmetric Block Ciphers <--- */ 39 /* ---> Symmetric Block Ciphers <--- */
40 #ifndef LTC_NO_CIPHERS
41
41 #define BLOWFISH 42 #define BLOWFISH
42 #define RC2 43 #define RC2
43 #define RC5 44 #define RC5
44 #define RC6 45 #define RC6
45 #define SAFERP 46 #define SAFERP
46 #define RIJNDAEL 47 #define RIJNDAEL
47 #define XTEA 48 #define XTEA
48 /* _TABLES tells it to use tables during setup, _SMALL means to use the smaller scheduled key format 49 /* _TABLES tells it to use tables during setup, _SMALL means to use the smaller scheduled key format
49 * (saves 4KB of ram), _ALL_TABLES enables all tables during setup */ 50 * (saves 4KB of ram), _ALL_TABLES enables all tables during setup */
50 #define TWOFISH 51 #define TWOFISH
51 #define TWOFISH_TABLES 52 #ifndef LTC_NO_TABLES
52 /* #define TWOFISH_ALL_TABLES */ 53 #define TWOFISH_TABLES
54 /* #define TWOFISH_ALL_TABLES */
55 #else
56 #define TWOFISH_SMALL
57 #endif
53 /* #define TWOFISH_SMALL */ 58 /* #define TWOFISH_SMALL */
54 /* DES includes EDE triple-DES */ 59 /* DES includes EDE triple-DES */
55 #define DES 60 #define DES
56 #define CAST5 61 #define CAST5
57 #define NOEKEON 62 #define NOEKEON
59 #define SAFER 64 #define SAFER
60 #define KHAZAD 65 #define KHAZAD
61 #define ANUBIS 66 #define ANUBIS
62 #define ANUBIS_TWEAK 67 #define ANUBIS_TWEAK
63 68
69 #endif /* LTC_NO_CIPHERS */
70
64 71
65 /* ---> Block Cipher Modes of Operation <--- */ 72 /* ---> Block Cipher Modes of Operation <--- */
73 #ifndef LTC_NO_MODES
74
66 #define CFB 75 #define CFB
67 #define OFB 76 #define OFB
68 #define ECB 77 #define ECB
69 #define CBC 78 #define CBC
70 #define CTR 79 #define CTR
71 80
81 #endif /* LTC_NO_MODES */
82
72 /* ---> One-Way Hash Functions <--- */ 83 /* ---> One-Way Hash Functions <--- */
84 #ifndef LTC_NO_HASHES
85
73 #define CHC_HASH 86 #define CHC_HASH
74 #define WHIRLPOOL 87 #define WHIRLPOOL
75 #define SHA512 88 #define SHA512
76 #define SHA384 89 #define SHA384
77 #define SHA256 90 #define SHA256
82 #define MD4 95 #define MD4
83 #define MD2 96 #define MD2
84 #define RIPEMD128 97 #define RIPEMD128
85 #define RIPEMD160 98 #define RIPEMD160
86 99
100 #endif /* LTC_NO_HASHES */
101
87 /* ---> MAC functions <--- */ 102 /* ---> MAC functions <--- */
103 #ifndef LTC_NO_MACS
104
88 #define HMAC 105 #define HMAC
89 #define OMAC 106 #define OMAC
90 #define PMAC 107 #define PMAC
91 #define PELICAN 108 #define PELICAN
92 109
93 #if defined(PELICAN) && !defined(RIJNDAEL) 110 #if defined(PELICAN) && !defined(RIJNDAEL)
94 #error Pelican-MAC requires RIJNDAEL 111 #error Pelican-MAC requires RIJNDAEL
95 #endif 112 #endif
96 113
97 /* ---> Encrypt + Authenticate Modes <--- */ 114 /* ---> Encrypt + Authenticate Modes <--- */
115
98 #define EAX_MODE 116 #define EAX_MODE
99 #if defined(EAX_MODE) && !(defined(CTR) && defined(OMAC)) 117 #if defined(EAX_MODE) && !(defined(CTR) && defined(OMAC))
100 #error EAX_MODE requires CTR and OMAC mode 118 #error EAX_MODE requires CTR and OMAC mode
101 #endif 119 #endif
102 120
103 #define OCB_MODE 121 #define OCB_MODE
104 #define CCM_MODE 122 #define CCM_MODE
105 123
106 #define GCM_MODE 124 #define GCM_MODE
125
107 /* Use 64KiB tables */ 126 /* Use 64KiB tables */
108 #define GCM_TABLES 127 #ifndef LTC_NO_TABLES
128 #define GCM_TABLES
129 #endif
130
131 #endif /* LTC_NO_MACS */
109 132
110 /* Various tidbits of modern neatoness */ 133 /* Various tidbits of modern neatoness */
111 #define BASE64 134 #define BASE64
112 135
113 /* --> Pseudo Random Number Generators <--- */ 136 /* --> Pseudo Random Number Generators <--- */
137 #ifndef LTC_NO_PRNGS
138
114 /* Yarrow */ 139 /* Yarrow */
115 #define YARROW 140 #define YARROW
116 /* which descriptor of AES to use? */ 141 /* which descriptor of AES to use? */
117 /* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */ 142 /* 0 = rijndael_enc 1 = aes_enc, 2 = rijndael [full], 3 = aes [full] */
118 #define YARROW_AES 0 143 #define YARROW_AES 0
140 /* the *nix style /dev/random device */ 165 /* the *nix style /dev/random device */
141 #define DEVRANDOM 166 #define DEVRANDOM
142 /* try /dev/urandom before trying /dev/random */ 167 /* try /dev/urandom before trying /dev/random */
143 #define TRY_URANDOM_FIRST 168 #define TRY_URANDOM_FIRST
144 169
170 #endif /* LTC_NO_PRNGS */
171
145 /* ---> Public Key Crypto <--- */ 172 /* ---> Public Key Crypto <--- */
173 #ifndef LTC_NO_PK
174
146 #define MRSA 175 #define MRSA
147 176
148 /* Digital Signature Algorithm */ 177 /* Digital Signature Algorithm */
149 #define MDSA 178 #define MDSA
150 /* Max diff between group and modulus size in bytes */ 179 /* Max diff between group and modulus size in bytes */
166 #define DH4096 195 #define DH4096
167 196
168 /* ECC */ 197 /* ECC */
169 #define MECC 198 #define MECC
170 /* Supported Key Sizes */ 199 /* Supported Key Sizes */
171 #define ECC160
172 #define ECC192 200 #define ECC192
173 #define ECC224 201 #define ECC224
174 #define ECC256 202 #define ECC256
175 #define ECC384 203 #define ECC384
176 #define ECC521 204 #define ECC521
177 205
178 /* Include the MPI functionality? (required by the PK algorithms) */ 206 /* Include the MPI functionality? (required by the PK algorithms) */
179 #define MPI 207 #define MPI
180 208
209 #endif /* LTC_NO_PK */
210
181 /* PKCS #1 (RSA) and #5 (Password Handling) stuff */ 211 /* PKCS #1 (RSA) and #5 (Password Handling) stuff */
212 #ifndef LTC_NO_PKCS
213
182 #define PKCS_1 214 #define PKCS_1
183 #define PKCS_5 215 #define PKCS_5
184 216
185 /* Include ASN.1 DER (required by DSA/RSA) */ 217 /* Include ASN.1 DER (required by DSA/RSA) */
186 #define LTC_DER 218 #define LTC_DER
190 222
191 #if (defined(MDSA) || defined(MRSA)) && !defined(LTC_DER) 223 #if (defined(MDSA) || defined(MRSA)) && !defined(LTC_DER)
192 #error RSA/DSA requires ASN.1 DER functionality, make sure LTC_DER is enabled 224 #error RSA/DSA requires ASN.1 DER functionality, make sure LTC_DER is enabled
193 #endif 225 #endif
194 226
195 #endif 227 #endif /* LTC_NO_PKCS */
196 228
229 #endif
230
231
232 /* THREAD management */
233
234 #ifdef LTC_PTHREAD
235
236 #include <pthread.h>
237
238 #define LTC_MUTEX_GLOBAL(x) pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;
239 #define LTC_MUTEX_PROTO(x) extern pthread_mutex_t x;
240 #define LTC_MUTEX_LOCK(x) pthread_mutex_lock(x);
241 #define LTC_MUTEX_UNLOCK(x) pthread_mutex_unlock(x);
242
243 #else
244
245 /* default no functions */
246 #define LTC_MUTEX_GLOBAL(x)
247 #define LTC_MUTEX_PROTO(x)
248 #define LTC_MUTEX_LOCK(x)
249 #define LTC_MUTEX_UNLOCK(x)
250
251 #endif
252
253
254 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_custom.h,v $ */
255 /* $Revision: 1.17 $ */
256 /* $Date: 2005/06/19 18:00:28 $ */