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

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

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/crypto/crypto_secret_boxer.h ('k') | net/quic/core/crypto/crypto_secret_boxer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/crypto/crypto_secret_boxer.cc
diff --git a/net/quic/core/crypto/crypto_secret_boxer.cc b/net/quic/core/crypto/crypto_secret_boxer.cc
index a1091524925dfa9d4d60e5a69c853d05f82e7c46..0ce5872d4e4fd2ca87492408245d7ed818fb98da 100644
--- a/net/quic/core/crypto/crypto_secret_boxer.cc
+++ b/net/quic/core/crypto/crypto_secret_boxer.cc
@@ -14,7 +14,6 @@
#include "net/quic/core/crypto/quic_encrypter.h"
#include "net/quic/core/crypto/quic_random.h"
-using base::StringPiece;
using std::string;
namespace net {
@@ -54,7 +53,8 @@ void CryptoSecretBoxer::SetKeys(const std::vector<string>& keys) {
keys_.swap(copy);
}
-string CryptoSecretBoxer::Box(QuicRandom* rand, StringPiece plaintext) const {
+string CryptoSecretBoxer::Box(QuicRandom* rand,
+ QuicStringPiece plaintext) const {
std::unique_ptr<Aes128Gcm12Encrypter> encrypter(new Aes128Gcm12Encrypter());
{
QuicReaderMutexLock l(&lock_);
@@ -76,7 +76,7 @@ string CryptoSecretBoxer::Box(QuicRandom* rand, StringPiece plaintext) const {
memcpy(data + kBoxNonceSize, plaintext.data(), plaintext.size());
if (!encrypter->Encrypt(
- StringPiece(data, kBoxNonceSize), StringPiece(), plaintext,
+ QuicStringPiece(data, kBoxNonceSize), QuicStringPiece(), plaintext,
reinterpret_cast<unsigned char*>(data + kBoxNonceSize))) {
DLOG(DFATAL) << "CryptoSecretBoxer's Encrypt failed.";
return string();
@@ -85,17 +85,18 @@ string CryptoSecretBoxer::Box(QuicRandom* rand, StringPiece plaintext) const {
return ret;
}
-bool CryptoSecretBoxer::Unbox(StringPiece ciphertext,
+bool CryptoSecretBoxer::Unbox(QuicStringPiece ciphertext,
string* out_storage,
- StringPiece* out) const {
+ QuicStringPiece* out) const {
if (ciphertext.size() < kBoxNonceSize) {
return false;
}
- StringPiece nonce(ciphertext.data(), kBoxNonceSize);
+ QuicStringPiece nonce(ciphertext.data(), kBoxNonceSize);
ciphertext.remove_prefix(kBoxNonceSize);
QuicPacketNumber packet_number;
- StringPiece nonce_prefix(nonce.data(), nonce.size() - sizeof(packet_number));
+ QuicStringPiece nonce_prefix(nonce.data(),
+ nonce.size() - sizeof(packet_number));
memcpy(&packet_number, nonce.data() + nonce_prefix.size(),
sizeof(packet_number));
@@ -109,7 +110,7 @@ bool CryptoSecretBoxer::Unbox(StringPiece ciphertext,
if (decrypter->SetKey(key)) {
decrypter->SetNoncePrefix(nonce_prefix);
if (decrypter->DecryptPacket(QUIC_VERSION_36, packet_number,
- /*associated data=*/StringPiece(),
+ /*associated data=*/QuicStringPiece(),
ciphertext, plaintext, &plaintext_length,
kMaxPacketSize)) {
ok = true;
« no previous file with comments | « net/quic/core/crypto/crypto_secret_boxer.h ('k') | net/quic/core/crypto/crypto_secret_boxer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698