📄 yassl_types.hpp
字号:
/* yassl_types.hpp * * Copyright (C) 2003 Sawtooth Consulting Ltd. * * This file is part of yaSSL. * * yaSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * yaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *//* yaSSL types header defines all constants, enums, and typedefs * from the SSL.v3 specification "draft-freier-ssl-version3-02.txt" */#ifndef yaSSL_TYPES_HPP#define yaSSL_TYPES_HPP#include <stddef.h>#include <assert.h>#include "type_traits.hpp"namespace yaSSL {// Delete static singleton memory holdersvoid CleanUp();// library allocationstruct new_t {}; // yaSSL New typeextern new_t ys; // pass in parameter} // namespace yaSSLvoid* operator new (size_t, yaSSL::new_t);void* operator new[](size_t, yaSSL::new_t);void operator delete (void*, yaSSL::new_t);void operator delete[](void*, yaSSL::new_t);namespace yaSSL {template<typename T>void ysDelete(T* ptr){ if (ptr) ptr->~T(); ::operator delete(ptr, yaSSL::ys);}template<typename T>void ysArrayDelete(T* ptr){ // can't do array placement destruction since not tracking size in // allocation, only allow builtins to use array placement since they // don't need destructors called typedef char builtin[TaoCrypt::IsFundamentalType<T>::Yes ? 1 : -1]; (void)sizeof(builtin); ::operator delete[](ptr, yaSSL::ys);}// to resolve compiler generated operator delete on base classes with// virtual destructors (when on stack), make sure doesn't get calledclass virtual_base {public: static void operator delete(void*) { assert(0); }};typedef unsigned char uint8;typedef unsigned short uint16;typedef unsigned int uint32;typedef uint8 uint24[3];typedef uint32 uint64[2];typedef uint8 opaque;typedef opaque byte;typedef unsigned int uint; // all length constants in bytesconst int ID_LEN = 32; // session id lengthconst int SUITE_LEN = 2; // cipher suite lengthconst int SECRET_LEN = 48; // pre RSA and all master secret lengthconst int MASTER_ROUNDS = 3; // master secret derivation roundsconst int RAN_LEN = 32; // client and server random lengthconst int MAC_BLOCK_SZ = 64; // MAC block size, & paddingconst int MD5_LEN = 16; // MD5 digest lengthconst int SHA_LEN = 20; // SHA digest lengthconst int RMD_LEN = 20; // RIPEMD-160 digest lengthconst int PREFIX = 3; // up to 3 prefix letters for secret roundsconst int KEY_PREFIX = 7; // up to 7 prefix letters for key roundsconst int FORTEZZA_MAX = 128; // Maximum Fortezza Key lengthconst int MAX_SUITE_SZ = 64; // 32 max suites * sizeof(suite)const int MAX_SUITE_NAME = 48; // max length of suite nameconst int MAX_CIPHER_LIST = 512; // max length of cipher list namesconst int SIZEOF_ENUM = 1; // SSL considers an enum 1 byte, not 4const int SIZEOF_SENDER = 4; // Sender constant, for finished generationconst int PAD_MD5 = 48; // pad length 1 and 2 for md5 finishedconst int PAD_SHA = 40; // should be 44, specd wrong by netscapeconst int PAD_RMD = 44; // pad length for RIPEMD-160, some use 40??const int CERT_HEADER = 3; // always use 3 bytes for certificateconst int CERT_TYPES = 7; // certificate request typesconst int REQUEST_HEADER = 2; // request uses 2 bytesconst int VERIFY_HEADER = 2; // verify length fieldconst int MIN_CERT_TYPES = 1; // minimum certificate request typesconst int MIN_DIS_NAMES = 3; // minimum distinguished namesconst int MIN_DIS_SIZE = 1; // minimum distinguished name sizeconst int RECORD_HEADER = 5; // type + version + length(2)const int HANDSHAKE_HEADER = 4; // type + length(3)const int FINISHED_SZ = MD5_LEN + SHA_LEN; // sizeof finished dataconst int TLS_FINISHED_SZ = 12; // TLS verify data sizeconst int SEQ_SZ = 8; // 64 bit sequence numberconst int LENGTH_SZ = 2; // length field for HMAC, data onlyconst int VERSION_SZ = SIZEOF_ENUM * 2; // SSL/TLS length of versionconst int DES_KEY_SZ = 8; // DES Key lengthconst int DES_EDE_KEY_SZ = 24; // DES EDE Key lengthconst int DES_BLOCK = 8; // DES is always fixed block size 8const int DES_IV_SZ = DES_BLOCK; // Init Vector length for DESconst int RC4_KEY_SZ = 16; // RC4 Key lengthconst int AES_128_KEY_SZ = 16; // AES 128bit Key lengthconst int AES_256_KEY_SZ = 32; // AES 256bit Key lengthconst int AES_BLOCK_SZ = 16; // AES 128bit block size, rfc 3268const int AES_IV_SZ = AES_BLOCK_SZ; // AES Init Vector lengthconst int DSS_SIG_SZ = 40; // two 20 byte high byte first Integersconst int DSS_ENCODED_EXTRA = 6; // seqID + len(1) + (intID + len(1)) * 2const int EVP_SALT_SZ = 8;const int MASTER_LABEL_SZ = 13; // TLS master secret label sizeconst int KEY_LABEL_SZ = 13; // TLS key block expansion sizeconst int FINISHED_LABEL_SZ = 15; // TLS finished lable lengthconst int SEED_LEN = RAN_LEN * 2; // TLS seed, client + server randomconst int DEFAULT_TIMEOUT = 500; // Default Session timeout in secondsconst int MAX_RECORD_SIZE = 16384; // 2^14, max size by standardtypedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLStypedef opaque Random[RAN_LEN];typedef opaque* DistinguishedName;typedef bool IsExportable;enum CompressionMethod { no_compression = 0 };enum CipherType { stream, block };enum CipherChoice { change_cipher_spec_choice = 1 };enum PublicValueEncoding { implicit_encoding, explicit_encoding };enum ConnectionEnd { server_end, client_end };enum AlertLevel { warning = 1, fatal = 2 };// Record Layer Header identifier from page 12enum ContentType { no_type = 0, change_cipher_spec = 20, alert = 21, handshake = 22, application_data = 23 };// HandShake Layer Header identifier from page 20enum HandShakeType { no_shake = -1, hello_request = 0, client_hello = 1, server_hello = 2, certificate = 11, server_key_exchange = 12, certificate_request = 13, server_hello_done = 14, certificate_verify = 15, client_key_exchange = 16, finished = 20};// Valid Alert types from page 16/17enum AlertDescription { close_notify = 0, unexpected_message = 10, bad_record_mac = 20, decompression_failure = 30, handshake_failure = 40, no_certificate = 41, bad_certificate = 42, unsupported_certificate = 43, certificate_revoked = 44, certificate_expired = 45, certificate_unknown = 46, illegal_parameter = 47};// Supported Key Exchange Protocolsenum KeyExchangeAlgorithm { no_kea = 0, rsa_kea, diffie_hellman_kea, fortezza_kea };// Supported Authentication Schemesenum SignatureAlgorithm { anonymous_sa_algo = 0, rsa_sa_algo, dsa_sa_algo };
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -