| 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 #include "net/quic/quic_time.h" |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 typedef uint32 CryptoTag; | 19 typedef uint32 CryptoTag; |
| 19 typedef std::map<CryptoTag, base::StringPiece> CryptoTagValueMap; | 20 typedef std::map<CryptoTag, std::string> CryptoTagValueMap; |
| 20 typedef std::vector<CryptoTag> CryptoTagVector; | 21 typedef std::vector<CryptoTag> CryptoTagVector; |
| 21 struct NET_EXPORT_PRIVATE CryptoHandshakeMessage { | 22 struct NET_EXPORT_PRIVATE CryptoHandshakeMessage { |
| 22 CryptoHandshakeMessage(); | 23 CryptoHandshakeMessage(); |
| 23 ~CryptoHandshakeMessage(); | 24 ~CryptoHandshakeMessage(); |
| 24 CryptoTag tag; | 25 CryptoTag tag; |
| 25 CryptoTagValueMap tag_value_map; | 26 CryptoTagValueMap tag_value_map; |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 // Crypto tags are written to the wire with a big-endian | 29 // Crypto tags are written to the wire with a big-endian |
| 29 // representation of the name of the tag. For example | 30 // representation of the name of the tag. For example |
| 30 // the client hello tag (CHLO) will be written as the | 31 // the client hello tag (CHLO) will be written as the |
| 31 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is | 32 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is |
| 32 // stored in memory as a little endian uint32, we need | 33 // stored in memory as a little endian uint32, we need |
| 33 // to reverse the order of the bytes. | 34 // to reverse the order of the bytes. |
| 34 #define MAKE_TAG(a, b, c, d) (d << 24) + (c << 16) + (b << 8) + a | 35 #define MAKE_TAG(a, b, c, d) (d << 24) + (c << 16) + (b << 8) + a |
| 35 | 36 |
| 36 const CryptoTag kCHLO = MAKE_TAG('C', 'H', 'L', 'O'); // Client hello | 37 const CryptoTag kCHLO = MAKE_TAG('C', 'H', 'L', 'O'); // Client hello |
| 37 const CryptoTag kSHLO = MAKE_TAG('S', 'H', 'L', 'O'); // Server hello | 38 const CryptoTag kSHLO = MAKE_TAG('S', 'H', 'L', 'O'); // Server hello |
| 38 | 39 |
| 40 // Key exchange methods |
| 41 const CryptoTag kP256 = MAKE_TAG('P', '2', '5', '6'); // ECDH, Curve P-256 |
| 42 const CryptoTag kC255 = MAKE_TAG('C', '2', '5', '5'); // ECDH, Curve25519 |
| 43 |
| 39 // AEAD algorithms | 44 // AEAD algorithms |
| 40 const CryptoTag kNULL = MAKE_TAG('N', 'U', 'L', 'L'); // null algorithm | 45 const CryptoTag kNULL = MAKE_TAG('N', 'U', 'L', 'L'); // null algorithm |
| 41 const CryptoTag kAESH = MAKE_TAG('A', 'E', 'S', 'H'); // AES128 + SHA256 | 46 const CryptoTag kAESH = MAKE_TAG('A', 'E', 'S', 'H'); // AES128 + SHA256 |
| 47 const CryptoTag kAESG = MAKE_TAG('A', 'E', 'S', 'G'); // AES128 + GCM |
| 48 |
| 49 // Congestion control feedback types |
| 50 const CryptoTag kQBIC = MAKE_TAG('Q', 'B', 'I', 'C'); // TCP cubic |
| 51 const CryptoTag kINAR = MAKE_TAG('I', 'N', 'A', 'R'); // Inter arrival |
| 52 |
| 53 // Client hello tags |
| 54 const CryptoTag kVERS = MAKE_TAG('V', 'E', 'R', 'S'); // Version |
| 55 const CryptoTag kNONC = MAKE_TAG('N', 'O', 'N', 'C'); // The connection nonce |
| 56 const CryptoTag kSSID = MAKE_TAG('S', 'S', 'I', 'D'); // Session ID |
| 57 const CryptoTag kKEXS = MAKE_TAG('K', 'E', 'X', 'S'); // Key exchange methods |
| 58 const CryptoTag kAEAD = MAKE_TAG('A', 'E', 'A', 'D'); // Authenticated |
| 59 // encryption algorithms |
| 60 const CryptoTag kCGST = MAKE_TAG('C', 'G', 'S', 'T'); // Congestion control |
| 61 // feedback types |
| 62 const CryptoTag kICSL = MAKE_TAG('I', 'C', 'S', 'L'); // Idle connection state |
| 63 // lifetime |
| 64 const CryptoTag kKATO = MAKE_TAG('K', 'A', 'T', 'O'); // Keepalive timeout |
| 65 const CryptoTag kSNI = MAKE_TAG('S', 'N', 'I', '\0'); // Server name |
| 66 // indication |
| 67 const CryptoTag kPUBS = MAKE_TAG('P', 'U', 'B', 'S'); // Public key values |
| 42 | 68 |
| 43 const size_t kMaxEntries = 16; // Max number of entries in a message. | 69 const size_t kMaxEntries = 16; // Max number of entries in a message. |
| 44 | 70 |
| 71 const size_t kNonceSize = 32; // Size in bytes of the connection nonce. |
| 72 |
| 73 // Client-side crypto configuration settings. |
| 74 struct NET_EXPORT_PRIVATE QuicClientCryptoConfig { |
| 75 // Initializes the members to 0 or empty values. |
| 76 QuicClientCryptoConfig(); |
| 77 ~QuicClientCryptoConfig(); |
| 78 |
| 79 // Sets the members to default values. |
| 80 void SetDefaults(); |
| 81 |
| 82 // Protocol version |
| 83 uint16 version; |
| 84 // Key exchange methods |
| 85 CryptoTagVector key_exchange; |
| 86 // Authenticated encryption with associated data (AEAD) algorithms |
| 87 CryptoTagVector aead; |
| 88 // Congestion control feedback types |
| 89 CryptoTagVector congestion_control; |
| 90 // Idle connection state lifetime |
| 91 QuicTime::Delta idle_connection_state_lifetime; |
| 92 // Keepalive timeout, or 0 to turn off keepalive probes |
| 93 QuicTime::Delta keepalive_timeout; |
| 94 // Server's hostname |
| 95 std::string server_hostname; |
| 96 }; |
| 97 |
| 45 } // namespace net | 98 } // namespace net |
| 46 | 99 |
| 47 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ | 100 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ |
| OLD | NEW |