Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / net / quic / crypto / crypto_protocol.h
blobb6340843c53ca9ebc9e9f6c82a68e8db57859d56
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_
6 #define NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_
8 #include <string>
10 #include "net/base/net_export.h"
11 #include "net/quic/quic_protocol.h"
13 // Version and Crypto tags are written to the wire with a big-endian
14 // representation of the name of the tag. For example
15 // the client hello tag (CHLO) will be written as the
16 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is
17 // stored in memory as a little endian uint32, we need
18 // to reverse the order of the bytes.
20 // We use a macro to ensure that no static initialisers are created. Use the
21 // MakeQuicTag function in normal code.
22 #define TAG(a, b, c, d) ((d << 24) + (c << 16) + (b << 8) + a)
24 namespace net {
26 typedef std::string ServerConfigID;
28 const QuicTag kCHLO = TAG('C', 'H', 'L', 'O'); // Client hello
29 const QuicTag kSHLO = TAG('S', 'H', 'L', 'O'); // Server hello
30 const QuicTag kSCFG = TAG('S', 'C', 'F', 'G'); // Server config
31 const QuicTag kREJ = TAG('R', 'E', 'J', '\0'); // Reject
32 const QuicTag kCETV = TAG('C', 'E', 'T', 'V'); // Client encrypted tag-value
33 // pairs
34 const QuicTag kPRST = TAG('P', 'R', 'S', 'T'); // Public reset
36 // Key exchange methods
37 const QuicTag kP256 = TAG('P', '2', '5', '6'); // ECDH, Curve P-256
38 const QuicTag kC255 = TAG('C', '2', '5', '5'); // ECDH, Curve25519
40 // AEAD algorithms
41 const QuicTag kNULL = TAG('N', 'U', 'L', 'N'); // null algorithm
42 const QuicTag kAESG = TAG('A', 'E', 'S', 'G'); // AES128 + GCM-12
43 const QuicTag kCC12 = TAG('C', 'C', '1', '2'); // ChaCha20 + Poly1305
45 // Congestion control feedback types
46 const QuicTag kQBIC = TAG('Q', 'B', 'I', 'C'); // TCP cubic
47 const QuicTag kPACE = TAG('P', 'A', 'C', 'E'); // Paced TCP cubic
48 const QuicTag kINAR = TAG('I', 'N', 'A', 'R'); // Inter arrival
50 // Proof types (i.e. certificate types)
51 // NOTE: although it would be silly to do so, specifying both kX509 and kX59R
52 // is allowed and is equivalent to specifying only kX509.
53 const QuicTag kX509 = TAG('X', '5', '0', '9'); // X.509 certificate, all key
54 // types
55 const QuicTag kX59R = TAG('X', '5', '9', 'R'); // X.509 certificate, RSA keys
56 // only
57 const QuicTag kCHID = TAG('C', 'H', 'I', 'D'); // Channel ID.
59 // Client hello tags
60 const QuicTag kVER = TAG('V', 'E', 'R', '\0'); // Version (new)
61 const QuicTag kNONC = TAG('N', 'O', 'N', 'C'); // The client's nonce
62 const QuicTag kKEXS = TAG('K', 'E', 'X', 'S'); // Key exchange methods
63 const QuicTag kAEAD = TAG('A', 'E', 'A', 'D'); // Authenticated
64 // encryption algorithms
65 const QuicTag kCGST = TAG('C', 'G', 'S', 'T'); // Congestion control
66 // feedback types
67 const QuicTag kICSL = TAG('I', 'C', 'S', 'L'); // Idle connection state
68 // lifetime
69 const QuicTag kKATO = TAG('K', 'A', 'T', 'O'); // Keepalive timeout
70 const QuicTag kMSPC = TAG('M', 'S', 'P', 'C'); // Max streams per connection.
71 const QuicTag kIRTT = TAG('I', 'R', 'T', 'T'); // Estimated initial RTT in us.
72 const QuicTag kSWND = TAG('S', 'W', 'N', 'D'); // Server's Initial congestion
73 // window.
74 const QuicTag kSNI = TAG('S', 'N', 'I', '\0'); // Server name
75 // indication
76 const QuicTag kPUBS = TAG('P', 'U', 'B', 'S'); // Public key values
77 const QuicTag kSCID = TAG('S', 'C', 'I', 'D'); // Server config id
78 const QuicTag kORBT = TAG('O', 'B', 'I', 'T'); // Server orbit.
79 const QuicTag kPDMD = TAG('P', 'D', 'M', 'D'); // Proof demand.
80 const QuicTag kPROF = TAG('P', 'R', 'O', 'F'); // Proof (signature).
81 const QuicTag kCCS = TAG('C', 'C', 'S', 0); // Common certificate set
82 const QuicTag kCCRT = TAG('C', 'C', 'R', 'T'); // Cached certificate
83 const QuicTag kEXPY = TAG('E', 'X', 'P', 'Y'); // Expiry
84 const QuicTag kIFCW = TAG('I', 'F', 'C', 'W'); // Initial flow control receive
85 // window.
87 // Server hello tags
88 const QuicTag kCADR = TAG('C', 'A', 'D', 'R'); // Client IP address and port
90 // CETV tags
91 const QuicTag kCIDK = TAG('C', 'I', 'D', 'K'); // ChannelID key
92 const QuicTag kCIDS = TAG('C', 'I', 'D', 'S'); // ChannelID signature
94 // Public reset tags
95 const QuicTag kRNON = TAG('R', 'N', 'O', 'N'); // Public reset nonce proof
96 const QuicTag kRSEQ = TAG('R', 'S', 'E', 'Q'); // Rejected sequence number
98 // Universal tags
99 const QuicTag kPAD = TAG('P', 'A', 'D', '\0'); // Padding
101 // These tags have a special form so that they appear either at the beginning
102 // or the end of a handshake message. Since handshake messages are sorted by
103 // tag value, the tags with 0 at the end will sort first and those with 255 at
104 // the end will sort last.
106 // The certificate chain should have a tag that will cause it to be sorted at
107 // the end of any handshake messages because it's likely to be large and the
108 // client might be able to get everything that it needs from the small values at
109 // the beginning.
111 // Likewise tags with random values should be towards the beginning of the
112 // message because the server mightn't hold state for a rejected client hello
113 // and therefore the client may have issues reassembling the rejection message
114 // in the event that it sent two client hellos.
115 const QuicTag kServerNonceTag =
116 TAG('S', 'N', 'O', 0); // The server's nonce
117 const QuicTag kSourceAddressTokenTag =
118 TAG('S', 'T', 'K', 0); // Source-address token
119 const QuicTag kCertificateTag =
120 TAG('C', 'R', 'T', 255); // Certificate chain
122 #undef TAG
124 const size_t kMaxEntries = 128; // Max number of entries in a message.
126 const size_t kNonceSize = 32; // Size in bytes of the connection nonce.
128 const size_t kOrbitSize = 8; // Number of bytes in an orbit value.
130 // kProofSignatureLabel is prepended to server configs before signing to avoid
131 // any cross-protocol attacks on the signature.
132 const char kProofSignatureLabel[] = "QUIC server config signature";
134 // kClientHelloMinimumSize is the minimum size of a client hello. Client hellos
135 // will have PAD tags added in order to ensure this minimum is met and client
136 // hellos smaller than this will be an error. This minimum size reduces the
137 // amplification factor of any mirror DoS attack.
139 // A client may pad an inchoate client hello to a size larger than
140 // kClientHelloMinimumSize to make it more likely to receive a complete
141 // rejection message.
142 const size_t kClientHelloMinimumSize = 1024;
144 } // namespace net
146 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_