OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ | 5 #ifndef NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ |
6 #define NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ | 6 #define NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/string_piece.h" | |
14 #include "net/base/net_export.h" | 14 #include "net/base/net_export.h" |
15 | 15 |
16 namespace net { | 16 namespace net { |
17 | 17 |
18 typedef uint32 CryptoTag; | 18 typedef uint32 CryptoTag; |
19 typedef std::map<CryptoTag, base::StringPiece> CryptoTagValueMap; | 19 typedef std::map<CryptoTag, std::string> CryptoTagValueMap; |
20 typedef std::vector<CryptoTag> CryptoTagVector; | 20 typedef std::vector<CryptoTag> CryptoTagVector; |
21 struct NET_EXPORT_PRIVATE CryptoHandshakeMessage { | 21 struct NET_EXPORT_PRIVATE CryptoHandshakeMessage { |
22 CryptoHandshakeMessage(); | 22 CryptoHandshakeMessage(); |
23 ~CryptoHandshakeMessage(); | 23 ~CryptoHandshakeMessage(); |
24 CryptoTag tag; | 24 CryptoTag tag; |
25 CryptoTagValueMap tag_value_map; | 25 CryptoTagValueMap tag_value_map; |
26 }; | 26 }; |
27 | 27 |
28 // Crypto tags are written to the wire with a big-endian | 28 // Crypto tags are written to the wire with a big-endian |
29 // representation of the name of the tag. For example | 29 // representation of the name of the tag. For example |
30 // the client hello tag (CHLO) will be written as the | 30 // the client hello tag (CHLO) will be written as the |
31 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is | 31 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is |
32 // stored in memory as a little endian uint32, we need | 32 // stored in memory as a little endian uint32, we need |
33 // to reverse the order of the bytes. | 33 // to reverse the order of the bytes. |
34 #define MAKE_TAG(a, b, c, d) (d << 24) + (c << 16) + (b << 8) + a | 34 #define MAKE_TAG(a, b, c, d) (d << 24) + (c << 16) + (b << 8) + a |
35 | 35 |
36 const CryptoTag kCHLO = MAKE_TAG('C', 'H', 'L', 'O'); // Client hello | 36 const CryptoTag kCHLO = MAKE_TAG('C', 'H', 'L', 'O'); // Client hello |
37 const CryptoTag kSHLO = MAKE_TAG('S', 'H', 'L', 'O'); // Server hello | 37 const CryptoTag kSHLO = MAKE_TAG('S', 'H', 'L', 'O'); // Server hello |
38 | 38 |
| 39 // Key exchange methods |
| 40 const CryptoTag kP256 = MAKE_TAG('P', '2', '5', '6'); // ECDH, Curve P-256 |
| 41 const CryptoTag kC255 = MAKE_TAG('C', '2', '5', '5'); // ECDH, Curve25519 |
| 42 |
39 // AEAD algorithms | 43 // AEAD algorithms |
40 const CryptoTag kNULL = MAKE_TAG('N', 'U', 'L', 'L'); // null algorithm | 44 const CryptoTag kNULL = MAKE_TAG('N', 'U', 'L', 'L'); // null algorithm |
41 const CryptoTag kAESH = MAKE_TAG('A', 'E', 'S', 'H'); // AES128 + SHA256 | 45 const CryptoTag kAESH = MAKE_TAG('A', 'E', 'S', 'H'); // AES128 + SHA256 |
| 46 const CryptoTag kAESG = MAKE_TAG('A', 'E', 'S', 'G'); // AES128 + GCM |
| 47 |
| 48 // Congestion control feedback types |
| 49 const CryptoTag kQBIC = MAKE_TAG('Q', 'B', 'I', 'C'); // TCP cubic |
| 50 const CryptoTag kINAR = MAKE_TAG('I', 'N', 'A', 'R'); // Inter arrival |
| 51 |
| 52 // Client hello tags |
| 53 const CryptoTag kVERS = MAKE_TAG('V', 'E', 'R', 'S'); // Version |
| 54 const CryptoTag kNONC = MAKE_TAG('N', 'O', 'N', 'C'); // The connection nonce |
| 55 const CryptoTag kSSID = MAKE_TAG('S', 'S', 'I', 'D'); // Session ID |
| 56 const CryptoTag kKEXS = MAKE_TAG('K', 'E', 'X', 'S'); // Key exchange methods |
| 57 const CryptoTag kAEAD = MAKE_TAG('A', 'E', 'A', 'D'); // Authenticated |
| 58 // encryption algorithms |
| 59 const CryptoTag kCGST = MAKE_TAG('C', 'G', 'S', 'T'); // Congestion control |
| 60 // feedback types |
| 61 const CryptoTag kICSL = MAKE_TAG('I', 'C', 'S', 'L'); // Idle connection state |
| 62 // lifetime |
| 63 const CryptoTag kKATO = MAKE_TAG('K', 'A', 'T', 'O'); // Keepalive timeout |
| 64 const CryptoTag kSNI = MAKE_TAG('S', 'N', 'I', '\0'); // Server name |
| 65 // indication |
| 66 const CryptoTag kPUBS = MAKE_TAG('P', 'U', 'B', 'S'); // Public key values |
42 | 67 |
43 const size_t kMaxEntries = 16; // Max number of entries in a message. | 68 const size_t kMaxEntries = 16; // Max number of entries in a message. |
44 | 69 |
| 70 const size_t kNonceSize = 32; // Size in bytes of the connection nonce. |
| 71 |
45 } // namespace net | 72 } // namespace net |
46 | 73 |
47 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ | 74 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ |
OLD | NEW |