24 #ifndef yaSSL_TYPES_HPP
25 #define yaSSL_TYPES_HPP
28 #include "type_traits.hpp"
34 #pragma warning(disable:4244 4996)
41 #pragma warning(disable:4244 4996)
58 void*
operator new (size_t, yaSSL::new_t);
59 void*
operator new[](size_t, yaSSL::new_t);
61 void operator delete (
void*, yaSSL::new_t);
62 void operator delete[](
void*, yaSSL::new_t);
72 ::operator
delete(ptr, yaSSL::ys);
76 void ysArrayDelete(T* ptr)
82 (void)
sizeof(builtin);
84 ::operator
delete[](ptr, yaSSL::ys);
87 #define NEW_YS new (yaSSL::ys)
93 static void operator delete(
void*) { }
101 void ysDelete(T* ptr)
107 void ysArrayDelete(T* ptr)
118 #endif // YASSL_PURE_C
121 typedef unsigned char uint8;
122 typedef unsigned short uint16;
123 typedef unsigned int uint32;
124 typedef uint8 uint24[3];
125 typedef uint32 uint64[2];
127 typedef uint8 opaque;
130 typedef unsigned int uint;
135 #define STL_VECTOR_FILE <vector>
136 #define STL_LIST_FILE <list>
137 #define STL_ALGORITHM_FILE <algorithm>
138 #define STL_MEMORY_FILE <memory>
139 #define STL_PAIR_FILE <utility>
141 #define STL_NAMESPACE std
144 #define STL_VECTOR_FILE "vector.hpp"
145 #define STL_LIST_FILE "list.hpp"
146 #define STL_ALGORITHM_FILE "algorithm.hpp"
147 #define STL_MEMORY_FILE "memory.hpp"
148 #define STL_PAIR_FILE "pair.hpp"
150 #define STL_NAMESPACE mySTL
158 template <
typename T>
161 return a < b ? a : b;
167 const int ID_LEN = 32;
168 const int SUITE_LEN = 2;
169 const int SECRET_LEN = 48;
170 const int MASTER_ROUNDS = 3;
171 const int RAN_LEN = 32;
172 const int MAC_BLOCK_SZ = 64;
173 const int MD5_LEN = 16;
174 const int SHA_LEN = 20;
175 const int RMD_LEN = 20;
176 const int PREFIX = 3;
177 const int KEY_PREFIX = 7;
178 const int FORTEZZA_MAX = 128;
179 const int MAX_SUITE_SZ = 128;
180 const int MAX_SUITE_NAME = 48;
181 const int MAX_CIPHERS = 32;
182 const int SIZEOF_ENUM = 1;
183 const int SIZEOF_SENDER = 4;
184 const int PAD_MD5 = 48;
185 const int PAD_SHA = 40;
186 const int PAD_RMD = 44;
187 const int CERT_HEADER = 3;
188 const int CERT_TYPES = 7;
189 const int REQUEST_HEADER = 2;
190 const int VERIFY_HEADER = 2;
191 const int MIN_CERT_TYPES = 1;
192 const int MIN_DIS_NAMES = 3;
193 const int MIN_DIS_SIZE = 1;
194 const int RECORD_HEADER = 5;
195 const int HANDSHAKE_HEADER = 4;
196 const int FINISHED_SZ = MD5_LEN + SHA_LEN;
197 const int TLS_FINISHED_SZ = 12;
198 const int SEQ_SZ = 8;
199 const int LENGTH_SZ = 2;
200 const int VERSION_SZ = SIZEOF_ENUM * 2;
201 const int DES_KEY_SZ = 8;
202 const int DES_EDE_KEY_SZ = 24;
203 const int DES_BLOCK = 8;
204 const int DES_IV_SZ = DES_BLOCK;
205 const int RC4_KEY_SZ = 16;
206 const int AES_128_KEY_SZ = 16;
207 const int AES_192_KEY_SZ = 24;
208 const int AES_256_KEY_SZ = 32;
209 const int AES_BLOCK_SZ = 16;
210 const int AES_IV_SZ = AES_BLOCK_SZ;
211 const int DSS_SIG_SZ = 40;
212 const int DSS_ENCODED_EXTRA = 6;
213 const int EVP_SALT_SZ = 8;
214 const int MASTER_LABEL_SZ = 13;
215 const int KEY_LABEL_SZ = 13;
216 const int FINISHED_LABEL_SZ = 15;
217 const int SEED_LEN = RAN_LEN * 2;
218 const int DEFAULT_TIMEOUT = 500;
219 const int MAX_RECORD_SIZE = 16384;
220 const int COMPRESS_EXTRA = 1024;
221 const int SESSION_FLUSH_COUNT = 256;
222 const int MAX_PAD_SIZE = 256;
223 const int COMPRESS_CONSTANT = 13;
224 const int COMPRESS_UPPER = 55;
225 const int COMPRESS_LOWER = 64;
226 const int COMPRESS_DUMMY_SIZE = 64;
228 typedef uint8 Cipher;
230 typedef opaque Random[RAN_LEN];
232 typedef opaque* DistinguishedName;
234 typedef bool IsExportable;
237 enum CompressionMethod { no_compression = 0, zlib = 221 };
239 enum CipherType { stream,
block };
241 enum CipherChoice { change_cipher_spec_choice = 1 };
243 enum PublicValueEncoding { implicit_encoding, explicit_encoding };
245 enum ConnectionEnd { server_end, client_end };
247 enum AlertLevel { warning = 1, fatal = 2 };
254 change_cipher_spec = 20,
257 application_data = 23
268 server_key_exchange = 12,
269 certificate_request = 13,
270 server_hello_done = 14,
271 certificate_verify = 15,
272 client_key_exchange = 16,
278 enum AlertDescription {
280 unexpected_message = 10,
282 decompression_failure = 30,
283 handshake_failure = 40,
285 bad_certificate = 42,
286 unsupported_certificate = 43,
287 certificate_revoked = 44,
288 certificate_expired = 45,
289 certificate_unknown = 46,
290 illegal_parameter = 47
295 enum KeyExchangeAlgorithm {
304 enum SignatureAlgorithm {
305 anonymous_sa_algo = 0,
312 enum ClientCertificateType {
317 rsa_ephemeral_dh = 5,
318 dss_ephemeral_dh = 6,
319 fortezza_kea_cert = 20
324 enum BulkCipherAlgorithm {
346 enum CertType { Cert = 0, PrivateKey, CA };
350 const Cipher SSL_NULL_WITH_NULL_NULL = 0;
351 const Cipher SSL_RSA_WITH_NULL_MD5 = 1;
352 const Cipher SSL_RSA_WITH_NULL_SHA = 2;
353 const Cipher SSL_RSA_EXPORT_WITH_RC4_40_MD5 = 3;
354 const Cipher SSL_RSA_WITH_RC4_128_MD5 = 4;
355 const Cipher SSL_RSA_WITH_RC4_128_SHA = 5;
356 const Cipher SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5 = 6;
357 const Cipher SSL_RSA_WITH_IDEA_CBC_SHA = 7;
358 const Cipher SSL_RSA_EXPORT_WITH_DES40_CBC_SHA = 8;
359 const Cipher SSL_RSA_WITH_DES_CBC_SHA = 9;
360 const Cipher SSL_RSA_WITH_3DES_EDE_CBC_SHA = 10;
361 const Cipher SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA = 11;
362 const Cipher SSL_DH_DSS_WITH_DES_CBC_SHA = 12;
363 const Cipher SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA = 13;
364 const Cipher SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA = 14;
365 const Cipher SSL_DH_RSA_WITH_DES_CBC_SHA = 15;
366 const Cipher SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA = 16;
367 const Cipher SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA = 17;
368 const Cipher SSL_DHE_DSS_WITH_DES_CBC_SHA = 18;
369 const Cipher SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA = 19;
370 const Cipher SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA = 20;
371 const Cipher SSL_DHE_RSA_WITH_DES_CBC_SHA = 21;
372 const Cipher SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA = 22;
373 const Cipher SSL_DH_anon_EXPORT_WITH_RC4_40_MD5 = 23;
374 const Cipher SSL_DH_anon_WITH_RC4_128_MD5 = 24;
375 const Cipher SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA = 25;
376 const Cipher SSL_DH_anon_WITH_DES_CBC_SHA = 26;
377 const Cipher SSL_DH_anon_WITH_3DES_EDE_CBC_SHA = 27;
378 const Cipher SSL_FORTEZZA_KEA_WITH_NULL_SHA = 28;
379 const Cipher SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 29;
380 const Cipher SSL_FORTEZZA_KEA_WITH_RC4_128_SHA = 30;
386 const Cipher TLS_RSA_WITH_AES_128_CBC_SHA = 47;
387 const Cipher TLS_DH_DSS_WITH_AES_128_CBC_SHA = 48;
388 const Cipher TLS_DH_RSA_WITH_AES_128_CBC_SHA = 49;
389 const Cipher TLS_DHE_DSS_WITH_AES_128_CBC_SHA = 50;
390 const Cipher TLS_DHE_RSA_WITH_AES_128_CBC_SHA = 51;
391 const Cipher TLS_DH_anon_WITH_AES_128_CBC_SHA = 52;
393 const Cipher TLS_RSA_WITH_AES_256_CBC_SHA = 53;
394 const Cipher TLS_DH_DSS_WITH_AES_256_CBC_SHA = 54;
395 const Cipher TLS_DH_RSA_WITH_AES_256_CBC_SHA = 55;
396 const Cipher TLS_DHE_DSS_WITH_AES_256_CBC_SHA = 56;
397 const Cipher TLS_DHE_RSA_WITH_AES_256_CBC_SHA = 57;
398 const Cipher TLS_DH_anon_WITH_AES_256_CBC_SHA = 58;
403 const Cipher TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 = 114;
404 const Cipher TLS_DHE_DSS_WITH_AES_128_CBC_RMD160 = 115;
405 const Cipher TLS_DHE_DSS_WITH_AES_256_CBC_RMD160 = 116;
406 const Cipher TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 = 119;
407 const Cipher TLS_DHE_RSA_WITH_AES_128_CBC_RMD160 = 120;
408 const Cipher TLS_DHE_RSA_WITH_AES_256_CBC_RMD160 = 121;
409 const Cipher TLS_RSA_WITH_3DES_EDE_CBC_RMD160 = 124;
410 const Cipher TLS_RSA_WITH_AES_128_CBC_RMD160 = 125;
411 const Cipher TLS_RSA_WITH_AES_256_CBC_RMD160 = 126;
414 const char*
const null_str =
"";
416 const char*
const cipher_names[128] =
437 "EDH-DSS-DES-CBC-SHA",
438 "EDH-DSS-DES-CBC3-SHA",
441 "EDH-RSA-DES-CBC-SHA",
442 "EDH-RSA-DES-CBC3-SHA",
452 null_str, null_str, null_str, null_str, null_str,
453 null_str, null_str, null_str, null_str, null_str,
454 null_str, null_str, null_str, null_str, null_str,
461 "DHE-DSS-AES128-SHA",
462 "DHE-RSA-AES128-SHA",
468 "DHE-DSS-AES256-SHA",
469 "DHE-RSA-AES256-SHA",
474 null_str, null_str, null_str, null_str, null_str,
475 null_str, null_str, null_str, null_str, null_str,
476 null_str, null_str, null_str, null_str, null_str,
477 null_str, null_str, null_str, null_str, null_str,
478 null_str, null_str, null_str, null_str, null_str,
479 null_str, null_str, null_str, null_str, null_str,
480 null_str, null_str, null_str, null_str, null_str,
481 null_str, null_str, null_str, null_str, null_str,
482 null_str, null_str, null_str, null_str, null_str,
483 null_str, null_str, null_str, null_str, null_str,
484 null_str, null_str, null_str,
486 "DHE-DSS-DES-CBC3-RMD",
487 "DHE-DSS-AES128-RMD",
488 "DHE-DSS-AES256-RMD",
491 "DHE-RSA-DES-CBC3-RMD",
492 "DHE-RSA-AES128-RMD",
493 "DHE-RSA-AES256-RMD",
503 const opaque PAD1[PAD_MD5] = { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
504 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
505 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
506 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
507 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,
508 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36
510 const opaque PAD2[PAD_MD5] = { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
511 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
512 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
513 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
514 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,
515 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c
518 const opaque client[SIZEOF_SENDER] = { 0x43, 0x4C, 0x4E, 0x54 };
519 const opaque server[SIZEOF_SENDER] = { 0x53, 0x52, 0x56, 0x52 };
521 const opaque tls_client[FINISHED_LABEL_SZ + 1] =
"client finished";
522 const opaque tls_server[FINISHED_LABEL_SZ + 1] =
"server finished";
524 const opaque master_label[MASTER_LABEL_SZ + 1] =
"master secret";
525 const opaque key_label [KEY_LABEL_SZ + 1] =
"key expansion";
530 #if __GNUC__ == 2 && __GNUC_MINOR__ <= 96
540 #endif // yaSSL_TYPES_HPP