| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 54 // Proof types (i.e. certificate types) | 54 // Proof types (i.e. certificate types) |
| 55 // NOTE: although it would be silly to do so, specifying both kX509 and kX59R | 55 // NOTE: although it would be silly to do so, specifying both kX509 and kX59R |
| 56 // is allowed and is equivalent to specifying only kX509. | 56 // is allowed and is equivalent to specifying only kX509. |
| 57 const QuicTag kX509 = TAG('X', '5', '0', '9'); // X.509 certificate, all key | 57 const QuicTag kX509 = TAG('X', '5', '0', '9'); // X.509 certificate, all key |
| 58 // types | 58 // types |
| 59 const QuicTag kX59R = TAG('X', '5', '9', 'R'); // X.509 certificate, RSA keys | 59 const QuicTag kX59R = TAG('X', '5', '9', 'R'); // X.509 certificate, RSA keys |
| 60 // only | 60 // only |
| 61 const QuicTag kCHID = TAG('C', 'H', 'I', 'D'); // Channel ID. | 61 const QuicTag kCHID = TAG('C', 'H', 'I', 'D'); // Channel ID. |
| 62 | 62 |
| 63 // Client hello tags | 63 // Client hello tags |
| 64 const QuicTag kVER = TAG('V', 'E', 'R', '\0'); // Version (new) | 64 const QuicTag kVER = TAG('V', 'E', 'R', '\0'); // Version (new) |
| 65 const QuicTag kNONC = TAG('N', 'O', 'N', 'C'); // The client's nonce | 65 const QuicTag kNONC = TAG('N', 'O', 'N', 'C'); // The client's nonce |
| 66 const QuicTag kKEXS = TAG('K', 'E', 'X', 'S'); // Key exchange methods | 66 const QuicTag kKEXS = TAG('K', 'E', 'X', 'S'); // Key exchange methods |
| 67 const QuicTag kAEAD = TAG('A', 'E', 'A', 'D'); // Authenticated | 67 const QuicTag kAEAD = TAG('A', 'E', 'A', 'D'); // Authenticated |
| 68 // encryption algorithms | 68 // encryption algorithms |
| 69 const QuicTag kCGST = TAG('C', 'G', 'S', 'T'); // Congestion control | 69 const QuicTag kCGST = TAG('C', 'G', 'S', 'T'); // Congestion control |
| 70 // feedback types | 70 // feedback types |
| 71 // kLOSS was 'L', 'O', 'S', 'S', but was changed from a tag vector to a tag. | 71 // kLOSS was 'L', 'O', 'S', 'S', but was changed from a tag vector to a tag. |
| 72 const QuicTag kLOSS = TAG('L', 'O', 'S', 'A'); // Loss detection algorithms | 72 const QuicTag kLOSS = TAG('L', 'O', 'S', 'A'); // Loss detection algorithms |
| 73 const QuicTag kICSL = TAG('I', 'C', 'S', 'L'); // Idle connection state | 73 const QuicTag kICSL = TAG('I', 'C', 'S', 'L'); // Idle connection state |
| 74 // lifetime | 74 // lifetime |
| 75 const QuicTag kKATO = TAG('K', 'A', 'T', 'O'); // Keepalive timeout | 75 const QuicTag kKATO = TAG('K', 'A', 'T', 'O'); // Keepalive timeout |
| 76 const QuicTag kMSPC = TAG('M', 'S', 'P', 'C'); // Max streams per connection. | 76 const QuicTag kMSPC = TAG('M', 'S', 'P', 'C'); // Max streams per connection. |
| 77 const QuicTag kIRTT = TAG('I', 'R', 'T', 'T'); // Estimated initial RTT in us. | 77 const QuicTag kIRTT = TAG('I', 'R', 'T', 'T'); // Estimated initial RTT in us. |
| 78 const QuicTag kSWND = TAG('S', 'W', 'N', 'D'); // Server's Initial congestion | 78 const QuicTag kSWND = TAG('S', 'W', 'N', 'D'); // Server's Initial congestion |
| 79 // window. | 79 // window. |
| 80 const QuicTag kSNI = TAG('S', 'N', 'I', '\0'); // Server name | 80 const QuicTag kSNI = TAG('S', 'N', 'I', '\0'); // Server name |
| 81 // indication | 81 // indication |
| 82 const QuicTag kPUBS = TAG('P', 'U', 'B', 'S'); // Public key values | 82 const QuicTag kPUBS = TAG('P', 'U', 'B', 'S'); // Public key values |
| 83 const QuicTag kSCID = TAG('S', 'C', 'I', 'D'); // Server config id | 83 const QuicTag kSCID = TAG('S', 'C', 'I', 'D'); // Server config id |
| 84 const QuicTag kORBT = TAG('O', 'B', 'I', 'T'); // Server orbit. | 84 const QuicTag kORBT = TAG('O', 'B', 'I', 'T'); // Server orbit. |
| 85 const QuicTag kPDMD = TAG('P', 'D', 'M', 'D'); // Proof demand. | 85 const QuicTag kPDMD = TAG('P', 'D', 'M', 'D'); // Proof demand. |
| 86 const QuicTag kPROF = TAG('P', 'R', 'O', 'F'); // Proof (signature). | 86 const QuicTag kPROF = TAG('P', 'R', 'O', 'F'); // Proof (signature). |
| 87 const QuicTag kCCS = TAG('C', 'C', 'S', 0); // Common certificate set | 87 const QuicTag kCCS = TAG('C', 'C', 'S', 0); // Common certificate set |
| 88 const QuicTag kCCRT = TAG('C', 'C', 'R', 'T'); // Cached certificate | 88 const QuicTag kCCRT = TAG('C', 'C', 'R', 'T'); // Cached certificate |
| 89 const QuicTag kEXPY = TAG('E', 'X', 'P', 'Y'); // Expiry | 89 const QuicTag kEXPY = TAG('E', 'X', 'P', 'Y'); // Expiry |
| 90 const QuicTag kIFCW = TAG('I', 'F', 'C', 'W'); // Initial flow control receive | 90 const QuicTag kIFCW = TAG('I', 'F', 'C', 'W'); // Initial flow control receive |
| 91 // window. | 91 // window. |
| 92 | 92 |
| 93 // Server hello tags | 93 // Server hello tags |
| 94 const QuicTag kCADR = TAG('C', 'A', 'D', 'R'); // Client IP address and port | 94 const QuicTag kCADR = TAG('C', 'A', 'D', 'R'); // Client IP address and port |
| 95 | 95 |
| 96 // CETV tags | 96 // CETV tags |
| 97 const QuicTag kCIDK = TAG('C', 'I', 'D', 'K'); // ChannelID key | 97 const QuicTag kCIDK = TAG('C', 'I', 'D', 'K'); // ChannelID key |
| 98 const QuicTag kCIDS = TAG('C', 'I', 'D', 'S'); // ChannelID signature | 98 const QuicTag kCIDS = TAG('C', 'I', 'D', 'S'); // ChannelID signature |
| 99 | 99 |
| 100 // Public reset tags | 100 // Public reset tags |
| 101 const QuicTag kRNON = TAG('R', 'N', 'O', 'N'); // Public reset nonce proof | 101 const QuicTag kRNON = TAG('R', 'N', 'O', 'N'); // Public reset nonce proof |
| 102 const QuicTag kRSEQ = TAG('R', 'S', 'E', 'Q'); // Rejected sequence number | 102 const QuicTag kRSEQ = TAG('R', 'S', 'E', 'Q'); // Rejected sequence number |
| 103 | 103 |
| 104 // Universal tags | 104 // Universal tags |
| 105 const QuicTag kPAD = TAG('P', 'A', 'D', '\0'); // Padding | 105 const QuicTag kPAD = TAG('P', 'A', 'D', '\0'); // Padding |
| 106 | 106 |
| 107 // These tags have a special form so that they appear either at the beginning | 107 // These tags have a special form so that they appear either at the beginning |
| 108 // or the end of a handshake message. Since handshake messages are sorted by | 108 // or the end of a handshake message. Since handshake messages are sorted by |
| 109 // tag value, the tags with 0 at the end will sort first and those with 255 at | 109 // tag value, the tags with 0 at the end will sort first and those with 255 at |
| 110 // the end will sort last. | 110 // the end will sort last. |
| 111 // | 111 // |
| 112 // The certificate chain should have a tag that will cause it to be sorted at | 112 // The certificate chain should have a tag that will cause it to be sorted at |
| 113 // the end of any handshake messages because it's likely to be large and the | 113 // the end of any handshake messages because it's likely to be large and the |
| 114 // client might be able to get everything that it needs from the small values at | 114 // client might be able to get everything that it needs from the small values at |
| 115 // the beginning. | 115 // the beginning. |
| 116 // | 116 // |
| 117 // Likewise tags with random values should be towards the beginning of the | 117 // Likewise tags with random values should be towards the beginning of the |
| 118 // message because the server mightn't hold state for a rejected client hello | 118 // message because the server mightn't hold state for a rejected client hello |
| 119 // and therefore the client may have issues reassembling the rejection message | 119 // and therefore the client may have issues reassembling the rejection message |
| 120 // in the event that it sent two client hellos. | 120 // in the event that it sent two client hellos. |
| 121 const QuicTag kServerNonceTag = | 121 const QuicTag kServerNonceTag = TAG('S', 'N', 'O', 0); // The server's nonce |
| 122 TAG('S', 'N', 'O', 0); // The server's nonce | |
| 123 const QuicTag kSourceAddressTokenTag = | 122 const QuicTag kSourceAddressTokenTag = |
| 124 TAG('S', 'T', 'K', 0); // Source-address token | 123 TAG('S', 'T', 'K', 0); // Source-address token |
| 125 const QuicTag kCertificateTag = | 124 const QuicTag kCertificateTag = TAG('C', 'R', 'T', 255); // Certificate chain |
| 126 TAG('C', 'R', 'T', 255); // Certificate chain | |
| 127 | 125 |
| 128 #undef TAG | 126 #undef TAG |
| 129 | 127 |
| 130 const size_t kMaxEntries = 128; // Max number of entries in a message. | 128 const size_t kMaxEntries = 128; // Max number of entries in a message. |
| 131 | 129 |
| 132 const size_t kNonceSize = 32; // Size in bytes of the connection nonce. | 130 const size_t kNonceSize = 32; // Size in bytes of the connection nonce. |
| 133 | 131 |
| 134 const size_t kOrbitSize = 8; // Number of bytes in an orbit value. | 132 const size_t kOrbitSize = 8; // Number of bytes in an orbit value. |
| 135 | 133 |
| 136 // kProofSignatureLabel is prepended to server configs before signing to avoid | 134 // kProofSignatureLabel is prepended to server configs before signing to avoid |
| 137 // any cross-protocol attacks on the signature. | 135 // any cross-protocol attacks on the signature. |
| 138 const char kProofSignatureLabel[] = "QUIC server config signature"; | 136 const char kProofSignatureLabel[] = "QUIC server config signature"; |
| 139 | 137 |
| 140 // kClientHelloMinimumSize is the minimum size of a client hello. Client hellos | 138 // kClientHelloMinimumSize is the minimum size of a client hello. Client hellos |
| 141 // will have PAD tags added in order to ensure this minimum is met and client | 139 // will have PAD tags added in order to ensure this minimum is met and client |
| 142 // hellos smaller than this will be an error. This minimum size reduces the | 140 // hellos smaller than this will be an error. This minimum size reduces the |
| 143 // amplification factor of any mirror DoS attack. | 141 // amplification factor of any mirror DoS attack. |
| 144 // | 142 // |
| 145 // A client may pad an inchoate client hello to a size larger than | 143 // A client may pad an inchoate client hello to a size larger than |
| 146 // kClientHelloMinimumSize to make it more likely to receive a complete | 144 // kClientHelloMinimumSize to make it more likely to receive a complete |
| 147 // rejection message. | 145 // rejection message. |
| 148 const size_t kClientHelloMinimumSize = 1024; | 146 const size_t kClientHelloMinimumSize = 1024; |
| 149 | 147 |
| 150 } // namespace net | 148 } // namespace net |
| 151 | 149 |
| 152 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ | 150 #endif // NET_QUIC_CRYPTO_CRYPTO_PROTOCOL_H_ |
| OLD | NEW |