| // WARNING: This file is machine generated by fidlgen. |
| |
| #pragma once |
| |
| #include <lib/fidl/internal.h> |
| #include <lib/fidl/txn_header.h> |
| #include <lib/fidl/llcpp/array.h> |
| #include <lib/fidl/llcpp/coding.h> |
| #include <lib/fidl/llcpp/connect_service.h> |
| #include <lib/fidl/llcpp/service_handler_interface.h> |
| #include <lib/fidl/llcpp/string_view.h> |
| #include <lib/fidl/llcpp/sync_call.h> |
| #include <lib/fidl/llcpp/traits.h> |
| #include <lib/fidl/llcpp/transaction.h> |
| #include <lib/fidl/llcpp/vector_view.h> |
| #include <lib/fit/function.h> |
| #include <lib/zx/channel.h> |
| #include <zircon/fidl.h> |
| |
| namespace llcpp { |
| |
| namespace fuchsia { |
| namespace hardware { |
| namespace block { |
| namespace encrypted { |
| |
| class DeviceManager; |
| |
| extern "C" const fidl_type_t v1_fuchsia_hardware_block_encrypted_DeviceManagerUnsealRequestTable; |
| extern "C" const fidl_type_t v1_fuchsia_hardware_block_encrypted_DeviceManagerUnsealResponseTable; |
| extern "C" const fidl_type_t v1_fuchsia_hardware_block_encrypted_DeviceManagerSealRequestTable; |
| extern "C" const fidl_type_t v1_fuchsia_hardware_block_encrypted_DeviceManagerSealResponseTable; |
| |
| // An interface to the zxcrypt driver, as bound to a single block device with |
| // a zxcrypt superblock. zxcrypt devices are encrypted, and before their |
| // plaintext contents can be accessed, they must be unsealed with a key. |
| // This protocol allows the caller to make requests to unseal the device (by |
| // providing the appropriate key) and to seal the device (rendering its |
| // contents inaccessible). |
| class DeviceManager final { |
| DeviceManager() = delete; |
| public: |
| |
| struct UnsealResponse final { |
| FIDL_ALIGNDECL |
| fidl_message_header_t _hdr; |
| int32_t status; |
| |
| static constexpr const fidl_type_t* Type = &v1_fuchsia_hardware_block_encrypted_DeviceManagerUnsealResponseTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 24; |
| static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasFlexibleEnvelope = false; |
| static constexpr bool HasPointer = false; |
| static constexpr bool ContainsUnion = false; |
| static constexpr ::fidl::internal::TransactionalMessageKind MessageKind = |
| ::fidl::internal::TransactionalMessageKind::kResponse; |
| }; |
| struct UnsealRequest final { |
| FIDL_ALIGNDECL |
| fidl_message_header_t _hdr; |
| ::fidl::VectorView<uint8_t> key; |
| uint8_t slot; |
| |
| static constexpr const fidl_type_t* Type = &v1_fuchsia_hardware_block_encrypted_DeviceManagerUnsealRequestTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 40; |
| static constexpr uint32_t MaxOutOfLine = 256; |
| static constexpr uint32_t AltPrimarySize = 40; |
| static constexpr uint32_t AltMaxOutOfLine = 256; |
| static constexpr bool HasFlexibleEnvelope = false; |
| static constexpr bool HasPointer = true; |
| static constexpr bool ContainsUnion = false; |
| static constexpr ::fidl::internal::TransactionalMessageKind MessageKind = |
| ::fidl::internal::TransactionalMessageKind::kRequest; |
| using ResponseType = UnsealResponse; |
| }; |
| |
| struct SealResponse final { |
| FIDL_ALIGNDECL |
| fidl_message_header_t _hdr; |
| int32_t status; |
| |
| static constexpr const fidl_type_t* Type = &v1_fuchsia_hardware_block_encrypted_DeviceManagerSealResponseTable; |
| static constexpr uint32_t MaxNumHandles = 0; |
| static constexpr uint32_t PrimarySize = 24; |
| static constexpr uint32_t MaxOutOfLine = 0; |
| static constexpr bool HasFlexibleEnvelope = false; |
| static constexpr bool HasPointer = false; |
| static constexpr bool ContainsUnion = false; |
| static constexpr ::fidl::internal::TransactionalMessageKind MessageKind = |
| ::fidl::internal::TransactionalMessageKind::kResponse; |
| }; |
| using SealRequest = ::fidl::AnyZeroArgMessage; |
| |
| |
| // Collection of return types of FIDL calls in this interface. |
| class ResultOf final { |
| ResultOf() = delete; |
| private: |
| template <typename ResponseType> |
| class Unseal_Impl final : private ::fidl::internal::OwnedSyncCallBase<ResponseType> { |
| using Super = ::fidl::internal::OwnedSyncCallBase<ResponseType>; |
| public: |
| Unseal_Impl(::zx::unowned_channel _client_end, ::fidl::VectorView<uint8_t> key, uint8_t slot); |
| ~Unseal_Impl() = default; |
| Unseal_Impl(Unseal_Impl&& other) = default; |
| Unseal_Impl& operator=(Unseal_Impl&& other) = default; |
| using Super::status; |
| using Super::error; |
| using Super::ok; |
| using Super::Unwrap; |
| using Super::value; |
| using Super::operator->; |
| using Super::operator*; |
| }; |
| template <typename ResponseType> |
| class Seal_Impl final : private ::fidl::internal::OwnedSyncCallBase<ResponseType> { |
| using Super = ::fidl::internal::OwnedSyncCallBase<ResponseType>; |
| public: |
| Seal_Impl(::zx::unowned_channel _client_end); |
| ~Seal_Impl() = default; |
| Seal_Impl(Seal_Impl&& other) = default; |
| Seal_Impl& operator=(Seal_Impl&& other) = default; |
| using Super::status; |
| using Super::error; |
| using Super::ok; |
| using Super::Unwrap; |
| using Super::value; |
| using Super::operator->; |
| using Super::operator*; |
| }; |
| |
| public: |
| using Unseal = Unseal_Impl<UnsealResponse>; |
| using Seal = Seal_Impl<SealResponse>; |
| }; |
| |
| // Collection of return types of FIDL calls in this interface, |
| // when the caller-allocate flavor or in-place call is used. |
| class UnownedResultOf final { |
| UnownedResultOf() = delete; |
| private: |
| template <typename ResponseType> |
| class Unseal_Impl final : private ::fidl::internal::UnownedSyncCallBase<ResponseType> { |
| using Super = ::fidl::internal::UnownedSyncCallBase<ResponseType>; |
| public: |
| Unseal_Impl(::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::fidl::VectorView<uint8_t> key, uint8_t slot, ::fidl::BytePart _response_buffer); |
| ~Unseal_Impl() = default; |
| Unseal_Impl(Unseal_Impl&& other) = default; |
| Unseal_Impl& operator=(Unseal_Impl&& other) = default; |
| using Super::status; |
| using Super::error; |
| using Super::ok; |
| using Super::Unwrap; |
| using Super::value; |
| using Super::operator->; |
| using Super::operator*; |
| }; |
| template <typename ResponseType> |
| class Seal_Impl final : private ::fidl::internal::UnownedSyncCallBase<ResponseType> { |
| using Super = ::fidl::internal::UnownedSyncCallBase<ResponseType>; |
| public: |
| Seal_Impl(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer); |
| ~Seal_Impl() = default; |
| Seal_Impl(Seal_Impl&& other) = default; |
| Seal_Impl& operator=(Seal_Impl&& other) = default; |
| using Super::status; |
| using Super::error; |
| using Super::ok; |
| using Super::Unwrap; |
| using Super::value; |
| using Super::operator->; |
| using Super::operator*; |
| }; |
| |
| public: |
| using Unseal = Unseal_Impl<UnsealResponse>; |
| using Seal = Seal_Impl<SealResponse>; |
| }; |
| |
| class SyncClient final { |
| public: |
| explicit SyncClient(::zx::channel channel) : channel_(std::move(channel)) {} |
| ~SyncClient() = default; |
| SyncClient(SyncClient&&) = default; |
| SyncClient& operator=(SyncClient&&) = default; |
| |
| const ::zx::channel& channel() const { return channel_; } |
| |
| ::zx::channel* mutable_channel() { return &channel_; } |
| |
| // Attempts to unseal the device by using the provided master key to unwrap |
| // the data key wrapped in the specified key slot. If the key provided was |
| // the correct key for this slot, then the device node responding to this |
| // protocol will create an unsealed zxcrypt device as a child of itself in |
| // the device tree before returning success. |
| // Returns `ZX_ERR_INVALID_ARGS` if `slot` is invalid. |
| // Returns `ZX_ERR_BAD_STATE` and keeps the device open if the device is already unsealed. |
| // Returns other errors if operations on the underlying block device return errors. |
| // Returns `ZX_OK` on success. |
| // Allocates 320 bytes of message buffer on the stack. No heap allocation necessary. |
| ResultOf::Unseal Unseal(::fidl::VectorView<uint8_t> key, uint8_t slot); |
| |
| // Attempts to unseal the device by using the provided master key to unwrap |
| // the data key wrapped in the specified key slot. If the key provided was |
| // the correct key for this slot, then the device node responding to this |
| // protocol will create an unsealed zxcrypt device as a child of itself in |
| // the device tree before returning success. |
| // Returns `ZX_ERR_INVALID_ARGS` if `slot` is invalid. |
| // Returns `ZX_ERR_BAD_STATE` and keeps the device open if the device is already unsealed. |
| // Returns other errors if operations on the underlying block device return errors. |
| // Returns `ZX_OK` on success. |
| // Caller provides the backing storage for FIDL message via request and response buffers. |
| UnownedResultOf::Unseal Unseal(::fidl::BytePart _request_buffer, ::fidl::VectorView<uint8_t> key, uint8_t slot, ::fidl::BytePart _response_buffer); |
| |
| // Seals the device, causing any previously-created child zxcrypt Device to |
| // be removed some time later. (Someday we'd like this to only return once |
| // the unsealed child device is removed, but that's not straightforward today.) |
| // Returns `ZX_ERR_BAD_STATE` if the device is already sealed. |
| // Returns `ZX_OK` on success. |
| // Allocates 40 bytes of message buffer on the stack. No heap allocation necessary. |
| ResultOf::Seal Seal(); |
| |
| // Seals the device, causing any previously-created child zxcrypt Device to |
| // be removed some time later. (Someday we'd like this to only return once |
| // the unsealed child device is removed, but that's not straightforward today.) |
| // Returns `ZX_ERR_BAD_STATE` if the device is already sealed. |
| // Returns `ZX_OK` on success. |
| // Caller provides the backing storage for FIDL message via request and response buffers. |
| UnownedResultOf::Seal Seal(::fidl::BytePart _response_buffer); |
| |
| private: |
| ::zx::channel channel_; |
| }; |
| |
| // Methods to make a sync FIDL call directly on an unowned channel, avoiding setting up a client. |
| class Call final { |
| Call() = delete; |
| public: |
| |
| // Attempts to unseal the device by using the provided master key to unwrap |
| // the data key wrapped in the specified key slot. If the key provided was |
| // the correct key for this slot, then the device node responding to this |
| // protocol will create an unsealed zxcrypt device as a child of itself in |
| // the device tree before returning success. |
| // Returns `ZX_ERR_INVALID_ARGS` if `slot` is invalid. |
| // Returns `ZX_ERR_BAD_STATE` and keeps the device open if the device is already unsealed. |
| // Returns other errors if operations on the underlying block device return errors. |
| // Returns `ZX_OK` on success. |
| // Allocates 320 bytes of message buffer on the stack. No heap allocation necessary. |
| static ResultOf::Unseal Unseal(::zx::unowned_channel _client_end, ::fidl::VectorView<uint8_t> key, uint8_t slot); |
| |
| // Attempts to unseal the device by using the provided master key to unwrap |
| // the data key wrapped in the specified key slot. If the key provided was |
| // the correct key for this slot, then the device node responding to this |
| // protocol will create an unsealed zxcrypt device as a child of itself in |
| // the device tree before returning success. |
| // Returns `ZX_ERR_INVALID_ARGS` if `slot` is invalid. |
| // Returns `ZX_ERR_BAD_STATE` and keeps the device open if the device is already unsealed. |
| // Returns other errors if operations on the underlying block device return errors. |
| // Returns `ZX_OK` on success. |
| // Caller provides the backing storage for FIDL message via request and response buffers. |
| static UnownedResultOf::Unseal Unseal(::zx::unowned_channel _client_end, ::fidl::BytePart _request_buffer, ::fidl::VectorView<uint8_t> key, uint8_t slot, ::fidl::BytePart _response_buffer); |
| |
| // Seals the device, causing any previously-created child zxcrypt Device to |
| // be removed some time later. (Someday we'd like this to only return once |
| // the unsealed child device is removed, but that's not straightforward today.) |
| // Returns `ZX_ERR_BAD_STATE` if the device is already sealed. |
| // Returns `ZX_OK` on success. |
| // Allocates 40 bytes of message buffer on the stack. No heap allocation necessary. |
| static ResultOf::Seal Seal(::zx::unowned_channel _client_end); |
| |
| // Seals the device, causing any previously-created child zxcrypt Device to |
| // be removed some time later. (Someday we'd like this to only return once |
| // the unsealed child device is removed, but that's not straightforward today.) |
| // Returns `ZX_ERR_BAD_STATE` if the device is already sealed. |
| // Returns `ZX_OK` on success. |
| // Caller provides the backing storage for FIDL message via request and response buffers. |
| static UnownedResultOf::Seal Seal(::zx::unowned_channel _client_end, ::fidl::BytePart _response_buffer); |
| |
| }; |
| |
| // Messages are encoded and decoded in-place when these methods are used. |
| // Additionally, requests must be already laid-out according to the FIDL wire-format. |
| class InPlace final { |
| InPlace() = delete; |
| public: |
| |
| // Attempts to unseal the device by using the provided master key to unwrap |
| // the data key wrapped in the specified key slot. If the key provided was |
| // the correct key for this slot, then the device node responding to this |
| // protocol will create an unsealed zxcrypt device as a child of itself in |
| // the device tree before returning success. |
| // Returns `ZX_ERR_INVALID_ARGS` if `slot` is invalid. |
| // Returns `ZX_ERR_BAD_STATE` and keeps the device open if the device is already unsealed. |
| // Returns other errors if operations on the underlying block device return errors. |
| // Returns `ZX_OK` on success. |
| static ::fidl::DecodeResult<UnsealResponse> Unseal(::zx::unowned_channel _client_end, ::fidl::DecodedMessage<UnsealRequest> params, ::fidl::BytePart response_buffer); |
| |
| // Seals the device, causing any previously-created child zxcrypt Device to |
| // be removed some time later. (Someday we'd like this to only return once |
| // the unsealed child device is removed, but that's not straightforward today.) |
| // Returns `ZX_ERR_BAD_STATE` if the device is already sealed. |
| // Returns `ZX_OK` on success. |
| static ::fidl::DecodeResult<SealResponse> Seal(::zx::unowned_channel _client_end, ::fidl::BytePart response_buffer); |
| |
| }; |
| |
| // Pure-virtual interface to be implemented by a server. |
| class Interface { |
| public: |
| Interface() = default; |
| virtual ~Interface() = default; |
| using _Outer = DeviceManager; |
| using _Base = ::fidl::CompleterBase; |
| |
| class UnsealCompleterBase : public _Base { |
| public: |
| void Reply(int32_t status); |
| void Reply(::fidl::BytePart _buffer, int32_t status); |
| void Reply(::fidl::DecodedMessage<UnsealResponse> params); |
| |
| protected: |
| using ::fidl::CompleterBase::CompleterBase; |
| }; |
| |
| using UnsealCompleter = ::fidl::Completer<UnsealCompleterBase>; |
| |
| virtual void Unseal(::fidl::VectorView<uint8_t> key, uint8_t slot, UnsealCompleter::Sync _completer) = 0; |
| |
| class SealCompleterBase : public _Base { |
| public: |
| void Reply(int32_t status); |
| void Reply(::fidl::BytePart _buffer, int32_t status); |
| void Reply(::fidl::DecodedMessage<SealResponse> params); |
| |
| protected: |
| using ::fidl::CompleterBase::CompleterBase; |
| }; |
| |
| using SealCompleter = ::fidl::Completer<SealCompleterBase>; |
| |
| virtual void Seal(SealCompleter::Sync _completer) = 0; |
| |
| }; |
| |
| // Attempts to dispatch the incoming message to a handler function in the server implementation. |
| // If there is no matching handler, it returns false, leaving the message and transaction intact. |
| // In all other cases, it consumes the message and returns true. |
| // It is possible to chain multiple TryDispatch functions in this manner. |
| static bool TryDispatch(Interface* impl, fidl_msg_t* msg, ::fidl::Transaction* txn); |
| |
| // Dispatches the incoming message to one of the handlers functions in the interface. |
| // If there is no matching handler, it closes all the handles in |msg| and closes the channel with |
| // a |ZX_ERR_NOT_SUPPORTED| epitaph, before returning false. The message should then be discarded. |
| static bool Dispatch(Interface* impl, fidl_msg_t* msg, ::fidl::Transaction* txn); |
| |
| // Same as |Dispatch|, but takes a |void*| instead of |Interface*|. Only used with |fidl::Bind| |
| // to reduce template expansion. |
| // Do not call this method manually. Use |Dispatch| instead. |
| static bool TypeErasedDispatch(void* impl, fidl_msg_t* msg, ::fidl::Transaction* txn) { |
| return Dispatch(static_cast<Interface*>(impl), msg, txn); |
| } |
| |
| |
| // Helper functions to fill in the transaction header in a |DecodedMessage<TransactionalMessage>|. |
| class SetTransactionHeaderFor final { |
| SetTransactionHeaderFor() = delete; |
| public: |
| static void UnsealRequest(const ::fidl::DecodedMessage<DeviceManager::UnsealRequest>& _msg); |
| static void UnsealResponse(const ::fidl::DecodedMessage<DeviceManager::UnsealResponse>& _msg); |
| static void SealRequest(const ::fidl::DecodedMessage<DeviceManager::SealRequest>& _msg); |
| static void SealResponse(const ::fidl::DecodedMessage<DeviceManager::SealResponse>& _msg); |
| }; |
| }; |
| |
| // We require simple layout to use the simple C bindings, and simple layout |
| // requires that we have non-maximal length bounds, so give some excessively |
| // large key length here so we can use the simple layout. |
| constexpr uint32_t MAX_KEY_SIZE = 256u; |
| |
| } // namespace encrypted |
| } // namespace block |
| } // namespace hardware |
| } // namespace fuchsia |
| } // namespace llcpp |
| |
| namespace fidl { |
| |
| template <> |
| struct IsFidlType<::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealRequest> : public std::true_type {}; |
| template <> |
| struct IsFidlMessage<::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealRequest> : public std::true_type {}; |
| static_assert(sizeof(::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealRequest) |
| == ::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealRequest::PrimarySize); |
| static_assert(offsetof(::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealRequest, key) == 16); |
| static_assert(offsetof(::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealRequest, slot) == 32); |
| |
| template <> |
| struct IsFidlType<::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealResponse> : public std::true_type {}; |
| template <> |
| struct IsFidlMessage<::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealResponse> : public std::true_type {}; |
| static_assert(sizeof(::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealResponse) |
| == ::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealResponse::PrimarySize); |
| static_assert(offsetof(::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::UnsealResponse, status) == 16); |
| |
| template <> |
| struct IsFidlType<::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::SealResponse> : public std::true_type {}; |
| template <> |
| struct IsFidlMessage<::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::SealResponse> : public std::true_type {}; |
| static_assert(sizeof(::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::SealResponse) |
| == ::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::SealResponse::PrimarySize); |
| static_assert(offsetof(::llcpp::fuchsia::hardware::block::encrypted::DeviceManager::SealResponse, status) == 16); |
| |
| } // namespace fidl |