#include "quiche/oblivious_http/common/oblivious_http_header_key_config.h"
#include <algorithm>
#include <cstdint>
#include <functional>
#include <string>
#include <utility>
#include <vector>
#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "absl/strings/escaping.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "openssl/base.h"
#include "openssl/hpke.h"
#include "quiche/common/platform/api/quiche_bug_tracker.h"
#include "quiche/common/platform/api/quiche_logging.h"
#include "quiche/common/quiche_data_writer.h"
#include "quiche/common/quiche_endian.h"
namespace quiche {
namespace {
constexpr size_t kSizeOfHpkeKemId = …;
constexpr size_t kSizeOfSymmetricAlgorithmHpkeKdfId = …;
constexpr size_t kSizeOfSymmetricAlgorithmHpkeAeadId = …;
absl::StatusOr<const EVP_HPKE_KEM*> CheckKemId(uint16_t kem_id) { … }
absl::StatusOr<const EVP_HPKE_KDF*> CheckKdfId(uint16_t kdf_id) { … }
absl::StatusOr<const EVP_HPKE_AEAD*> CheckAeadId(uint16_t aead_id) { … }
}
ObliviousHttpHeaderKeyConfig::ObliviousHttpHeaderKeyConfig(uint8_t key_id,
uint16_t kem_id,
uint16_t kdf_id,
uint16_t aead_id)
: … { … }
absl::StatusOr<ObliviousHttpHeaderKeyConfig>
ObliviousHttpHeaderKeyConfig::Create(uint8_t key_id, uint16_t kem_id,
uint16_t kdf_id, uint16_t aead_id) { … }
absl::Status ObliviousHttpHeaderKeyConfig::ValidateKeyConfig() const { … }
const EVP_HPKE_KEM* ObliviousHttpHeaderKeyConfig::GetHpkeKem() const { … }
const EVP_HPKE_KDF* ObliviousHttpHeaderKeyConfig::GetHpkeKdf() const { … }
const EVP_HPKE_AEAD* ObliviousHttpHeaderKeyConfig::GetHpkeAead() const { … }
std::string ObliviousHttpHeaderKeyConfig::SerializeRecipientContextInfo(
absl::string_view request_label) const { … }
absl::Status ObliviousHttpHeaderKeyConfig::ParseOhttpPayloadHeader(
absl::string_view payload_bytes) const { … }
absl::Status ObliviousHttpHeaderKeyConfig::ParseOhttpPayloadHeader(
QuicheDataReader& reader) const { … }
absl::StatusOr<uint8_t>
ObliviousHttpHeaderKeyConfig::ParseKeyIdFromObliviousHttpRequestPayload(
absl::string_view payload_bytes) { … }
std::string ObliviousHttpHeaderKeyConfig::SerializeOhttpPayloadHeader() const { … }
namespace {
absl::StatusOr<uint16_t> KeyLength(uint16_t kem_id) { … }
absl::StatusOr<std::string> SerializeOhttpKeyWithPublicKey(
uint8_t key_id, absl::string_view public_key,
const std::vector<ObliviousHttpHeaderKeyConfig>& ohttp_configs) { … }
std::string GetDebugStringForFailedKeyConfig(
const ObliviousHttpKeyConfigs::OhttpKeyConfig& failed_key_config) { … }
absl::Status StoreKeyConfigIfValid(
ObliviousHttpKeyConfigs::OhttpKeyConfig key_config,
absl::btree_map<uint8_t, std::vector<ObliviousHttpHeaderKeyConfig>,
std::greater<uint8_t>>& configs,
absl::flat_hash_map<uint8_t, std::string>& keys) { … }
}
absl::StatusOr<ObliviousHttpKeyConfigs>
ObliviousHttpKeyConfigs::ParseConcatenatedKeys(absl::string_view key_config) { … }
absl::StatusOr<ObliviousHttpKeyConfigs> ObliviousHttpKeyConfigs::Create(
absl::flat_hash_set<ObliviousHttpKeyConfigs::OhttpKeyConfig>
ohttp_key_configs) { … }
absl::StatusOr<ObliviousHttpKeyConfigs> ObliviousHttpKeyConfigs::Create(
const ObliviousHttpHeaderKeyConfig& single_key_config,
absl::string_view public_key) { … }
absl::StatusOr<std::string> ObliviousHttpKeyConfigs::GenerateConcatenatedKeys()
const { … }
ObliviousHttpHeaderKeyConfig ObliviousHttpKeyConfigs::PreferredConfig() const { … }
absl::StatusOr<absl::string_view> ObliviousHttpKeyConfigs::GetPublicKeyForId(
uint8_t key_id) const { … }
absl::Status ObliviousHttpKeyConfigs::ReadSingleKeyConfig(
QuicheDataReader& reader, ConfigMap& configs, PublicKeyMap& keys) { … }
}