This fails to build, so for now revert until fixed properly.

From ab7f198d2edb9494e45800e401d43be1ed7ff168 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <vital.had@gmail.com>
Date: Fri, 12 Jan 2024 09:34:52 +0800
Subject: [PATCH] Revert "Read b64 encoded ECH Config List in fizz client
 command tool"

This reverts commit 6efc106e48e4f7d9c63f7b52b14e596fe8b7c741.
---
 fizz/tool/FizzCommandCommon.cpp          | 24 +++-------------------
 fizz/tool/FizzCommandCommon.h            | 11 ----------
 fizz/tool/test/FizzCommandCommonTest.cpp | 26 ------------------------
 3 files changed, 3 insertions(+), 58 deletions(-)

diff --git fizz/tool/FizzCommandCommon.cpp fizz/tool/FizzCommandCommon.cpp
index b4d188cc..39d6e6a1 100644
--- fizz/tool/FizzCommandCommon.cpp
+++ fizz/tool/FizzCommandCommon.cpp
@@ -14,7 +14,6 @@
 #include <fizz/tool/FizzCommandCommon.h>
 #include <folly/FileUtil.h>
 #include <folly/String.h>
-#include <folly/base64.h>
 
 #include <fstream>
 
@@ -144,20 +143,15 @@ hpke::KEMId getKEMId(std::string kemStr) {
   throw std::runtime_error("Input doesn't match any KEM id");
 }
 
-std::string tryReadFile(const std::string& echFile) {
+folly::Optional<folly::dynamic> readECHConfigsJson(std::string echFile) {
   if (echFile.empty()) {
     throw std::runtime_error("No file provided");
   }
 
-  std::string echConfigStr;
-  if (!folly::readFile(echFile.c_str(), echConfigStr)) {
+  std::string echConfigJson;
+  if (!folly::readFile(echFile.c_str(), echConfigJson)) {
     throw std::runtime_error("Unable to read file provided");
   }
-  return echConfigStr;
-}
-
-folly::Optional<folly::dynamic> readECHConfigsJson(std::string echFile) {
-  auto echConfigJson = tryReadFile(echFile);
 
   auto json = folly::parseJson(echConfigJson);
   if (!json.isObject()) {
@@ -170,18 +164,6 @@ folly::Optional<folly::dynamic> readECHConfigsJson(std::string echFile) {
   return json;
 }
 
-folly::Optional<ech::ECHConfigList> parseECHConfigsBase64(
-    std::string echConfigListBase64) {
-  std::vector<ech::ECHConfig> echConfigs;
-  echConfigListBase64.erase(
-      std::remove(echConfigListBase64.begin(), echConfigListBase64.end(), '\n'),
-      echConfigListBase64.cend());
-  auto configBuf =
-      folly::IOBuf::copyBuffer(folly::base64Decode(echConfigListBase64));
-  folly::io::Cursor cursor(configBuf.get());
-  return decode<ech::ECHConfigList>(cursor);
-}
-
 folly::Optional<ech::ECHConfigList> parseECHConfigs(folly::dynamic json) {
   auto getKDFId = [](std::string kdfStr) {
     if (kdfStr == "Sha256") {
diff --git fizz/tool/FizzCommandCommon.h fizz/tool/FizzCommandCommon.h
index dbc1af7f..7f024999 100644
--- fizz/tool/FizzCommandCommon.h
+++ fizz/tool/FizzCommandCommon.h
@@ -35,17 +35,6 @@
 namespace fizz {
 namespace tool {
 
-std::string tryReadFile(const std::string& echFile);
-
-/** Parses base64 encoded ECH config list.
- * @param echConfigListBase64 ECH config list encoded in base64. It must use
- * the format specified in the ECH RFC
- *(https://www.ietf.org/archive/id/draft-ietf-tls-esni-16.html#name-encrypted-clienthello-confi)
- * @return Parsed ECH config list.
- **/
-folly::Optional<ech::ECHConfigList> parseECHConfigsBase64(
-    std::string echConfigListBase64);
-
 folly::Optional<ech::ECHConfigList> parseECHConfigs(folly::dynamic json);
 
 folly::Optional<folly::dynamic> readECHConfigsJson(std::string echFile);
diff --git fizz/tool/test/FizzCommandCommonTest.cpp fizz/tool/test/FizzCommandCommonTest.cpp
index 59689964..bab9e227 100644
--- fizz/tool/test/FizzCommandCommonTest.cpp
+++ fizz/tool/test/FizzCommandCommonTest.cpp
@@ -17,32 +17,6 @@ namespace fizz {
 namespace tool {
 namespace test {
 
-TEST(FizzCommandCommonTest, TestParseECHConfigsBase64) {
-  auto echConfig64 =
-      "AEj+DQBEAQAgACAX5SnnUbopIr5I/MqIqLWuSAZckHI2sR+aIr0slN2uGAAEAAEAAWQVZWNoLXB1YmxpYy5hdG1ldGEuY29tAAA=";
-  auto expectedPubKey =
-      "17e529e751ba2922be48fcca88a8b5ae48065c907236b11f9a22bd2c94ddae18";
-  auto echConfigs = parseECHConfigsBase64(echConfig64);
-  ASSERT_EQ(echConfigs->configs.size(), 1);
-  auto firstConfig = echConfigs->configs[0];
-  ASSERT_EQ(firstConfig.version, ech::ECHVersion::Draft15);
-  folly::io::Cursor cursor(firstConfig.ech_config_content.get());
-  auto echConfigContent = decode<ech::ECHConfigContentDraft>(cursor);
-  ASSERT_TRUE(folly::IOBufEqualTo()(
-      echConfigContent.public_name,
-      folly::IOBuf::copyBuffer("ech-public.atmeta.com")));
-  ASSERT_EQ(echConfigContent.key_config.kem_id, hpke::KEMId::x25519);
-  ASSERT_EQ(
-      echConfigContent.key_config.cipher_suites[0].kdf_id, hpke::KDFId::Sha256);
-  ASSERT_EQ(
-      echConfigContent.key_config.cipher_suites[0].aead_id,
-      hpke::AeadId::TLS_AES_128_GCM_SHA256);
-  ASSERT_EQ(echConfigContent.maximum_name_length, 100);
-  ASSERT_TRUE(folly::IOBufEqualTo()(
-      echConfigContent.key_config.public_key,
-      folly::IOBuf::copyBuffer(folly::unhexlify(expectedPubKey))));
-}
-
 TEST(FizzCommandCommonTest, TestValidHostPortFromString) {
   struct ExpectedValues {
     std::string input;
