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