masque_tcp_server: add post-quantum support PiperOrigin-RevId: 947502062
diff --git a/quiche/quic/masque/masque_ohttp_client.cc b/quiche/quic/masque/masque_ohttp_client.cc index 1db2d45..e86e825 100644 --- a/quiche/quic/masque/masque_ohttp_client.cc +++ b/quiche/quic/masque/masque_ohttp_client.cc
@@ -647,6 +647,10 @@ } QUICHE_LOG(INFO) << ENDPOINT << "Using relay URL: " << relay_url_.ToString(); ObliviousHttpHeaderKeyConfig key_config = key_configs->PreferredConfig(); + if (key_configs->NumKeys() > 1) { + QUICHE_LOG(INFO) << ENDPOINT << "Using key ID: " + << static_cast<int>(key_config.GetKeyId()); + } absl::StatusOr<absl::string_view> public_key = key_configs->GetPublicKeyForId(key_config.GetKeyId()); if (!public_key.ok()) {
diff --git a/quiche/quic/masque/masque_tcp_server_bin.cc b/quiche/quic/masque/masque_tcp_server_bin.cc index e741222..f78054e 100644 --- a/quiche/quic/masque/masque_tcp_server_bin.cc +++ b/quiche/quic/masque/masque_tcp_server_bin.cc
@@ -75,6 +75,16 @@ "Hex-encoded bytes of the OHTTP HPKE private key."); DEFINE_QUICHE_COMMAND_LINE_FLAG( + bool, pq, false, "Enable OHTTP Post Quantum support via X-Wing."); + +DEFINE_QUICHE_COMMAND_LINE_FLAG( + std::string, pq_key, "", + "Hex-encoded bytes of the X-Wing OHTTP HPKE private key."); + +DEFINE_QUICHE_COMMAND_LINE_FLAG(bool, no_classic, false, + "Disable X25519 for OHTTP."); + +DEFINE_QUICHE_COMMAND_LINE_FLAG( std::string, gateway_path, "", "Enables and configures an OHTTP gateway. Sets the path at which the " "gateway will respond to both key requests and encapsulated requests. " @@ -157,9 +167,16 @@ static absl::StatusOr<std::unique_ptr<MasqueOhttpGateway>> Create() { auto ohttp_gateway = absl::WrapUnique(new MasqueOhttpGateway()); - QUICHE_RETURN_IF_ERROR(ohttp_gateway->AddKeyConfig( - /*key_id=*/0x01, EVP_HPKE_DHKEM_X25519_HKDF_SHA256, - quiche::GetQuicheCommandLineFlag(FLAGS_ohttp_key))); + if (!quiche::GetQuicheCommandLineFlag(FLAGS_no_classic)) { + QUICHE_RETURN_IF_ERROR(ohttp_gateway->AddKeyConfig( + /*key_id=*/0x01, EVP_HPKE_DHKEM_X25519_HKDF_SHA256, + quiche::GetQuicheCommandLineFlag(FLAGS_ohttp_key))); + } + if (quiche::GetQuicheCommandLineFlag(FLAGS_pq)) { + QUICHE_RETURN_IF_ERROR(ohttp_gateway->AddKeyConfig( + /*key_id=*/0x02, EVP_HPKE_XWING, + quiche::GetQuicheCommandLineFlag(FLAGS_pq_key))); + } return ohttp_gateway; }