| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "net/base/net_export.h" | 10 #include "net/base/net_export.h" |
| 11 #include "net/quic/quic_protocol.h" | 11 #include "net/quic/quic_protocol.h" |
| 12 | 12 |
| 13 // Version and Crypto tags are written to the wire with a big-endian | 13 // Version and Crypto tags are written to the wire with a big-endian |
| 14 // representation of the name of the tag. For example | 14 // representation of the name of the tag. For example |
| 15 // the client hello tag (CHLO) will be written as the | 15 // the client hello tag (CHLO) will be written as the |
| 16 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is | 16 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is |
| 17 // stored in memory as a little endian uint32, we need | 17 // stored in memory as a little endian uint32, we need |
| 18 // to reverse the order of the bytes. | 18 // to reverse the order of the bytes. |
| 19 // | 19 // |
| 20 // We use a macro to ensure that no static initialisers are created. Use the | 20 // We use a macro to ensure that no static initialisers are created. Use the |
| 21 // MakeQuicTag function in normal code. | 21 // MakeQuicTag function in normal code. |
| 22 #define TAG(a, b, c, d) ((d << 24) + (c << 16) + (b << 8) + a) | 22 #define TAG(a, b, c, d) ((d << 24) + (c << 16) + (b << 8) + a) |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 | 25 |
| 26 typedef std::string ServerConfigID; | 26 typedef std::string ServerConfigID; |
| 27 | 27 |
| 28 const QuicTag kCHLO = TAG('C', 'H', 'L', 'O'); // Client hello | 28 const QuicTag kCHLO = TAG('C', 'H', 'L', 'O'); // Client hello |
| 29 const QuicTag kSHLO = TAG('S', 'H', 'L', 'O'); // Server hello | 29 const QuicTag kSHLO = TAG('S', 'H', 'L', 'O'); // Server hello |
| 30 const QuicTag kSCFG = TAG('S', 'C', 'F', 'G'); // Server config | 30 const QuicTag kSCFG = TAG('S', 'C', 'F', 'G'); // Server config |
| 31 const QuicTag kREJ = TAG('R', 'E', 'J', '\0'); // Reject | 31 const QuicTag kREJ = TAG('R', 'E', 'J', '\0'); // Reject |
| 32 const QuicTag kCETV = TAG('C', 'E', 'T', 'V'); // Client encrypted tag-value | 32 const QuicTag kCETV = TAG('C', 'E', 'T', 'V'); // Client encrypted tag-value |
| 33 // pairs | 33 // pairs |
| 34 const QuicTag kPRST = TAG('P', 'R', 'S', 'T'); // Public reset | 34 const QuicTag kPRST = TAG('P', 'R', 'S', 'T'); // Public reset |
| 35 | 35 |
| 36 // Key exchange methods | 36 // Key exchange methods |
| 37 const QuicTag kP256 = TAG('P', '2', '5', '6'); // ECDH, Curve P-256 | 37 const QuicTag kP256 = TAG('P', '2', '5', '6'); // ECDH, Curve P-256 |
| 38 const QuicTag kC255 = TAG('C', '2', '5', '5'); // ECDH, Curve25519 | 38 const QuicTag kC255 = TAG('C', '2', '5', '5'); // ECDH, Curve25519 |
| 39 | 39 |
| 40 // AEAD algorithms | 40 // AEAD algorithms |
| 41 const QuicTag kNULL = TAG('N', 'U', 'L', 'N'); // null algorithm | 41 const QuicTag kNULL = TAG('N', 'U', 'L', 'N'); // null algorithm |
| 42 const QuicTag kAESG = TAG('A', 'E', 'S', 'G'); // AES128 + GCM-12 | 42 const QuicTag kAESG = TAG('A', 'E', 'S', 'G'); // AES128 + GCM-12 |
| 43 const QuicTag kCC12 = TAG('C', 'C', '1', '2'); // ChaCha20 + Poly1305 | 43 const QuicTag kCC12 = TAG('C', 'C', '1', '2'); // ChaCha20 + Poly1305 |
| 44 | 44 |
| 45 // Congestion control feedback types | 45 // Congestion control feedback types |
| 46 const QuicTag kQBIC = TAG('Q', 'B', 'I', 'C'); // TCP cubic | 46 const QuicTag kQBIC = TAG('Q', 'B', 'I', 'C'); // TCP cubic |
| 47 const QuicTag kPACE = TAG('P', 'A', 'C', 'E'); // Paced 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 | 48 const QuicTag kINAR = TAG('I', 'N', 'A', 'R'); // Inter arrival |
| 49 | 49 |
| 50 // Congestion control options | 50 // Congestion control options |
| 51 const QuicTag kTBBR = TAG('T', 'B', 'B', 'R'); // Reduced Buffer Bloat TCP | 51 const QuicTag kTBBR = TAG('T', 'B', 'B', 'R'); // Reduced Buffer Bloat TCP |
| 52 | 52 |
| 53 // Loss detection algorithm types | 53 // Loss detection algorithm types |
| 54 const QuicTag kNACK = TAG('N', 'A', 'C', 'K'); // TCP style nack counting | 54 const QuicTag kNACK = TAG('N', 'A', 'C', 'K'); // TCP style nack counting |
| 55 const QuicTag kTIME = TAG('T', 'I', 'M', 'E'); // Time based | 55 const QuicTag kTIME = TAG('T', 'I', 'M', 'E'); // Time based |
| 56 | 56 |
| 57 // Proof types (i.e. certificate types) | 57 // Proof types (i.e. certificate types) |
| 58 // NOTE: although it would be silly to do so, specifying both kX509 and kX59R | 58 // NOTE: although it would be silly to do so, specifying both kX509 and kX59R |
| 59 // is allowed and is equivalent to specifying only kX509. | 59 // is allowed and is equivalent to specifying only kX509. |
| 60 const QuicTag kX509 = TAG('X', '5', '0', '9'); // X.509 certificate, all key | 60 const QuicTag kX509 = TAG('X', '5', '0', '9'); // X.509 certificate, all key |
| 61 // types | 61 // types |
| 62 const QuicTag kX59R = TAG('X', '5', '9', 'R'); // X.509 certificate, RSA keys | 62 const QuicTag kX59R = TAG('X', '5', '9', 'R'); // X.509 certificate, RSA keys |
| 63 // only | 63 // only |
| 64 const QuicTag kCHID = TAG('C', 'H', 'I', 'D'); // Channel ID. | 64 const QuicTag kCHID = TAG('C', 'H', 'I', 'D'); // Channel ID. |
| 65 | 65 |
| 66 // Client hello tags | 66 // Client hello tags |
| 67 const QuicTag kVER = TAG('V', 'E', 'R', '\0'); // Version (new) | 67 const QuicTag kVER = TAG('V', 'E', 'R', '\0'); // Version (new) |
| 68 const QuicTag kNONC = TAG('N', 'O', 'N', 'C'); // The client's nonce | 68 const QuicTag kNONC = TAG('N', 'O', 'N', 'C'); // The client's nonce |
| 69 const QuicTag kKEXS = TAG('K', 'E', 'X', 'S'); // Key exchange methods | 69 const QuicTag kKEXS = TAG('K', 'E', 'X', 'S'); // Key exchange methods |
| 70 const QuicTag kAEAD = TAG('A', 'E', 'A', 'D'); // Authenticated | 70 const QuicTag kAEAD = TAG('A', 'E', 'A', 'D'); // Authenticated |
| 71 // encryption algorithms | 71 // encryption algorithms |
| 72 const QuicTag kCGST = TAG('C', 'G', 'S', 'T'); // Congestion control | 72 const QuicTag kCGST = TAG('C', 'G', 'S', 'T'); // Congestion control |
| 73 // feedback types | 73 // feedback types |
| 74 const QuicTag kCOPT = TAG('C', 'O', 'P', 'T'); // Congestion control options | 74 const QuicTag kCOPT = TAG('C', 'O', 'P', 'T'); // Congestion control options |
| 75 // kLOSS was 'L', 'O', 'S', 'S', but was changed from a tag vector to a tag. | 75 // kLOSS was 'L', 'O', 'S', 'S', but was changed from a tag vector to a tag. |
| 76 const QuicTag kLOSS = TAG('L', 'O', 'S', 'A'); // Loss detection algorithms | 76 const QuicTag kLOSS = TAG('L', 'O', 'S', 'A'); // Loss detection algorithms |
| 77 const QuicTag kICSL = TAG('I', 'C', 'S', 'L'); // Idle connection state | 77 const QuicTag kICSL = TAG('I', 'C', 'S', 'L'); // Idle connection state |
| 78 // lifetime | 78 // lifetime |
| 79 const QuicTag kKATO = TAG('K', 'A', 'T', 'O'); // Keepalive timeout | 79 const QuicTag kKATO = TAG('K', 'A', 'T', 'O'); // Keepalive timeout |
| 80 const QuicTag kMSPC = TAG('M', 'S', 'P', 'C'); // Max streams per connection. | 80 const QuicTag kMSPC = TAG('M', 'S', 'P', 'C'); // Max streams per connection. |
| 81 const QuicTag kIRTT = TAG('I', 'R', 'T', 'T'); // Estimated initial RTT in us. | 81 const QuicTag kIRTT = TAG('I', 'R', 'T', 'T'); // Estimated initial RTT in us. |
| 82 const QuicTag kSWND = TAG('S', 'W', 'N', 'D'); // Server's Initial congestion | 82 const QuicTag kSWND = TAG('S', 'W', 'N', 'D'); // Server's Initial congestion |
| 83 // window. | 83 // window. |
| 84 const QuicTag kSNI = TAG('S', 'N', 'I', '\0'); // Server name | 84 const QuicTag kSNI = TAG('S', 'N', 'I', '\0'); // Server name |
| 85 // indication | 85 // indication |
| 86 const QuicTag kPUBS = TAG('P', 'U', 'B', 'S'); // Public key values | 86 const QuicTag kPUBS = TAG('P', 'U', 'B', 'S'); // Public key values |
| 87 const QuicTag kSCID = TAG('S', 'C', 'I', 'D'); // Server config id | 87 const QuicTag kSCID = TAG('S', 'C', 'I', 'D'); // Server config id |
| 88 const QuicTag kORBT = TAG('O', 'B', 'I', 'T'); // Server orbit. | 88 const QuicTag kORBT = TAG('O', 'B', 'I', 'T'); // Server orbit. |
| 89 const QuicTag kPDMD = TAG('P', 'D', 'M', 'D'); // Proof demand. | 89 const QuicTag kPDMD = TAG('P', 'D', 'M', 'D'); // Proof demand. |
| 90 const QuicTag kPROF = TAG('P', 'R', 'O', 'F'); // Proof (signature). | 90 const QuicTag kPROF = TAG('P', 'R', 'O', 'F'); // Proof (signature). |
| 91 const QuicTag kCCS = TAG('C', 'C', 'S', 0); // Common certificate set | 91 const QuicTag kCCS = TAG('C', 'C', 'S', 0); // Common certificate set |
| 92 const QuicTag kCCRT = TAG('C', 'C', 'R', 'T'); // Cached certificate | 92 const QuicTag kCCRT = TAG('C', 'C', 'R', 'T'); // Cached certificate |
| 93 const QuicTag kEXPY = TAG('E', 'X', 'P', 'Y'); // Expiry | 93 const QuicTag kEXPY = TAG('E', 'X', 'P', 'Y'); // Expiry |
| 94 const QuicTag kIFCW = TAG('I', 'F', 'C', 'W'); // Initial flow control receive | 94 const QuicTag kIFCW = TAG('I', 'F', 'C', 'W'); // Initial flow control receive |
| 95 // window. | 95 // window. |
| 96 const QuicTag kUAID = TAG('U', 'A', 'I', 'D'); // Client's User Agent ID. | 96 const QuicTag kUAID = TAG('U', 'A', 'I', 'D'); // Client's User Agent ID. |
| 97 | 97 |
| 98 | 98 |
| 99 // Server hello tags | 99 // Server hello tags |
| 100 const QuicTag kCADR = TAG('C', 'A', 'D', 'R'); // Client IP address and port | 100 const QuicTag kCADR = TAG('C', 'A', 'D', 'R'); // Client IP address and port |
| 101 | 101 |
| 102 // CETV tags | 102 // CETV tags |
| 103 const QuicTag kCIDK = TAG('C', 'I', 'D', 'K'); // ChannelID key | 103 const QuicTag kCIDK = TAG('C', 'I', 'D', 'K'); // ChannelID key |
| 104 const QuicTag kCIDS = TAG('C', 'I', 'D', 'S'); // ChannelID signature | 104 const QuicTag kCIDS = TAG('C', 'I', 'D', 'S'); // ChannelID signature |
| 105 | 105 |
| 106 // Public reset tags | 106 // Public reset tags |
| 107 const QuicTag kRNON = TAG('R', 'N', 'O', 'N'); // Public reset nonce proof | 107 const QuicTag kRNON = TAG('R', 'N', 'O', 'N'); // Public reset nonce proof |
| 108 const QuicTag kRSEQ = TAG('R', 'S', 'E', 'Q'); // Rejected sequence number | 108 const QuicTag kRSEQ = TAG('R', 'S', 'E', 'Q'); // Rejected sequence number |
| 109 | 109 |
| 110 // Universal tags | 110 // Universal tags |
| 111 const QuicTag kPAD = TAG('P', 'A', 'D', '\0'); // Padding | 111 const QuicTag kPAD = TAG('P', 'A', 'D', '\0'); // Padding |
| 112 | 112 |
| 113 // These tags have a special form so that they appear either at the beginning | 113 // These tags have a special form so that they appear either at the beginning |
| 114 // or the end of a handshake message. Since handshake messages are sorted by | 114 // or the end of a handshake message. Since handshake messages are sorted by |
| 115 // tag value, the tags with 0 at the end will sort first and those with 255 at | 115 // tag value, the tags with 0 at the end will sort first and those with 255 at |
| 116 // the end will sort last. | 116 // the end will sort last. |
| 117 // | 117 // |
| 118 // The certificate chain should have a tag that will cause it to be sorted at | 118 // The certificate chain should have a tag that will cause it to be sorted at |
| 119 // the end of any handshake messages because it's likely to be large and the | 119 // the end of any handshake messages because it's likely to be large and the |
| 120 // client might be able to get everything that it needs from the small values at | 120 // client might be able to get everything that it needs from the small values at |
| 121 // the beginning. | 121 // the beginning. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 149 // amplification factor of any mirror DoS attack. | 149 // amplification factor of any mirror DoS attack. |
| 150 // | 150 // |
| 151 // A client may pad an inchoate client hello to a size larger than | 151 // A client may pad an inchoate client hello to a size larger than |
| 152 // kClientHelloMinimumSize to make it more likely to receive a complete | 152 // kClientHelloMinimumSize to make it more likely to receive a complete |
| 153 // rejection message. | 153 // rejection message. |
| 154 const size_t kClientHelloMinimumSize = 1024; | 154 const size_t kClientHelloMinimumSize = 1024; |
| 155 | 155 |
| 156 } // namespace net | 156 } // namespace net |
| 157 | 157 |
| 158 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ | 158 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ |
| OLD | NEW |