chromium/services/network/trust_tokens/trust_token_key_commitment_parser.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "services/network/trust_tokens/trust_token_key_commitment_parser.h"

#include "base/base64.h"
#include "base/json/json_reader.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/values.h"
#include "services/network/public/mojom/trust_tokens.mojom.h"
#include "services/network/trust_tokens/suitable_trust_token_origin.h"
#include "services/network/trust_tokens/types.h"

namespace network {

const char kTrustTokenKeyCommitmentProtocolVersionField[] =;
const char kTrustTokenKeyCommitmentIDField[] =;
const char kTrustTokenKeyCommitmentBatchsizeField[] =;
const char kTrustTokenKeyCommitmentKeysField[] =;
const char kTrustTokenKeyCommitmentExpiryField[] =;
const char kTrustTokenKeyCommitmentKeyField[] =;

namespace {

// Parses a single key label. If |in| is the string representation of an integer
// in in the representable range of uint32_t, returns true. Otherwise, returns
// false.
bool ParseSingleKeyLabel(std::string_view in) {}

enum class ParseKeyResult {};

// Parses a single key, consisting of a body (the key material) and an expiry
// timestamp. Fails the parse if either field is missing or malformed. If the
// key has expired but is otherwise valid, ignores the key rather than failing
// the prase.
ParseKeyResult ParseSingleKeyExceptLabel(
    const base::Value::Dict& in,
    mojom::TrustTokenVerificationKey* out) {}

mojom::TrustTokenKeyCommitmentResultPtr ParseSingleIssuer(
    const base::Value& commitments_by_version) {}

// Entry is a convenience struct used as an intermediate representation when
// parsing multiple issuers. In addition to a parsed canonicalized issuer, it
// preserves the raw JSON string key (the second entry) in order
// deterministically to deduplicate entries with keys canonicalizing to the same
// issuer.
Entry;
SuitableTrustTokenOrigin& canonicalized_issuer(Entry& e) {}
mojom::TrustTokenKeyCommitmentResultPtr& commitment(Entry& e) {}

}  // namespace

mojom::TrustTokenKeyCommitmentResultPtr TrustTokenKeyCommitmentParser::Parse(
    std::string_view response_body) {}

std::unique_ptr<base::flat_map<SuitableTrustTokenOrigin,
                               mojom::TrustTokenKeyCommitmentResultPtr>>
TrustTokenKeyCommitmentParser::ParseMultipleIssuers(
    std::string_view response_body) {}

}  // namespace network