Replace QuicheStringPiece with absl::string_view PiperOrigin-RevId: 336144170 Change-Id: Ida08f1aca54f25f437c405cb34a50b9a9fec138e
diff --git a/quic/core/crypto/aead_base_decrypter.cc b/quic/core/crypto/aead_base_decrypter.cc index f3be16e..3753635 100644 --- a/quic/core/crypto/aead_base_decrypter.cc +++ b/quic/core/crypto/aead_base_decrypter.cc
@@ -7,6 +7,7 @@ #include <cstdint> #include <string> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/crypto.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "third_party/boringssl/src/include/openssl/evp.h" @@ -14,7 +15,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -69,7 +69,7 @@ AeadBaseDecrypter::~AeadBaseDecrypter() {} -bool AeadBaseDecrypter::SetKey(quiche::QuicheStringPiece key) { +bool AeadBaseDecrypter::SetKey(absl::string_view key) { DCHECK_EQ(key.size(), key_size_); if (key.size() != key_size_) { return false; @@ -86,7 +86,7 @@ return true; } -bool AeadBaseDecrypter::SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) { +bool AeadBaseDecrypter::SetNoncePrefix(absl::string_view nonce_prefix) { if (use_ietf_nonce_construction_) { QUIC_BUG << "Attempted to set nonce prefix on IETF QUIC crypter"; return false; @@ -99,7 +99,7 @@ return true; } -bool AeadBaseDecrypter::SetIV(quiche::QuicheStringPiece iv) { +bool AeadBaseDecrypter::SetIV(absl::string_view iv) { if (!use_ietf_nonce_construction_) { QUIC_BUG << "Attempted to set IV on Google QUIC crypter"; return false; @@ -112,7 +112,7 @@ return true; } -bool AeadBaseDecrypter::SetPreliminaryKey(quiche::QuicheStringPiece key) { +bool AeadBaseDecrypter::SetPreliminaryKey(absl::string_view key) { DCHECK(!have_preliminary_key_); SetKey(key); have_preliminary_key_ = true; @@ -132,10 +132,9 @@ prefix_size -= sizeof(QuicPacketNumber); } DiversifyPreliminaryKey( - quiche::QuicheStringPiece(reinterpret_cast<const char*>(key_), key_size_), - quiche::QuicheStringPiece(reinterpret_cast<const char*>(iv_), - prefix_size), - nonce, key_size_, prefix_size, &key, &nonce_prefix); + absl::string_view(reinterpret_cast<const char*>(key_), key_size_), + absl::string_view(reinterpret_cast<const char*>(iv_), prefix_size), nonce, + key_size_, prefix_size, &key, &nonce_prefix); if (!SetKey(key) || (!use_ietf_nonce_construction_ && !SetNoncePrefix(nonce_prefix)) || @@ -149,8 +148,8 @@ } bool AeadBaseDecrypter::DecryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext, + absl::string_view associated_data, + absl::string_view ciphertext, char* output, size_t* output_length, size_t max_output_length) { @@ -201,14 +200,13 @@ return nonce_size_; } -quiche::QuicheStringPiece AeadBaseDecrypter::GetKey() const { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(key_), - key_size_); +absl::string_view AeadBaseDecrypter::GetKey() const { + return absl::string_view(reinterpret_cast<const char*>(key_), key_size_); } -quiche::QuicheStringPiece AeadBaseDecrypter::GetNoncePrefix() const { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(iv_), - nonce_size_ - sizeof(QuicPacketNumber)); +absl::string_view AeadBaseDecrypter::GetNoncePrefix() const { + return absl::string_view(reinterpret_cast<const char*>(iv_), + nonce_size_ - sizeof(QuicPacketNumber)); } } // namespace quic
diff --git a/quic/core/crypto/aead_base_decrypter.h b/quic/core/crypto/aead_base_decrypter.h index e69b0ed..c4c04fe 100644 --- a/quic/core/crypto/aead_base_decrypter.h +++ b/quic/core/crypto/aead_base_decrypter.h
@@ -7,10 +7,10 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -29,22 +29,22 @@ ~AeadBaseDecrypter() override; // QuicDecrypter implementation - bool SetKey(quiche::QuicheStringPiece key) override; - bool SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) override; - bool SetIV(quiche::QuicheStringPiece iv) override; - bool SetPreliminaryKey(quiche::QuicheStringPiece key) override; + bool SetKey(absl::string_view key) override; + bool SetNoncePrefix(absl::string_view nonce_prefix) override; + bool SetIV(absl::string_view iv) override; + bool SetPreliminaryKey(absl::string_view key) override; bool SetDiversificationNonce(const DiversificationNonce& nonce) override; bool DecryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext, + absl::string_view associated_data, + absl::string_view ciphertext, char* output, size_t* output_length, size_t max_output_length) override; size_t GetKeySize() const override; size_t GetNoncePrefixSize() const override; size_t GetIVSize() const override; - quiche::QuicheStringPiece GetKey() const override; - quiche::QuicheStringPiece GetNoncePrefix() const override; + absl::string_view GetKey() const override; + absl::string_view GetNoncePrefix() const override; protected: // Make these constants available to the subclasses so that the subclasses
diff --git a/quic/core/crypto/aead_base_encrypter.cc b/quic/core/crypto/aead_base_encrypter.cc index 14aca26..d6360f4 100644 --- a/quic/core/crypto/aead_base_encrypter.cc +++ b/quic/core/crypto/aead_base_encrypter.cc
@@ -4,6 +4,7 @@ #include "net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h" +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/crypto.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "third_party/boringssl/src/include/openssl/evp.h" @@ -12,7 +13,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -59,7 +59,7 @@ AeadBaseEncrypter::~AeadBaseEncrypter() {} -bool AeadBaseEncrypter::SetKey(quiche::QuicheStringPiece key) { +bool AeadBaseEncrypter::SetKey(absl::string_view key) { DCHECK_EQ(key.size(), key_size_); if (key.size() != key_size_) { return false; @@ -77,7 +77,7 @@ return true; } -bool AeadBaseEncrypter::SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) { +bool AeadBaseEncrypter::SetNoncePrefix(absl::string_view nonce_prefix) { if (use_ietf_nonce_construction_) { QUIC_BUG << "Attempted to set nonce prefix on IETF QUIC crypter"; return false; @@ -90,7 +90,7 @@ return true; } -bool AeadBaseEncrypter::SetIV(quiche::QuicheStringPiece iv) { +bool AeadBaseEncrypter::SetIV(absl::string_view iv) { if (!use_ietf_nonce_construction_) { QUIC_BUG << "Attempted to set IV on Google QUIC crypter"; return false; @@ -103,9 +103,9 @@ return true; } -bool AeadBaseEncrypter::Encrypt(quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext, +bool AeadBaseEncrypter::Encrypt(absl::string_view nonce, + absl::string_view associated_data, + absl::string_view plaintext, unsigned char* output) { DCHECK_EQ(nonce.size(), nonce_size_); @@ -125,8 +125,8 @@ } bool AeadBaseEncrypter::EncryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext, + absl::string_view associated_data, + absl::string_view plaintext, char* output, size_t* output_length, size_t max_output_length) { @@ -148,9 +148,8 @@ memcpy(nonce_buffer + prefix_len, &packet_number, sizeof(packet_number)); } - if (!Encrypt(quiche::QuicheStringPiece(nonce_buffer, nonce_size_), - associated_data, plaintext, - reinterpret_cast<unsigned char*>(output))) { + if (!Encrypt(absl::string_view(nonce_buffer, nonce_size_), associated_data, + plaintext, reinterpret_cast<unsigned char*>(output))) { return false; } *output_length = ciphertext_size; @@ -177,14 +176,13 @@ return plaintext_size + auth_tag_size_; } -quiche::QuicheStringPiece AeadBaseEncrypter::GetKey() const { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(key_), - key_size_); +absl::string_view AeadBaseEncrypter::GetKey() const { + return absl::string_view(reinterpret_cast<const char*>(key_), key_size_); } -quiche::QuicheStringPiece AeadBaseEncrypter::GetNoncePrefix() const { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(iv_), - GetNoncePrefixSize()); +absl::string_view AeadBaseEncrypter::GetNoncePrefix() const { + return absl::string_view(reinterpret_cast<const char*>(iv_), + GetNoncePrefixSize()); } } // namespace quic
diff --git a/quic/core/crypto/aead_base_encrypter.h b/quic/core/crypto/aead_base_encrypter.h index 5209a02..5ef8b96 100644 --- a/quic/core/crypto/aead_base_encrypter.h +++ b/quic/core/crypto/aead_base_encrypter.h
@@ -7,10 +7,10 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -29,12 +29,12 @@ ~AeadBaseEncrypter() override; // QuicEncrypter implementation - bool SetKey(quiche::QuicheStringPiece key) override; - bool SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) override; - bool SetIV(quiche::QuicheStringPiece iv) override; + bool SetKey(absl::string_view key) override; + bool SetNoncePrefix(absl::string_view nonce_prefix) override; + bool SetIV(absl::string_view iv) override; bool EncryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext, + absl::string_view associated_data, + absl::string_view plaintext, char* output, size_t* output_length, size_t max_output_length) override; @@ -43,14 +43,14 @@ size_t GetIVSize() const override; size_t GetMaxPlaintextSize(size_t ciphertext_size) const override; size_t GetCiphertextSize(size_t plaintext_size) const override; - quiche::QuicheStringPiece GetKey() const override; - quiche::QuicheStringPiece GetNoncePrefix() const override; + absl::string_view GetKey() const override; + absl::string_view GetNoncePrefix() const override; // Necessary so unit tests can explicitly specify a nonce, instead of an IV // (or nonce prefix) and packet number. - bool Encrypt(quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext, + bool Encrypt(absl::string_view nonce, + absl::string_view associated_data, + absl::string_view plaintext, unsigned char* output); protected:
diff --git a/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc b/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc index 0319d42..52a099e 100644 --- a/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc +++ b/quic/core/crypto/aes_128_gcm_12_decrypter_test.cc
@@ -7,11 +7,11 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -202,12 +202,12 @@ // DecryptWithNonce wraps the |Decrypt| method of |decrypter| to allow passing // in an nonce and also to allocate the buffer needed for the plaintext. QuicData* DecryptWithNonce(Aes128Gcm12Decrypter* decrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view ciphertext) { uint64_t packet_number; - quiche::QuicheStringPiece nonce_prefix(nonce.data(), - nonce.size() - sizeof(packet_number)); + absl::string_view nonce_prefix(nonce.data(), + nonce.size() - sizeof(packet_number)); decrypter->SetNoncePrefix(nonce_prefix); memcpy(&packet_number, nonce.data() + nonce_prefix.size(), sizeof(packet_number)); @@ -270,7 +270,7 @@ // This deliberately tests that the decrypter can // handle an AAD that is set to nullptr, as opposed // to a zero-length, non-nullptr pointer. - aad.length() ? aad : quiche::QuicheStringPiece(), ciphertext)); + aad.length() ? aad : absl::string_view(), ciphertext)); if (!decrypted) { EXPECT_FALSE(has_pt); continue;
diff --git a/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc b/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc index bc3f611..9e395cc 100644 --- a/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc +++ b/quic/core/crypto/aes_128_gcm_12_encrypter_test.cc
@@ -7,11 +7,11 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -160,9 +160,9 @@ // EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing // in an nonce and also to allocate the buffer needed for the ciphertext. QuicData* EncryptWithNonce(Aes128Gcm12Encrypter* encrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view plaintext) { size_t ciphertext_size = encrypter->GetCiphertextSize(plaintext.length()); std::unique_ptr<char[]> ciphertext(new char[ciphertext_size]); @@ -201,12 +201,12 @@ Aes128Gcm12Encrypter encrypter; ASSERT_TRUE(encrypter.SetKey(key)); - std::unique_ptr<QuicData> encrypted(EncryptWithNonce( - &encrypter, iv, - // This deliberately tests that the encrypter can - // handle an AAD that is set to nullptr, as opposed - // to a zero-length, non-nullptr pointer. - aad.length() ? aad : quiche::QuicheStringPiece(), pt)); + std::unique_ptr<QuicData> encrypted( + EncryptWithNonce(&encrypter, iv, + // This deliberately tests that the encrypter can + // handle an AAD that is set to nullptr, as opposed + // to a zero-length, non-nullptr pointer. + aad.length() ? aad : absl::string_view(), pt)); ASSERT_TRUE(encrypted.get()); // The test vectors have 16 byte authenticators but this code only uses
diff --git a/quic/core/crypto/aes_128_gcm_decrypter_test.cc b/quic/core/crypto/aes_128_gcm_decrypter_test.cc index a444284..33c3781 100644 --- a/quic/core/crypto/aes_128_gcm_decrypter_test.cc +++ b/quic/core/crypto/aes_128_gcm_decrypter_test.cc
@@ -201,9 +201,9 @@ // DecryptWithNonce wraps the |Decrypt| method of |decrypter| to allow passing // in an nonce and also to allocate the buffer needed for the plaintext. QuicData* DecryptWithNonce(Aes128GcmDecrypter* decrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view ciphertext) { decrypter->SetIV(nonce); std::unique_ptr<char[]> output(new char[ciphertext.length()]); size_t output_length = 0; @@ -258,7 +258,7 @@ // This deliberately tests that the decrypter can // handle an AAD that is set to nullptr, as opposed // to a zero-length, non-nullptr pointer. - aad.length() ? aad : quiche::QuicheStringPiece(), ciphertext)); + aad.length() ? aad : absl::string_view(), ciphertext)); if (!decrypted) { EXPECT_FALSE(has_pt); continue;
diff --git a/quic/core/crypto/aes_128_gcm_encrypter_test.cc b/quic/core/crypto/aes_128_gcm_encrypter_test.cc index 69f8c4d..b163689 100644 --- a/quic/core/crypto/aes_128_gcm_encrypter_test.cc +++ b/quic/core/crypto/aes_128_gcm_encrypter_test.cc
@@ -159,9 +159,9 @@ // EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing // in an nonce and also to allocate the buffer needed for the ciphertext. QuicData* EncryptWithNonce(Aes128GcmEncrypter* encrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view plaintext) { size_t ciphertext_size = encrypter->GetCiphertextSize(plaintext.length()); std::unique_ptr<char[]> ciphertext(new char[ciphertext_size]); @@ -200,12 +200,12 @@ Aes128GcmEncrypter encrypter; ASSERT_TRUE(encrypter.SetKey(key)); - std::unique_ptr<QuicData> encrypted(EncryptWithNonce( - &encrypter, iv, - // This deliberately tests that the encrypter can - // handle an AAD that is set to nullptr, as opposed - // to a zero-length, non-nullptr pointer. - aad.length() ? aad : quiche::QuicheStringPiece(), pt)); + std::unique_ptr<QuicData> encrypted( + EncryptWithNonce(&encrypter, iv, + // This deliberately tests that the encrypter can + // handle an AAD that is set to nullptr, as opposed + // to a zero-length, non-nullptr pointer. + aad.length() ? aad : absl::string_view(), pt)); ASSERT_TRUE(encrypted.get()); ASSERT_EQ(ct.length() + tag.length(), encrypted->length());
diff --git a/quic/core/crypto/aes_256_gcm_decrypter_test.cc b/quic/core/crypto/aes_256_gcm_decrypter_test.cc index 7c69724..e244f4a 100644 --- a/quic/core/crypto/aes_256_gcm_decrypter_test.cc +++ b/quic/core/crypto/aes_256_gcm_decrypter_test.cc
@@ -7,11 +7,11 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -206,9 +206,9 @@ // DecryptWithNonce wraps the |Decrypt| method of |decrypter| to allow passing // in an nonce and also to allocate the buffer needed for the plaintext. QuicData* DecryptWithNonce(Aes256GcmDecrypter* decrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view ciphertext) { decrypter->SetIV(nonce); std::unique_ptr<char[]> output(new char[ciphertext.length()]); size_t output_length = 0; @@ -263,7 +263,7 @@ // This deliberately tests that the decrypter can // handle an AAD that is set to nullptr, as opposed // to a zero-length, non-nullptr pointer. - aad.length() ? aad : quiche::QuicheStringPiece(), ciphertext)); + aad.length() ? aad : absl::string_view(), ciphertext)); if (!decrypted) { EXPECT_FALSE(has_pt); continue;
diff --git a/quic/core/crypto/aes_256_gcm_encrypter_test.cc b/quic/core/crypto/aes_256_gcm_encrypter_test.cc index 0899262..bdebfca 100644 --- a/quic/core/crypto/aes_256_gcm_encrypter_test.cc +++ b/quic/core/crypto/aes_256_gcm_encrypter_test.cc
@@ -7,11 +7,11 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -167,9 +167,9 @@ // EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing // in an nonce and also to allocate the buffer needed for the ciphertext. QuicData* EncryptWithNonce(Aes256GcmEncrypter* encrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view plaintext) { size_t ciphertext_size = encrypter->GetCiphertextSize(plaintext.length()); std::unique_ptr<char[]> ciphertext(new char[ciphertext_size]); @@ -208,12 +208,12 @@ Aes256GcmEncrypter encrypter; ASSERT_TRUE(encrypter.SetKey(key)); - std::unique_ptr<QuicData> encrypted(EncryptWithNonce( - &encrypter, iv, - // This deliberately tests that the encrypter can - // handle an AAD that is set to nullptr, as opposed - // to a zero-length, non-nullptr pointer. - aad.length() ? aad : quiche::QuicheStringPiece(), pt)); + std::unique_ptr<QuicData> encrypted( + EncryptWithNonce(&encrypter, iv, + // This deliberately tests that the encrypter can + // handle an AAD that is set to nullptr, as opposed + // to a zero-length, non-nullptr pointer. + aad.length() ? aad : absl::string_view(), pt)); ASSERT_TRUE(encrypted.get()); ASSERT_EQ(ct.length() + tag.length(), encrypted->length());
diff --git a/quic/core/crypto/aes_base_decrypter.cc b/quic/core/crypto/aes_base_decrypter.cc index f8c83f3..5bd9c33 100644 --- a/quic/core/crypto/aes_base_decrypter.cc +++ b/quic/core/crypto/aes_base_decrypter.cc
@@ -4,13 +4,13 @@ #include "net/third_party/quiche/src/quic/core/crypto/aes_base_decrypter.h" +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { -bool AesBaseDecrypter::SetHeaderProtectionKey(quiche::QuicheStringPiece key) { +bool AesBaseDecrypter::SetHeaderProtectionKey(absl::string_view key) { if (key.size() != GetKeySize()) { QUIC_BUG << "Invalid key size for header protection"; return false; @@ -25,7 +25,7 @@ std::string AesBaseDecrypter::GenerateHeaderProtectionMask( QuicDataReader* sample_reader) { - quiche::QuicheStringPiece sample; + absl::string_view sample; if (!sample_reader->ReadStringPiece(&sample, AES_BLOCK_SIZE)) { return std::string(); }
diff --git a/quic/core/crypto/aes_base_decrypter.h b/quic/core/crypto/aes_base_decrypter.h index 2ff63a7..e3613e4 100644 --- a/quic/core/crypto/aes_base_decrypter.h +++ b/quic/core/crypto/aes_base_decrypter.h
@@ -7,10 +7,10 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" #include "net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -18,7 +18,7 @@ public: using AeadBaseDecrypter::AeadBaseDecrypter; - bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; + bool SetHeaderProtectionKey(absl::string_view key) override; std::string GenerateHeaderProtectionMask( QuicDataReader* sample_reader) override;
diff --git a/quic/core/crypto/aes_base_encrypter.cc b/quic/core/crypto/aes_base_encrypter.cc index c620329..436b7bd 100644 --- a/quic/core/crypto/aes_base_encrypter.cc +++ b/quic/core/crypto/aes_base_encrypter.cc
@@ -4,13 +4,13 @@ #include "net/third_party/quiche/src/quic/core/crypto/aes_base_encrypter.h" +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { -bool AesBaseEncrypter::SetHeaderProtectionKey(quiche::QuicheStringPiece key) { +bool AesBaseEncrypter::SetHeaderProtectionKey(absl::string_view key) { if (key.size() != GetKeySize()) { QUIC_BUG << "Invalid key size for header protection: " << key.size(); return false; @@ -24,7 +24,7 @@ } std::string AesBaseEncrypter::GenerateHeaderProtectionMask( - quiche::QuicheStringPiece sample) { + absl::string_view sample) { if (sample.size() != AES_BLOCK_SIZE) { return std::string(); }
diff --git a/quic/core/crypto/aes_base_encrypter.h b/quic/core/crypto/aes_base_encrypter.h index ba518fe..7339640 100644 --- a/quic/core/crypto/aes_base_encrypter.h +++ b/quic/core/crypto/aes_base_encrypter.h
@@ -7,10 +7,10 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aes.h" #include "net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -18,9 +18,8 @@ public: using AeadBaseEncrypter::AeadBaseEncrypter; - bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; - std::string GenerateHeaderProtectionMask( - quiche::QuicheStringPiece sample) override; + bool SetHeaderProtectionKey(absl::string_view key) override; + std::string GenerateHeaderProtectionMask(absl::string_view sample) override; private: // The key used for packet number encryption.
diff --git a/quic/core/crypto/boring_utils.h b/quic/core/crypto/boring_utils.h index 5af87ae..9de61f4 100644 --- a/quic/core/crypto/boring_utils.h +++ b/quic/core/crypto/boring_utils.h
@@ -5,19 +5,18 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_BORING_UTILS_H_ #define QUICHE_QUIC_CORE_CRYPTO_BORING_UTILS_H_ +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { -inline QUIC_EXPORT_PRIVATE quiche::QuicheStringPiece CbsToStringPiece(CBS cbs) { - return quiche::QuicheStringPiece( - reinterpret_cast<const char*>(CBS_data(&cbs)), CBS_len(&cbs)); +inline QUIC_EXPORT_PRIVATE absl::string_view CbsToStringPiece(CBS cbs) { + return absl::string_view(reinterpret_cast<const char*>(CBS_data(&cbs)), + CBS_len(&cbs)); } -inline QUIC_EXPORT_PRIVATE CBS -StringPieceToCbs(quiche::QuicheStringPiece piece) { +inline QUIC_EXPORT_PRIVATE CBS StringPieceToCbs(absl::string_view piece) { CBS result; CBS_init(&result, reinterpret_cast<const uint8_t*>(piece.data()), piece.size());
diff --git a/quic/core/crypto/cert_compressor.cc b/quic/core/crypto/cert_compressor.cc index a1ba748..ec5ebac 100644 --- a/quic/core/crypto/cert_compressor.cc +++ b/quic/core/crypto/cert_compressor.cc
@@ -9,8 +9,8 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "third_party/zlib/zlib.h" namespace quic { @@ -175,11 +175,10 @@ // efficiently represent |certs| to a peer who has the common sets identified // by |client_common_set_hashes| and who has cached the certificates with the // 64-bit, FNV-1a hashes in |client_cached_cert_hashes|. -std::vector<CertEntry> MatchCerts( - const std::vector<std::string>& certs, - quiche::QuicheStringPiece client_common_set_hashes, - quiche::QuicheStringPiece client_cached_cert_hashes, - const CommonCertSets* common_sets) { +std::vector<CertEntry> MatchCerts(const std::vector<std::string>& certs, + absl::string_view client_common_set_hashes, + absl::string_view client_cached_cert_hashes, + const CommonCertSets* common_sets) { std::vector<CertEntry> entries; entries.reserve(certs.size()); @@ -330,12 +329,12 @@ // |in_out| and writes them to |out_entries|. CACHED and COMMON entries are // resolved using |cached_certs| and |common_sets| and written to |out_certs|. // |in_out| is updated to contain the trailing data. -bool ParseEntries(quiche::QuicheStringPiece* in_out, +bool ParseEntries(absl::string_view* in_out, const std::vector<std::string>& cached_certs, const CommonCertSets* common_sets, std::vector<CertEntry>* out_entries, std::vector<std::string>* out_certs) { - quiche::QuicheStringPiece in = *in_out; + absl::string_view in = *in_out; std::vector<uint64_t> cached_hashes; out_entries->clear(); @@ -394,7 +393,7 @@ memcpy(&entry.index, in.data(), sizeof(uint32_t)); in.remove_prefix(sizeof(uint32_t)); - quiche::QuicheStringPiece cert = + absl::string_view cert = common_sets->GetCert(entry.set_hash, entry.index); if (cert.empty()) { return false; @@ -452,8 +451,8 @@ // static std::string CertCompressor::CompressChain( const std::vector<std::string>& certs, - quiche::QuicheStringPiece client_common_set_hashes, - quiche::QuicheStringPiece client_cached_cert_hashes, + absl::string_view client_common_set_hashes, + absl::string_view client_cached_cert_hashes, const CommonCertSets* common_sets) { const std::vector<CertEntry> entries = MatchCerts( certs, client_common_set_hashes, client_cached_cert_hashes, common_sets); @@ -553,7 +552,7 @@ // static bool CertCompressor::DecompressChain( - quiche::QuicheStringPiece in, + absl::string_view in, const std::vector<std::string>& cached_certs, const CommonCertSets* common_sets, std::vector<std::string>* out_certs) { @@ -564,7 +563,7 @@ DCHECK_EQ(entries.size(), out_certs->size()); std::unique_ptr<uint8_t[]> uncompressed_data; - quiche::QuicheStringPiece uncompressed; + absl::string_view uncompressed; if (!in.empty()) { if (in.size() < sizeof(uint32_t)) { @@ -609,7 +608,7 @@ return false; } - uncompressed = quiche::QuicheStringPiece( + uncompressed = absl::string_view( reinterpret_cast<char*>(uncompressed_data.get()), uncompressed_size); }
diff --git a/quic/core/crypto/cert_compressor.h b/quic/core/crypto/cert_compressor.h index dfb4d21..a9e9ec9 100644 --- a/quic/core/crypto/cert_compressor.h +++ b/quic/core/crypto/cert_compressor.h
@@ -8,10 +8,10 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -36,17 +36,16 @@ // sets known locally and |client_common_set_hashes| contains the hashes of // the common sets known to the peer. |client_cached_cert_hashes| contains // 64-bit, FNV-1a hashes of certificates that the peer already possesses. - static std::string CompressChain( - const std::vector<std::string>& certs, - quiche::QuicheStringPiece client_common_set_hashes, - quiche::QuicheStringPiece client_cached_cert_hashes, - const CommonCertSets* common_sets); + static std::string CompressChain(const std::vector<std::string>& certs, + absl::string_view client_common_set_hashes, + absl::string_view client_cached_cert_hashes, + const CommonCertSets* common_sets); // DecompressChain decompresses the result of |CompressChain|, given in |in|, // into a series of certificates that are written to |out_certs|. // |cached_certs| contains certificates that the peer may have omitted and // |common_sets| contains the common certificate sets known locally. - static bool DecompressChain(quiche::QuicheStringPiece in, + static bool DecompressChain(absl::string_view in, const std::vector<std::string>& cached_certs, const CommonCertSets* common_sets, std::vector<std::string>* out_certs);
diff --git a/quic/core/crypto/cert_compressor_test.cc b/quic/core/crypto/cert_compressor_test.cc index a7517f4..6a3c27c 100644 --- a/quic/core/crypto/cert_compressor_test.cc +++ b/quic/core/crypto/cert_compressor_test.cc
@@ -7,10 +7,10 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -21,7 +21,7 @@ TEST_F(CertCompressorTest, EmptyChain) { std::vector<std::string> chain; const std::string compressed = CertCompressor::CompressChain( - chain, quiche::QuicheStringPiece(), quiche::QuicheStringPiece(), nullptr); + chain, absl::string_view(), absl::string_view(), nullptr); EXPECT_EQ("00", quiche::QuicheTextUtils::HexEncode(compressed)); std::vector<std::string> chain2, cached_certs; @@ -34,7 +34,7 @@ std::vector<std::string> chain; chain.push_back("testcert"); const std::string compressed = CertCompressor::CompressChain( - chain, quiche::QuicheStringPiece(), quiche::QuicheStringPiece(), nullptr); + chain, absl::string_view(), absl::string_view(), nullptr); ASSERT_GE(compressed.size(), 2u); EXPECT_EQ("0100", quiche::QuicheTextUtils::HexEncode(compressed.substr(0, 2))); @@ -54,9 +54,9 @@ crypto_test_utils::MockCommonCertSets(chain[0], set_hash, 1)); const std::string compressed = CertCompressor::CompressChain( chain, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(&set_hash), - sizeof(set_hash)), - quiche::QuicheStringPiece(), common_sets.get()); + absl::string_view(reinterpret_cast<const char*>(&set_hash), + sizeof(set_hash)), + absl::string_view(), common_sets.get()); EXPECT_EQ( "03" /* common */ "2a00000000000000" /* set hash 42 */ @@ -75,10 +75,9 @@ std::vector<std::string> chain; chain.push_back("testcert"); uint64_t hash = QuicUtils::FNV1a_64_Hash(chain[0]); - quiche::QuicheStringPiece hash_bytes(reinterpret_cast<char*>(&hash), - sizeof(hash)); + absl::string_view hash_bytes(reinterpret_cast<char*>(&hash), sizeof(hash)); const std::string compressed = CertCompressor::CompressChain( - chain, quiche::QuicheStringPiece(), hash_bytes, nullptr); + chain, absl::string_view(), hash_bytes, nullptr); EXPECT_EQ("02" /* cached */ + quiche::QuicheTextUtils::HexEncode(hash_bytes) + "00" /* end of list */,
diff --git a/quic/core/crypto/certificate_view.cc b/quic/core/crypto/certificate_view.cc index 36b6d3f..1fe0052 100644 --- a/quic/core/crypto/certificate_view.cc +++ b/quic/core/crypto/certificate_view.cc
@@ -9,6 +9,7 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/digest.h" @@ -26,7 +27,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/common/platform/api/quiche_optional.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_time_utils.h" #include "net/third_party/quiche/src/common/quiche_data_reader.h" @@ -34,7 +34,6 @@ namespace { using ::quiche::QuicheOptional; -using ::quiche::QuicheStringPiece; using ::quiche::QuicheTextUtils; // The literals below were encoded using `ascii2der | xxd -i`. The comments @@ -106,7 +105,7 @@ namespace quic { QuicheOptional<quic::QuicWallTime> ParseDerTime(unsigned tag, - QuicheStringPiece payload) { + absl::string_view payload) { if (tag != CBS_ASN1_GENERALIZEDTIME && tag != CBS_ASN1_UTCTIME) { QUIC_BUG << "Invalid tag supplied for a DER timestamp"; return QUICHE_NULLOPT; @@ -139,15 +138,15 @@ } PemReadResult ReadNextPemMessage(std::istream* input) { - constexpr QuicheStringPiece kPemBegin = "-----BEGIN "; - constexpr QuicheStringPiece kPemEnd = "-----END "; - constexpr QuicheStringPiece kPemDashes = "-----"; + constexpr absl::string_view kPemBegin = "-----BEGIN "; + constexpr absl::string_view kPemEnd = "-----END "; + constexpr absl::string_view kPemDashes = "-----"; std::string line_buffer, encoded_message_contents, expected_end; bool pending_message = false; PemReadResult result; while (std::getline(*input, line_buffer)) { - QuicheStringPiece line(line_buffer); + absl::string_view line(line_buffer); QuicheTextUtils::RemoveLeadingAndTrailingWhitespace(&line); // Handle BEGIN lines. @@ -184,7 +183,7 @@ } std::unique_ptr<CertificateView> CertificateView::ParseSingleCertificate( - QuicheStringPiece certificate) { + absl::string_view certificate) { std::unique_ptr<CertificateView> result(new CertificateView()); CBS top = StringPieceToCbs(certificate); @@ -348,7 +347,7 @@ return false; } - QuicheStringPiece alt_name = CbsToStringPiece(alt_name_cbs); + absl::string_view alt_name = CbsToStringPiece(alt_name_cbs); QuicIpAddress ip_address; // GeneralName ::= CHOICE { switch (alt_name_tag) { @@ -417,8 +416,8 @@ } } -bool CertificateView::VerifySignature(QuicheStringPiece data, - QuicheStringPiece signature, +bool CertificateView::VerifySignature(absl::string_view data, + absl::string_view signature, uint16_t signature_algorithm) const { if (PublicKeyTypeFromSignatureAlgorithm(signature_algorithm) != PublicKeyTypeFromKey(public_key_.get())) { @@ -448,7 +447,7 @@ } std::unique_ptr<CertificatePrivateKey> CertificatePrivateKey::LoadFromDer( - QuicheStringPiece private_key) { + absl::string_view private_key) { std::unique_ptr<CertificatePrivateKey> result(new CertificatePrivateKey()); CBS private_key_cbs = StringPieceToCbs(private_key); result->private_key_.reset(EVP_parse_private_key(&private_key_cbs)); @@ -506,7 +505,7 @@ return nullptr; } -std::string CertificatePrivateKey::Sign(QuicheStringPiece input, +std::string CertificatePrivateKey::Sign(absl::string_view input, uint16_t signature_algorithm) { if (!ValidForSignatureAlgorithm(signature_algorithm)) { QUIC_BUG << "Mismatch between the requested signature algorithm and the "
diff --git a/quic/core/crypto/certificate_view.h b/quic/core/crypto/certificate_view.h index d06ff78..18f62f0 100644 --- a/quic/core/crypto/certificate_view.h +++ b/quic/core/crypto/certificate_view.h
@@ -9,6 +9,7 @@ #include <memory> #include <vector> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/evp.h" @@ -18,7 +19,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" #include "net/third_party/quiche/src/common/platform/api/quiche_optional.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -43,7 +43,7 @@ // Parses a single DER-encoded X.509 certificate. Returns nullptr on parse // error. static std::unique_ptr<CertificateView> ParseSingleCertificate( - quiche::QuicheStringPiece certificate); + absl::string_view certificate); // Loads all PEM-encoded X.509 certificates found in the |input| stream // without parsing them. Returns an empty vector if any parsing error occurs. @@ -53,8 +53,7 @@ QuicWallTime validity_end() const { return validity_end_; } const EVP_PKEY* public_key() const { return public_key_.get(); } - const std::vector<quiche::QuicheStringPiece>& subject_alt_name_domains() - const { + const std::vector<absl::string_view>& subject_alt_name_domains() const { return subject_alt_name_domains_; } const std::vector<QuicIpAddress>& subject_alt_name_ips() const { @@ -62,8 +61,8 @@ } // |signature_algorithm| is a TLS signature algorithm ID. - bool VerifySignature(quiche::QuicheStringPiece data, - quiche::QuicheStringPiece signature, + bool VerifySignature(absl::string_view data, + absl::string_view signature, uint16_t signature_algorithm) const; private: @@ -76,7 +75,7 @@ bssl::UniquePtr<EVP_PKEY> public_key_; // SubjectAltName, https://tools.ietf.org/html/rfc5280#section-4.2.1.6 - std::vector<quiche::QuicheStringPiece> subject_alt_name_domains_; + std::vector<absl::string_view> subject_alt_name_domains_; std::vector<QuicIpAddress> subject_alt_name_ips_; // Called from ParseSingleCertificate(). @@ -93,7 +92,7 @@ // Loads a DER-encoded PrivateKeyInfo structure (RFC 5958) as a private key. static std::unique_ptr<CertificatePrivateKey> LoadFromDer( - quiche::QuicheStringPiece private_key); + absl::string_view private_key); // Loads a private key from a PEM file formatted according to RFC 7468. Also // supports legacy OpenSSL RSA key format ("BEGIN RSA PRIVATE KEY"). @@ -101,8 +100,7 @@ std::istream* input); // |signature_algorithm| is a TLS signature algorithm ID. - std::string Sign(quiche::QuicheStringPiece input, - uint16_t signature_algorithm); + std::string Sign(absl::string_view input, uint16_t signature_algorithm); // Verifies that the private key in question matches the public key of the // certificate |view|. @@ -124,7 +122,7 @@ // testing. QUIC_EXPORT_PRIVATE quiche::QuicheOptional<quic::QuicWallTime> ParseDerTime( unsigned tag, - quiche::QuicheStringPiece payload); + absl::string_view payload); } // namespace quic
diff --git a/quic/core/crypto/certificate_view_test.cc b/quic/core/crypto/certificate_view_test.cc index e7ce0ce..c205360 100644 --- a/quic/core/crypto/certificate_view_test.cc +++ b/quic/core/crypto/certificate_view_test.cc
@@ -7,6 +7,7 @@ #include <memory> #include <sstream> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/evp.h" @@ -15,7 +16,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_ip_address.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/test_certificates.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_time_utils.h" namespace quic { @@ -43,9 +43,9 @@ ASSERT_TRUE(view != nullptr); EXPECT_THAT(view->subject_alt_name_domains(), - ElementsAre(quiche::QuicheStringPiece("www.example.org"), - quiche::QuicheStringPiece("mail.example.org"), - quiche::QuicheStringPiece("mail.example.com"))); + ElementsAre(absl::string_view("www.example.org"), + absl::string_view("mail.example.org"), + absl::string_view("mail.example.com"))); EXPECT_THAT(view->subject_alt_name_ips(), ElementsAre(QuicIpAddress::Loopback4())); EXPECT_EQ(EVP_PKEY_id(view->public_key()), EVP_PKEY_RSA);
diff --git a/quic/core/crypto/chacha20_poly1305_decrypter_test.cc b/quic/core/crypto/chacha20_poly1305_decrypter_test.cc index 83e52b1..ab1baad 100644 --- a/quic/core/crypto/chacha20_poly1305_decrypter_test.cc +++ b/quic/core/crypto/chacha20_poly1305_decrypter_test.cc
@@ -7,10 +7,10 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -115,12 +115,12 @@ // DecryptWithNonce wraps the |Decrypt| method of |decrypter| to allow passing // in an nonce and also to allocate the buffer needed for the plaintext. QuicData* DecryptWithNonce(ChaCha20Poly1305Decrypter* decrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view ciphertext) { uint64_t packet_number; - quiche::QuicheStringPiece nonce_prefix(nonce.data(), - nonce.size() - sizeof(packet_number)); + absl::string_view nonce_prefix(nonce.data(), + nonce.size() - sizeof(packet_number)); decrypter->SetNoncePrefix(nonce_prefix); memcpy(&packet_number, nonce.data() + nonce_prefix.size(), sizeof(packet_number)); @@ -160,8 +160,7 @@ &decrypter, fixed + iv, // This deliberately tests that the decrypter can handle an AAD that // is set to nullptr, as opposed to a zero-length, non-nullptr pointer. - quiche::QuicheStringPiece(aad.length() ? aad.data() : nullptr, - aad.length()), + absl::string_view(aad.length() ? aad.data() : nullptr, aad.length()), ct)); if (!decrypted) { EXPECT_FALSE(has_pt);
diff --git a/quic/core/crypto/chacha20_poly1305_encrypter_test.cc b/quic/core/crypto/chacha20_poly1305_encrypter_test.cc index 47ee3d0..3672f75 100644 --- a/quic/core/crypto/chacha20_poly1305_encrypter_test.cc +++ b/quic/core/crypto/chacha20_poly1305_encrypter_test.cc
@@ -7,12 +7,12 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_decrypter.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -72,9 +72,9 @@ // EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing // in an nonce and also to allocate the buffer needed for the ciphertext. QuicData* EncryptWithNonce(ChaCha20Poly1305Encrypter* encrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view plaintext) { size_t ciphertext_size = encrypter->GetCiphertextSize(plaintext.length()); std::unique_ptr<char[]> ciphertext(new char[ciphertext_size]); @@ -106,7 +106,7 @@ ASSERT_TRUE(encrypter.EncryptPacket(packet_number, associated_data, plaintext, encrypted, &len, QUICHE_ARRAYSIZE(encrypted))); - quiche::QuicheStringPiece ciphertext(encrypted, len); + absl::string_view ciphertext(encrypted, len); char decrypted[1024]; ASSERT_TRUE(decrypter.DecryptPacket(packet_number, associated_data, ciphertext, decrypted, &len, @@ -130,8 +130,7 @@ &encrypter, fixed + iv, // This deliberately tests that the encrypter can handle an AAD that // is set to nullptr, as opposed to a zero-length, non-nullptr pointer. - quiche::QuicheStringPiece(aad.length() ? aad.data() : nullptr, - aad.length()), + absl::string_view(aad.length() ? aad.data() : nullptr, aad.length()), pt)); ASSERT_TRUE(encrypted.get()); EXPECT_EQ(12u, ct.size() - pt.size());
diff --git a/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc b/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc index 9127cd4..2c7aba1 100644 --- a/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc +++ b/quic/core/crypto/chacha20_poly1305_tls_decrypter_test.cc
@@ -7,10 +7,10 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -115,9 +115,9 @@ // DecryptWithNonce wraps the |Decrypt| method of |decrypter| to allow passing // in an nonce and also to allocate the buffer needed for the plaintext. QuicData* DecryptWithNonce(ChaCha20Poly1305TlsDecrypter* decrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view ciphertext) { decrypter->SetIV(nonce); std::unique_ptr<char[]> output(new char[ciphertext.length()]); size_t output_length = 0; @@ -155,8 +155,7 @@ &decrypter, fixed + iv, // This deliberately tests that the decrypter can handle an AAD that // is set to nullptr, as opposed to a zero-length, non-nullptr pointer. - quiche::QuicheStringPiece(aad.length() ? aad.data() : nullptr, - aad.length()), + absl::string_view(aad.length() ? aad.data() : nullptr, aad.length()), ct)); if (!decrypted) { EXPECT_FALSE(has_pt);
diff --git a/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc b/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc index dd642a3..9191768 100644 --- a/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc +++ b/quic/core/crypto/chacha20_poly1305_tls_encrypter_test.cc
@@ -7,12 +7,12 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_tls_decrypter.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" @@ -72,9 +72,9 @@ // EncryptWithNonce wraps the |Encrypt| method of |encrypter| to allow passing // in an nonce and also to allocate the buffer needed for the ciphertext. QuicData* EncryptWithNonce(ChaCha20Poly1305TlsEncrypter* encrypter, - quiche::QuicheStringPiece nonce, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext) { + absl::string_view nonce, + absl::string_view associated_data, + absl::string_view plaintext) { size_t ciphertext_size = encrypter->GetCiphertextSize(plaintext.length()); std::unique_ptr<char[]> ciphertext(new char[ciphertext_size]); @@ -106,7 +106,7 @@ ASSERT_TRUE(encrypter.EncryptPacket(packet_number, associated_data, plaintext, encrypted, &len, QUICHE_ARRAYSIZE(encrypted))); - quiche::QuicheStringPiece ciphertext(encrypted, len); + absl::string_view ciphertext(encrypted, len); char decrypted[1024]; ASSERT_TRUE(decrypter.DecryptPacket(packet_number, associated_data, ciphertext, decrypted, &len, @@ -130,8 +130,7 @@ &encrypter, fixed + iv, // This deliberately tests that the encrypter can handle an AAD that // is set to nullptr, as opposed to a zero-length, non-nullptr pointer. - quiche::QuicheStringPiece(aad.length() ? aad.data() : nullptr, - aad.length()), + absl::string_view(aad.length() ? aad.data() : nullptr, aad.length()), pt)); ASSERT_TRUE(encrypted.get()); EXPECT_EQ(16u, ct.size() - pt.size());
diff --git a/quic/core/crypto/chacha_base_decrypter.cc b/quic/core/crypto/chacha_base_decrypter.cc index bc09b66..d857e5a 100644 --- a/quic/core/crypto/chacha_base_decrypter.cc +++ b/quic/core/crypto/chacha_base_decrypter.cc
@@ -6,17 +6,16 @@ #include <cstdint> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/chacha.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { -bool ChaChaBaseDecrypter::SetHeaderProtectionKey( - quiche::QuicheStringPiece key) { +bool ChaChaBaseDecrypter::SetHeaderProtectionKey(absl::string_view key) { if (key.size() != GetKeySize()) { QUIC_BUG << "Invalid key size for header protection"; return false; @@ -27,7 +26,7 @@ std::string ChaChaBaseDecrypter::GenerateHeaderProtectionMask( QuicDataReader* sample_reader) { - quiche::QuicheStringPiece sample; + absl::string_view sample; if (!sample_reader->ReadStringPiece(&sample, 16)) { return std::string(); }
diff --git a/quic/core/crypto/chacha_base_decrypter.h b/quic/core/crypto/chacha_base_decrypter.h index 24ca820..610bc59 100644 --- a/quic/core/crypto/chacha_base_decrypter.h +++ b/quic/core/crypto/chacha_base_decrypter.h
@@ -7,9 +7,9 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/aead_base_decrypter.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -17,7 +17,7 @@ public: using AeadBaseDecrypter::AeadBaseDecrypter; - bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; + bool SetHeaderProtectionKey(absl::string_view key) override; std::string GenerateHeaderProtectionMask( QuicDataReader* sample_reader) override;
diff --git a/quic/core/crypto/chacha_base_encrypter.cc b/quic/core/crypto/chacha_base_encrypter.cc index 7fdc019..7d84358 100644 --- a/quic/core/crypto/chacha_base_encrypter.cc +++ b/quic/core/crypto/chacha_base_encrypter.cc
@@ -4,17 +4,16 @@ #include "net/third_party/quiche/src/quic/core/crypto/chacha_base_encrypter.h" +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/chacha.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { -bool ChaChaBaseEncrypter::SetHeaderProtectionKey( - quiche::QuicheStringPiece key) { +bool ChaChaBaseEncrypter::SetHeaderProtectionKey(absl::string_view key) { if (key.size() != GetKeySize()) { QUIC_BUG << "Invalid key size for header protection"; return false; @@ -24,7 +23,7 @@ } std::string ChaChaBaseEncrypter::GenerateHeaderProtectionMask( - quiche::QuicheStringPiece sample) { + absl::string_view sample) { if (sample.size() != 16) { return std::string(); }
diff --git a/quic/core/crypto/chacha_base_encrypter.h b/quic/core/crypto/chacha_base_encrypter.h index 16d1df1..97385c3 100644 --- a/quic/core/crypto/chacha_base_encrypter.h +++ b/quic/core/crypto/chacha_base_encrypter.h
@@ -7,9 +7,9 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/aead_base_encrypter.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -17,9 +17,8 @@ public: using AeadBaseEncrypter::AeadBaseEncrypter; - bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; - std::string GenerateHeaderProtectionMask( - quiche::QuicheStringPiece sample) override; + bool SetHeaderProtectionKey(absl::string_view key) override; + std::string GenerateHeaderProtectionMask(absl::string_view sample) override; private: // The key used for packet number encryption.
diff --git a/quic/core/crypto/channel_id.cc b/quic/core/crypto/channel_id.cc index facd552..2d30147 100644 --- a/quic/core/crypto/channel_id.cc +++ b/quic/core/crypto/channel_id.cc
@@ -6,12 +6,12 @@ #include <cstdint> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/bn.h" #include "third_party/boringssl/src/include/openssl/ec.h" #include "third_party/boringssl/src/include/openssl/ecdsa.h" #include "third_party/boringssl/src/include/openssl/nid.h" #include "third_party/boringssl/src/include/openssl/sha.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -21,16 +21,16 @@ const char ChannelIDVerifier::kClientToServerStr[] = "client -> server"; // static -bool ChannelIDVerifier::Verify(quiche::QuicheStringPiece key, - quiche::QuicheStringPiece signed_data, - quiche::QuicheStringPiece signature) { +bool ChannelIDVerifier::Verify(absl::string_view key, + absl::string_view signed_data, + absl::string_view signature) { return VerifyRaw(key, signed_data, signature, true); } // static -bool ChannelIDVerifier::VerifyRaw(quiche::QuicheStringPiece key, - quiche::QuicheStringPiece signed_data, - quiche::QuicheStringPiece signature, +bool ChannelIDVerifier::VerifyRaw(absl::string_view key, + absl::string_view signed_data, + absl::string_view signature, bool is_channel_id_signature) { if (key.size() != 32 * 2 || signature.size() != 32 * 2) { return false;
diff --git a/quic/core/crypto/channel_id.h b/quic/core/crypto/channel_id.h index c04aac3..e176cdb 100644 --- a/quic/core/crypto/channel_id.h +++ b/quic/core/crypto/channel_id.h
@@ -8,9 +8,9 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -30,17 +30,17 @@ // Verify returns true iff |signature| is a valid signature of |signed_data| // by |key|. - static bool Verify(quiche::QuicheStringPiece key, - quiche::QuicheStringPiece signed_data, - quiche::QuicheStringPiece signature); + static bool Verify(absl::string_view key, + absl::string_view signed_data, + absl::string_view signature); // FOR TESTING ONLY: VerifyRaw returns true iff |signature| is a valid // signature of |signed_data| by |key|. |is_channel_id_signature| indicates // whether |signature| is a ChannelID signature (with kContextStr prepended // to the data to be signed). - static bool VerifyRaw(quiche::QuicheStringPiece key, - quiche::QuicheStringPiece signed_data, - quiche::QuicheStringPiece signature, + static bool VerifyRaw(absl::string_view key, + absl::string_view signed_data, + absl::string_view signature, bool is_channel_id_signature); };
diff --git a/quic/core/crypto/channel_id_test.cc b/quic/core/crypto/channel_id_test.cc index d4a14cd..cd95539 100644 --- a/quic/core/crypto/channel_id_test.cc +++ b/quic/core/crypto/channel_id_test.cc
@@ -7,9 +7,9 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -275,12 +275,11 @@ EXPECT_EQ(sizeof(signature) / 2, r_len); EXPECT_EQ(sizeof(signature) / 2, s_len); - EXPECT_EQ( - test_vector[i].result, - ChannelIDVerifier::VerifyRaw( - quiche::QuicheStringPiece(key, sizeof(key)), - quiche::QuicheStringPiece(msg, msg_len), - quiche::QuicheStringPiece(signature, sizeof(signature)), false)); + EXPECT_EQ(test_vector[i].result, + ChannelIDVerifier::VerifyRaw( + absl::string_view(key, sizeof(key)), + absl::string_view(msg, msg_len), + absl::string_view(signature, sizeof(signature)), false)); } }
diff --git a/quic/core/crypto/common_cert_set.cc b/quic/core/crypto/common_cert_set.cc index 0ccbf2d..7894037 100644 --- a/quic/core/crypto/common_cert_set.cc +++ b/quic/core/crypto/common_cert_set.cc
@@ -6,9 +6,9 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -56,7 +56,7 @@ // Compare returns a value less than, equal to or greater than zero if |a| is // lexicographically less than, equal to or greater than |b|, respectively. -int Compare(quiche::QuicheStringPiece a, const unsigned char* b, size_t b_len) { +int Compare(absl::string_view a, const unsigned char* b, size_t b_len) { size_t len = a.size(); if (len > b_len) { len = b_len; @@ -79,18 +79,16 @@ class CommonCertSetsQUIC : public CommonCertSets { public: // CommonCertSets interface. - quiche::QuicheStringPiece GetCommonHashes() const override { - return quiche::QuicheStringPiece( - reinterpret_cast<const char*>(kSetHashes), - sizeof(uint64_t) * QUICHE_ARRAYSIZE(kSetHashes)); + absl::string_view GetCommonHashes() const override { + return absl::string_view(reinterpret_cast<const char*>(kSetHashes), + sizeof(uint64_t) * QUICHE_ARRAYSIZE(kSetHashes)); } - quiche::QuicheStringPiece GetCert(uint64_t hash, - uint32_t index) const override { + absl::string_view GetCert(uint64_t hash, uint32_t index) const override { for (size_t i = 0; i < QUICHE_ARRAYSIZE(kSets); i++) { if (kSets[i].hash == hash) { if (index < kSets[i].num_certs) { - return quiche::QuicheStringPiece( + return absl::string_view( reinterpret_cast<const char*>(kSets[i].certs[index]), kSets[i].lens[index]); } @@ -98,11 +96,11 @@ } } - return quiche::QuicheStringPiece(); + return absl::string_view(); } - bool MatchCert(quiche::QuicheStringPiece cert, - quiche::QuicheStringPiece common_set_hashes, + bool MatchCert(absl::string_view cert, + absl::string_view common_set_hashes, uint64_t* out_hash, uint32_t* out_index) const override { if (common_set_hashes.size() % sizeof(uint64_t) != 0) {
diff --git a/quic/core/crypto/common_cert_set.h b/quic/core/crypto/common_cert_set.h index af211ad..ae83e1d 100644 --- a/quic/core/crypto/common_cert_set.h +++ b/quic/core/crypto/common_cert_set.h
@@ -7,9 +7,9 @@ #include <cstdint> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -22,23 +22,22 @@ // GetInstanceQUIC returns the standard QUIC common certificate sets. static const CommonCertSets* GetInstanceQUIC(); - // GetCommonHashes returns a quiche::QuicheStringPiece containing the hashes + // GetCommonHashes returns a absl::string_view containing the hashes // of common sets supported by this object. The 64-bit hashes are concatenated - // in the quiche::QuicheStringPiece. - virtual quiche::QuicheStringPiece GetCommonHashes() const = 0; + // in the absl::string_view. + virtual absl::string_view GetCommonHashes() const = 0; // GetCert returns a specific certificate (at index |index|) in the common // set identified by |hash|. If no such certificate is known, an empty - // quiche::QuicheStringPiece is returned. - virtual quiche::QuicheStringPiece GetCert(uint64_t hash, - uint32_t index) const = 0; + // absl::string_view is returned. + virtual absl::string_view GetCert(uint64_t hash, uint32_t index) const = 0; // MatchCert tries to find |cert| in one of the common certificate sets // identified by |common_set_hashes|. On success it puts the hash of the // set in |out_hash|, the index of |cert| in the set in |out_index| and // returns true. Otherwise it returns false. - virtual bool MatchCert(quiche::QuicheStringPiece cert, - quiche::QuicheStringPiece common_set_hashes, + virtual bool MatchCert(absl::string_view cert, + absl::string_view common_set_hashes, uint64_t* out_hash, uint32_t* out_index) const = 0; };
diff --git a/quic/core/crypto/common_cert_set_empty.cc b/quic/core/crypto/common_cert_set_empty.cc index 537bab9..603624d 100644 --- a/quic/core/crypto/common_cert_set_empty.cc +++ b/quic/core/crypto/common_cert_set_empty.cc
@@ -6,9 +6,9 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -17,17 +17,17 @@ class CommonCertSetsEmpty : public CommonCertSets { public: // CommonCertSets interface. - quiche::QuicheStringPiece GetCommonHashes() const override { - return quiche::QuicheStringPiece(); + absl::string_view GetCommonHashes() const override { + return absl::string_view(); } - quiche::QuicheStringPiece GetCert(uint64_t /* hash */, - uint32_t /* index */) const override { - return quiche::QuicheStringPiece(); + absl::string_view GetCert(uint64_t /* hash */, + uint32_t /* index */) const override { + return absl::string_view(); } - bool MatchCert(quiche::QuicheStringPiece /* cert */, - quiche::QuicheStringPiece /* common_set_hashes */, + bool MatchCert(absl::string_view /* cert */, + absl::string_view /* common_set_hashes */, uint64_t* /* out_hash */, uint32_t* /* out_index */) const override { return false;
diff --git a/quic/core/crypto/common_cert_set_test.cc b/quic/core/crypto/common_cert_set_test.cc index 148914d..01996c3 100644 --- a/quic/core/crypto/common_cert_set_test.cc +++ b/quic/core/crypto/common_cert_set_test.cc
@@ -6,8 +6,8 @@ #include <cstdint> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -193,44 +193,44 @@ class CommonCertSetsTest : public QuicTest {}; TEST_F(CommonCertSetsTest, FindGIA_2) { - quiche::QuicheStringPiece gia(reinterpret_cast<const char*>(kGIACertificate2), - sizeof(kGIACertificate2)); + absl::string_view gia(reinterpret_cast<const char*>(kGIACertificate2), + sizeof(kGIACertificate2)); const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); // Common Cert Set 2's hash. const uint64_t in_hash = UINT64_C(0xe81a92926081e801); uint64_t hash; uint32_t index; - ASSERT_TRUE(sets->MatchCert( - gia, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(&in_hash), - sizeof(in_hash)), - &hash, &index)); + ASSERT_TRUE( + sets->MatchCert(gia, + absl::string_view(reinterpret_cast<const char*>(&in_hash), + sizeof(in_hash)), + &hash, &index)); EXPECT_EQ(in_hash, hash); - quiche::QuicheStringPiece gia_copy = sets->GetCert(hash, index); + absl::string_view gia_copy = sets->GetCert(hash, index); EXPECT_FALSE(gia_copy.empty()); ASSERT_EQ(gia.size(), gia_copy.size()); EXPECT_EQ(0, memcmp(gia.data(), gia_copy.data(), gia.size())); } TEST_F(CommonCertSetsTest, FindGIA_3) { - quiche::QuicheStringPiece gia(reinterpret_cast<const char*>(kGIACertificate3), - sizeof(kGIACertificate3)); + absl::string_view gia(reinterpret_cast<const char*>(kGIACertificate3), + sizeof(kGIACertificate3)); const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); // Common Cert Set 3's hash. const uint64_t in_hash = UINT64_C(0x918215a28680ed7e); uint64_t hash; uint32_t index; - ASSERT_TRUE(sets->MatchCert( - gia, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(&in_hash), - sizeof(in_hash)), - &hash, &index)); + ASSERT_TRUE( + sets->MatchCert(gia, + absl::string_view(reinterpret_cast<const char*>(&in_hash), + sizeof(in_hash)), + &hash, &index)); EXPECT_EQ(in_hash, hash); - quiche::QuicheStringPiece gia_copy = sets->GetCert(hash, index); + absl::string_view gia_copy = sets->GetCert(hash, index); EXPECT_FALSE(gia_copy.empty()); ASSERT_EQ(gia.size(), gia_copy.size()); EXPECT_EQ(0, memcmp(gia.data(), gia_copy.data(), gia.size())); @@ -238,15 +238,15 @@ TEST_F(CommonCertSetsTest, NonMatch) { const CommonCertSets* sets(CommonCertSets::GetInstanceQUIC()); - quiche::QuicheStringPiece not_a_cert("hello"); + absl::string_view not_a_cert("hello"); const uint64_t in_hash = UINT64_C(0xc9fef74053f99f39); uint64_t hash; uint32_t index; - EXPECT_FALSE(sets->MatchCert( - not_a_cert, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(&in_hash), - sizeof(in_hash)), - &hash, &index)); + EXPECT_FALSE( + sets->MatchCert(not_a_cert, + absl::string_view(reinterpret_cast<const char*>(&in_hash), + sizeof(in_hash)), + &hash, &index)); } } // namespace test
diff --git a/quic/core/crypto/crypto_framer.cc b/quic/core/crypto/crypto_framer.cc index 6a18884..adfa248 100644 --- a/quic/core/crypto/crypto_framer.cc +++ b/quic/core/crypto/crypto_framer.cc
@@ -7,6 +7,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" #include "net/third_party/quiche/src/quic/core/quic_data_writer.h" @@ -15,7 +16,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -60,7 +60,7 @@ // static std::unique_ptr<CryptoHandshakeMessage> CryptoFramer::ParseMessage( - quiche::QuicheStringPiece in) { + absl::string_view in) { OneShotVisitor visitor; CryptoFramer framer; @@ -81,12 +81,12 @@ return error_detail_; } -bool CryptoFramer::ProcessInput(quiche::QuicheStringPiece input, +bool CryptoFramer::ProcessInput(absl::string_view input, EncryptionLevel /*level*/) { return ProcessInput(input); } -bool CryptoFramer::ProcessInput(quiche::QuicheStringPiece input) { +bool CryptoFramer::ProcessInput(absl::string_view input) { DCHECK_EQ(QUIC_NO_ERROR, error_); if (error_ != QUIC_NO_ERROR) { return false; @@ -121,7 +121,7 @@ QuicDataReader reader(buffer_.data(), buffer_.length(), quiche::HOST_BYTE_ORDER); for (const std::pair<QuicTag, size_t>& item : tags_and_lengths_) { - quiche::QuicheStringPiece value; + absl::string_view value; if (reader.BytesRemaining() < item.second) { break; } @@ -243,7 +243,7 @@ state_ = STATE_READING_TAG; } -QuicErrorCode CryptoFramer::Process(quiche::QuicheStringPiece input) { +QuicErrorCode CryptoFramer::Process(absl::string_view input) { // Add this data to the buffer. buffer_.append(input.data(), input.length()); QuicDataReader reader(buffer_.data(), buffer_.length(), @@ -319,7 +319,7 @@ << values_len_ - reader.BytesRemaining() << " bytes."; } for (const std::pair<QuicTag, size_t>& item : tags_and_lengths_) { - quiche::QuicheStringPiece value; + absl::string_view value; if (!reader.ReadStringPiece(&value, item.second)) { DCHECK(process_truncated_messages_); // Store an empty value.
diff --git a/quic/core/crypto/crypto_framer.h b/quic/core/crypto/crypto_framer.h index 8dc0d96..e7289eb 100644 --- a/quic/core/crypto/crypto_framer.h +++ b/quic/core/crypto/crypto_framer.h
@@ -12,10 +12,10 @@ #include <utility> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_message_parser.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -43,10 +43,10 @@ ~CryptoFramer() override; // ParseMessage parses exactly one message from the given - // quiche::QuicheStringPiece. If there is an error, the message is truncated, + // absl::string_view. If there is an error, the message is truncated, // or the message has trailing garbage then nullptr will be returned. static std::unique_ptr<CryptoHandshakeMessage> ParseMessage( - quiche::QuicheStringPiece in); + absl::string_view in); // Set callbacks to be called from the framer. A visitor must be set, or // else the framer will crash. It is acceptable for the visitor to do @@ -63,9 +63,8 @@ // false if there was an error, and true otherwise. ProcessInput optionally // takes an EncryptionLevel, but it is ignored. The variant with the // EncryptionLevel is provided to match the CryptoMessageParser interface. - bool ProcessInput(quiche::QuicheStringPiece input, - EncryptionLevel level) override; - bool ProcessInput(quiche::QuicheStringPiece input); + bool ProcessInput(absl::string_view input, EncryptionLevel level) override; + bool ProcessInput(absl::string_view input); // Returns the number of bytes of buffered input data remaining to be // parsed. @@ -96,7 +95,7 @@ // Process does does the work of |ProcessInput|, but returns an error code, // doesn't set error_ and doesn't call |visitor_->OnError()|. - QuicErrorCode Process(quiche::QuicheStringPiece input); + QuicErrorCode Process(absl::string_view input); static bool WritePadTag(QuicDataWriter* writer, size_t pad_length,
diff --git a/quic/core/crypto/crypto_framer_test.cc b/quic/core/crypto/crypto_framer_test.cc index d598c49..c1f558f 100644 --- a/quic/core/crypto/crypto_framer_test.cc +++ b/quic/core/crypto/crypto_framer_test.cc
@@ -8,6 +8,7 @@ #include <memory> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" @@ -16,7 +17,6 @@ #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/test_tools/quiche_test_utils.h" namespace quic { @@ -264,7 +264,7 @@ }; EXPECT_TRUE(framer.ProcessInput( - quiche::QuicheStringPiece(AsChars(input), QUICHE_ARRAYSIZE(input)))); + absl::string_view(AsChars(input), QUICHE_ARRAYSIZE(input)))); EXPECT_EQ(0u, framer.InputBytesRemaining()); EXPECT_EQ(0, visitor.error_count_); ASSERT_EQ(1u, visitor.messages_.size()); @@ -308,7 +308,7 @@ }; EXPECT_TRUE(framer.ProcessInput( - quiche::QuicheStringPiece(AsChars(input), QUICHE_ARRAYSIZE(input)))); + absl::string_view(AsChars(input), QUICHE_ARRAYSIZE(input)))); EXPECT_EQ(0u, framer.InputBytesRemaining()); EXPECT_EQ(0, visitor.error_count_); ASSERT_EQ(1u, visitor.messages_.size()); @@ -347,8 +347,7 @@ }; for (size_t i = 0; i < QUICHE_ARRAYSIZE(input); i++) { - EXPECT_TRUE( - framer.ProcessInput(quiche::QuicheStringPiece(AsChars(input) + i, 1))); + EXPECT_TRUE(framer.ProcessInput(absl::string_view(AsChars(input) + i, 1))); } EXPECT_EQ(0u, framer.InputBytesRemaining()); ASSERT_EQ(1u, visitor.messages_.size()); @@ -382,7 +381,7 @@ }; EXPECT_FALSE(framer.ProcessInput( - quiche::QuicheStringPiece(AsChars(input), QUICHE_ARRAYSIZE(input)))); + absl::string_view(AsChars(input), QUICHE_ARRAYSIZE(input)))); EXPECT_THAT(framer.error(), IsError(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); EXPECT_EQ(1, visitor.error_count_); } @@ -410,7 +409,7 @@ }; EXPECT_FALSE(framer.ProcessInput( - quiche::QuicheStringPiece(AsChars(input), QUICHE_ARRAYSIZE(input)))); + absl::string_view(AsChars(input), QUICHE_ARRAYSIZE(input)))); EXPECT_THAT(framer.error(), IsError(QUIC_CRYPTO_TAGS_OUT_OF_ORDER)); EXPECT_EQ(1, visitor.error_count_); } @@ -430,7 +429,7 @@ }; EXPECT_FALSE(framer.ProcessInput( - quiche::QuicheStringPiece(AsChars(input), QUICHE_ARRAYSIZE(input)))); + absl::string_view(AsChars(input), QUICHE_ARRAYSIZE(input)))); EXPECT_THAT(framer.error(), IsError(QUIC_CRYPTO_TOO_MANY_ENTRIES)); EXPECT_EQ(1, visitor.error_count_); } @@ -458,7 +457,7 @@ }; EXPECT_TRUE(framer.ProcessInput( - quiche::QuicheStringPiece(AsChars(input), QUICHE_ARRAYSIZE(input)))); + absl::string_view(AsChars(input), QUICHE_ARRAYSIZE(input)))); EXPECT_EQ(0, visitor.error_count_); }
diff --git a/quic/core/crypto/crypto_handshake_message.cc b/quic/core/crypto/crypto_handshake_message.cc index 3df9f12..db80a05 100644 --- a/quic/core/crypto/crypto_handshake_message.cc +++ b/quic/core/crypto/crypto_handshake_message.cc
@@ -7,6 +7,7 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_framer.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_utils.h" @@ -15,7 +16,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -97,7 +97,7 @@ } void CryptoHandshakeMessage::SetStringPiece(QuicTag tag, - quiche::QuicheStringPiece value) { + absl::string_view value) { tag_value_map_[tag] = std::string(value); } @@ -159,9 +159,8 @@ return QUIC_NO_ERROR; } -bool CryptoHandshakeMessage::GetStringPiece( - QuicTag tag, - quiche::QuicheStringPiece* out) const { +bool CryptoHandshakeMessage::GetStringPiece(QuicTag tag, + absl::string_view* out) const { auto it = tag_value_map_.find(tag); if (it == tag_value_map_.end()) { return false; @@ -177,8 +176,8 @@ QuicErrorCode CryptoHandshakeMessage::GetNthValue24( QuicTag tag, unsigned index, - quiche::QuicheStringPiece* out) const { - quiche::QuicheStringPiece value; + absl::string_view* out) const { + absl::string_view value; if (!GetStringPiece(tag, &value)) { return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND; } @@ -203,7 +202,7 @@ } if (i == index) { - *out = quiche::QuicheStringPiece(value.data(), size); + *out = absl::string_view(value.data(), size); return QUIC_NO_ERROR; }
diff --git a/quic/core/crypto/crypto_handshake_message.h b/quic/core/crypto/crypto_handshake_message.h index 9539050..5c50127 100644 --- a/quic/core/crypto/crypto_handshake_message.h +++ b/quic/core/crypto/crypto_handshake_message.h
@@ -11,10 +11,10 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -78,7 +78,7 @@ const QuicTagValueMap& tag_value_map() const { return tag_value_map_; } - void SetStringPiece(QuicTag tag, quiche::QuicheStringPiece value); + void SetStringPiece(QuicTag tag, absl::string_view value); // Erase removes a tag/value, if present, from the message. void Erase(QuicTag tag); @@ -99,7 +99,7 @@ // Otherwise it populates |out| with the label and returns QUIC_NO_ERROR. QuicErrorCode GetVersionLabel(QuicTag tag, QuicVersionLabel* out) const; - bool GetStringPiece(QuicTag tag, quiche::QuicheStringPiece* out) const; + bool GetStringPiece(QuicTag tag, absl::string_view* out) const; bool HasStringPiece(QuicTag tag) const; // GetNthValue24 interprets the value with the given tag to be a series of @@ -107,7 +107,7 @@ // index. QuicErrorCode GetNthValue24(QuicTag tag, unsigned index, - quiche::QuicheStringPiece* out) const; + absl::string_view* out) const; QuicErrorCode GetUint32(QuicTag tag, uint32_t* out) const; QuicErrorCode GetUint64(QuicTag tag, uint64_t* out) const; QuicErrorCode GetUint128(QuicTag tag, QuicUint128* out) const;
diff --git a/quic/core/crypto/crypto_message_parser.h b/quic/core/crypto/crypto_message_parser.h index 8038664..b5e6a9d 100644 --- a/quic/core/crypto/crypto_message_parser.h +++ b/quic/core/crypto/crypto_message_parser.h
@@ -7,9 +7,9 @@ #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_error_codes.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -23,8 +23,7 @@ // Processes input data, which must be delivered in order. The input data // being processed was received at encryption level |level|. Returns // false if there was an error, and true otherwise. - virtual bool ProcessInput(quiche::QuicheStringPiece input, - EncryptionLevel level) = 0; + virtual bool ProcessInput(absl::string_view input, EncryptionLevel level) = 0; // Returns the number of bytes of buffered input data remaining to be // parsed.
diff --git a/quic/core/crypto/crypto_secret_boxer.cc b/quic/core/crypto/crypto_secret_boxer.cc index 78cf768..1f75e0c 100644 --- a/quic/core/crypto/crypto_secret_boxer.cc +++ b/quic/core/crypto/crypto_secret_boxer.cc
@@ -7,11 +7,11 @@ #include "net/third_party/quiche/src/quic/core/crypto/crypto_secret_boxer.h" +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/aead.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -68,7 +68,7 @@ } std::string CryptoSecretBoxer::Box(QuicRandom* rand, - quiche::QuicheStringPiece plaintext) const { + absl::string_view plaintext) const { // The box is formatted as: // 12 bytes of random nonce // n bytes of ciphertext @@ -104,9 +104,9 @@ return ret; } -bool CryptoSecretBoxer::Unbox(quiche::QuicheStringPiece in_ciphertext, +bool CryptoSecretBoxer::Unbox(absl::string_view in_ciphertext, std::string* out_storage, - quiche::QuicheStringPiece* out) const { + absl::string_view* out) const { if (in_ciphertext.size() < kSIVNonceSize) { return false; } @@ -130,7 +130,7 @@ kSIVNonceSize, ciphertext, ciphertext_len, nullptr, 0)) { ok = true; - *out = quiche::QuicheStringPiece(out_storage->data(), bytes_written); + *out = absl::string_view(out_storage->data(), bytes_written); break; }
diff --git a/quic/core/crypto/crypto_secret_boxer.h b/quic/core/crypto/crypto_secret_boxer.h index dc4e0b1..6cf61b4 100644 --- a/quic/core/crypto/crypto_secret_boxer.h +++ b/quic/core/crypto/crypto_secret_boxer.h
@@ -10,9 +10,9 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -41,16 +41,16 @@ // returns the resulting ciphertext. Since an authenticator and nonce are // included, the result will be slightly larger than |plaintext|. The first // key in the vector supplied to |SetKeys| will be used. - std::string Box(QuicRandom* rand, quiche::QuicheStringPiece plaintext) const; + std::string Box(QuicRandom* rand, absl::string_view plaintext) const; // Unbox takes the result of a previous call to |Box| in |ciphertext| and // authenticates+decrypts it. If |ciphertext| cannot be decrypted with any of // the supplied keys, the function returns false. Otherwise, |out_storage| is // used to store the result and |out| is set to point into |out_storage| and // contains the original plaintext. - bool Unbox(quiche::QuicheStringPiece ciphertext, + bool Unbox(absl::string_view ciphertext, std::string* out_storage, - quiche::QuicheStringPiece* out) const; + absl::string_view* out) const; private: struct State;
diff --git a/quic/core/crypto/crypto_secret_boxer_test.cc b/quic/core/crypto/crypto_secret_boxer_test.cc index 57a5712..b63d081 100644 --- a/quic/core/crypto/crypto_secret_boxer_test.cc +++ b/quic/core/crypto/crypto_secret_boxer_test.cc
@@ -6,9 +6,9 @@ #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -16,7 +16,7 @@ class CryptoSecretBoxerTest : public QuicTest {}; TEST_F(CryptoSecretBoxerTest, BoxAndUnbox) { - quiche::QuicheStringPiece message("hello world"); + absl::string_view message("hello world"); CryptoSecretBoxer boxer; boxer.SetKeys({std::string(CryptoSecretBoxer::GetKeySize(), 0x11)}); @@ -24,7 +24,7 @@ const std::string box = boxer.Box(QuicRandom::GetInstance(), message); std::string storage; - quiche::QuicheStringPiece result; + absl::string_view result; EXPECT_TRUE(boxer.Unbox(box, &storage, &result)); EXPECT_EQ(result, message); @@ -40,10 +40,10 @@ // Helper function to test whether one boxer can decode the output of another. static bool CanDecode(const CryptoSecretBoxer& decoder, const CryptoSecretBoxer& encoder) { - quiche::QuicheStringPiece message("hello world"); + absl::string_view message("hello world"); const std::string boxed = encoder.Box(QuicRandom::GetInstance(), message); std::string storage; - quiche::QuicheStringPiece result; + absl::string_view result; bool ok = decoder.Unbox(boxed, &storage, &result); if (ok) { EXPECT_EQ(result, message);
diff --git a/quic/core/crypto/crypto_server_test.cc b/quic/core/crypto/crypto_server_test.cc index 17ab10b..2236448 100644 --- a/quic/core/crypto/crypto_server_test.cc +++ b/quic/core/crypto/crypto_server_test.cc
@@ -10,6 +10,7 @@ #include <utility> #include <vector> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/sha.h" #include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" #include "net/third_party/quiche/src/quic/core/crypto/common_cert_set.h" @@ -31,7 +32,6 @@ #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -127,7 +127,7 @@ std::unique_ptr<CryptoHandshakeMessage> msg( config_.AddConfig(primary_config, clock_.WallNow())); - quiche::QuicheStringPiece orbit; + absl::string_view orbit; CHECK(msg->GetStringPiece(kORBT, &orbit)); CHECK_EQ(sizeof(orbit_), orbit.size()); memcpy(orbit_, orbit.data(), orbit.size()); @@ -156,15 +156,15 @@ SERVER_CONFIG_INCHOATE_HELLO_FAILURE}; CheckRejectReasons(kRejectReasons, QUICHE_ARRAYSIZE(kRejectReasons)); - quiche::QuicheStringPiece srct; + absl::string_view srct; ASSERT_TRUE(out_.GetStringPiece(kSourceAddressTokenTag, &srct)); srct_hex_ = "#" + quiche::QuicheTextUtils::HexEncode(srct); - quiche::QuicheStringPiece scfg; + absl::string_view scfg; ASSERT_TRUE(out_.GetStringPiece(kSCFG, &scfg)); server_config_ = CryptoFramer::ParseMessage(scfg); - quiche::QuicheStringPiece scid; + absl::string_view scid; ASSERT_TRUE(server_config_->GetStringPiece(kSCID, &scid)); scid_hex_ = "#" + quiche::QuicheTextUtils::HexEncode(scid); @@ -211,7 +211,7 @@ EXPECT_EQ(CreateQuicVersionLabel(supported_versions_[i]), versions[i]); } - quiche::QuicheStringPiece address; + absl::string_view address; ASSERT_TRUE(server_hello.GetStringPiece(kCADR, &address)); QuicSocketAddressCoder decoder; ASSERT_TRUE(decoder.Decode(address.data(), address.size())); @@ -313,8 +313,8 @@ std::string nonce; CryptoUtils::GenerateNonce( clock_.WallNow(), rand_, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(orbit_), - sizeof(orbit_)), + absl::string_view(reinterpret_cast<const char*>(orbit_), + sizeof(orbit_)), &nonce); return nonce; } @@ -413,7 +413,7 @@ kClientHelloMinimumSize); ShouldSucceed(msg); - quiche::QuicheStringPiece cert, proof, cert_sct; + absl::string_view cert, proof, cert_sct; EXPECT_TRUE(out_.GetStringPiece(kCertificateTag, &cert)); EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); EXPECT_TRUE(out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); @@ -442,7 +442,7 @@ config_.set_chlo_multiplier(1); ShouldSucceed(msg); - quiche::QuicheStringPiece cert, proof, cert_sct; + absl::string_view cert, proof, cert_sct; EXPECT_FALSE(out_.GetStringPiece(kCertificateTag, &cert)); EXPECT_FALSE(out_.GetStringPiece(kPROF, &proof)); EXPECT_FALSE(out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); @@ -469,7 +469,7 @@ config_.set_chlo_multiplier(1); ShouldSucceed(msg); - quiche::QuicheStringPiece cert, proof, cert_sct; + absl::string_view cert, proof, cert_sct; EXPECT_TRUE(out_.GetStringPiece(kCertificateTag, &cert)); EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); EXPECT_TRUE(out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); @@ -496,7 +496,7 @@ config_.set_chlo_multiplier(1); ShouldSucceed(msg); - quiche::QuicheStringPiece cert, proof, cert_sct; + absl::string_view cert, proof, cert_sct; EXPECT_TRUE(out_.GetStringPiece(kCertificateTag, &cert)); EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); EXPECT_TRUE(out_.GetStringPiece(kCertificateSCTTag, &cert_sct)); @@ -780,13 +780,13 @@ SOURCE_ADDRESS_TOKEN_DIFFERENT_IP_ADDRESS_FAILURE}; CheckRejectReasons(kRejectReasons, QUICHE_ARRAYSIZE(kRejectReasons)); - quiche::QuicheStringPiece cert, proof, scfg_str; + absl::string_view cert, proof, scfg_str; EXPECT_TRUE(out_.GetStringPiece(kCertificateTag, &cert)); EXPECT_TRUE(out_.GetStringPiece(kPROF, &proof)); EXPECT_TRUE(out_.GetStringPiece(kSCFG, &scfg_str)); std::unique_ptr<CryptoHandshakeMessage> scfg( CryptoFramer::ParseMessage(scfg_str)); - quiche::QuicheStringPiece scid; + absl::string_view scid; EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid)); EXPECT_NE(scid, kOldConfigId); @@ -886,7 +886,7 @@ ShouldSucceed(msg); EXPECT_EQ(kSHLO, out_.tag()); - quiche::QuicheStringPiece nonce; + absl::string_view nonce; EXPECT_TRUE(out_.GetStringPiece(kServerNonceTag, &nonce)); } @@ -922,7 +922,7 @@ ShouldSucceed(msg); // Decompress cert chain from server to individual certs. - quiche::QuicheStringPiece certs_compressed; + absl::string_view certs_compressed; ASSERT_TRUE(out_.GetStringPiece(kCertificateTag, &certs_compressed)); ASSERT_NE(0u, certs_compressed.size()); std::vector<std::string> certs; @@ -942,7 +942,7 @@ ShouldSucceed(msg); // Server responds with inchoate REJ containing valid source-address token. - quiche::QuicheStringPiece srct; + absl::string_view srct; ASSERT_TRUE(out_.GetStringPiece(kSourceAddressTokenTag, &srct)); // Client now drops cached certs; sends CHLO with updated source-address @@ -1003,7 +1003,7 @@ std::unique_ptr<CryptoHandshakeMessage> scfg_b( b.AddDefaultConfig(&rand_b, &clock, options)); - quiche::QuicheStringPiece scid_a, scid_b; + absl::string_view scid_a, scid_b; EXPECT_TRUE(scfg_a->GetStringPiece(kSCID, &scid_a)); EXPECT_TRUE(scfg_b->GetStringPiece(kSCID, &scid_b)); @@ -1021,7 +1021,7 @@ std::unique_ptr<CryptoHandshakeMessage> scfg( a.AddDefaultConfig(&rand_a, &clock, options)); - quiche::QuicheStringPiece scid; + absl::string_view scid; EXPECT_TRUE(scfg->GetStringPiece(kSCID, &scid)); // Need to take a copy of |scid| has we're about to call |Erase|. const std::string scid_str(scid);
diff --git a/quic/core/crypto/crypto_utils.cc b/quic/core/crypto/crypto_utils.cc index d98cf58..6c435ff 100644 --- a/quic/core/crypto/crypto_utils.cc +++ b/quic/core/crypto/crypto_utils.cc
@@ -8,6 +8,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/bytestring.h" #include "third_party/boringssl/src/include/openssl/hkdf.h" #include "third_party/boringssl/src/include/openssl/mem.h" @@ -35,7 +36,6 @@ #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -105,12 +105,12 @@ HkdfExpandLabel(prf, pp_secret, "quic iv", crypter->GetIVSize()); std::vector<uint8_t> pn = HkdfExpandLabel(prf, pp_secret, "quic hp", crypter->GetKeySize()); - crypter->SetKey(quiche::QuicheStringPiece(reinterpret_cast<char*>(key.data()), - key.size())); + crypter->SetKey( + absl::string_view(reinterpret_cast<char*>(key.data()), key.size())); crypter->SetIV( - quiche::QuicheStringPiece(reinterpret_cast<char*>(iv.data()), iv.size())); + absl::string_view(reinterpret_cast<char*>(iv.data()), iv.size())); crypter->SetHeaderProtectionKey( - quiche::QuicheStringPiece(reinterpret_cast<char*>(pn.data()), pn.size())); + absl::string_view(reinterpret_cast<char*>(pn.data()), pn.size())); } namespace { @@ -214,8 +214,8 @@ 0x35, 0x9f, 0x16, 0xd1, 0xed, 0x80, 0x90, 0x8e, 0xec, 0x85, 0xc4, 0xd6}; bool RetryIntegrityKeysForVersion(const ParsedQuicVersion& version, - quiche::QuicheStringPiece* key, - quiche::QuicheStringPiece* nonce) { + absl::string_view* key, + absl::string_view* nonce) { static_assert(SupportedVersions().size() == 7u, "Supported versions out of sync with retry integrity keys"); if (!version.HasRetryIntegrityTag()) { @@ -223,42 +223,42 @@ << version; return false; } else if (version == ParsedQuicVersion::Draft29()) { - *key = quiche::QuicheStringPiece( + *key = absl::string_view( reinterpret_cast<const char*>(kDraft29RetryIntegrityKey), QUICHE_ARRAYSIZE(kDraft29RetryIntegrityKey)); - *nonce = quiche::QuicheStringPiece( + *nonce = absl::string_view( reinterpret_cast<const char*>(kDraft29RetryIntegrityNonce), QUICHE_ARRAYSIZE(kDraft29RetryIntegrityNonce)); return true; } else if (version == ParsedQuicVersion::Draft27()) { - *key = quiche::QuicheStringPiece( + *key = absl::string_view( reinterpret_cast<const char*>(kDraft27RetryIntegrityKey), QUICHE_ARRAYSIZE(kDraft27RetryIntegrityKey)); - *nonce = quiche::QuicheStringPiece( + *nonce = absl::string_view( reinterpret_cast<const char*>(kDraft27RetryIntegrityNonce), QUICHE_ARRAYSIZE(kDraft27RetryIntegrityNonce)); return true; } else if (version == ParsedQuicVersion::T051()) { - *key = quiche::QuicheStringPiece( - reinterpret_cast<const char*>(kT051RetryIntegrityKey), - QUICHE_ARRAYSIZE(kT051RetryIntegrityKey)); - *nonce = quiche::QuicheStringPiece( + *key = + absl::string_view(reinterpret_cast<const char*>(kT051RetryIntegrityKey), + QUICHE_ARRAYSIZE(kT051RetryIntegrityKey)); + *nonce = absl::string_view( reinterpret_cast<const char*>(kT051RetryIntegrityNonce), QUICHE_ARRAYSIZE(kT051RetryIntegrityNonce)); return true; } else if (version == ParsedQuicVersion::T050()) { - *key = quiche::QuicheStringPiece( - reinterpret_cast<const char*>(kT050RetryIntegrityKey), - QUICHE_ARRAYSIZE(kT050RetryIntegrityKey)); - *nonce = quiche::QuicheStringPiece( + *key = + absl::string_view(reinterpret_cast<const char*>(kT050RetryIntegrityKey), + QUICHE_ARRAYSIZE(kT050RetryIntegrityKey)); + *nonce = absl::string_view( reinterpret_cast<const char*>(kT050RetryIntegrityNonce), QUICHE_ARRAYSIZE(kT050RetryIntegrityNonce)); return true; } else if (version == ParsedQuicVersion::ReservedForNegotiation()) { - *key = quiche::QuicheStringPiece( + *key = absl::string_view( reinterpret_cast<const char*>(kReservedForNegotiationRetryIntegrityKey), QUICHE_ARRAYSIZE(kReservedForNegotiationRetryIntegrityKey)); - *nonce = quiche::QuicheStringPiece( + *nonce = absl::string_view( reinterpret_cast<const char*>( kReservedForNegotiationRetryIntegrityNonce), QUICHE_ARRAYSIZE(kReservedForNegotiationRetryIntegrityNonce)); @@ -329,8 +329,8 @@ bool CryptoUtils::ValidateRetryIntegrityTag( ParsedQuicVersion version, QuicConnectionId original_connection_id, - quiche::QuicheStringPiece retry_without_tag, - quiche::QuicheStringPiece integrity_tag) { + absl::string_view retry_without_tag, + absl::string_view integrity_tag) { unsigned char computed_integrity_tag[kRetryIntegrityTagLength]; if (integrity_tag.length() != QUICHE_ARRAYSIZE(computed_integrity_tag)) { QUIC_BUG << "Invalid retry integrity tag length " << integrity_tag.length(); @@ -347,16 +347,16 @@ QUIC_BUG << "Failed to write retry without tag in retry pseudo packet"; return false; } - quiche::QuicheStringPiece key; - quiche::QuicheStringPiece nonce; + absl::string_view key; + absl::string_view nonce; if (!RetryIntegrityKeysForVersion(version, &key, &nonce)) { // RetryIntegrityKeysForVersion already logs failures. return false; } Aes128GcmEncrypter crypter; crypter.SetKey(key); - quiche::QuicheStringPiece associated_data(writer.data(), writer.length()); - quiche::QuicheStringPiece plaintext; // Plaintext is empty. + absl::string_view associated_data(writer.data(), writer.length()); + absl::string_view plaintext; // Plaintext is empty. if (!crypter.Encrypt(nonce, associated_data, plaintext, computed_integrity_tag)) { QUIC_BUG << "Failed to compute retry integrity tag"; @@ -373,7 +373,7 @@ // static void CryptoUtils::GenerateNonce(QuicWallTime now, QuicRandom* random_generator, - quiche::QuicheStringPiece orbit, + absl::string_view orbit, std::string* nonce) { // a 4-byte timestamp + 28 random bytes. nonce->reserve(kNonceSize); @@ -399,11 +399,11 @@ // static bool CryptoUtils::DeriveKeys(const ParsedQuicVersion& version, - quiche::QuicheStringPiece premaster_secret, + absl::string_view premaster_secret, QuicTag aead, - quiche::QuicheStringPiece client_nonce, - quiche::QuicheStringPiece server_nonce, - quiche::QuicheStringPiece pre_shared_key, + absl::string_view client_nonce, + absl::string_view server_nonce, + absl::string_view pre_shared_key, const std::string& hkdf_input, Perspective perspective, Diversification diversification, @@ -412,7 +412,7 @@ // If the connection is using PSK, concatenate it with the pre-master secret. std::unique_ptr<char[]> psk_premaster_secret; if (!pre_shared_key.empty()) { - const quiche::QuicheStringPiece label(kPreSharedKeyLabel); + const absl::string_view label(kPreSharedKeyLabel); const size_t psk_premaster_secret_size = label.size() + 1 + pre_shared_key.size() + 8 + premaster_secret.size() + 8; @@ -430,8 +430,8 @@ return false; } - premaster_secret = quiche::QuicheStringPiece(psk_premaster_secret.get(), - psk_premaster_secret_size); + premaster_secret = absl::string_view(psk_premaster_secret.get(), + psk_premaster_secret_size); } crypters->encrypter = QuicEncrypter::Create(version, aead); @@ -445,7 +445,7 @@ size_t subkey_secret_bytes = subkey_secret == nullptr ? 0 : premaster_secret.length(); - quiche::QuicheStringPiece nonce = client_nonce; + absl::string_view nonce = client_nonce; std::string nonce_storage; if (!server_nonce.empty()) { nonce_storage = std::string(client_nonce) + std::string(server_nonce); @@ -542,9 +542,9 @@ } // static -bool CryptoUtils::ExportKeyingMaterial(quiche::QuicheStringPiece subkey_secret, - quiche::QuicheStringPiece label, - quiche::QuicheStringPiece context, +bool CryptoUtils::ExportKeyingMaterial(absl::string_view subkey_secret, + absl::string_view label, + absl::string_view context, size_t result_len, std::string* result) { for (size_t i = 0; i < label.length(); i++) { @@ -564,14 +564,14 @@ info.append(reinterpret_cast<char*>(&context_length), sizeof(context_length)); info.append(context.data(), context.length()); - QuicHKDF hkdf(subkey_secret, quiche::QuicheStringPiece() /* no salt */, info, + QuicHKDF hkdf(subkey_secret, absl::string_view() /* no salt */, info, result_len, 0 /* no fixed IV */, 0 /* no subkey secret */); *result = std::string(hkdf.client_write_key()); return true; } // static -uint64_t CryptoUtils::ComputeLeafCertHash(quiche::QuicheStringPiece cert) { +uint64_t CryptoUtils::ComputeLeafCertHash(absl::string_view cert) { return QuicUtils::FNV1a_64_Hash(cert); }
diff --git a/quic/core/crypto/crypto_utils.h b/quic/core/crypto/crypto_utils.h index 964f81f..c21c534 100644 --- a/quic/core/crypto/crypto_utils.h +++ b/quic/core/crypto/crypto_utils.h
@@ -11,6 +11,7 @@ #include <cstdint> #include <string> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" @@ -22,7 +23,6 @@ #include "net/third_party/quiche/src/quic/core/quic_time.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -101,11 +101,10 @@ // IETF QUIC Retry packets carry a retry integrity tag to detect packet // corruption and make it harder for an attacker to spoof. This function // checks whether a given retry packet is valid. - static bool ValidateRetryIntegrityTag( - ParsedQuicVersion version, - QuicConnectionId original_connection_id, - quiche::QuicheStringPiece retry_without_tag, - quiche::QuicheStringPiece integrity_tag); + static bool ValidateRetryIntegrityTag(ParsedQuicVersion version, + QuicConnectionId original_connection_id, + absl::string_view retry_without_tag, + absl::string_view integrity_tag); // Generates the connection nonce. The nonce is formed as: // <4 bytes> current time @@ -113,7 +112,7 @@ // <20 bytes> random static void GenerateNonce(QuicWallTime now, QuicRandom* random_generator, - quiche::QuicheStringPiece orbit, + absl::string_view orbit, std::string* nonce); // DeriveKeys populates |crypters->encrypter|, |crypters->decrypter|, and @@ -136,11 +135,11 @@ // |SetDiversificationNonce| with a diversification nonce will be needed to // complete keying. static bool DeriveKeys(const ParsedQuicVersion& version, - quiche::QuicheStringPiece premaster_secret, + absl::string_view premaster_secret, QuicTag aead, - quiche::QuicheStringPiece client_nonce, - quiche::QuicheStringPiece server_nonce, - quiche::QuicheStringPiece pre_shared_key, + absl::string_view client_nonce, + absl::string_view server_nonce, + absl::string_view pre_shared_key, const std::string& hkdf_input, Perspective perspective, Diversification diversification, @@ -151,15 +150,15 @@ // dependent on |subkey_secret|, |label|, and |context|. Returns false if the // parameters are invalid (e.g. |label| contains null bytes); returns true on // success. - static bool ExportKeyingMaterial(quiche::QuicheStringPiece subkey_secret, - quiche::QuicheStringPiece label, - quiche::QuicheStringPiece context, + static bool ExportKeyingMaterial(absl::string_view subkey_secret, + absl::string_view label, + absl::string_view context, size_t result_len, std::string* result); // Computes the FNV-1a hash of the provided DER-encoded cert for use in the // XLCT tag. - static uint64_t ComputeLeafCertHash(quiche::QuicheStringPiece cert); + static uint64_t ComputeLeafCertHash(absl::string_view cert); // Validates that |server_hello| is actually an SHLO message and that it is // not part of a downgrade attack.
diff --git a/quic/core/crypto/curve25519_key_exchange.cc b/quic/core/crypto/curve25519_key_exchange.cc index 2f19e9d..acdf9a8 100644 --- a/quic/core/crypto/curve25519_key_exchange.cc +++ b/quic/core/crypto/curve25519_key_exchange.cc
@@ -8,11 +8,11 @@ #include <cstring> #include <string> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/curve25519.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -31,7 +31,7 @@ // static std::unique_ptr<Curve25519KeyExchange> Curve25519KeyExchange::New( - quiche::QuicheStringPiece private_key) { + absl::string_view private_key) { // We don't want to #include the BoringSSL headers in the public header file, // so we use literals for the sizes of private_key_ and public_key_. Here we // assert that those values are equal to the values from the BoringSSL @@ -61,7 +61,7 @@ } bool Curve25519KeyExchange::CalculateSharedKeySync( - quiche::QuicheStringPiece peer_public_value, + absl::string_view peer_public_value, std::string* shared_key) const { if (peer_public_value.size() != X25519_PUBLIC_VALUE_LEN) { return false; @@ -77,9 +77,9 @@ return true; } -quiche::QuicheStringPiece Curve25519KeyExchange::public_value() const { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(public_key_), - sizeof(public_key_)); +absl::string_view Curve25519KeyExchange::public_value() const { + return absl::string_view(reinterpret_cast<const char*>(public_key_), + sizeof(public_key_)); } } // namespace quic
diff --git a/quic/core/crypto/curve25519_key_exchange.h b/quic/core/crypto/curve25519_key_exchange.h index 76fd23f..e6703ec 100644 --- a/quic/core/crypto/curve25519_key_exchange.h +++ b/quic/core/crypto/curve25519_key_exchange.h
@@ -8,9 +8,9 @@ #include <cstdint> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -29,16 +29,16 @@ // New creates a new key-exchange object from a private key. If |private_key| // is invalid, nullptr is returned. static std::unique_ptr<Curve25519KeyExchange> New( - quiche::QuicheStringPiece private_key); + absl::string_view private_key); // NewPrivateKey returns a private key, generated from |rand|, suitable for // passing to |New|. static std::string NewPrivateKey(QuicRandom* rand); // SynchronousKeyExchange interface. - bool CalculateSharedKeySync(quiche::QuicheStringPiece peer_public_value, + bool CalculateSharedKeySync(absl::string_view peer_public_value, std::string* shared_key) const override; - quiche::QuicheStringPiece public_value() const override; + absl::string_view public_value() const override; QuicTag type() const override { return kC255; } private:
diff --git a/quic/core/crypto/curve25519_key_exchange_test.cc b/quic/core/crypto/curve25519_key_exchange_test.cc index 2e5dfb4..f100df5 100644 --- a/quic/core/crypto/curve25519_key_exchange_test.cc +++ b/quic/core/crypto/curve25519_key_exchange_test.cc
@@ -8,9 +8,9 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -55,8 +55,8 @@ std::unique_ptr<Curve25519KeyExchange> bob( Curve25519KeyExchange::New(bob_key)); - const quiche::QuicheStringPiece alice_public(alice->public_value()); - const quiche::QuicheStringPiece bob_public(bob->public_value()); + const absl::string_view alice_public(alice->public_value()); + const absl::string_view bob_public(bob->public_value()); std::string alice_shared, bob_shared; ASSERT_TRUE(alice->CalculateSharedKeySync(bob_public, &alice_shared)); @@ -79,8 +79,8 @@ std::unique_ptr<Curve25519KeyExchange> bob( Curve25519KeyExchange::New(bob_key)); - const quiche::QuicheStringPiece alice_public(alice->public_value()); - const quiche::QuicheStringPiece bob_public(bob->public_value()); + const absl::string_view alice_public(alice->public_value()); + const absl::string_view bob_public(bob->public_value()); std::string alice_shared, bob_shared; TestCallbackResult alice_result;
diff --git a/quic/core/crypto/key_exchange.cc b/quic/core/crypto/key_exchange.cc index 84f9c86..d7c0105 100644 --- a/quic/core/crypto/key_exchange.cc +++ b/quic/core/crypto/key_exchange.cc
@@ -3,16 +3,16 @@ // found in the LICENSE file. #include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/curve25519_key_exchange.h" #include "net/third_party/quiche/src/quic/core/crypto/p256_key_exchange.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { std::unique_ptr<SynchronousKeyExchange> CreateLocalSynchronousKeyExchange( QuicTag type, - quiche::QuicheStringPiece private_key) { + absl::string_view private_key) { switch (type) { case kC255: return Curve25519KeyExchange::New(private_key);
diff --git a/quic/core/crypto/key_exchange.h b/quic/core/crypto/key_exchange.h index cb6fdbc..e4288d7 100644 --- a/quic/core/crypto/key_exchange.h +++ b/quic/core/crypto/key_exchange.h
@@ -8,9 +8,9 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -48,7 +48,7 @@ // that |callback| might be invoked synchronously. Results will be written // into |*shared_key|. virtual void CalculateSharedKeyAsync( - quiche::QuicheStringPiece peer_public_value, + absl::string_view peer_public_value, std::string* shared_key, std::unique_ptr<Callback> callback) const = 0; @@ -66,7 +66,7 @@ // AyncKeyExchange API. Note that this method is marked 'final.' Subclasses // should implement CalculateSharedKeySync only. - void CalculateSharedKeyAsync(quiche::QuicheStringPiece peer_public_value, + void CalculateSharedKeyAsync(absl::string_view peer_public_value, std::string* shared_key, std::unique_ptr<Callback> callback) const final { const bool ok = CalculateSharedKeySync(peer_public_value, shared_key); @@ -75,15 +75,14 @@ // CalculateSharedKey computes the shared key between a local private key and // a public value from the peer. Results will be written into |*shared_key|. - virtual bool CalculateSharedKeySync( - quiche::QuicheStringPiece peer_public_value, - std::string* shared_key) const = 0; + virtual bool CalculateSharedKeySync(absl::string_view peer_public_value, + std::string* shared_key) const = 0; // public_value returns the local public key which can be sent to a peer in - // order to complete a key exchange. The returned quiche::QuicheStringPiece is + // order to complete a key exchange. The returned absl::string_view is // a reference to a member of this object and is only valid for as long as it // exists. - virtual quiche::QuicheStringPiece public_value() const = 0; + virtual absl::string_view public_value() const = 0; }; // Create a SynchronousKeyExchange object which will use a keypair generated @@ -92,7 +91,7 @@ // invalid. std::unique_ptr<SynchronousKeyExchange> CreateLocalSynchronousKeyExchange( QuicTag type, - quiche::QuicheStringPiece private_key); + absl::string_view private_key); // Create a SynchronousKeyExchange object which will use a keypair generated // from |rand|, and a key-exchange algorithm specified by |type|, which must be
diff --git a/quic/core/crypto/null_decrypter.cc b/quic/core/crypto/null_decrypter.cc index d453a35..ef0342c 100644 --- a/quic/core/crypto/null_decrypter.cc +++ b/quic/core/crypto/null_decrypter.cc
@@ -6,35 +6,35 @@ #include <cstdint> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { NullDecrypter::NullDecrypter(Perspective perspective) : perspective_(perspective) {} -bool NullDecrypter::SetKey(quiche::QuicheStringPiece key) { +bool NullDecrypter::SetKey(absl::string_view key) { return key.empty(); } -bool NullDecrypter::SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) { +bool NullDecrypter::SetNoncePrefix(absl::string_view nonce_prefix) { return nonce_prefix.empty(); } -bool NullDecrypter::SetIV(quiche::QuicheStringPiece iv) { +bool NullDecrypter::SetIV(absl::string_view iv) { return iv.empty(); } -bool NullDecrypter::SetHeaderProtectionKey(quiche::QuicheStringPiece key) { +bool NullDecrypter::SetHeaderProtectionKey(absl::string_view key) { return key.empty(); } -bool NullDecrypter::SetPreliminaryKey(quiche::QuicheStringPiece /*key*/) { +bool NullDecrypter::SetPreliminaryKey(absl::string_view /*key*/) { QUIC_BUG << "Should not be called"; return false; } @@ -46,8 +46,8 @@ } bool NullDecrypter::DecryptPacket(uint64_t /*packet_number*/, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext, + absl::string_view associated_data, + absl::string_view ciphertext, char* output, size_t* output_length, size_t max_output_length) { @@ -59,7 +59,7 @@ return false; } - quiche::QuicheStringPiece plaintext = reader.ReadRemainingPayload(); + absl::string_view plaintext = reader.ReadRemainingPayload(); if (plaintext.length() > max_output_length) { QUIC_BUG << "Output buffer must be larger than the plaintext."; return false; @@ -90,12 +90,12 @@ return 0; } -quiche::QuicheStringPiece NullDecrypter::GetKey() const { - return quiche::QuicheStringPiece(); +absl::string_view NullDecrypter::GetKey() const { + return absl::string_view(); } -quiche::QuicheStringPiece NullDecrypter::GetNoncePrefix() const { - return quiche::QuicheStringPiece(); +absl::string_view NullDecrypter::GetNoncePrefix() const { + return absl::string_view(); } uint32_t NullDecrypter::cipher_id() const { @@ -112,9 +112,8 @@ return true; } -QuicUint128 NullDecrypter::ComputeHash( - const quiche::QuicheStringPiece data1, - const quiche::QuicheStringPiece data2) const { +QuicUint128 NullDecrypter::ComputeHash(const absl::string_view data1, + const absl::string_view data2) const { QuicUint128 correct_hash; if (perspective_ == Perspective::IS_CLIENT) { // Peer is a server.
diff --git a/quic/core/crypto/null_decrypter.h b/quic/core/crypto/null_decrypter.h index c3bd203..a760ab5 100644 --- a/quic/core/crypto/null_decrypter.h +++ b/quic/core/crypto/null_decrypter.h
@@ -8,11 +8,11 @@ #include <cstddef> #include <cstdint> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_decrypter.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_uint128.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -29,15 +29,15 @@ ~NullDecrypter() override {} // QuicDecrypter implementation - bool SetKey(quiche::QuicheStringPiece key) override; - bool SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) override; - bool SetIV(quiche::QuicheStringPiece iv) override; - bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; - bool SetPreliminaryKey(quiche::QuicheStringPiece key) override; + bool SetKey(absl::string_view key) override; + bool SetNoncePrefix(absl::string_view nonce_prefix) override; + bool SetIV(absl::string_view iv) override; + bool SetHeaderProtectionKey(absl::string_view key) override; + bool SetPreliminaryKey(absl::string_view key) override; bool SetDiversificationNonce(const DiversificationNonce& nonce) override; bool DecryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext, + absl::string_view associated_data, + absl::string_view ciphertext, char* output, size_t* output_length, size_t max_output_length) override; @@ -46,15 +46,15 @@ size_t GetKeySize() const override; size_t GetNoncePrefixSize() const override; size_t GetIVSize() const override; - quiche::QuicheStringPiece GetKey() const override; - quiche::QuicheStringPiece GetNoncePrefix() const override; + absl::string_view GetKey() const override; + absl::string_view GetNoncePrefix() const override; uint32_t cipher_id() const override; private: bool ReadHash(QuicDataReader* reader, QuicUint128* hash); - QuicUint128 ComputeHash(quiche::QuicheStringPiece data1, - quiche::QuicheStringPiece data2) const; + QuicUint128 ComputeHash(absl::string_view data1, + absl::string_view data2) const; Perspective perspective_; };
diff --git a/quic/core/crypto/null_decrypter_test.cc b/quic/core/crypto/null_decrypter_test.cc index 1baecad..63b715b 100644 --- a/quic/core/crypto/null_decrypter_test.cc +++ b/quic/core/crypto/null_decrypter_test.cc
@@ -42,11 +42,10 @@ NullDecrypter decrypter(Perspective::IS_SERVER); char buffer[256]; size_t length = 0; - ASSERT_TRUE(decrypter.DecryptPacket(0, "hello world!", - quiche::QuicheStringPiece(data, len), - buffer, &length, 256)); + ASSERT_TRUE(decrypter.DecryptPacket( + 0, "hello world!", absl::string_view(data, len), buffer, &length, 256)); EXPECT_LT(0u, length); - EXPECT_EQ("goodbye!", quiche::QuicheStringPiece(buffer, length)); + EXPECT_EQ("goodbye!", absl::string_view(buffer, length)); } TEST_F(NullDecrypterTest, DecryptServer) { @@ -79,11 +78,10 @@ NullDecrypter decrypter(Perspective::IS_CLIENT); char buffer[256]; size_t length = 0; - ASSERT_TRUE(decrypter.DecryptPacket(0, "hello world!", - quiche::QuicheStringPiece(data, len), - buffer, &length, 256)); + ASSERT_TRUE(decrypter.DecryptPacket( + 0, "hello world!", absl::string_view(data, len), buffer, &length, 256)); EXPECT_LT(0u, length); - EXPECT_EQ("goodbye!", quiche::QuicheStringPiece(buffer, length)); + EXPECT_EQ("goodbye!", absl::string_view(buffer, length)); } TEST_F(NullDecrypterTest, BadHash) { @@ -116,9 +114,8 @@ NullDecrypter decrypter(Perspective::IS_CLIENT); char buffer[256]; size_t length = 0; - ASSERT_FALSE(decrypter.DecryptPacket(0, "hello world!", - quiche::QuicheStringPiece(data, len), - buffer, &length, 256)); + ASSERT_FALSE(decrypter.DecryptPacket( + 0, "hello world!", absl::string_view(data, len), buffer, &length, 256)); } TEST_F(NullDecrypterTest, ShortInput) { @@ -131,9 +128,8 @@ NullDecrypter decrypter(Perspective::IS_CLIENT); char buffer[256]; size_t length = 0; - ASSERT_FALSE(decrypter.DecryptPacket(0, "hello world!", - quiche::QuicheStringPiece(data, len), - buffer, &length, 256)); + ASSERT_FALSE(decrypter.DecryptPacket( + 0, "hello world!", absl::string_view(data, len), buffer, &length, 256)); } } // namespace test
diff --git a/quic/core/crypto/null_encrypter.cc b/quic/core/crypto/null_encrypter.cc index 4de1510..1d5dd8b 100644 --- a/quic/core/crypto/null_encrypter.cc +++ b/quic/core/crypto/null_encrypter.cc
@@ -4,9 +4,9 @@ #include "net/third_party/quiche/src/quic/core/crypto/null_encrypter.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_data_writer.h" #include "net/third_party/quiche/src/quic/core/quic_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -15,25 +15,25 @@ NullEncrypter::NullEncrypter(Perspective perspective) : perspective_(perspective) {} -bool NullEncrypter::SetKey(quiche::QuicheStringPiece key) { +bool NullEncrypter::SetKey(absl::string_view key) { return key.empty(); } -bool NullEncrypter::SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) { +bool NullEncrypter::SetNoncePrefix(absl::string_view nonce_prefix) { return nonce_prefix.empty(); } -bool NullEncrypter::SetIV(quiche::QuicheStringPiece iv) { +bool NullEncrypter::SetIV(absl::string_view iv) { return iv.empty(); } -bool NullEncrypter::SetHeaderProtectionKey(quiche::QuicheStringPiece key) { +bool NullEncrypter::SetHeaderProtectionKey(absl::string_view key) { return key.empty(); } bool NullEncrypter::EncryptPacket(uint64_t /*packet_number*/, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext, + absl::string_view associated_data, + absl::string_view plaintext, char* output, size_t* output_length, size_t max_output_length) { @@ -59,7 +59,7 @@ } std::string NullEncrypter::GenerateHeaderProtectionMask( - quiche::QuicheStringPiece /*sample*/) { + absl::string_view /*sample*/) { return std::string(5, 0); } @@ -83,12 +83,12 @@ return plaintext_size + GetHashLength(); } -quiche::QuicheStringPiece NullEncrypter::GetKey() const { - return quiche::QuicheStringPiece(); +absl::string_view NullEncrypter::GetKey() const { + return absl::string_view(); } -quiche::QuicheStringPiece NullEncrypter::GetNoncePrefix() const { - return quiche::QuicheStringPiece(); +absl::string_view NullEncrypter::GetNoncePrefix() const { + return absl::string_view(); } size_t NullEncrypter::GetHashLength() const {
diff --git a/quic/core/crypto/null_encrypter.h b/quic/core/crypto/null_encrypter.h index bda73dc..bdfd2e7 100644 --- a/quic/core/crypto/null_encrypter.h +++ b/quic/core/crypto/null_encrypter.h
@@ -7,10 +7,10 @@ #include <cstddef> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_encrypter.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -25,25 +25,24 @@ ~NullEncrypter() override {} // QuicEncrypter implementation - bool SetKey(quiche::QuicheStringPiece key) override; - bool SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) override; - bool SetIV(quiche::QuicheStringPiece iv) override; - bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) override; + bool SetKey(absl::string_view key) override; + bool SetNoncePrefix(absl::string_view nonce_prefix) override; + bool SetIV(absl::string_view iv) override; + bool SetHeaderProtectionKey(absl::string_view key) override; bool EncryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext, + absl::string_view associated_data, + absl::string_view plaintext, char* output, size_t* output_length, size_t max_output_length) override; - std::string GenerateHeaderProtectionMask( - quiche::QuicheStringPiece sample) override; + std::string GenerateHeaderProtectionMask(absl::string_view sample) override; size_t GetKeySize() const override; size_t GetNoncePrefixSize() const override; size_t GetIVSize() const override; size_t GetMaxPlaintextSize(size_t ciphertext_size) const override; size_t GetCiphertextSize(size_t plaintext_size) const override; - quiche::QuicheStringPiece GetKey() const override; - quiche::QuicheStringPiece GetNoncePrefix() const override; + absl::string_view GetKey() const override; + absl::string_view GetNoncePrefix() const override; private: size_t GetHashLength() const;
diff --git a/quic/core/crypto/p256_key_exchange.cc b/quic/core/crypto/p256_key_exchange.cc index 01f345d..7a543b9 100644 --- a/quic/core/crypto/p256_key_exchange.cc +++ b/quic/core/crypto/p256_key_exchange.cc
@@ -10,13 +10,13 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ec.h" #include "third_party/boringssl/src/include/openssl/ecdh.h" #include "third_party/boringssl/src/include/openssl/err.h" #include "third_party/boringssl/src/include/openssl/evp.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -34,8 +34,7 @@ } // static -std::unique_ptr<P256KeyExchange> P256KeyExchange::New( - quiche::QuicheStringPiece key) { +std::unique_ptr<P256KeyExchange> P256KeyExchange::New(absl::string_view key) { if (key.empty()) { QUIC_DLOG(INFO) << "Private key is empty"; return nullptr; @@ -85,7 +84,7 @@ } bool P256KeyExchange::CalculateSharedKeySync( - quiche::QuicheStringPiece peer_public_value, + absl::string_view peer_public_value, std::string* shared_key) const { if (peer_public_value.size() != kUncompressedP256PointBytes) { QUIC_DLOG(INFO) << "Peer public value is invalid"; @@ -115,9 +114,9 @@ return true; } -quiche::QuicheStringPiece P256KeyExchange::public_value() const { - return quiche::QuicheStringPiece(reinterpret_cast<const char*>(public_key_), - sizeof(public_key_)); +absl::string_view P256KeyExchange::public_value() const { + return absl::string_view(reinterpret_cast<const char*>(public_key_), + sizeof(public_key_)); } } // namespace quic
diff --git a/quic/core/crypto/p256_key_exchange.h b/quic/core/crypto/p256_key_exchange.h index 10cc542..2b6f9b8 100644 --- a/quic/core/crypto/p256_key_exchange.h +++ b/quic/core/crypto/p256_key_exchange.h
@@ -8,10 +8,10 @@ #include <cstdint> #include <string> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "net/third_party/quiche/src/quic/core/crypto/key_exchange.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -26,8 +26,7 @@ // New creates a new key-exchange object from a private key. If |private_key| // is invalid, nullptr is returned. - static std::unique_ptr<P256KeyExchange> New( - quiche::QuicheStringPiece private_key); + static std::unique_ptr<P256KeyExchange> New(absl::string_view private_key); // NewPrivateKey returns a private key, suitable for passing to |New|. // If |NewPrivateKey| can't generate a private key, it returns an empty @@ -35,9 +34,9 @@ static std::string NewPrivateKey(); // SynchronousKeyExchange interface. - bool CalculateSharedKeySync(quiche::QuicheStringPiece peer_public_value, + bool CalculateSharedKeySync(absl::string_view peer_public_value, std::string* shared_key) const override; - quiche::QuicheStringPiece public_value() const override; + absl::string_view public_value() const override; QuicTag type() const override { return kP256; } private:
diff --git a/quic/core/crypto/p256_key_exchange_test.cc b/quic/core/crypto/p256_key_exchange_test.cc index 7e7dcd7..9419dcb 100644 --- a/quic/core/crypto/p256_key_exchange_test.cc +++ b/quic/core/crypto/p256_key_exchange_test.cc
@@ -8,8 +8,8 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { @@ -57,8 +57,8 @@ ASSERT_TRUE(alice != nullptr); ASSERT_TRUE(bob != nullptr); - const quiche::QuicheStringPiece alice_public(alice->public_value()); - const quiche::QuicheStringPiece bob_public(bob->public_value()); + const absl::string_view alice_public(alice->public_value()); + const absl::string_view bob_public(bob->public_value()); std::string alice_shared, bob_shared; ASSERT_TRUE(alice->CalculateSharedKeySync(bob_public, &alice_shared)); @@ -84,8 +84,8 @@ ASSERT_TRUE(alice != nullptr); ASSERT_TRUE(bob != nullptr); - const quiche::QuicheStringPiece alice_public(alice->public_value()); - const quiche::QuicheStringPiece bob_public(bob->public_value()); + const absl::string_view alice_public(alice->public_value()); + const absl::string_view bob_public(bob->public_value()); std::string alice_shared, bob_shared; TestCallbackResult alice_result;
diff --git a/quic/core/crypto/proof_source.h b/quic/core/crypto/proof_source.h index 637dd0c..e9358d5 100644 --- a/quic/core/crypto/proof_source.h +++ b/quic/core/crypto/proof_source.h
@@ -9,13 +9,13 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_crypto_proof.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -137,7 +137,7 @@ const std::string& hostname, const std::string& server_config, QuicTransportVersion transport_version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, std::unique_ptr<Callback> callback) = 0; // Returns the certificate chain for |hostname| in leaf-first order. @@ -159,7 +159,7 @@ const QuicSocketAddress& client_address, const std::string& hostname, uint16_t signature_algorithm, - quiche::QuicheStringPiece in, + absl::string_view in, std::unique_ptr<SignatureCallback> callback) = 0; class QUIC_EXPORT_PRIVATE DecryptCallback { @@ -193,13 +193,13 @@ // returns the encrypted ticket. The resulting value must not be larger than // MaxOverhead bytes larger than |in|. If encryption fails, this method // returns an empty vector. - virtual std::vector<uint8_t> Encrypt(quiche::QuicheStringPiece in) = 0; + virtual std::vector<uint8_t> Encrypt(absl::string_view in) = 0; // Decrypt takes an encrypted ticket |in|, decrypts it, and calls // |callback->Run| with the decrypted ticket, which must not be larger than // |in|. If decryption fails, the callback is invoked with an empty // vector. - virtual void Decrypt(quiche::QuicheStringPiece in, + virtual void Decrypt(absl::string_view in, std::unique_ptr<DecryptCallback> callback) = 0; };
diff --git a/quic/core/crypto/proof_source_x509.cc b/quic/core/crypto/proof_source_x509.cc index e432682..7a46ff2 100644 --- a/quic/core/crypto/proof_source_x509.cc +++ b/quic/core/crypto/proof_source_x509.cc
@@ -6,6 +6,7 @@ #include <memory> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" @@ -13,7 +14,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/common/platform/api/quiche_endian.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -34,7 +34,7 @@ const std::string& hostname, const std::string& server_config, QuicTransportVersion /*transport_version*/, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, std::unique_ptr<ProofSource::Callback> callback) { QuicCryptoProof proof; @@ -54,9 +54,9 @@ } Certificate* certificate = GetCertificate(hostname); - proof.signature = certificate->key.Sign( - quiche::QuicheStringPiece(payload.get(), payload_size), - SSL_SIGN_RSA_PSS_RSAE_SHA256); + proof.signature = + certificate->key.Sign(absl::string_view(payload.get(), payload_size), + SSL_SIGN_RSA_PSS_RSAE_SHA256); callback->Run(/*ok=*/!proof.signature.empty(), certificate->chain, proof, nullptr); } @@ -73,7 +73,7 @@ const QuicSocketAddress& /*client_address*/, const std::string& hostname, uint16_t signature_algorithm, - quiche::QuicheStringPiece in, + absl::string_view in, std::unique_ptr<ProofSource::SignatureCallback> callback) { std::string signature = GetCertificate(hostname)->key.Sign(in, signature_algorithm); @@ -109,7 +109,7 @@ }); Certificate* certificate = &certificates_.front(); - for (quiche::QuicheStringPiece host : leaf->subject_alt_name_domains()) { + for (absl::string_view host : leaf->subject_alt_name_domains()) { certificate_map_[std::string(host)] = certificate; } return true;
diff --git a/quic/core/crypto/proof_source_x509.h b/quic/core/crypto/proof_source_x509.h index 8632d4b..38a70ae 100644 --- a/quic/core/crypto/proof_source_x509.h +++ b/quic/core/crypto/proof_source_x509.h
@@ -8,11 +8,11 @@ #include <forward_list> #include <memory> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" #include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" #include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" #include "net/third_party/quiche/src/quic/platform/api/quic_macros.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -32,7 +32,7 @@ const std::string& hostname, const std::string& server_config, QuicTransportVersion transport_version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, std::unique_ptr<Callback> callback) override; QuicReferenceCountedPointer<Chain> GetCertChain( const QuicSocketAddress& server_address, @@ -43,7 +43,7 @@ const QuicSocketAddress& client_address, const std::string& hostname, uint16_t signature_algorithm, - quiche::QuicheStringPiece in, + absl::string_view in, std::unique_ptr<SignatureCallback> callback) override; TicketCrypter* GetTicketCrypter() override;
diff --git a/quic/core/crypto/proof_source_x509_test.cc b/quic/core/crypto/proof_source_x509_test.cc index 23311d0..e0b45c6 100644 --- a/quic/core/crypto/proof_source_x509_test.cc +++ b/quic/core/crypto/proof_source_x509_test.cc
@@ -6,6 +6,7 @@ #include <memory> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/certificate_view.h" #include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" @@ -15,14 +16,13 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/test_certificates.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test { namespace { QuicReferenceCountedPointer<ProofSource::Chain> MakeChain( - quiche::QuicheStringPiece cert) { + absl::string_view cert) { return QuicReferenceCountedPointer<ProofSource::Chain>( new ProofSource::Chain(std::vector<std::string>{std::string(cert)})); }
diff --git a/quic/core/crypto/proof_verifier.h b/quic/core/crypto/proof_verifier.h index 0380b8a..7576620 100644 --- a/quic/core/crypto/proof_verifier.h +++ b/quic/core/crypto/proof_verifier.h
@@ -9,10 +9,10 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -79,7 +79,7 @@ const uint16_t port, const std::string& server_config, QuicTransportVersion transport_version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, const std::vector<std::string>& certs, const std::string& cert_sct, const std::string& signature,
diff --git a/quic/core/crypto/quic_crypter.cc b/quic/core/crypto/quic_crypter.cc index d8e7f2d..036f694 100644 --- a/quic/core/crypto/quic_crypter.cc +++ b/quic/core/crypto/quic_crypter.cc
@@ -3,13 +3,12 @@ // found in the LICENSE file. #include "net/third_party/quiche/src/quic/core/crypto/quic_crypter.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" +#include "absl/strings/string_view.h" namespace quic { -bool QuicCrypter::SetNoncePrefixOrIV( - const ParsedQuicVersion& version, - quiche::QuicheStringPiece nonce_prefix_or_iv) { +bool QuicCrypter::SetNoncePrefixOrIV(const ParsedQuicVersion& version, + absl::string_view nonce_prefix_or_iv) { if (version.UsesInitialObfuscators()) { return SetIV(nonce_prefix_or_iv); }
diff --git a/quic/core/crypto/quic_crypter.h b/quic/core/crypto/quic_crypter.h index a12cd6f..348a3fb 100644 --- a/quic/core/crypto/quic_crypter.h +++ b/quic/core/crypto/quic_crypter.h
@@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_QUIC_CRYPTER_H_ #define QUICHE_QUIC_CORE_CRYPTO_QUIC_CRYPTER_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -24,7 +24,7 @@ // // NOTE: The key is the client_write_key or server_write_key derived from // the master secret. - virtual bool SetKey(quiche::QuicheStringPiece key) = 0; + virtual bool SetKey(absl::string_view key) = 0; // Sets the fixed initial bytes of the nonce. Returns true on success, // false on failure. This method must only be used with Google QUIC crypters. @@ -41,7 +41,7 @@ // // The security of the nonce format requires that QUIC never reuse a // packet number, even when retransmitting a lost packet. - virtual bool SetNoncePrefix(quiche::QuicheStringPiece nonce_prefix) = 0; + virtual bool SetNoncePrefix(absl::string_view nonce_prefix) = 0; // Sets |iv| as the initialization vector to use when constructing the nonce. // Returns true on success, false on failure. This method must only be used @@ -68,15 +68,15 @@ // // The security of the nonce format requires that QUIC never reuse a // packet number, even when retransmitting a lost packet. - virtual bool SetIV(quiche::QuicheStringPiece iv) = 0; + virtual bool SetIV(absl::string_view iv) = 0; // Calls SetNoncePrefix or SetIV depending on whether |version| uses the // Google QUIC crypto or IETF QUIC nonce construction. virtual bool SetNoncePrefixOrIV(const ParsedQuicVersion& version, - quiche::QuicheStringPiece nonce_prefix_or_iv); + absl::string_view nonce_prefix_or_iv); // Sets the key to use for header protection. - virtual bool SetHeaderProtectionKey(quiche::QuicheStringPiece key) = 0; + virtual bool SetHeaderProtectionKey(absl::string_view key) = 0; // GetKeySize, GetIVSize, and GetNoncePrefixSize are used to know how many // bytes of key material needs to be derived from the master secret.
diff --git a/quic/core/crypto/quic_crypto_client_config.cc b/quic/core/crypto/quic_crypto_client_config.cc index c110f8e..a74e16f 100644 --- a/quic/core/crypto/quic_crypto_client_config.cc +++ b/quic/core/crypto/quic_crypto_client_config.cc
@@ -8,6 +8,7 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" #include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" @@ -32,7 +33,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_map_util.h" #include "net/third_party/quiche/src/quic/platform/api/quic_ptr_util.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -144,7 +144,7 @@ QuicCryptoClientConfig::CachedState::ServerConfigState QuicCryptoClientConfig::CachedState::SetServerConfig( - quiche::QuicheStringPiece server_config, + absl::string_view server_config, QuicWallTime now, QuicWallTime expiry_time, std::string* error_details) { @@ -199,9 +199,9 @@ void QuicCryptoClientConfig::CachedState::SetProof( const std::vector<std::string>& certs, - quiche::QuicheStringPiece cert_sct, - quiche::QuicheStringPiece chlo_hash, - quiche::QuicheStringPiece signature) { + absl::string_view cert_sct, + absl::string_view chlo_hash, + absl::string_view signature) { bool has_changed = signature != server_config_sig_ || chlo_hash != chlo_hash_ || certs_.size() != certs.size(); @@ -257,12 +257,12 @@ } bool QuicCryptoClientConfig::CachedState::Initialize( - quiche::QuicheStringPiece server_config, - quiche::QuicheStringPiece source_address_token, + absl::string_view server_config, + absl::string_view source_address_token, const std::vector<std::string>& certs, const std::string& cert_sct, - quiche::QuicheStringPiece chlo_hash, - quiche::QuicheStringPiece signature, + absl::string_view chlo_hash, + absl::string_view signature, QuicWallTime now, QuicWallTime expiration_time) { DCHECK(server_config_.empty()); @@ -330,12 +330,12 @@ } void QuicCryptoClientConfig::CachedState::set_source_address_token( - quiche::QuicheStringPiece token) { + absl::string_view token) { source_address_token_ = std::string(token); } void QuicCryptoClientConfig::CachedState::set_cert_sct( - quiche::QuicheStringPiece cert_sct) { + absl::string_view cert_sct) { cert_sct_ = std::string(cert_sct); } @@ -439,7 +439,7 @@ // the STK can be validated by the server. const CryptoHandshakeMessage* scfg = cached->GetServerConfig(); if (scfg != nullptr) { - quiche::QuicheStringPiece scid; + absl::string_view scid; if (scfg->GetStringPiece(kSCID, &scid)) { out->SetStringPiece(kSCID, scid); } @@ -455,8 +455,8 @@ char proof_nonce[32]; rand->RandBytes(proof_nonce, QUICHE_ARRAYSIZE(proof_nonce)); - out->SetStringPiece(kNONP, quiche::QuicheStringPiece( - proof_nonce, QUICHE_ARRAYSIZE(proof_nonce))); + out->SetStringPiece( + kNONP, absl::string_view(proof_nonce, QUICHE_ARRAYSIZE(proof_nonce))); out->SetVector(kPDMD, QuicTagVector{kX509}); @@ -513,7 +513,7 @@ return QUIC_CRYPTO_INTERNAL_ERROR; } - quiche::QuicheStringPiece scid; + absl::string_view scid; if (!scfg->GetStringPiece(kSCID, &scid)) { *error_details = "SCFG missing SCID"; return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; @@ -545,14 +545,14 @@ out->SetVector(kAEAD, QuicTagVector{out_params->aead}); out->SetVector(kKEXS, QuicTagVector{out_params->key_exchange}); - quiche::QuicheStringPiece public_value; + absl::string_view 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; } - quiche::QuicheStringPiece orbit; + absl::string_view orbit; if (!scfg->GetStringPiece(kORBT, &orbit) || orbit.size() != kOrbitSize) { *error_details = "SCFG missing OBIT"; return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND; @@ -635,13 +635,13 @@ const CryptoHandshakeMessage& message, QuicWallTime now, QuicTransportVersion /*version*/, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, const std::vector<std::string>& cached_certs, CachedState* cached, std::string* error_details) { DCHECK(error_details != nullptr); - quiche::QuicheStringPiece scfg; + absl::string_view scfg; if (!message.GetStringPiece(kSCFG, &scfg)) { *error_details = "Missing SCFG"; return QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND; @@ -666,12 +666,12 @@ return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; } - quiche::QuicheStringPiece token; + absl::string_view token; if (message.GetStringPiece(kSourceAddressTokenTag, &token)) { cached->set_source_address_token(token); } - quiche::QuicheStringPiece proof, cert_bytes, cert_sct; + absl::string_view 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) { @@ -707,7 +707,7 @@ const CryptoHandshakeMessage& rej, QuicWallTime now, const QuicTransportVersion version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, CachedState* cached, QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details) { @@ -725,7 +725,7 @@ return error; } - quiche::QuicheStringPiece nonce; + absl::string_view nonce; if (rej.GetStringPiece(kServerNonceTag, &nonce)) { out_params->server_nonce = std::string(nonce); } @@ -750,12 +750,12 @@ } // Learn about updated source address tokens. - quiche::QuicheStringPiece token; + absl::string_view token; if (server_hello.GetStringPiece(kSourceAddressTokenTag, &token)) { cached->set_source_address_token(token); } - quiche::QuicheStringPiece shlo_nonce; + absl::string_view shlo_nonce; if (!server_hello.GetStringPiece(kServerNonceTag, &shlo_nonce)) { *error_details = "server hello missing server nonce"; return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; @@ -764,7 +764,7 @@ // TODO(agl): // learn about updated SCFGs. - quiche::QuicheStringPiece public_value; + absl::string_view public_value; if (!server_hello.GetStringPiece(kPUBS, &public_value)) { *error_details = "server hello missing forward secure public value"; return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; @@ -800,7 +800,7 @@ const CryptoHandshakeMessage& server_config_update, QuicWallTime now, const QuicTransportVersion version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, CachedState* cached, QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details) {
diff --git a/quic/core/crypto/quic_crypto_client_config.h b/quic/core/crypto/quic_crypto_client_config.h index 701b7ff..913ddf9 100644 --- a/quic/core/crypto/quic_crypto_client_config.h +++ b/quic/core/crypto/quic_crypto_client_config.h
@@ -11,6 +11,7 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" @@ -21,7 +22,6 @@ #include "net/third_party/quiche/src/quic/core/quic_server_id.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" #include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -131,7 +131,7 @@ // SetServerConfig checks that |server_config| parses correctly and stores // it in |server_config_|. |now| is used to judge whether |server_config| // has expired. - ServerConfigState SetServerConfig(quiche::QuicheStringPiece server_config, + ServerConfigState SetServerConfig(absl::string_view server_config, QuicWallTime now, QuicWallTime expiry_time, std::string* error_details); @@ -141,9 +141,9 @@ // SetProof stores a cert chain, cert signed timestamp and signature. void SetProof(const std::vector<std::string>& certs, - quiche::QuicheStringPiece cert_sct, - quiche::QuicheStringPiece chlo_hash, - quiche::QuicheStringPiece signature); + absl::string_view cert_sct, + absl::string_view chlo_hash, + absl::string_view signature); // Clears all the data. void Clear(); @@ -171,9 +171,9 @@ uint64_t generation_counter() const; const ProofVerifyDetails* proof_verify_details() const; - void set_source_address_token(quiche::QuicheStringPiece token); + void set_source_address_token(absl::string_view token); - void set_cert_sct(quiche::QuicheStringPiece cert_sct); + void set_cert_sct(absl::string_view cert_sct); // Adds the servernonce to the queue of server nonces. void add_server_nonce(const std::string& server_nonce); @@ -198,12 +198,12 @@ // Initializes this cached state based on the arguments provided. // Returns false if there is a problem parsing the server config. - bool Initialize(quiche::QuicheStringPiece server_config, - quiche::QuicheStringPiece source_address_token, + bool Initialize(absl::string_view server_config, + absl::string_view source_address_token, const std::vector<std::string>& certs, const std::string& cert_sct, - quiche::QuicheStringPiece chlo_hash, - quiche::QuicheStringPiece signature, + absl::string_view chlo_hash, + absl::string_view signature, QuicWallTime now, QuicWallTime expiration_time); @@ -311,7 +311,7 @@ const CryptoHandshakeMessage& rej, QuicWallTime now, QuicTransportVersion version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, CachedState* cached, QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details); @@ -343,7 +343,7 @@ const CryptoHandshakeMessage& server_update, QuicWallTime now, const QuicTransportVersion version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, CachedState* cached, QuicReferenceCountedPointer<QuicCryptoNegotiatedParameters> out_params, std::string* error_details); @@ -380,7 +380,7 @@ void set_alpn(const std::string& alpn) { alpn_ = alpn; } // Saves the pre-shared key used during the handshake. - void set_pre_shared_key(quiche::QuicheStringPiece psk) { + void set_pre_shared_key(absl::string_view psk) { pre_shared_key_ = std::string(psk); } @@ -407,7 +407,7 @@ const CryptoHandshakeMessage& message, QuicWallTime now, QuicTransportVersion version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, const std::vector<std::string>& cached_certs, CachedState* cached, std::string* error_details);
diff --git a/quic/core/crypto/quic_crypto_client_config_test.cc b/quic/core/crypto/quic_crypto_client_config_test.cc index 88b3eb6..d7625cd 100644 --- a/quic/core/crypto/quic_crypto_client_config_test.cc +++ b/quic/core/crypto/quic_crypto_client_config_test.cc
@@ -6,6 +6,7 @@ #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/proof_verifier.h" #include "net/third_party/quiche/src/quic/core/quic_server_id.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" @@ -15,7 +16,6 @@ #include "net/third_party/quiche/src/quic/test_tools/crypto_test_utils.h" #include "net/third_party/quiche/src/quic/test_tools/mock_random.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" using testing::StartsWith; @@ -149,13 +149,13 @@ QuicVersionLabel cver; EXPECT_THAT(msg.GetVersionLabel(kVER, &cver), IsQuicNoError()); EXPECT_EQ(CreateQuicVersionLabel(QuicVersionMax()), cver); - quiche::QuicheStringPiece proof_nonce; + absl::string_view proof_nonce; EXPECT_TRUE(msg.GetStringPiece(kNONP, &proof_nonce)); EXPECT_EQ(std::string(32, 'r'), proof_nonce); - quiche::QuicheStringPiece user_agent_id; + absl::string_view user_agent_id; EXPECT_TRUE(msg.GetStringPiece(kUAID, &user_agent_id)); EXPECT_EQ("quic-tester", user_agent_id); - quiche::QuicheStringPiece alpn; + absl::string_view alpn; EXPECT_TRUE(msg.GetStringPiece(kALPN, &alpn)); EXPECT_EQ("hq", alpn); EXPECT_EQ(msg.minimum_size(), 1u); @@ -203,7 +203,7 @@ QuicTag pdmd; EXPECT_THAT(msg.GetUint32(kPDMD, &pdmd), IsQuicNoError()); EXPECT_EQ(kX509, pdmd); - quiche::QuicheStringPiece scid; + absl::string_view scid; EXPECT_FALSE(msg.GetStringPiece(kSCID, &scid)); } @@ -229,7 +229,7 @@ config.FillInchoateClientHello(server_id, QuicVersionMax(), &state, &rand, /* demand_x509_proof= */ true, params, &msg); - quiche::QuicheStringPiece scid; + absl::string_view scid; EXPECT_TRUE(msg.GetStringPiece(kSCID, &scid)); EXPECT_EQ("12345678", scid); } @@ -255,7 +255,7 @@ config.FillInchoateClientHello(server_id, QuicVersionMax(), &state, &rand, /* demand_x509_proof= */ true, params, &msg); - quiche::QuicheStringPiece scid; + absl::string_view scid; EXPECT_TRUE(msg.GetStringPiece(kSCID, &scid)); EXPECT_EQ("12345678", scid); }
diff --git a/quic/core/crypto/quic_crypto_server_config.cc b/quic/core/crypto/quic_crypto_server_config.cc index ec535cf..3e558d0 100644 --- a/quic/core/crypto/quic_crypto_server_config.cc +++ b/quic/core/crypto/quic_crypto_server_config.cc
@@ -10,6 +10,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/sha.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h" @@ -48,7 +49,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" #include "net/third_party/quiche/src/quic/platform/api/quic_testvalue.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -64,11 +64,11 @@ const int kMaxTokenAddresses = 4; std::string DeriveSourceAddressTokenKey( - quiche::QuicheStringPiece source_address_token_secret) { - QuicHKDF hkdf( - source_address_token_secret, quiche::QuicheStringPiece() /* no salt */, - "QUIC source address token key", CryptoSecretBoxer::GetKeySize(), - 0 /* no fixed IV needed */, 0 /* no subkey secret */); + absl::string_view source_address_token_secret) { + QuicHKDF hkdf(source_address_token_secret, absl::string_view() /* no salt */, + "QUIC source address token key", + CryptoSecretBoxer::GetKeySize(), 0 /* no fixed IV needed */, + 0 /* no subkey secret */); return std::string(hkdf.server_write_key()); } @@ -82,7 +82,7 @@ std::string /*server_config_id*/, bool /* is_fallback */, QuicTag type, - quiche::QuicheStringPiece private_key) override { + absl::string_view private_key) override { if (private_key.empty()) { QUIC_LOG(WARNING) << "Server config contains key exchange method without " "corresponding private key of type " @@ -232,7 +232,7 @@ } QuicCryptoServerConfig::QuicCryptoServerConfig( - quiche::QuicheStringPiece source_address_token_secret, + absl::string_view source_address_token_secret, QuicRandom* server_nonce_entropy, std::unique_ptr<ProofSource> proof_source, std::unique_ptr<KeyExchangeSource> key_exchange_source) @@ -281,8 +281,7 @@ Curve25519KeyExchange::NewPrivateKey(rand); std::unique_ptr<Curve25519KeyExchange> curve25519 = Curve25519KeyExchange::New(curve25519_private_key); - quiche::QuicheStringPiece curve25519_public_value = - curve25519->public_value(); + absl::string_view curve25519_public_value = curve25519->public_value(); std::string encoded_public_values; // First three bytes encode the length of the public value. @@ -301,7 +300,7 @@ p256_private_key = P256KeyExchange::NewPrivateKey(); std::unique_ptr<P256KeyExchange> p256( P256KeyExchange::New(p256_private_key)); - quiche::QuicheStringPiece p256_public_value = p256->public_value(); + absl::string_view p256_public_value = p256->public_value(); DCHECK_LT(p256_public_value.size(), (1U << 24)); encoded_public_values.push_back( @@ -340,8 +339,8 @@ DCHECK(options.orbit.empty()); rand->RandBytes(orbit_bytes, sizeof(orbit_bytes)); } - msg.SetStringPiece( - kORBT, quiche::QuicheStringPiece(orbit_bytes, sizeof(orbit_bytes))); + msg.SetStringPiece(kORBT, + absl::string_view(orbit_bytes, sizeof(orbit_bytes))); if (options.channel_id_enabled) { msg.SetVector(kPDMD, QuicTagVector{kCHID}); @@ -358,9 +357,9 @@ serialized->length(), scid_bytes); // The SCID is a truncated SHA-256 digest. static_assert(16 <= SHA256_DIGEST_LENGTH, "SCID length too high."); - msg.SetStringPiece(kSCID, - quiche::QuicheStringPiece( - reinterpret_cast<const char*>(scid_bytes), 16)); + msg.SetStringPiece( + kSCID, + absl::string_view(reinterpret_cast<const char*>(scid_bytes), 16)); } else { msg.SetStringPiece(kSCID, options.id); } @@ -538,7 +537,7 @@ new ValidateClientHelloResultCallback::Result( client_hello, client_address.host(), now)); - quiche::QuicheStringPiece requested_scid; + absl::string_view requested_scid; client_hello.GetStringPiece(kSCID, &requested_scid); Configs configs; if (!GetCurrentConfigs(now, requested_scid, @@ -594,7 +593,7 @@ std::unique_ptr<ProofSource::Details> proof_source_details, QuicTag key_exchange_type, std::unique_ptr<CryptoHandshakeMessage> out, - quiche::QuicheStringPiece public_value, + absl::string_view public_value, std::unique_ptr<ProcessClientHelloContext> context, const Configs& configs) : config_(config), @@ -687,7 +686,7 @@ return; } - quiche::QuicheStringPiece requested_scid; + absl::string_view requested_scid; context->client_hello().GetStringPiece(kSCID, &requested_scid); Configs configs; if (!GetCurrentConfigs(context->clock()->WallNow(), requested_scid, @@ -748,7 +747,7 @@ auto out_diversification_nonce = std::make_unique<DiversificationNonce>(); - quiche::QuicheStringPiece cert_sct; + absl::string_view cert_sct; if (context->client_hello().GetStringPiece(kCertificateSCTTag, &cert_sct) && cert_sct.empty()) { context->params()->sct_supported_by_client = true; @@ -791,7 +790,7 @@ return; } - quiche::QuicheStringPiece public_value; + absl::string_view public_value; if (!context->client_hello().GetStringPiece(kPUBS, &public_value)) { context->Fail(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, "Missing public value"); @@ -819,7 +818,7 @@ std::unique_ptr<ProofSource::Details> proof_source_details, QuicTag key_exchange_type, std::unique_ptr<CryptoHandshakeMessage> out, - quiche::QuicheStringPiece public_value, + absl::string_view public_value, std::unique_ptr<ProcessClientHelloContext> context, const Configs& configs) const { QUIC_BUG_IF(!QuicUtils::IsConnectionIdValidForVersion( @@ -868,7 +867,7 @@ } hkdf_suffix.append(context->signed_config()->chain->certs.at(0)); - quiche::QuicheStringPiece cetv_ciphertext; + absl::string_view cetv_ciphertext; if (configs.requested->channel_id_enabled && context->client_hello().GetStringPiece(kCETV, &cetv_ciphertext)) { CryptoHandshakeMessage client_hello_copy(context->client_hello()); @@ -901,22 +900,21 @@ char plaintext[kMaxOutgoingPacketSize]; size_t plaintext_length = 0; const bool success = crypters.decrypter->DecryptPacket( - 0 /* packet number */, - quiche::QuicheStringPiece() /* associated data */, cetv_ciphertext, - plaintext, &plaintext_length, kMaxOutgoingPacketSize); + 0 /* packet number */, absl::string_view() /* associated data */, + cetv_ciphertext, plaintext, &plaintext_length, kMaxOutgoingPacketSize); if (!success) { context->Fail(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, "CETV decryption failure"); return; } std::unique_ptr<CryptoHandshakeMessage> cetv(CryptoFramer::ParseMessage( - quiche::QuicheStringPiece(plaintext, plaintext_length))); + absl::string_view(plaintext, plaintext_length))); if (!cetv) { context->Fail(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, "CETV parse error"); return; } - quiche::QuicheStringPiece key, signature; + absl::string_view key, signature; if (cetv->GetStringPiece(kCIDK, &key) && cetv->GetStringPiece(kCIDS, &signature)) { if (!ChannelIDVerifier::Verify(key, hkdf_input, signature)) { @@ -1055,7 +1053,7 @@ QuicReferenceCountedPointer<QuicCryptoServerConfig::Config> QuicCryptoServerConfig::GetConfigWithScid( - quiche::QuicheStringPiece requested_scid) const { + absl::string_view requested_scid) const { configs_lock_.AssertReaderHeld(); if (!requested_scid.empty()) { @@ -1072,7 +1070,7 @@ bool QuicCryptoServerConfig::GetCurrentConfigs( const QuicWallTime& now, - quiche::QuicheStringPiece requested_scid, + absl::string_view requested_scid, QuicReferenceCountedPointer<Config> old_primary_config, Configs* configs) const { QuicReaderMutexLock locked(&configs_lock_); @@ -1230,7 +1228,7 @@ HandshakeFailureReason source_address_token_error = MAX_FAILURE_REASON; if (validate_source_address_token_) { - quiche::QuicheStringPiece srct; + absl::string_view srct; if (client_hello.GetStringPiece(kSourceAddressTokenTag, &srct)) { Config& config = configs.requested != nullptr ? *configs.requested : *configs.primary; @@ -1253,7 +1251,7 @@ } if (!configs.requested) { - quiche::QuicheStringPiece requested_scid; + absl::string_view requested_scid; if (client_hello.GetStringPiece(kSCID, &requested_scid)) { info->reject_reasons.push_back(SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE); } else { @@ -1308,7 +1306,7 @@ void QuicCryptoServerConfig::BuildServerConfigUpdateMessage( QuicTransportVersion version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, const SourceAddressTokens& previous_source_address_tokens, const QuicSocketAddress& server_address, const QuicSocketAddress& client_address, @@ -1457,13 +1455,13 @@ return; } - quiche::QuicheStringPiece client_common_set_hashes; + absl::string_view client_common_set_hashes; if (context.client_hello().GetStringPiece(kCCS, &client_common_set_hashes)) { context.params()->client_common_set_hashes = std::string(client_common_set_hashes); } - quiche::QuicheStringPiece client_cached_cert_hashes; + absl::string_view client_cached_cert_hashes; if (context.client_hello().GetStringPiece(kCCRT, &client_cached_cert_hashes)) { context.params()->client_cached_cert_hashes = @@ -1511,7 +1509,7 @@ // This is for debugging b/28342827. const std::vector<std::string>& certs = context.signed_config()->chain->certs; - quiche::QuicheStringPiece ca_subject; + absl::string_view ca_subject; if (!certs.empty()) { QuicCertUtils::ExtractSubjectNameFromDERCert(certs[0], &ca_subject); } @@ -1578,7 +1576,7 @@ config->priority = protobuf.priority(); - quiche::QuicheStringPiece scid; + absl::string_view scid; if (!msg->GetStringPiece(kSCID, &scid)) { QUIC_LOG(WARNING) << "Server config message is missing SCID"; return nullptr; @@ -1596,7 +1594,7 @@ return nullptr; } - quiche::QuicheStringPiece orbit; + absl::string_view orbit; if (!msg->GetStringPiece(kORBT, &orbit)) { QUIC_LOG(WARNING) << "Server config message is missing ORBT"; return nullptr; @@ -1767,10 +1765,10 @@ HandshakeFailureReason QuicCryptoServerConfig::ParseSourceAddressToken( const Config& config, - quiche::QuicheStringPiece token, + absl::string_view token, SourceAddressTokens* tokens) const { std::string storage; - quiche::QuicheStringPiece plaintext; + absl::string_view plaintext; if (!config.source_address_token_boxer->Unbox(token, &storage, &plaintext)) { return SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE; } @@ -1860,8 +1858,8 @@ sizeof(server_nonce) - sizeof(timestamp)); return server_nonce_boxer_.Box( - rand, quiche::QuicheStringPiece(reinterpret_cast<char*>(server_nonce), - sizeof(server_nonce))); + rand, absl::string_view(reinterpret_cast<char*>(server_nonce), + sizeof(server_nonce))); } bool QuicCryptoServerConfig::ValidateExpectedLeafCertificate(
diff --git a/quic/core/crypto/quic_crypto_server_config.h b/quic/core/crypto/quic_crypto_server_config.h index 9f2db60..bd3111b 100644 --- a/quic/core/crypto/quic_crypto_server_config.h +++ b/quic/core/crypto/quic_crypto_server_config.h
@@ -12,6 +12,7 @@ #include <string> #include <vector> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/base.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" @@ -30,7 +31,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_mutex.h" #include "net/third_party/quiche/src/quic/platform/api/quic_reference_counted.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -54,10 +54,10 @@ // Outputs from EvaluateClientHello. bool valid_source_address_token; - quiche::QuicheStringPiece sni; - quiche::QuicheStringPiece client_nonce; - quiche::QuicheStringPiece server_nonce; - quiche::QuicheStringPiece user_agent_id; + absl::string_view sni; + absl::string_view client_nonce; + absl::string_view server_nonce; + absl::string_view user_agent_id; SourceAddressTokens source_address_tokens; // Errors from EvaluateClientHello. @@ -171,7 +171,7 @@ std::string server_config_id, bool is_fallback, QuicTag type, - quiche::QuicheStringPiece private_key) = 0; + absl::string_view private_key) = 0; }; // QuicCryptoServerConfig contains the crypto configuration of a QUIC server. @@ -215,7 +215,7 @@ // |proof_source|: provides certificate chains and signatures. // |key_exchange_source|: provides key-exchange functionality. QuicCryptoServerConfig( - quiche::QuicheStringPiece source_address_token_secret, + absl::string_view source_address_token_secret, QuicRandom* server_nonce_entropy, std::unique_ptr<ProofSource> proof_source, std::unique_ptr<KeyExchangeSource> key_exchange_source); @@ -357,7 +357,7 @@ // |cached_network_params| is optional, and can be nullptr. void BuildServerConfigUpdateMessage( QuicTransportVersion version, - quiche::QuicheStringPiece chlo_hash, + absl::string_view chlo_hash, const SourceAddressTokens& previous_source_address_tokens, const QuicSocketAddress& server_address, const QuicSocketAddress& client_address, @@ -434,7 +434,7 @@ // Pre-shared key used during the handshake. const std::string& pre_shared_key() const { return pre_shared_key_; } - void set_pre_shared_key(quiche::QuicheStringPiece psk) { + void set_pre_shared_key(absl::string_view psk) { pre_shared_key_ = std::string(psk); } @@ -516,7 +516,7 @@ // Get a ref to the config with a given server config id. QuicReferenceCountedPointer<Config> GetConfigWithScid( - quiche::QuicheStringPiece requested_scid) const + absl::string_view requested_scid) const QUIC_SHARED_LOCKS_REQUIRED(configs_lock_); // A snapshot of the configs associated with an in-progress handshake. @@ -533,7 +533,7 @@ // Returns true if any configs are loaded. If false is returned, |configs| is // not modified. bool GetCurrentConfigs(const QuicWallTime& now, - quiche::QuicheStringPiece requested_scid, + absl::string_view requested_scid, QuicReferenceCountedPointer<Config> old_primary_config, Configs* configs) const; @@ -687,7 +687,7 @@ std::unique_ptr<ProofSource::Details> proof_source_details, QuicTag key_exchange_type, std::unique_ptr<CryptoHandshakeMessage> out, - quiche::QuicheStringPiece public_value, + absl::string_view public_value, std::unique_ptr<ProcessClientHelloContext> context, const Configs& configs) const; @@ -761,7 +761,7 @@ // failure. HandshakeFailureReason ParseSourceAddressToken( const Config& config, - quiche::QuicheStringPiece token, + absl::string_view token, SourceAddressTokens* tokens) const; // ValidateSourceAddressTokens returns HANDSHAKE_OK if the source address
diff --git a/quic/core/crypto/quic_crypto_server_config_test.cc b/quic/core/crypto/quic_crypto_server_config_test.cc index 6f0c047..b91113d 100644 --- a/quic/core/crypto/quic_crypto_server_config_test.cc +++ b/quic/core/crypto/quic_crypto_server_config_test.cc
@@ -9,6 +9,7 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/cert_compressor.h" #include "net/third_party/quiche/src/quic/core/crypto/chacha20_poly1305_encrypter.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_handshake_message.h" @@ -23,7 +24,6 @@ #include "net/third_party/quiche/src/quic/test_tools/mock_clock.h" #include "net/third_party/quiche/src/quic/test_tools/quic_crypto_server_config_peer.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -142,7 +142,7 @@ static const uint64_t set_hash = 42; std::unique_ptr<CommonCertSets> common_sets( crypto_test_utils::MockCommonCertSets(certs[0], set_hash, 1)); - quiche::QuicheStringPiece different_common_certs( + absl::string_view different_common_certs( reinterpret_cast<const char*>(&set_hash), sizeof(set_hash)); std::string compressed3 = QuicCryptoServerConfigPeer::CompressChain( &compressed_certs_cache, chain, std::string(different_common_certs), @@ -193,16 +193,15 @@ clock_.WallNow(), cached_network_params); } - HandshakeFailureReason ValidateSourceAddressTokens( - std::string config_id, - quiche::QuicheStringPiece srct, - const QuicIpAddress& ip) { + HandshakeFailureReason ValidateSourceAddressTokens(std::string config_id, + absl::string_view srct, + const QuicIpAddress& ip) { return ValidateSourceAddressTokens(config_id, srct, ip, nullptr); } HandshakeFailureReason ValidateSourceAddressTokens( std::string config_id, - quiche::QuicheStringPiece srct, + absl::string_view srct, const QuicIpAddress& ip, CachedNetworkParameters* cached_network_params) { return peer_.ValidateSourceAddressTokens(
diff --git a/quic/core/crypto/quic_decrypter.cc b/quic/core/crypto/quic_decrypter.cc index c424901..29e1e18 100644 --- a/quic/core/crypto/quic_decrypter.cc +++ b/quic/core/crypto/quic_decrypter.cc
@@ -7,6 +7,7 @@ #include <string> #include <utility> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/tls1.h" #include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_12_decrypter.h" #include "net/third_party/quiche/src/quic/core/crypto/aes_128_gcm_decrypter.h" @@ -18,7 +19,6 @@ #include "net/third_party/quiche/src/quic/core/crypto/quic_hkdf.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -62,16 +62,15 @@ } // static -void QuicDecrypter::DiversifyPreliminaryKey( - quiche::QuicheStringPiece preliminary_key, - quiche::QuicheStringPiece nonce_prefix, - const DiversificationNonce& nonce, - size_t key_size, - size_t nonce_prefix_size, - std::string* out_key, - std::string* out_nonce_prefix) { +void QuicDecrypter::DiversifyPreliminaryKey(absl::string_view preliminary_key, + absl::string_view nonce_prefix, + const DiversificationNonce& nonce, + size_t key_size, + size_t nonce_prefix_size, + std::string* out_key, + std::string* out_nonce_prefix) { QuicHKDF hkdf((std::string(preliminary_key)) + (std::string(nonce_prefix)), - quiche::QuicheStringPiece(nonce.data(), nonce.size()), + absl::string_view(nonce.data(), nonce.size()), "QUIC key diversification", 0, key_size, 0, nonce_prefix_size, 0); *out_key = std::string(hkdf.server_write_key());
diff --git a/quic/core/crypto/quic_decrypter.h b/quic/core/crypto/quic_decrypter.h index 7f4d93d..21712f6 100644 --- a/quic/core/crypto/quic_decrypter.h +++ b/quic/core/crypto/quic_decrypter.h
@@ -10,11 +10,11 @@ #include <memory> #include <string> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_crypter.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -38,7 +38,7 @@ // // If this function is called, neither |SetKey| nor |SetNoncePrefix| may be // called. - virtual bool SetPreliminaryKey(quiche::QuicheStringPiece key) = 0; + virtual bool SetPreliminaryKey(absl::string_view key) = 0; // SetDiversificationNonce uses |nonce| to derive final keys based on the // input keying material given by calling |SetPreliminaryKey|. @@ -56,8 +56,8 @@ // TODO(wtc): add a way for DecryptPacket to report decryption failure due // to non-authentic inputs, as opposed to other reasons for failure. virtual bool DecryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece ciphertext, + absl::string_view associated_data, + absl::string_view ciphertext, char* output, size_t* output_length, size_t max_output_length) = 0; @@ -74,11 +74,11 @@ virtual uint32_t cipher_id() const = 0; // For use by unit tests only. - virtual quiche::QuicheStringPiece GetKey() const = 0; - virtual quiche::QuicheStringPiece GetNoncePrefix() const = 0; + virtual absl::string_view GetKey() const = 0; + virtual absl::string_view GetNoncePrefix() const = 0; - static void DiversifyPreliminaryKey(quiche::QuicheStringPiece preliminary_key, - quiche::QuicheStringPiece nonce_prefix, + static void DiversifyPreliminaryKey(absl::string_view preliminary_key, + absl::string_view nonce_prefix, const DiversificationNonce& nonce, size_t key_size, size_t nonce_prefix_size,
diff --git a/quic/core/crypto/quic_encrypter.h b/quic/core/crypto/quic_encrypter.h index 6fe552d..89d7fed 100644 --- a/quic/core/crypto/quic_encrypter.h +++ b/quic/core/crypto/quic_encrypter.h
@@ -8,10 +8,10 @@ #include <cstddef> #include <memory> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/quic_crypter.h" #include "net/third_party/quiche/src/quic/core/quic_packets.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -36,8 +36,8 @@ // |associated_data|. If |output| overlaps with |plaintext| then // |plaintext| must be <= |output|. virtual bool EncryptPacket(uint64_t packet_number, - quiche::QuicheStringPiece associated_data, - quiche::QuicheStringPiece plaintext, + absl::string_view associated_data, + absl::string_view plaintext, char* output, size_t* output_length, size_t max_output_length) = 0; @@ -47,7 +47,7 @@ // success, the mask will be at least 5 bytes long; on failure the string will // be empty. virtual std::string GenerateHeaderProtectionMask( - quiche::QuicheStringPiece sample) = 0; + absl::string_view sample) = 0; // Returns the maximum length of plaintext that can be encrypted // to ciphertext no larger than |ciphertext_size|. @@ -58,8 +58,8 @@ virtual size_t GetCiphertextSize(size_t plaintext_size) const = 0; // For use by unit tests only. - virtual quiche::QuicheStringPiece GetKey() const = 0; - virtual quiche::QuicheStringPiece GetNoncePrefix() const = 0; + virtual absl::string_view GetKey() const = 0; + virtual absl::string_view GetNoncePrefix() const = 0; }; } // namespace quic
diff --git a/quic/core/crypto/quic_hkdf.cc b/quic/core/crypto/quic_hkdf.cc index 28cf4a9..59c3eb0 100644 --- a/quic/core/crypto/quic_hkdf.cc +++ b/quic/core/crypto/quic_hkdf.cc
@@ -6,19 +6,19 @@ #include <memory> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/digest.h" #include "third_party/boringssl/src/include/openssl/hkdf.h" #include "net/third_party/quiche/src/quic/platform/api/quic_logging.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { const size_t kSHA256HashLength = 32; const size_t kMaxKeyMaterialSize = kSHA256HashLength * 256; -QuicHKDF::QuicHKDF(quiche::QuicheStringPiece secret, - quiche::QuicheStringPiece salt, - quiche::QuicheStringPiece info, +QuicHKDF::QuicHKDF(absl::string_view secret, + absl::string_view salt, + absl::string_view info, size_t key_bytes_to_generate, size_t iv_bytes_to_generate, size_t subkey_secret_bytes_to_generate) @@ -31,9 +31,9 @@ iv_bytes_to_generate, subkey_secret_bytes_to_generate) {} -QuicHKDF::QuicHKDF(quiche::QuicheStringPiece secret, - quiche::QuicheStringPiece salt, - quiche::QuicheStringPiece info, +QuicHKDF::QuicHKDF(absl::string_view secret, + absl::string_view salt, + absl::string_view info, size_t client_key_bytes_to_generate, size_t server_key_bytes_to_generate, size_t client_iv_bytes_to_generate, @@ -60,44 +60,44 @@ size_t j = 0; if (client_key_bytes_to_generate) { - client_write_key_ = quiche::QuicheStringPiece( - reinterpret_cast<char*>(&output_[j]), client_key_bytes_to_generate); + client_write_key_ = absl::string_view(reinterpret_cast<char*>(&output_[j]), + client_key_bytes_to_generate); j += client_key_bytes_to_generate; } if (server_key_bytes_to_generate) { - server_write_key_ = quiche::QuicheStringPiece( - reinterpret_cast<char*>(&output_[j]), server_key_bytes_to_generate); + server_write_key_ = absl::string_view(reinterpret_cast<char*>(&output_[j]), + server_key_bytes_to_generate); j += server_key_bytes_to_generate; } if (client_iv_bytes_to_generate) { - client_write_iv_ = quiche::QuicheStringPiece( - reinterpret_cast<char*>(&output_[j]), client_iv_bytes_to_generate); + client_write_iv_ = absl::string_view(reinterpret_cast<char*>(&output_[j]), + client_iv_bytes_to_generate); j += client_iv_bytes_to_generate; } if (server_iv_bytes_to_generate) { - server_write_iv_ = quiche::QuicheStringPiece( - reinterpret_cast<char*>(&output_[j]), server_iv_bytes_to_generate); + server_write_iv_ = absl::string_view(reinterpret_cast<char*>(&output_[j]), + server_iv_bytes_to_generate); j += server_iv_bytes_to_generate; } if (subkey_secret_bytes_to_generate) { - subkey_secret_ = quiche::QuicheStringPiece( - reinterpret_cast<char*>(&output_[j]), subkey_secret_bytes_to_generate); + subkey_secret_ = absl::string_view(reinterpret_cast<char*>(&output_[j]), + subkey_secret_bytes_to_generate); j += subkey_secret_bytes_to_generate; } // Repeat client and server key bytes for header protection keys. if (client_key_bytes_to_generate) { - client_hp_key_ = quiche::QuicheStringPiece( - reinterpret_cast<char*>(&output_[j]), client_key_bytes_to_generate); + client_hp_key_ = absl::string_view(reinterpret_cast<char*>(&output_[j]), + client_key_bytes_to_generate); j += client_key_bytes_to_generate; } if (server_key_bytes_to_generate) { - server_hp_key_ = quiche::QuicheStringPiece( - reinterpret_cast<char*>(&output_[j]), server_key_bytes_to_generate); + server_hp_key_ = absl::string_view(reinterpret_cast<char*>(&output_[j]), + server_key_bytes_to_generate); j += server_key_bytes_to_generate; } }
diff --git a/quic/core/crypto/quic_hkdf.h b/quic/core/crypto/quic_hkdf.h index 2945173..63018b4 100644 --- a/quic/core/crypto/quic_hkdf.h +++ b/quic/core/crypto/quic_hkdf.h
@@ -7,8 +7,8 @@ #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -31,18 +31,18 @@ // client and server. // |subkey_secret_bytes_to_generate|: the number of bytes of subkey secret to // generate, shared between client and server. - QuicHKDF(quiche::QuicheStringPiece secret, - quiche::QuicheStringPiece salt, - quiche::QuicheStringPiece info, + QuicHKDF(absl::string_view secret, + absl::string_view salt, + absl::string_view info, size_t key_bytes_to_generate, size_t iv_bytes_to_generate, size_t subkey_secret_bytes_to_generate); // An alternative constructor that allows the client and server key/IV // lengths to be different. - QuicHKDF(quiche::QuicheStringPiece secret, - quiche::QuicheStringPiece salt, - quiche::QuicheStringPiece info, + QuicHKDF(absl::string_view secret, + absl::string_view salt, + absl::string_view info, size_t client_key_bytes_to_generate, size_t server_key_bytes_to_generate, size_t client_iv_bytes_to_generate, @@ -51,28 +51,24 @@ ~QuicHKDF(); - quiche::QuicheStringPiece client_write_key() const { - return client_write_key_; - } - quiche::QuicheStringPiece client_write_iv() const { return client_write_iv_; } - quiche::QuicheStringPiece server_write_key() const { - return server_write_key_; - } - quiche::QuicheStringPiece server_write_iv() const { return server_write_iv_; } - quiche::QuicheStringPiece subkey_secret() const { return subkey_secret_; } - quiche::QuicheStringPiece client_hp_key() const { return client_hp_key_; } - quiche::QuicheStringPiece server_hp_key() const { return server_hp_key_; } + absl::string_view client_write_key() const { return client_write_key_; } + absl::string_view client_write_iv() const { return client_write_iv_; } + absl::string_view server_write_key() const { return server_write_key_; } + absl::string_view server_write_iv() const { return server_write_iv_; } + absl::string_view subkey_secret() const { return subkey_secret_; } + absl::string_view client_hp_key() const { return client_hp_key_; } + absl::string_view server_hp_key() const { return server_hp_key_; } private: std::vector<uint8_t> output_; - quiche::QuicheStringPiece client_write_key_; - quiche::QuicheStringPiece server_write_key_; - quiche::QuicheStringPiece client_write_iv_; - quiche::QuicheStringPiece server_write_iv_; - quiche::QuicheStringPiece subkey_secret_; - quiche::QuicheStringPiece client_hp_key_; - quiche::QuicheStringPiece server_hp_key_; + absl::string_view client_write_key_; + absl::string_view server_write_key_; + absl::string_view client_write_iv_; + absl::string_view server_write_iv_; + absl::string_view subkey_secret_; + absl::string_view client_hp_key_; + absl::string_view server_hp_key_; }; } // namespace quic
diff --git a/quic/core/crypto/tls_connection.cc b/quic/core/crypto/tls_connection.cc index 8e4d391..427474c 100644 --- a/quic/core/crypto/tls_connection.cc +++ b/quic/core/crypto/tls_connection.cc
@@ -4,8 +4,8 @@ #include "net/third_party/quiche/src/quic/core/crypto/tls_connection.h" +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -151,7 +151,7 @@ size_t len) { ConnectionFromSsl(ssl)->delegate_->WriteMessage( QuicEncryptionLevel(level), - quiche::QuicheStringPiece(reinterpret_cast<const char*>(data), len)); + absl::string_view(reinterpret_cast<const char*>(data), len)); return 1; }
diff --git a/quic/core/crypto/tls_connection.h b/quic/core/crypto/tls_connection.h index 15a4f4f..ef5ca58 100644 --- a/quic/core/crypto/tls_connection.h +++ b/quic/core/crypto/tls_connection.h
@@ -7,9 +7,9 @@ #include <vector> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/quic_types.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -53,7 +53,7 @@ // the QUIC stack to write in a crypto frame. The data must be transmitted // at encryption level |level|. virtual void WriteMessage(EncryptionLevel level, - quiche::QuicheStringPiece data) = 0; + absl::string_view data) = 0; // FlushFlight is called to signal that the current flight of messages have // all been written (via calls to WriteMessage) and can be flushed to the
diff --git a/quic/core/crypto/tls_server_connection.cc b/quic/core/crypto/tls_server_connection.cc index c821a38..1809c9e 100644 --- a/quic/core/crypto/tls_server_connection.cc +++ b/quic/core/crypto/tls_server_connection.cc
@@ -4,10 +4,10 @@ #include "net/third_party/quiche/src/quic/core/crypto/tls_server_connection.h" +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/ssl.h" #include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -82,7 +82,7 @@ size_t in_len) { return ConnectionFromSsl(ssl)->delegate_->PrivateKeySign( out, out_len, max_out, sig_alg, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(in), in_len)); + absl::string_view(reinterpret_cast<const char*>(in), in_len)); } // static @@ -116,7 +116,7 @@ size_t in_len) { return ConnectionFromSsl(ssl)->delegate_->SessionTicketSeal( out, out_len, max_out_len, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(in), in_len)); + absl::string_view(reinterpret_cast<const char*>(in), in_len)); } // static @@ -129,7 +129,7 @@ size_t in_len) { return ConnectionFromSsl(ssl)->delegate_->SessionTicketOpen( out, out_len, max_out_len, - quiche::QuicheStringPiece(reinterpret_cast<const char*>(in), in_len)); + absl::string_view(reinterpret_cast<const char*>(in), in_len)); } } // namespace quic
diff --git a/quic/core/crypto/tls_server_connection.h b/quic/core/crypto/tls_server_connection.h index 6da8114..954f830 100644 --- a/quic/core/crypto/tls_server_connection.h +++ b/quic/core/crypto/tls_server_connection.h
@@ -5,9 +5,9 @@ #ifndef QUICHE_QUIC_CORE_CRYPTO_TLS_SERVER_CONNECTION_H_ #define QUICHE_QUIC_CORE_CRYPTO_TLS_SERVER_CONNECTION_H_ +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/proof_source.h" #include "net/third_party/quiche/src/quic/core/crypto/tls_connection.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { @@ -43,12 +43,11 @@ // ssl_private_key_failure is returned. Otherwise, ssl_private_key_success // is returned with the signature put in |*out| and the length in // |*out_len|. - virtual ssl_private_key_result_t PrivateKeySign( - uint8_t* out, - size_t* out_len, - size_t max_out, - uint16_t sig_alg, - quiche::QuicheStringPiece in) = 0; + virtual ssl_private_key_result_t PrivateKeySign(uint8_t* out, + size_t* out_len, + size_t max_out, + uint16_t sig_alg, + absl::string_view in) = 0; // When PrivateKeySign returns ssl_private_key_retry, PrivateKeyComplete // will be called after the async sign operation has completed. @@ -76,7 +75,7 @@ virtual int SessionTicketSeal(uint8_t* out, size_t* out_len, size_t max_out_len, - quiche::QuicheStringPiece in) = 0; + absl::string_view in) = 0; // SessionTicketOpen is called when BoringSSL has an encrypted session // ticket |in| and wants the ticket decrypted. This decryption operation can @@ -102,7 +101,7 @@ uint8_t* out, size_t* out_len, size_t max_out_len, - quiche::QuicheStringPiece in) = 0; + absl::string_view in) = 0; // Provides the delegate for callbacks that are shared between client and // server.
diff --git a/quic/core/crypto/transport_parameters.cc b/quic/core/crypto/transport_parameters.cc index 71a9dfb..b143d9d 100644 --- a/quic/core/crypto/transport_parameters.cc +++ b/quic/core/crypto/transport_parameters.cc
@@ -10,6 +10,7 @@ #include <memory> #include <utility> +#include "absl/strings/string_view.h" #include "third_party/boringssl/src/include/openssl/digest.h" #include "third_party/boringssl/src/include/openssl/sha.h" #include "net/third_party/quiche/src/quic/core/quic_connection_id.h" @@ -20,7 +21,6 @@ #include "net/third_party/quiche/src/quic/core/quic_versions.h" #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h" #include "net/third_party/quiche/src/common/platform/api/quiche_str_cat.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" #include "net/third_party/quiche/src/common/platform/api/quiche_text_utils.h" namespace quic { @@ -210,7 +210,7 @@ } bool WriteTransportParameterStringPiece(QuicDataWriter* writer, - quiche::QuicheStringPiece value, + absl::string_view value, ParsedQuicVersion version) { if (version.HasVarIntTransportParams()) { return writer->WriteStringPieceVarInt62(value); @@ -240,10 +240,9 @@ return true; } -bool ReadTransportParameterLengthAndValue( - QuicDataReader* reader, - ParsedQuicVersion version, - quiche::QuicheStringPiece* out_value) { +bool ReadTransportParameterLengthAndValue(QuicDataReader* reader, + ParsedQuicVersion version, + absl::string_view* out_value) { if (version.HasVarIntTransportParams()) { return reader->ReadStringPieceVarInt62(out_value); } @@ -488,8 +487,7 @@ if (kv.second.length() <= kMaxPrintableLength) { rv += quiche::QuicheTextUtils::HexEncode(kv.second); } else { - quiche::QuicheStringPiece truncated(kv.second.data(), - kMaxPrintableLength); + absl::string_view truncated(kv.second.data(), kMaxPrintableLength); rv += quiche::QuicheStrCat(quiche::QuicheTextUtils::HexEncode(truncated), "...(length ", kv.second.length(), ")"); } @@ -813,9 +811,8 @@ version) || !WriteTransportParameterStringPiece( &writer, - quiche::QuicheStringPiece( - original_destination_connection_id.data(), - original_destination_connection_id.length()), + absl::string_view(original_destination_connection_id.data(), + original_destination_connection_id.length()), version)) { QUIC_BUG << "Failed to write original_destination_connection_id " << original_destination_connection_id << " for " << in; @@ -836,7 +833,7 @@ &writer, TransportParameters::kStatelessResetToken, version) || !WriteTransportParameterStringPiece( &writer, - quiche::QuicheStringPiece( + absl::string_view( reinterpret_cast<const char*>(in.stateless_reset_token.data()), in.stateless_reset_token.size()), version)) { @@ -919,8 +916,8 @@ version) || !WriteTransportParameterStringPiece( &writer, - quiche::QuicheStringPiece(initial_source_connection_id.data(), - initial_source_connection_id.length()), + absl::string_view(initial_source_connection_id.data(), + initial_source_connection_id.length()), version)) { QUIC_BUG << "Failed to write initial_source_connection_id " << initial_source_connection_id << " for " << in; @@ -937,8 +934,8 @@ &writer, TransportParameters::kRetrySourceConnectionId, version) || !WriteTransportParameterStringPiece( &writer, - quiche::QuicheStringPiece(retry_source_connection_id.data(), - retry_source_connection_id.length()), + absl::string_view(retry_source_connection_id.data(), + retry_source_connection_id.length()), version)) { QUIC_BUG << "Failed to write retry_source_connection_id " << retry_source_connection_id << " for " << in; @@ -1079,7 +1076,7 @@ random->RandBytes(grease_contents, grease_length); if (!WriteTransportParameterId(&writer, grease_id, version) || !WriteTransportParameterStringPiece( - &writer, quiche::QuicheStringPiece(grease_contents, grease_length), + &writer, absl::string_view(grease_contents, grease_length), version)) { QUIC_BUG << "Failed to write GREASE parameter " << TransportParameterIdToString(grease_id); @@ -1141,7 +1138,7 @@ *error_details = "Failed to parse transport parameter ID"; return false; } - quiche::QuicheStringPiece value; + absl::string_view value; if (!ReadTransportParameterLengthAndValue(&reader, version, &value)) { *error_details = "Failed to read length and value of transport parameter " + @@ -1183,7 +1180,7 @@ *error_details = "Received a second stateless_reset_token"; return false; } - quiche::QuicheStringPiece stateless_reset_token = + absl::string_view stateless_reset_token = value_reader.ReadRemainingPayload(); if (stateless_reset_token.length() != kStatelessResetTokenLength) { *error_details = quiche::QuicheStrCat(
diff --git a/quic/core/crypto/transport_parameters.h b/quic/core/crypto/transport_parameters.h index bf8c607..0ec57e2 100644 --- a/quic/core/crypto/transport_parameters.h +++ b/quic/core/crypto/transport_parameters.h
@@ -8,6 +8,7 @@ #include <memory> #include <vector> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/quic_connection_id.h" #include "net/third_party/quiche/src/quic/core/quic_data_reader.h" #include "net/third_party/quiche/src/quic/core/quic_data_writer.h" @@ -17,7 +18,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_containers.h" #include "net/third_party/quiche/src/quic/platform/api/quic_socket_address.h" #include "net/third_party/quiche/src/common/platform/api/quiche_optional.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic {
diff --git a/quic/core/crypto/transport_parameters_test.cc b/quic/core/crypto/transport_parameters_test.cc index 0578e29..63adb63 100644 --- a/quic/core/crypto/transport_parameters_test.cc +++ b/quic/core/crypto/transport_parameters_test.cc
@@ -7,6 +7,7 @@ #include <cstring> #include <utility> +#include "absl/strings/string_view.h" #include "net/third_party/quiche/src/quic/core/crypto/crypto_protocol.h" #include "net/third_party/quiche/src/quic/core/quic_connection_id.h" #include "net/third_party/quiche/src/quic/core/quic_tag.h" @@ -17,7 +18,6 @@ #include "net/third_party/quiche/src/quic/platform/api/quic_test.h" #include "net/third_party/quiche/src/quic/test_tools/quic_test_utils.h" #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" -#include "net/third_party/quiche/src/common/platform/api/quiche_string_piece.h" namespace quic { namespace test {