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/quic_crypto_client_handshaker.cc b/quic/core/quic_crypto_client_handshaker.cc
index e758cb6..5d8a647 100644
--- a/quic/core/quic_crypto_client_handshaker.cc
+++ b/quic/core/quic_crypto_client_handshaker.cc
@@ -334,7 +334,7 @@
       return;
     }
     next_state_ = STATE_RECV_REJ;
-    CryptoUtils::HashHandshakeMessage(out, &chlo_hash_, Perspective::IS_CLIENT);
+    chlo_hash_ = CryptoUtils::HashHandshakeMessage(out, Perspective::IS_CLIENT);
     session()->connection()->set_fully_pad_crypto_hadshake_packets(
         crypto_config_->pad_inchoate_hello());
     SendHandshakeMessage(out);
@@ -364,7 +364,7 @@
     stream_->CloseConnectionWithDetails(error, error_details);
     return;
   }
-  CryptoUtils::HashHandshakeMessage(out, &chlo_hash_, Perspective::IS_CLIENT);
+  chlo_hash_ = CryptoUtils::HashHandshakeMessage(out, Perspective::IS_CLIENT);
   channel_id_sent_ = (channel_id_key_ != nullptr);
   if (cached->proof_verify_details()) {
     proof_handler_->OnProofVerifyDetailsAvailable(