Revert SipHash change.

This reverts https://quiche.googlesource.com/quiche/+/98400eb625603dd58fd32eaa04e9ad39c28f4d26.

PiperOrigin-RevId: 258561852
Change-Id: Iedc6d1da150c3c970838d434249a9bf53d85ecaf
diff --git a/quic/core/quic_connection_id.cc b/quic/core/quic_connection_id.cc
index 7b4f41b..a74e3b1 100644
--- a/quic/core/quic_connection_id.cc
+++ b/quic/core/quic_connection_id.cc
@@ -4,14 +4,11 @@
 
 #include "net/third_party/quiche/src/quic/core/quic_connection_id.h"
 
-#include <cstddef>
 #include <cstdint>
 #include <cstring>
 #include <iomanip>
 #include <string>
 
-#include "third_party/boringssl/src/include/openssl/siphash.h"
-#include "net/third_party/quiche/src/quic/core/crypto/quic_random.h"
 #include "net/third_party/quiche/src/quic/core/quic_types.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_bug_tracker.h"
 #include "net/third_party/quiche/src/quic/platform/api/quic_endian.h"
@@ -22,34 +19,6 @@
 
 namespace quic {
 
-namespace {
-
-// QuicConnectionIdHasher can be used to generate a stable connection ID hash
-// function that will return the same value for two equal connection IDs for
-// the duration of process lifetime. It is meant to be used as input to data
-// structures that do not outlast process lifetime. A new key is generated once
-// per process to prevent attackers from crafting connection IDs in such a way
-// that they always land in the same hash bucket.
-class QuicConnectionIdHasher {
- public:
-  inline QuicConnectionIdHasher()
-      : QuicConnectionIdHasher(QuicRandom::GetInstance()) {}
-
-  inline QuicConnectionIdHasher(QuicRandom* random) {
-    random->RandBytes(&sip_hash_key_, sizeof(sip_hash_key_));
-  }
-
-  inline size_t Hash(const char* input, size_t input_len) const {
-    return static_cast<size_t>(SIPHASH_24(
-        sip_hash_key_, reinterpret_cast<const uint8_t*>(input), input_len));
-  }
-
- private:
-  uint64_t sip_hash_key_[2];
-};
-
-}  // namespace
-
 QuicConnectionId::QuicConnectionId() : QuicConnectionId(nullptr, 0) {}
 
 QuicConnectionId::QuicConnectionId(const char* data, uint8_t length) {
@@ -158,20 +127,14 @@
 }
 
 size_t QuicConnectionId::Hash() const {
-  if (!GetQuicRestartFlag(quic_connection_id_use_siphash)) {
-    uint64_t data_bytes[3] = {0, 0, 0};
-    static_assert(sizeof(data_bytes) >= kQuicMaxConnectionIdLength,
-                  "kQuicMaxConnectionIdLength changed");
-    memcpy(data_bytes, data(), length_);
-    // This Hash function is designed to return the same value as the host byte
-    // order representation when the connection ID length is 64 bits.
-    return QuicEndian::NetToHost64(kQuicDefaultConnectionIdLength ^ length_ ^
-                                   data_bytes[0] ^ data_bytes[1] ^
-                                   data_bytes[2]);
-  }
-  QUIC_RESTART_FLAG_COUNT(quic_connection_id_use_siphash);
-  static const QuicConnectionIdHasher hasher = QuicConnectionIdHasher();
-  return hasher.Hash(data(), length_);
+  uint64_t data_bytes[3] = {0, 0, 0};
+  static_assert(sizeof(data_bytes) >= kQuicMaxConnectionIdLength,
+                "kQuicMaxConnectionIdLength changed");
+  memcpy(data_bytes, data(), length_);
+  // This Hash function is designed to return the same value as the host byte
+  // order representation when the connection ID length is 64 bits.
+  return QuicEndian::NetToHost64(kQuicDefaultConnectionIdLength ^ length_ ^
+                                 data_bytes[0] ^ data_bytes[1] ^ data_bytes[2]);
 }
 
 std::string QuicConnectionId::ToString() const {
diff --git a/quic/core/quic_connection_id.h b/quic/core/quic_connection_id.h
index 6b1b0bc..4b76f31 100644
--- a/quic/core/quic_connection_id.h
+++ b/quic/core/quic_connection_id.h
@@ -72,11 +72,6 @@
   bool IsEmpty() const;
 
   // Hash() is required to use connection IDs as keys in hash tables.
-  // During the lifetime of a process, the output of Hash() is guaranteed to be
-  // the same for connection IDs that are equal to one another. Note however
-  // that this property is not guaranteed across process lifetimes. This makes
-  // Hash() suitable for data structures such as hash tables but not for sending
-  // a hash over the network.
   size_t Hash() const;
 
   // Generates an ASCII string that represents
@@ -117,11 +112,6 @@
 QUIC_EXPORT_PRIVATE QuicConnectionId EmptyQuicConnectionId();
 
 // QuicConnectionIdHash can be passed as hash argument to hash tables.
-// During the lifetime of a process, the output of QuicConnectionIdHash is
-// guaranteed to be the same for connection IDs that are equal to one another.
-// Note however that this property is not guaranteed across process lifetimes.
-// This makes QuicConnectionIdHash suitable for data structures such as hash
-// tables but not for sending a hash over the network.
 class QuicConnectionIdHash {
  public:
   size_t operator()(QuicConnectionId const& connection_id) const noexcept {
diff --git a/quic/core/quic_connection_id_test.cc b/quic/core/quic_connection_id_test.cc
index 64afaf8..1d290fc 100644
--- a/quic/core/quic_connection_id_test.cc
+++ b/quic/core/quic_connection_id_test.cc
@@ -89,17 +89,6 @@
   EXPECT_NE(connection_id64_1.Hash(), connection_id64_2.Hash());
   EXPECT_NE(connection_id64_1.Hash(), connection_id64_3.Hash());
   EXPECT_NE(connection_id64_2.Hash(), connection_id64_3.Hash());
-
-  // Verify that any two all-zero connection IDs of different lengths never
-  // have the same hash.
-  const char connection_id_bytes[kQuicMaxConnectionIdLength] = {};
-  for (uint8_t i = 0; i < kQuicMaxConnectionIdLength - 1; ++i) {
-    QuicConnectionId connection_id_i(connection_id_bytes, i);
-    for (uint8_t j = i + 1; j < kQuicMaxConnectionIdLength; ++j) {
-      QuicConnectionId connection_id_j(connection_id_bytes, j);
-      EXPECT_NE(connection_id_i.Hash(), connection_id_j.Hash());
-    }
-  }
 }
 
 TEST_F(QuicConnectionIdTest, AssignAndCopy) {