signed_web_bundle_utils_unittest.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/web_package/signed_web_bundles/signed_web_bundle_utils.h"
  5. #include "testing/gtest/include/gtest/gtest.h"
  6. namespace web_package {
  7. namespace {
  8. constexpr uint8_t kFakeUnsignedWebBundleHash[] = {0x01, 0x02, 0x03};
  9. constexpr uint8_t kFakeIntegrityBlock[] = {0x04, 0x05, 0x06, 0x07};
  10. constexpr uint8_t kFakeAttributes[] = {0x08, 0x09};
  11. constexpr uint8_t kExpectedPayloadForSigning[] = {
  12. // length
  13. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
  14. // unsigned web bundle hash
  15. 0x01, 0x02, 0x03,
  16. // length
  17. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
  18. // integrity block
  19. 0x04, 0x05, 0x06, 0x07,
  20. // length
  21. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
  22. // attributes
  23. 0x08, 0x09};
  24. } // namespace
  25. TEST(SignedWebBundleUtilsTest, BuildSignaturePayload) {
  26. auto payload = CreateSignaturePayload(kFakeUnsignedWebBundleHash,
  27. kFakeIntegrityBlock, kFakeAttributes);
  28. EXPECT_EQ(payload, std::vector(std::begin(kExpectedPayloadForSigning),
  29. std::end(kExpectedPayloadForSigning)));
  30. }
  31. } // namespace web_package