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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
// 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_MOJOM_WEB_BUNDLE_PARSER_MOJOM_TRAITS_H_
#define COMPONENTS_WEB_PACKAGE_MOJOM_WEB_BUNDLE_PARSER_MOJOM_TRAITS_H_
#include "base/containers/span.h"
#include "components/web_package/mojom/web_bundle_parser.mojom-shared.h"
#include "components/web_package/signed_web_bundles/ecdsa_p256_public_key.h"
#include "components/web_package/signed_web_bundles/ecdsa_p256_sha256_signature.h"
#include "components/web_package/signed_web_bundles/ed25519_public_key.h"
#include "components/web_package/signed_web_bundles/ed25519_signature.h"
#include "components/web_package/signed_web_bundles/integrity_block_attributes.h"
namespace mojo {
template <>
class StructTraits<web_package::mojom::Ed25519PublicKeyDataView,
web_package::Ed25519PublicKey> {
public:
static base::span<const uint8_t, web_package::Ed25519PublicKey::kLength>
bytes(const web_package::Ed25519PublicKey& public_key) {
return public_key.bytes();
}
static bool Read(web_package::mojom::Ed25519PublicKeyDataView data,
web_package::Ed25519PublicKey* public_key);
};
template <>
class StructTraits<web_package::mojom::Ed25519SignatureDataView,
web_package::Ed25519Signature> {
public:
static base::span<const uint8_t, web_package::Ed25519Signature::kLength>
bytes(const web_package::Ed25519Signature& signature) {
return signature.bytes();
}
static bool Read(web_package::mojom::Ed25519SignatureDataView data,
web_package::Ed25519Signature* signature);
};
template <>
class StructTraits<web_package::mojom::EcdsaP256PublicKeyDataView,
web_package::EcdsaP256PublicKey> {
public:
static base::span<const uint8_t, web_package::EcdsaP256PublicKey::kLength>
bytes(const web_package::EcdsaP256PublicKey& public_key) {
return public_key.bytes();
}
static bool Read(web_package::mojom::EcdsaP256PublicKeyDataView data,
web_package::EcdsaP256PublicKey* public_key);
};
template <>
class StructTraits<web_package::mojom::EcdsaP256SHA256SignatureDataView,
web_package::EcdsaP256SHA256Signature> {
public:
static base::span<const uint8_t> bytes(
const web_package::EcdsaP256SHA256Signature& signature) {
return signature.bytes();
}
static bool Read(web_package::mojom::EcdsaP256SHA256SignatureDataView data,
web_package::EcdsaP256SHA256Signature* signature);
};
template <>
class StructTraits<web_package::mojom::BundleIntegrityBlockAttributesDataView,
web_package::IntegrityBlockAttributes> {
public:
static base::span<const uint8_t> cbor(
const web_package::IntegrityBlockAttributes& attributes) {
return attributes.cbor();
}
static const std::string& web_bundle_id(
const web_package::IntegrityBlockAttributes& attributes) {
return attributes.web_bundle_id();
}
static bool Read(
web_package::mojom::BundleIntegrityBlockAttributesDataView data,
web_package::IntegrityBlockAttributes* attributes);
};
} // namespace mojo
#endif // COMPONENTS_WEB_PACKAGE_MOJOM_WEB_BUNDLE_PARSER_MOJOM_TRAITS_H_
|