Consolidate definitions of CreateClientObliviousRequestWithSeedForTesting Chromium links all of the unit tests together into a single testing target, so the multiple definitions caused linking errors. PiperOrigin-RevId: 482210098
diff --git a/quiche/oblivious_http/buffers/oblivious_http_integration_test.cc b/quiche/oblivious_http/buffers/oblivious_http_integration_test.cc index ac096b7..5d00efc 100644 --- a/quiche/oblivious_http/buffers/oblivious_http_integration_test.cc +++ b/quiche/oblivious_http/buffers/oblivious_http_integration_test.cc
@@ -51,15 +51,6 @@ } } // namespace -absl::StatusOr<ObliviousHttpRequest> -CreateClientObliviousRequestWithSeedForTesting( - absl::string_view plaintext_payload, absl::string_view hpke_public_key, - const ObliviousHttpHeaderKeyConfig &ohttp_key_config, - absl::string_view seed) { - return ObliviousHttpRequest::EncapsulateWithSeed( - plaintext_payload, hpke_public_key, ohttp_key_config, seed); -} - using ObliviousHttpParameterizedTest = test::QuicheTestWithParam<ObliviousHttpResponseTestStrings>;
diff --git a/quiche/oblivious_http/buffers/oblivious_http_request.cc b/quiche/oblivious_http/buffers/oblivious_http_request.cc index 4ccd0fa..e7903b6 100644 --- a/quiche/oblivious_http/buffers/oblivious_http_request.cc +++ b/quiche/oblivious_http/buffers/oblivious_http_request.cc
@@ -104,6 +104,15 @@ ohttp_key_config, ""); } +absl::StatusOr<ObliviousHttpRequest> +ObliviousHttpRequest::CreateClientWithSeedForTesting( + absl::string_view plaintext_payload, absl::string_view hpke_public_key, + const ObliviousHttpHeaderKeyConfig& ohttp_key_config, + absl::string_view seed) { + return ObliviousHttpRequest::EncapsulateWithSeed( + plaintext_payload, hpke_public_key, ohttp_key_config, seed); +} + absl::StatusOr<ObliviousHttpRequest> ObliviousHttpRequest::EncapsulateWithSeed( absl::string_view plaintext_payload, absl::string_view hpke_public_key, const ObliviousHttpHeaderKeyConfig& ohttp_key_config,
diff --git a/quiche/oblivious_http/buffers/oblivious_http_request.h b/quiche/oblivious_http/buffers/oblivious_http_request.h index 75f4780..1aef1f2 100644 --- a/quiche/oblivious_http/buffers/oblivious_http_request.h +++ b/quiche/oblivious_http/buffers/oblivious_http_request.h
@@ -63,6 +63,12 @@ absl::string_view plaintext_payload, absl::string_view hpke_public_key, const ObliviousHttpHeaderKeyConfig& ohttp_key_config); + // Same as above but accepts a random number seed for testing. + static absl::StatusOr<ObliviousHttpRequest> CreateClientWithSeedForTesting( + absl::string_view plaintext_payload, absl::string_view hpke_public_key, + const ObliviousHttpHeaderKeyConfig& ohttp_key_config, + absl::string_view seed); + // Movable. ObliviousHttpRequest(ObliviousHttpRequest&& other) = default; ObliviousHttpRequest& operator=(ObliviousHttpRequest&& other) = default; @@ -92,12 +98,6 @@ } private: - friend absl::StatusOr<ObliviousHttpRequest> - CreateClientObliviousRequestWithSeedForTesting( - absl::string_view plaintext_payload, absl::string_view hpke_public_key, - const ObliviousHttpHeaderKeyConfig& ohttp_key_config, - absl::string_view seed); - explicit ObliviousHttpRequest( bssl::UniquePtr<EVP_HPKE_CTX> hpke_context, std::string encapsulated_key, const ObliviousHttpHeaderKeyConfig& ohttp_key_config,
diff --git a/quiche/oblivious_http/buffers/oblivious_http_request_test.cc b/quiche/oblivious_http/buffers/oblivious_http_request_test.cc index bfe7252..e313bb8 100644 --- a/quiche/oblivious_http/buffers/oblivious_http_request_test.cc +++ b/quiche/oblivious_http/buffers/oblivious_http_request_test.cc
@@ -20,15 +20,6 @@ namespace quiche { -absl::StatusOr<ObliviousHttpRequest> -CreateClientObliviousRequestWithSeedForTesting( - absl::string_view plaintext_payload, absl::string_view hpke_public_key, - const ObliviousHttpHeaderKeyConfig &ohttp_key_config, - absl::string_view seed) { - return ObliviousHttpRequest::EncapsulateWithSeed( - plaintext_payload, hpke_public_key, ohttp_key_config, seed); -} - namespace { const uint32_t kHeaderLength = ObliviousHttpHeaderKeyConfig::kHeaderLength; std::string GetHpkePrivateKey() { @@ -161,7 +152,7 @@ auto ohttp_key_config = GetOhttpKeyConfig(4, EVP_HPKE_DHKEM_X25519_HKDF_SHA256, EVP_HPKE_HKDF_SHA256, EVP_HPKE_AES_256_GCM); - auto encapsulated = CreateClientObliviousRequestWithSeedForTesting( + auto encapsulated = ObliviousHttpRequest::CreateClientWithSeedForTesting( "test", GetHpkePublicKey(), ohttp_key_config, GetSeed()); ASSERT_TRUE(encapsulated.ok()); auto encapsulated_request = encapsulated->EncapsulateAndSerialize(); @@ -184,12 +175,12 @@ GetOhttpKeyConfig(8, EVP_HPKE_DHKEM_X25519_HKDF_SHA256, EVP_HPKE_HKDF_SHA256, EVP_HPKE_AES_256_GCM); auto req_with_same_plaintext_1 = - CreateClientObliviousRequestWithSeedForTesting( + ObliviousHttpRequest::CreateClientWithSeedForTesting( "same plaintext", GetHpkePublicKey(), ohttp_key_config, GetSeed()); ASSERT_TRUE(req_with_same_plaintext_1.ok()); auto ciphertext_1 = req_with_same_plaintext_1->EncapsulateAndSerialize(); auto req_with_same_plaintext_2 = - CreateClientObliviousRequestWithSeedForTesting( + ObliviousHttpRequest::CreateClientWithSeedForTesting( "same plaintext", GetHpkePublicKey(), ohttp_key_config, GetSeed()); ASSERT_TRUE(req_with_same_plaintext_2.ok()); auto ciphertext_2 = req_with_same_plaintext_2->EncapsulateAndSerialize(); @@ -202,12 +193,12 @@ GetOhttpKeyConfig(8, EVP_HPKE_DHKEM_X25519_HKDF_SHA256, EVP_HPKE_HKDF_SHA256, EVP_HPKE_AES_256_GCM); auto req_with_different_plaintext_1 = - CreateClientObliviousRequestWithSeedForTesting( + ObliviousHttpRequest::CreateClientWithSeedForTesting( "different 1", GetHpkePublicKey(), ohttp_key_config, GetSeed()); ASSERT_TRUE(req_with_different_plaintext_1.ok()); auto ciphertext_1 = req_with_different_plaintext_1->EncapsulateAndSerialize(); auto req_with_different_plaintext_2 = - CreateClientObliviousRequestWithSeedForTesting( + ObliviousHttpRequest::CreateClientWithSeedForTesting( "different 2", GetHpkePublicKey(), ohttp_key_config, GetSeed()); ASSERT_TRUE(req_with_different_plaintext_2.ok()); auto ciphertext_2 = req_with_different_plaintext_2->EncapsulateAndSerialize();
diff --git a/quiche/oblivious_http/buffers/oblivious_http_response_test.cc b/quiche/oblivious_http/buffers/oblivious_http_response_test.cc index 1e8eb34..f19020d 100644 --- a/quiche/oblivious_http/buffers/oblivious_http_response_test.cc +++ b/quiche/oblivious_http/buffers/oblivious_http_response_test.cc
@@ -18,15 +18,6 @@ namespace quiche { -absl::StatusOr<ObliviousHttpRequest> -CreateClientObliviousRequestWithSeedForTesting( - absl::string_view plaintext_payload, absl::string_view hpke_public_key, - const ObliviousHttpHeaderKeyConfig &ohttp_key_config, - absl::string_view seed) { - return ObliviousHttpRequest::EncapsulateWithSeed( - plaintext_payload, hpke_public_key, ohttp_key_config, seed); -} - namespace { std::string GetHpkePrivateKey() { absl::string_view hpke_key_hex = @@ -102,7 +93,7 @@ absl::string_view plaintext) { auto ohttp_key_config = GetOhttpKeyConfig(key_id, kem_id, kdf_id, aead_id); auto client_request_encapsulate = - CreateClientObliviousRequestWithSeedForTesting( + ObliviousHttpRequest::CreateClientWithSeedForTesting( plaintext, GetHpkePublicKey(), ohttp_key_config, GetSeed()); EXPECT_TRUE(client_request_encapsulate.ok()); auto oblivious_request =