Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Private header file of libSSL. |
michael@0 | 2 | * Various and sundry protocol constants. DON'T CHANGE THESE. These |
michael@0 | 3 | * values are defined by the SSL 3.0 protocol specification. |
michael@0 | 4 | * |
michael@0 | 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef __ssl3proto_h_ |
michael@0 | 10 | #define __ssl3proto_h_ |
michael@0 | 11 | |
michael@0 | 12 | typedef PRUint8 SSL3Opaque; |
michael@0 | 13 | |
michael@0 | 14 | typedef PRUint16 SSL3ProtocolVersion; |
michael@0 | 15 | /* version numbers are defined in sslproto.h */ |
michael@0 | 16 | |
michael@0 | 17 | typedef PRUint16 ssl3CipherSuite; |
michael@0 | 18 | /* The cipher suites are defined in sslproto.h */ |
michael@0 | 19 | |
michael@0 | 20 | #define MAX_CERT_TYPES 10 |
michael@0 | 21 | #define MAX_COMPRESSION_METHODS 10 |
michael@0 | 22 | #define MAX_MAC_LENGTH 64 |
michael@0 | 23 | #define MAX_PADDING_LENGTH 64 |
michael@0 | 24 | #define MAX_KEY_LENGTH 64 |
michael@0 | 25 | #define EXPORT_KEY_LENGTH 5 |
michael@0 | 26 | #define SSL3_RANDOM_LENGTH 32 |
michael@0 | 27 | |
michael@0 | 28 | #define SSL3_RECORD_HEADER_LENGTH 5 |
michael@0 | 29 | |
michael@0 | 30 | /* SSL3_RECORD_HEADER_LENGTH + epoch/sequence_number */ |
michael@0 | 31 | #define DTLS_RECORD_HEADER_LENGTH 13 |
michael@0 | 32 | |
michael@0 | 33 | #define MAX_FRAGMENT_LENGTH 16384 |
michael@0 | 34 | |
michael@0 | 35 | typedef enum { |
michael@0 | 36 | content_change_cipher_spec = 20, |
michael@0 | 37 | content_alert = 21, |
michael@0 | 38 | content_handshake = 22, |
michael@0 | 39 | content_application_data = 23 |
michael@0 | 40 | } SSL3ContentType; |
michael@0 | 41 | |
michael@0 | 42 | typedef struct { |
michael@0 | 43 | SSL3ContentType type; |
michael@0 | 44 | SSL3ProtocolVersion version; |
michael@0 | 45 | PRUint16 length; |
michael@0 | 46 | SECItem fragment; |
michael@0 | 47 | } SSL3Plaintext; |
michael@0 | 48 | |
michael@0 | 49 | typedef struct { |
michael@0 | 50 | SSL3ContentType type; |
michael@0 | 51 | SSL3ProtocolVersion version; |
michael@0 | 52 | PRUint16 length; |
michael@0 | 53 | SECItem fragment; |
michael@0 | 54 | } SSL3Compressed; |
michael@0 | 55 | |
michael@0 | 56 | typedef struct { |
michael@0 | 57 | SECItem content; |
michael@0 | 58 | SSL3Opaque MAC[MAX_MAC_LENGTH]; |
michael@0 | 59 | } SSL3GenericStreamCipher; |
michael@0 | 60 | |
michael@0 | 61 | typedef struct { |
michael@0 | 62 | SECItem content; |
michael@0 | 63 | SSL3Opaque MAC[MAX_MAC_LENGTH]; |
michael@0 | 64 | PRUint8 padding[MAX_PADDING_LENGTH]; |
michael@0 | 65 | PRUint8 padding_length; |
michael@0 | 66 | } SSL3GenericBlockCipher; |
michael@0 | 67 | |
michael@0 | 68 | typedef enum { change_cipher_spec_choice = 1 } SSL3ChangeCipherSpecChoice; |
michael@0 | 69 | |
michael@0 | 70 | typedef struct { |
michael@0 | 71 | SSL3ChangeCipherSpecChoice choice; |
michael@0 | 72 | } SSL3ChangeCipherSpec; |
michael@0 | 73 | |
michael@0 | 74 | typedef enum { alert_warning = 1, alert_fatal = 2 } SSL3AlertLevel; |
michael@0 | 75 | |
michael@0 | 76 | typedef enum { |
michael@0 | 77 | close_notify = 0, |
michael@0 | 78 | unexpected_message = 10, |
michael@0 | 79 | bad_record_mac = 20, |
michael@0 | 80 | decryption_failed_RESERVED = 21, /* do not send; see RFC 5246 */ |
michael@0 | 81 | record_overflow = 22, /* TLS only */ |
michael@0 | 82 | decompression_failure = 30, |
michael@0 | 83 | handshake_failure = 40, |
michael@0 | 84 | no_certificate = 41, /* SSL3 only, NOT TLS */ |
michael@0 | 85 | bad_certificate = 42, |
michael@0 | 86 | unsupported_certificate = 43, |
michael@0 | 87 | certificate_revoked = 44, |
michael@0 | 88 | certificate_expired = 45, |
michael@0 | 89 | certificate_unknown = 46, |
michael@0 | 90 | illegal_parameter = 47, |
michael@0 | 91 | |
michael@0 | 92 | /* All alerts below are TLS only. */ |
michael@0 | 93 | unknown_ca = 48, |
michael@0 | 94 | access_denied = 49, |
michael@0 | 95 | decode_error = 50, |
michael@0 | 96 | decrypt_error = 51, |
michael@0 | 97 | export_restriction = 60, |
michael@0 | 98 | protocol_version = 70, |
michael@0 | 99 | insufficient_security = 71, |
michael@0 | 100 | internal_error = 80, |
michael@0 | 101 | inappropriate_fallback = 86, /* could also be sent for SSLv3 */ |
michael@0 | 102 | user_canceled = 90, |
michael@0 | 103 | no_renegotiation = 100, |
michael@0 | 104 | |
michael@0 | 105 | /* Alerts for client hello extensions */ |
michael@0 | 106 | unsupported_extension = 110, |
michael@0 | 107 | certificate_unobtainable = 111, |
michael@0 | 108 | unrecognized_name = 112, |
michael@0 | 109 | bad_certificate_status_response = 113, |
michael@0 | 110 | bad_certificate_hash_value = 114, |
michael@0 | 111 | no_application_protocol = 120 |
michael@0 | 112 | |
michael@0 | 113 | } SSL3AlertDescription; |
michael@0 | 114 | |
michael@0 | 115 | typedef struct { |
michael@0 | 116 | SSL3AlertLevel level; |
michael@0 | 117 | SSL3AlertDescription description; |
michael@0 | 118 | } SSL3Alert; |
michael@0 | 119 | |
michael@0 | 120 | typedef enum { |
michael@0 | 121 | hello_request = 0, |
michael@0 | 122 | client_hello = 1, |
michael@0 | 123 | server_hello = 2, |
michael@0 | 124 | hello_verify_request = 3, |
michael@0 | 125 | new_session_ticket = 4, |
michael@0 | 126 | certificate = 11, |
michael@0 | 127 | server_key_exchange = 12, |
michael@0 | 128 | certificate_request = 13, |
michael@0 | 129 | server_hello_done = 14, |
michael@0 | 130 | certificate_verify = 15, |
michael@0 | 131 | client_key_exchange = 16, |
michael@0 | 132 | finished = 20, |
michael@0 | 133 | certificate_status = 22, |
michael@0 | 134 | next_proto = 67 |
michael@0 | 135 | } SSL3HandshakeType; |
michael@0 | 136 | |
michael@0 | 137 | typedef struct { |
michael@0 | 138 | PRUint8 empty; |
michael@0 | 139 | } SSL3HelloRequest; |
michael@0 | 140 | |
michael@0 | 141 | typedef struct { |
michael@0 | 142 | SSL3Opaque rand[SSL3_RANDOM_LENGTH]; |
michael@0 | 143 | } SSL3Random; |
michael@0 | 144 | |
michael@0 | 145 | typedef struct { |
michael@0 | 146 | SSL3Opaque id[32]; |
michael@0 | 147 | PRUint8 length; |
michael@0 | 148 | } SSL3SessionID; |
michael@0 | 149 | |
michael@0 | 150 | typedef struct { |
michael@0 | 151 | SSL3ProtocolVersion client_version; |
michael@0 | 152 | SSL3Random random; |
michael@0 | 153 | SSL3SessionID session_id; |
michael@0 | 154 | SECItem cipher_suites; |
michael@0 | 155 | PRUint8 cm_count; |
michael@0 | 156 | SSLCompressionMethod compression_methods[MAX_COMPRESSION_METHODS]; |
michael@0 | 157 | } SSL3ClientHello; |
michael@0 | 158 | |
michael@0 | 159 | typedef struct { |
michael@0 | 160 | SSL3ProtocolVersion server_version; |
michael@0 | 161 | SSL3Random random; |
michael@0 | 162 | SSL3SessionID session_id; |
michael@0 | 163 | ssl3CipherSuite cipher_suite; |
michael@0 | 164 | SSLCompressionMethod compression_method; |
michael@0 | 165 | } SSL3ServerHello; |
michael@0 | 166 | |
michael@0 | 167 | typedef struct { |
michael@0 | 168 | SECItem list; |
michael@0 | 169 | } SSL3Certificate; |
michael@0 | 170 | |
michael@0 | 171 | /* SSL3SignType moved to ssl.h */ |
michael@0 | 172 | |
michael@0 | 173 | /* The SSL key exchange method used */ |
michael@0 | 174 | typedef enum { |
michael@0 | 175 | kea_null, |
michael@0 | 176 | kea_rsa, |
michael@0 | 177 | kea_rsa_export, |
michael@0 | 178 | kea_rsa_export_1024, |
michael@0 | 179 | kea_dh_dss, |
michael@0 | 180 | kea_dh_dss_export, |
michael@0 | 181 | kea_dh_rsa, |
michael@0 | 182 | kea_dh_rsa_export, |
michael@0 | 183 | kea_dhe_dss, |
michael@0 | 184 | kea_dhe_dss_export, |
michael@0 | 185 | kea_dhe_rsa, |
michael@0 | 186 | kea_dhe_rsa_export, |
michael@0 | 187 | kea_dh_anon, |
michael@0 | 188 | kea_dh_anon_export, |
michael@0 | 189 | kea_rsa_fips, |
michael@0 | 190 | kea_ecdh_ecdsa, |
michael@0 | 191 | kea_ecdhe_ecdsa, |
michael@0 | 192 | kea_ecdh_rsa, |
michael@0 | 193 | kea_ecdhe_rsa, |
michael@0 | 194 | kea_ecdh_anon |
michael@0 | 195 | } SSL3KeyExchangeAlgorithm; |
michael@0 | 196 | |
michael@0 | 197 | typedef struct { |
michael@0 | 198 | SECItem modulus; |
michael@0 | 199 | SECItem exponent; |
michael@0 | 200 | } SSL3ServerRSAParams; |
michael@0 | 201 | |
michael@0 | 202 | typedef struct { |
michael@0 | 203 | SECItem p; |
michael@0 | 204 | SECItem g; |
michael@0 | 205 | SECItem Ys; |
michael@0 | 206 | } SSL3ServerDHParams; |
michael@0 | 207 | |
michael@0 | 208 | typedef struct { |
michael@0 | 209 | union { |
michael@0 | 210 | SSL3ServerDHParams dh; |
michael@0 | 211 | SSL3ServerRSAParams rsa; |
michael@0 | 212 | } u; |
michael@0 | 213 | } SSL3ServerParams; |
michael@0 | 214 | |
michael@0 | 215 | /* This enum reflects HashAlgorithm enum from |
michael@0 | 216 | * https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 |
michael@0 | 217 | * |
michael@0 | 218 | * When updating, be sure to also update ssl3_TLSHashAlgorithmToOID. */ |
michael@0 | 219 | enum { |
michael@0 | 220 | tls_hash_md5 = 1, |
michael@0 | 221 | tls_hash_sha1 = 2, |
michael@0 | 222 | tls_hash_sha224 = 3, |
michael@0 | 223 | tls_hash_sha256 = 4, |
michael@0 | 224 | tls_hash_sha384 = 5, |
michael@0 | 225 | tls_hash_sha512 = 6 |
michael@0 | 226 | }; |
michael@0 | 227 | |
michael@0 | 228 | /* This enum reflects SignatureAlgorithm enum from |
michael@0 | 229 | * https://tools.ietf.org/html/rfc5246#section-7.4.1.4.1 */ |
michael@0 | 230 | typedef enum { |
michael@0 | 231 | tls_sig_rsa = 1, |
michael@0 | 232 | tls_sig_dsa = 2, |
michael@0 | 233 | tls_sig_ecdsa = 3 |
michael@0 | 234 | } TLSSignatureAlgorithm; |
michael@0 | 235 | |
michael@0 | 236 | typedef struct { |
michael@0 | 237 | SECOidTag hashAlg; |
michael@0 | 238 | TLSSignatureAlgorithm sigAlg; |
michael@0 | 239 | } SSL3SignatureAndHashAlgorithm; |
michael@0 | 240 | |
michael@0 | 241 | /* SSL3HashesIndividually contains a combination MD5/SHA1 hash, as used in TLS |
michael@0 | 242 | * prior to 1.2. */ |
michael@0 | 243 | typedef struct { |
michael@0 | 244 | PRUint8 md5[16]; |
michael@0 | 245 | PRUint8 sha[20]; |
michael@0 | 246 | } SSL3HashesIndividually; |
michael@0 | 247 | |
michael@0 | 248 | /* SSL3Hashes contains an SSL hash value. The digest is contained in |u.raw| |
michael@0 | 249 | * which, if |hashAlg==SEC_OID_UNKNOWN| is also a SSL3HashesIndividually |
michael@0 | 250 | * struct. */ |
michael@0 | 251 | typedef struct { |
michael@0 | 252 | unsigned int len; |
michael@0 | 253 | SECOidTag hashAlg; |
michael@0 | 254 | union { |
michael@0 | 255 | PRUint8 raw[64]; |
michael@0 | 256 | SSL3HashesIndividually s; |
michael@0 | 257 | } u; |
michael@0 | 258 | } SSL3Hashes; |
michael@0 | 259 | |
michael@0 | 260 | typedef struct { |
michael@0 | 261 | union { |
michael@0 | 262 | SSL3Opaque anonymous; |
michael@0 | 263 | SSL3Hashes certified; |
michael@0 | 264 | } u; |
michael@0 | 265 | } SSL3ServerKeyExchange; |
michael@0 | 266 | |
michael@0 | 267 | typedef enum { |
michael@0 | 268 | ct_RSA_sign = 1, |
michael@0 | 269 | ct_DSS_sign = 2, |
michael@0 | 270 | ct_RSA_fixed_DH = 3, |
michael@0 | 271 | ct_DSS_fixed_DH = 4, |
michael@0 | 272 | ct_RSA_ephemeral_DH = 5, |
michael@0 | 273 | ct_DSS_ephemeral_DH = 6, |
michael@0 | 274 | ct_ECDSA_sign = 64, |
michael@0 | 275 | ct_RSA_fixed_ECDH = 65, |
michael@0 | 276 | ct_ECDSA_fixed_ECDH = 66 |
michael@0 | 277 | |
michael@0 | 278 | } SSL3ClientCertificateType; |
michael@0 | 279 | |
michael@0 | 280 | typedef SECItem *SSL3DistinquishedName; |
michael@0 | 281 | |
michael@0 | 282 | typedef struct { |
michael@0 | 283 | SSL3Opaque client_version[2]; |
michael@0 | 284 | SSL3Opaque random[46]; |
michael@0 | 285 | } SSL3RSAPreMasterSecret; |
michael@0 | 286 | |
michael@0 | 287 | typedef SECItem SSL3EncryptedPreMasterSecret; |
michael@0 | 288 | |
michael@0 | 289 | |
michael@0 | 290 | typedef SSL3Opaque SSL3MasterSecret[48]; |
michael@0 | 291 | |
michael@0 | 292 | typedef enum { implicit, explicit } SSL3PublicValueEncoding; |
michael@0 | 293 | |
michael@0 | 294 | typedef struct { |
michael@0 | 295 | union { |
michael@0 | 296 | SSL3Opaque implicit; |
michael@0 | 297 | SECItem explicit; |
michael@0 | 298 | } dh_public; |
michael@0 | 299 | } SSL3ClientDiffieHellmanPublic; |
michael@0 | 300 | |
michael@0 | 301 | typedef struct { |
michael@0 | 302 | union { |
michael@0 | 303 | SSL3EncryptedPreMasterSecret rsa; |
michael@0 | 304 | SSL3ClientDiffieHellmanPublic diffie_helman; |
michael@0 | 305 | } exchange_keys; |
michael@0 | 306 | } SSL3ClientKeyExchange; |
michael@0 | 307 | |
michael@0 | 308 | typedef SSL3Hashes SSL3PreSignedCertificateVerify; |
michael@0 | 309 | |
michael@0 | 310 | typedef SECItem SSL3CertificateVerify; |
michael@0 | 311 | |
michael@0 | 312 | typedef enum { |
michael@0 | 313 | sender_client = 0x434c4e54, |
michael@0 | 314 | sender_server = 0x53525652 |
michael@0 | 315 | } SSL3Sender; |
michael@0 | 316 | |
michael@0 | 317 | typedef SSL3HashesIndividually SSL3Finished; |
michael@0 | 318 | |
michael@0 | 319 | typedef struct { |
michael@0 | 320 | SSL3Opaque verify_data[12]; |
michael@0 | 321 | } TLSFinished; |
michael@0 | 322 | |
michael@0 | 323 | /* |
michael@0 | 324 | * TLS extension related data structures and constants. |
michael@0 | 325 | */ |
michael@0 | 326 | |
michael@0 | 327 | /* SessionTicket extension related data structures. */ |
michael@0 | 328 | |
michael@0 | 329 | /* NewSessionTicket handshake message. */ |
michael@0 | 330 | typedef struct { |
michael@0 | 331 | PRUint32 received_timestamp; |
michael@0 | 332 | PRUint32 ticket_lifetime_hint; |
michael@0 | 333 | SECItem ticket; |
michael@0 | 334 | } NewSessionTicket; |
michael@0 | 335 | |
michael@0 | 336 | typedef enum { |
michael@0 | 337 | CLIENT_AUTH_ANONYMOUS = 0, |
michael@0 | 338 | CLIENT_AUTH_CERTIFICATE = 1 |
michael@0 | 339 | } ClientAuthenticationType; |
michael@0 | 340 | |
michael@0 | 341 | typedef struct { |
michael@0 | 342 | ClientAuthenticationType client_auth_type; |
michael@0 | 343 | union { |
michael@0 | 344 | SSL3Opaque *certificate_list; |
michael@0 | 345 | } identity; |
michael@0 | 346 | } ClientIdentity; |
michael@0 | 347 | |
michael@0 | 348 | #define SESS_TICKET_KEY_NAME_LEN 16 |
michael@0 | 349 | #define SESS_TICKET_KEY_NAME_PREFIX "NSS!" |
michael@0 | 350 | #define SESS_TICKET_KEY_NAME_PREFIX_LEN 4 |
michael@0 | 351 | #define SESS_TICKET_KEY_VAR_NAME_LEN 12 |
michael@0 | 352 | |
michael@0 | 353 | typedef struct { |
michael@0 | 354 | unsigned char *key_name; |
michael@0 | 355 | unsigned char *iv; |
michael@0 | 356 | SECItem encrypted_state; |
michael@0 | 357 | unsigned char *mac; |
michael@0 | 358 | } EncryptedSessionTicket; |
michael@0 | 359 | |
michael@0 | 360 | #define TLS_EX_SESS_TICKET_MAC_LENGTH 32 |
michael@0 | 361 | |
michael@0 | 362 | #define TLS_STE_NO_SERVER_NAME -1 |
michael@0 | 363 | |
michael@0 | 364 | #endif /* __ssl3proto_h_ */ |