#include "components/web_package/signed_web_bundles/signed_web_bundle_signature_verifier.h"
#include <utility>
#include <vector>
#include "base/containers/extend.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/overloaded.h"
#include "base/notreached.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "components/cbor/values.h"
#include "components/cbor/writer.h"
#include "components/web_package/signed_web_bundles/constants.h"
#include "components/web_package/signed_web_bundles/ecdsa_p256_utils.h"
#include "components/web_package/signed_web_bundles/identity_validator.h"
#include "components/web_package/signed_web_bundles/integrity_block_parser.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_id.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_integrity_block.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_signature_stack.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_signature_stack_entry.h"
#include "components/web_package/signed_web_bundles/signed_web_bundle_utils.h"
#include "crypto/secure_hash.h"
#include "third_party/boringssl/src/include/openssl/sha.h"
namespace web_package {
namespace {
std::vector<uint8_t> CreateIntegrityBlockCbor(
const SignedWebBundleIntegrityBlock& integrity_block) { … }
base::expected<void, SignedWebBundleSignatureVerifier::Error>
ValidateWebBundleId(const std::string& web_bundle_id,
const SignedWebBundleSignatureStack& signatures) { … }
}
SignedWebBundleSignatureVerifier::SignedWebBundleSignatureVerifier() { … }
SignedWebBundleSignatureVerifier::~SignedWebBundleSignatureVerifier() { … }
void SignedWebBundleSignatureVerifier::SetWebBundleChunkSizeForTesting(
uint64_t web_bundle_chunk_size) { … }
void SignedWebBundleSignatureVerifier::VerifySignatures(
base::File file,
SignedWebBundleIntegrityBlock integrity_block,
SignatureVerificationCallback callback) const { … }
base::expected<SignedWebBundleSignatureVerifier::SHA512Digest, std::string>
SignedWebBundleSignatureVerifier::CalculateHashOfUnsignedWebBundle(
base::File file,
int64_t web_bundle_chunk_size,
int64_t integrity_block_size) { … }
void SignedWebBundleSignatureVerifier::OnHashOfUnsignedWebBundleCalculated(
SignedWebBundleIntegrityBlock integrity_block,
SignatureVerificationCallback callback,
base::expected<SHA512Digest, std::string> unsigned_web_bundle_hash) const { … }
base::expected<void, SignedWebBundleSignatureVerifier::Error>
SignedWebBundleSignatureVerifier::VerifyWithHashForIntegrityBlock(
SHA512Digest unsigned_web_bundle_hash,
SignedWebBundleIntegrityBlock integrity_block) const { … }
}