Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(334)

Unified Diff: net/quic/crypto/crypto_utils.cc

Issue 12381018: QUIC - Some sketching of the crypto handshake. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/crypto/crypto_utils.h ('k') | net/quic/crypto/curve25519_key_exchange.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/crypto_utils.cc
===================================================================
--- net/quic/crypto/crypto_utils.cc (revision 184750)
+++ net/quic/crypto/crypto_utils.cc (working copy)
@@ -5,7 +5,6 @@
#include "net/quic/crypto/crypto_utils.h"
#include "base/string_piece.h"
-#include "net/base/net_util.h"
#include "net/quic/crypto/crypto_protocol.h"
#include "net/quic/crypto/quic_random.h"
#include "net/quic/quic_clock.h"
@@ -15,6 +14,24 @@
namespace net {
+// static
+bool CryptoUtils::FindMutualTag(const CryptoTagVector& preference,
+ const CryptoTagVector& supported,
+ CryptoTag* out_result) {
+ for (CryptoTagVector::const_iterator i = preference.begin();
+ i != preference.end(); i++) {
+ for (CryptoTagVector::const_iterator j = supported.begin();
+ j != supported.end(); j++) {
+ if (*i == *j) {
+ *out_result = *i;
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
void CryptoUtils::GenerateNonce(const QuicClock* clock,
QuicRandom* random_generator,
string* nonce) {
@@ -28,78 +45,4 @@
random_generator->RandBytes(&(*nonce)[time_size], kNonceSize - time_size);
}
-void CryptoUtils::FillClientHelloMessage(
- const QuicCryptoConfig& client_config,
- const string& nonce,
- const string& server_hostname,
- CryptoHandshakeMessage* message) {
- message->tag = kCHLO;
-
- // Version.
- message->tag_value_map[kVERS] = EncodeSingleValue(client_config.version);
-
- // Key exchange methods.
- message->tag_value_map[kKEXS] = EncodeVectorValue(client_config.key_exchange);
-
- // Authenticated encryption algorithms.
- message->tag_value_map[kAEAD] = EncodeVectorValue(client_config.aead);
-
- // Congestion control feedback types.
- message->tag_value_map[kCGST] =
- EncodeVectorValue(client_config.congestion_control);
-
- // Idle connection state lifetime.
- uint32 idle_connection_state_lifetime_secs =
- client_config.idle_connection_state_lifetime.ToSeconds();
- message->tag_value_map[kICSL] =
- EncodeSingleValue(idle_connection_state_lifetime_secs);
-
- // Keepalive timeout.
- uint32 keepalive_timeout_secs = client_config.keepalive_timeout.ToSeconds();
- message->tag_value_map[kKATO] = EncodeSingleValue(keepalive_timeout_secs);
-
- // Connection nonce.
- message->tag_value_map[kNONC] = nonce;
-
- // Server name indication.
- // If server_hostname is not an IP address literal, it is a DNS hostname.
- IPAddressNumber ip_number;
- if (!server_hostname.empty() &&
- !ParseIPLiteralToNumber(server_hostname, &ip_number)) {
- message->tag_value_map[kSNI] = server_hostname;
- }
-}
-
-void CryptoUtils::FillServerHelloMessage(
- const QuicCryptoNegotiatedParams& negotiated_params,
- const string& nonce,
- CryptoHandshakeMessage* message) {
- message->tag = kSHLO;
-
- // Version.
- message->tag_value_map[kVERS] = EncodeSingleValue(negotiated_params.version);
-
- // Key exchange method.
- message->tag_value_map[kKEXS] =
- EncodeSingleValue(negotiated_params.key_exchange);
-
- // Authenticated encryption algorithm.
- message->tag_value_map[kAEAD] = EncodeSingleValue(negotiated_params.aead);
-
- // Congestion control feedback type.
- message->tag_value_map[kCGST] =
- EncodeSingleValue(negotiated_params.congestion_control);
-
- // Idle connection state lifetime.
- uint32 idle_connection_state_lifetime_secs =
- negotiated_params.idle_connection_state_lifetime.ToSeconds();
- message->tag_value_map[kICSL] =
- EncodeSingleValue(idle_connection_state_lifetime_secs);
-
- // Keepalive timeout?
-
- // Connection nonce.
- message->tag_value_map[kNONC] = nonce;
-}
-
} // namespace net
« no previous file with comments | « net/quic/crypto/crypto_utils.h ('k') | net/quic/crypto/curve25519_key_exchange.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698