Make CryptoUtils::HashHandshakeMessage return by value
Also, during the handshake, don't hash the CHLO unless the hash is going to be used.
gfe-relnote: No-op refactoring, no functional change, not flag-protected.
PiperOrigin-RevId: 238635063
Change-Id: I76f033c33f436a1e95db5aae9494dbfdf7139ed5
diff --git a/quic/core/crypto/crypto_utils.cc b/quic/core/crypto/crypto_utils.cc
index ffb5f1c..e3e438b 100644
--- a/quic/core/crypto/crypto_utils.cc
+++ b/quic/core/crypto/crypto_utils.cc
@@ -455,14 +455,16 @@
}
// static
-void CryptoUtils::HashHandshakeMessage(const CryptoHandshakeMessage& message,
- std::string* output,
- Perspective perspective) {
+std::string CryptoUtils::HashHandshakeMessage(
+ const CryptoHandshakeMessage& message,
+ Perspective perspective) {
+ string output;
const QuicData& serialized = message.GetSerialized();
uint8_t digest[SHA256_DIGEST_LENGTH];
SHA256(reinterpret_cast<const uint8_t*>(serialized.data()),
serialized.length(), digest);
- output->assign(reinterpret_cast<const char*>(digest), sizeof(digest));
+ output.assign(reinterpret_cast<const char*>(digest), sizeof(digest));
+ return output;
}
#undef RETURN_STRING_LITERAL // undef for jumbo builds