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

Unified Diff: net/quic/core/crypto/quic_crypto_client_config.cc

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 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
Index: net/quic/core/crypto/quic_crypto_client_config.cc
diff --git a/net/quic/core/crypto/quic_crypto_client_config.cc b/net/quic/core/crypto/quic_crypto_client_config.cc
index e4366a962a7a794a2b8781d706eea91aace87788..291e33c547b867a22b112122dd4b0eb22083c2c9 100644
--- a/net/quic/core/crypto/quic_crypto_client_config.cc
+++ b/net/quic/core/crypto/quic_crypto_client_config.cc
@@ -28,7 +28,6 @@
#include "net/quic/platform/api/quic_ptr_util.h"
#include "net/quic/platform/api/quic_text_utils.h"
-using base::StringPiece;
using std::string;
namespace net {
@@ -139,10 +138,11 @@ bool QuicCryptoClientConfig::CachedState::has_server_nonce() const {
}
QuicCryptoClientConfig::CachedState::ServerConfigState
-QuicCryptoClientConfig::CachedState::SetServerConfig(StringPiece server_config,
- QuicWallTime now,
- QuicWallTime expiry_time,
- string* error_details) {
+QuicCryptoClientConfig::CachedState::SetServerConfig(
+ QuicStringPiece server_config,
+ QuicWallTime now,
+ QuicWallTime expiry_time,
+ string* error_details) {
const bool matches_existing = server_config == server_config_;
// Even if the new server config matches the existing one, we still wish to
@@ -196,9 +196,9 @@ void QuicCryptoClientConfig::CachedState::InvalidateServerConfig() {
void QuicCryptoClientConfig::CachedState::SetProof(
const std::vector<string>& certs,
- StringPiece cert_sct,
- StringPiece chlo_hash,
- StringPiece signature) {
+ QuicStringPiece cert_sct,
+ QuicStringPiece chlo_hash,
+ QuicStringPiece signature) {
bool has_changed = signature != server_config_sig_ ||
chlo_hash != chlo_hash_ || certs_.size() != certs.size();
@@ -256,12 +256,12 @@ void QuicCryptoClientConfig::CachedState::SetProofInvalid() {
}
bool QuicCryptoClientConfig::CachedState::Initialize(
- StringPiece server_config,
- StringPiece source_address_token,
+ QuicStringPiece server_config,
+ QuicStringPiece source_address_token,
const std::vector<string>& certs,
const string& cert_sct,
- StringPiece chlo_hash,
- StringPiece signature,
+ QuicStringPiece chlo_hash,
+ QuicStringPiece signature,
QuicWallTime now,
QuicWallTime expiration_time) {
DCHECK(server_config_.empty());
@@ -327,11 +327,12 @@ QuicCryptoClientConfig::CachedState::proof_verify_details() const {
}
void QuicCryptoClientConfig::CachedState::set_source_address_token(
- StringPiece token) {
+ QuicStringPiece token) {
source_address_token_ = token.as_string();
}
-void QuicCryptoClientConfig::CachedState::set_cert_sct(StringPiece cert_sct) {
+void QuicCryptoClientConfig::CachedState::set_cert_sct(
+ QuicStringPiece cert_sct) {
cert_sct_ = cert_sct.as_string();
}
@@ -441,7 +442,7 @@ void QuicCryptoClientConfig::FillInchoateClientHello(
// the STK can be validated by the server.
const CryptoHandshakeMessage* scfg = cached->GetServerConfig();
if (scfg != nullptr) {
- StringPiece scid;
+ QuicStringPiece scid;
if (scfg->GetStringPiece(kSCID, &scid)) {
out->SetStringPiece(kSCID, scid);
}
@@ -457,7 +458,8 @@ void QuicCryptoClientConfig::FillInchoateClientHello(
char proof_nonce[32];
rand->RandBytes(proof_nonce, arraysize(proof_nonce));
- out->SetStringPiece(kNONP, StringPiece(proof_nonce, arraysize(proof_nonce)));
+ out->SetStringPiece(kNONP,
+ QuicStringPiece(proof_nonce, arraysize(proof_nonce)));
out->SetVector(kPDMD, QuicTagVector{kX509});
@@ -508,7 +510,7 @@ QuicErrorCode QuicCryptoClientConfig::FillClientHello(
return QUIC_CRYPTO_INTERNAL_ERROR;
}
- StringPiece scid;
+ QuicStringPiece scid;
if (!scfg->GetStringPiece(kSCID, &scid)) {
*error_details = "SCFG missing SCID";
return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
@@ -564,14 +566,14 @@ QuicErrorCode QuicCryptoClientConfig::FillClientHello(
}
}
- StringPiece public_value;
+ QuicStringPiece public_value;
if (scfg->GetNthValue24(kPUBS, key_exchange_index, &public_value) !=
QUIC_NO_ERROR) {
*error_details = "Missing public value";
return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
}
- StringPiece orbit;
+ QuicStringPiece orbit;
if (!scfg->GetStringPiece(kORBT, &orbit) || orbit.size() != kOrbitSize) {
*error_details = "SCFG missing OBIT";
return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND;
@@ -659,13 +661,14 @@ QuicErrorCode QuicCryptoClientConfig::FillClientHello(
size_t output_size = 0;
if (!crypters.encrypter->EncryptPacket(
preferred_version, 0 /* packet number */,
- StringPiece() /* associated data */, cetv_plaintext.AsStringPiece(),
- output.get(), &output_size, encrypted_len)) {
+ QuicStringPiece() /* associated data */,
+ cetv_plaintext.AsStringPiece(), output.get(), &output_size,
+ encrypted_len)) {
*error_details = "Packet encryption failed";
return QUIC_ENCRYPTION_FAILURE;
}
- out->SetStringPiece(kCETV, StringPiece(output.get(), output_size));
+ out->SetStringPiece(kCETV, QuicStringPiece(output.get(), output_size));
out->MarkDirty();
out->set_minimum_size(orig_min_size);
@@ -712,13 +715,13 @@ QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig(
const CryptoHandshakeMessage& message,
QuicWallTime now,
QuicVersion version,
- StringPiece chlo_hash,
+ QuicStringPiece chlo_hash,
const std::vector<string>& cached_certs,
CachedState* cached,
string* error_details) {
DCHECK(error_details != nullptr);
- StringPiece scfg;
+ QuicStringPiece scfg;
if (!message.GetStringPiece(kSCFG, &scfg)) {
*error_details = "Missing SCFG";
return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND;
@@ -743,12 +746,12 @@ QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig(
return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
}
- StringPiece token;
+ QuicStringPiece token;
if (message.GetStringPiece(kSourceAddressTokenTag, &token)) {
cached->set_source_address_token(token);
}
- StringPiece proof, cert_bytes, cert_sct;
+ QuicStringPiece proof, cert_bytes, cert_sct;
bool has_proof = message.GetStringPiece(kPROF, &proof);
bool has_cert = message.GetStringPiece(kCertificateTag, &cert_bytes);
if (has_proof && has_cert) {
@@ -784,7 +787,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessRejection(
const CryptoHandshakeMessage& rej,
QuicWallTime now,
const QuicVersion version,
- StringPiece chlo_hash,
+ QuicStringPiece chlo_hash,
CachedState* cached,
QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params,
string* error_details) {
@@ -802,7 +805,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessRejection(
return error;
}
- StringPiece nonce;
+ QuicStringPiece nonce;
if (rej.GetStringPiece(kServerNonceTag, &nonce)) {
out_params->server_nonce = nonce.as_string();
}
@@ -840,12 +843,12 @@ QuicErrorCode QuicCryptoClientConfig::ProcessServerHello(
}
// Learn about updated source address tokens.
- StringPiece token;
+ QuicStringPiece token;
if (server_hello.GetStringPiece(kSourceAddressTokenTag, &token)) {
cached->set_source_address_token(token);
}
- StringPiece shlo_nonce;
+ QuicStringPiece shlo_nonce;
if (!server_hello.GetStringPiece(kServerNonceTag, &shlo_nonce)) {
*error_details = "server hello missing server nonce";
return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
@@ -854,7 +857,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessServerHello(
// TODO(agl):
// learn about updated SCFGs.
- StringPiece public_value;
+ QuicStringPiece public_value;
if (!server_hello.GetStringPiece(kPUBS, &public_value)) {
*error_details = "server hello missing forward secure public value";
return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
@@ -890,7 +893,7 @@ QuicErrorCode QuicCryptoClientConfig::ProcessServerConfigUpdate(
const CryptoHandshakeMessage& server_config_update,
QuicWallTime now,
const QuicVersion version,
- StringPiece chlo_hash,
+ QuicStringPiece chlo_hash,
CachedState* cached,
QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params,
string* error_details) {
« no previous file with comments | « net/quic/core/crypto/quic_crypto_client_config.h ('k') | net/quic/core/crypto/quic_crypto_client_config_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698