1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_WEB_PACKAGE_SIGNED_WEB_BUNDLES_SIGNED_WEB_BUNDLE_SIGNATURE_STACK_H_
#define COMPONENTS_WEB_PACKAGE_SIGNED_WEB_BUNDLES_SIGNED_WEB_BUNDLE_SIGNATURE_STACK_H_
#include <vector>
#include "base/check.h"
#include "base/containers/span.h"
#include "base/notreached.h"
#include "components/web_package/mojom/web_bundle_parser.mojom-forward.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_id.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_signature_stack_entry.h"
#include "components/web_package/signed_web_bundles/types.h"
namespace web_package {
class SignedWebBundleIntegrityBlock;
// This class represents the signature stack of the integrity block of a Signed
// Web Bundle. See the documentation of `SignedWebBundleIntegrityBlock` for more
// details of how this class is used.
class SignedWebBundleSignatureStack {
public:
static base::expected<SignedWebBundleSignatureStack, std::string> Create(
base::span<const SignedWebBundleSignatureStackEntry> entries);
static base::expected<SignedWebBundleSignatureStack, std::string> Create(
std::vector<mojom::BundleIntegrityBlockSignatureStackEntryPtr>&& entries);
SignedWebBundleSignatureStack(const SignedWebBundleSignatureStack& other);
SignedWebBundleSignatureStack& operator=(
const SignedWebBundleSignatureStack& other);
~SignedWebBundleSignatureStack();
friend bool operator==(const SignedWebBundleSignatureStack&,
const SignedWebBundleSignatureStack&) = default;
// Returns the signature stack entries. There is guaranteed to be at least one
// entry. The first entry corresponds to the entry at the bottom of the stack.
const std::vector<SignedWebBundleSignatureStackEntry>& entries() const {
CHECK(!entries_.empty());
return entries_;
}
std::vector<PublicKey> public_keys() const;
// Returns the number of entries in the signature stack. This is guaranteed to
// be at least 1.
size_t size() const { return entries().size(); }
private:
explicit SignedWebBundleSignatureStack(
std::vector<SignedWebBundleSignatureStackEntry> entries);
std::vector<SignedWebBundleSignatureStackEntry> entries_;
};
} // namespace web_package
#endif // COMPONENTS_WEB_PACKAGE_SIGNED_WEB_BUNDLES_SIGNED_WEB_BUNDLE_SIGNATURE_STACK_H_
|