[cast-auth] Uplift to latest tidl

Bug: 237027615
Change-Id: I92cd74d2e4a7f3883534d53562392df3f0505e8b
diff --git a/aidl/Bn/rules.mk b/aidl/Bn/rules.mk
new file mode 100644
index 0000000..c2a8f5a
--- /dev/null
+++ b/aidl/Bn/rules.mk
@@ -0,0 +1,50 @@
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+MODULE := $(LOCAL_DIR)
+
+
+
+IFACE_USE_PREBUILTS := 1
+
+ifeq ($(IFACE_USE_PREBUILTS),1)
+
+
+# for the Bn (Binder Native), i.e. the service, we shall not link in
+# the client c wrapper (however the service can reuse the c wrapper header).
+
+MODULE_SRCS := \
+	$(LOCAL_DIR)/../generated/ICastAuth.cpp \
+
+MODULE_LIBRARY_EXPORTED_DEPS += \
+	trusty/user/base/experimental/lib/tidl \
+
+MODULE_EXPORT_INCLUDES += \
+	$(LOCAL_DIR)/../generated/include
+
+include make/library.mk
+
+else
+
+AIDL_CWRAPPER_DOMAIN := trusty_user
+
+MODULE_AIDLS := \
+	$(LOCAL_DIR)/../ICastAuth.aidl \
+
+AIDL_CWRAPPER_BN := $(findstring Bn, $(shell basename $(LOCAL_DIR)))
+
+include make/aidl.mk
+endif
diff --git a/aidl/Bp/rules.mk b/aidl/Bp/rules.mk
new file mode 100644
index 0000000..191f4f7
--- /dev/null
+++ b/aidl/Bp/rules.mk
@@ -0,0 +1,48 @@
+# Copyright (C) 2022 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+MODULE := $(LOCAL_DIR)
+
+
+
+IFACE_USE_PREBUILTS := 1
+
+ifeq ($(IFACE_USE_PREBUILTS),1)
+
+
+MODULE_SRCS := \
+	$(LOCAL_DIR)/../generated/ICastAuth.cpp \
+	$(LOCAL_DIR)/../generated/ICastAuth_CBp.cpp \
+
+MODULE_LIBRARY_EXPORTED_DEPS += \
+	trusty/user/base/experimental/lib/tidl \
+
+MODULE_EXPORT_INCLUDES += \
+	$(LOCAL_DIR)/../generated/include
+
+include make/library.mk
+
+else
+
+AIDL_CWRAPPER_DOMAIN := trusty_user
+
+MODULE_AIDLS := \
+	$(LOCAL_DIR)/../ICastAuth.aidl \
+
+AIDL_CWRAPPER_BN := $(findstring Bn, $(shell basename $(LOCAL_DIR)))
+
+include make/aidl.mk
+endif
diff --git a/aidl/ICastAuth.aidl b/aidl/ICastAuth.aidl
index e6673d5..4a36210 100644
--- a/aidl/ICastAuth.aidl
+++ b/aidl/ICastAuth.aidl
@@ -1,9 +1,7 @@
 interface ICastAuth {
     const String PORT = "com.android.trusty.cast_auth";
 
-    @TrustyPayload(response=false)
-    void ProvisionKey();
+    @TrustyPayload(response=false) void ProvisionKey();
 
-    @TrustyPayload()
-    void SignHash();
+    @TrustyPayload() void SignHash();
 }
diff --git a/aidl/generated/BnCastAuth.cpp b/aidl/generated/BnCastAuth.cpp
deleted file mode 100644
index a750905..0000000
--- a/aidl/generated/BnCastAuth.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-#include "BnCastAuth.h"
-#include <cassert>
-
-namespace aidl {
-struct __PACKED Request {
-  ::trusty::aidl::RequestHeader hdr;
-  union __PACKED {
-    BnCastAuth::Request_ProvisionKey ProvisionKey;
-    BnCastAuth::Request_SignHash SignHash;
-  } req;
-};
-struct __PACKED Response {
-  ::trusty::aidl::ResponseHeader hdr;
-  union __PACKED {
-  } resp;
-};
-union __PACKED LongestMessage {
-  Request req;
-  Response resp;
-};
-BnCastAuth::BnCastAuth(const char *port,
-                       const ::trusty::aidl::ipc::Service::PortAcl *acl,
-                       uint32_t maximum_payload_size)
-    : Service("BnCastAuth", port, sizeof(LongestMessage) + maximum_payload_size,
-              acl, &kOps) {}
-int BnCastAuth::get_instance(ICastAuth *&instance, const struct uuid *) {
-  instance = this;
-  return ::android::OK;
-}
-::trusty::aidl::ipc::Service::Ops BnCastAuth::kOps = {
-    .on_connect = BnCastAuth::on_connect,
-    .on_message = BnCastAuth::on_message,
-    .on_channel_cleanup = BnCastAuth::on_channel_cleanup,
-};
-int BnCastAuth::on_connect(const ::trusty::aidl::ipc::Service::Port *port,
-                           ::trusty::aidl::Handle chan, const struct uuid *peer,
-                           void **ctx_p) {
-  auto *bn_impl = static_cast<BnCastAuth *>(
-      reinterpret_cast<Service *>(const_cast<void *>(port->priv)));
-  assert(bn_impl);
-  ICastAuth *instance;
-  int rc = bn_impl->get_instance(instance, peer);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  *ctx_p = instance;
-  return ::android::OK;
-}
-void BnCastAuth::on_channel_cleanup(void *ctx) {
-  auto *impl = reinterpret_cast<ICastAuth *>(ctx);
-  assert(impl);
-  impl->destroy();
-}
-int BnCastAuth::on_message(const ::trusty::aidl::ipc::Service::Port *port,
-                           ::trusty::aidl::Handle chan, void *ctx) {
-  auto *impl = reinterpret_cast<ICastAuth *>(ctx);
-  auto *bn_impl = static_cast<BnCastAuth *>(
-      reinterpret_cast<Service *>(const_cast<void *>(port->priv)));
-  assert(impl);
-  assert(bn_impl);
-  ::trusty::aidl::Payload req_payload;
-  ::trusty::aidl::Payload resp_payload;
-  ipc_msg_info_t mi;
-  int rc = get_msg(chan, &mi);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  bool call_put_msg = true;
-  ::trusty::aidl::RequestHeader req_hdr;
-  struct iovec req_hdr_iov = {.iov_base = &req_hdr, .iov_len = sizeof(req_hdr)};
-  ipc_msg_t req_hdr_msg = {
-      .num_iov = 1, .iov = &req_hdr_iov, .num_handles = 0, .handles = nullptr};
-  rc = read_msg(chan, mi.id, 0, &req_hdr_msg);
-  if (rc < 0) {
-    goto done;
-  }
-  if (static_cast<size_t>(rc) < sizeof(req_hdr)) {
-    rc = ::android::NOT_ENOUGH_DATA;
-    goto done;
-  }
-  switch (req_hdr.cmd) {
-  case CMD_ProvisionKey: {
-    Request_ProvisionKey req;
-    constexpr uint32_t min_msg_len = sizeof(req_hdr) + sizeof(req);
-    if (mi.len < min_msg_len) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    rc = bn_impl->get_payload_buffer(req_payload, mi.len - min_msg_len, false);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    constexpr uint32_t req_num_handles = Request_ProvisionKey::num_handles;
-    ::trusty::aidl::Handle req_handles[req_num_handles];
-    struct iovec req_iov[] = {
-        {.iov_base = &req, .iov_len = sizeof(req)},
-        {.iov_base = req_payload.data(), .iov_len = req_payload.size()},
-    };
-    ipc_msg_t req_msg = {.num_iov = countof(req_iov),
-                         .iov = req_iov,
-                         .num_handles = req_num_handles,
-                         .handles = req_handles};
-    rc = read_msg(chan, mi.id, sizeof(req_hdr), &req_msg);
-    if (rc < 0) {
-      goto done;
-    }
-    if (static_cast<size_t>(rc) <
-        sizeof(req) + static_cast<size_t>(req_payload.size())) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    put_msg(chan, mi.id);
-    call_put_msg = false;
-    ::trusty::aidl::Handle *hptr = req_handles;
-    req.recv_handles(hptr);
-    assert(hptr == &req_handles[req_num_handles]);
-    rc = impl->ProvisionKey(req_payload);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    ::trusty::aidl::ResponseHeader resp_hdr = {
-        .cmd = req_hdr.cmd | RESP_BIT,
-        .rc = rc,
-    };
-    rc = ::trusty::aidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr), nullptr,
-                                   0);
-    if (rc < 0) {
-      goto done;
-    }
-    if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-      rc = ::android::IO_ERROR;
-      goto done;
-    }
-    break;
-  }
-  case CMD_SignHash: {
-    Request_SignHash req;
-    constexpr uint32_t min_msg_len = sizeof(req_hdr) + sizeof(req);
-    if (mi.len < min_msg_len) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    rc = bn_impl->get_payload_buffer(req_payload, mi.len - min_msg_len, false);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    rc = bn_impl->get_payload_buffer(resp_payload, req_hdr.resp_payload_size,
-                                     true);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    constexpr uint32_t req_num_handles = Request_SignHash::num_handles;
-    ::trusty::aidl::Handle req_handles[req_num_handles];
-    struct iovec req_iov[] = {
-        {.iov_base = &req, .iov_len = sizeof(req)},
-        {.iov_base = req_payload.data(), .iov_len = req_payload.size()},
-    };
-    ipc_msg_t req_msg = {.num_iov = countof(req_iov),
-                         .iov = req_iov,
-                         .num_handles = req_num_handles,
-                         .handles = req_handles};
-    rc = read_msg(chan, mi.id, sizeof(req_hdr), &req_msg);
-    if (rc < 0) {
-      goto done;
-    }
-    if (static_cast<size_t>(rc) <
-        sizeof(req) + static_cast<size_t>(req_payload.size())) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    put_msg(chan, mi.id);
-    call_put_msg = false;
-    ::trusty::aidl::Handle *hptr = req_handles;
-    req.recv_handles(hptr);
-    assert(hptr == &req_handles[req_num_handles]);
-    rc = impl->SignHash(req_payload, &resp_payload);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    ::trusty::aidl::ResponseHeader resp_hdr = {
-        .cmd = req_hdr.cmd | RESP_BIT,
-        .resp_payload_size = resp_payload.size(),
-        .rc = rc,
-    };
-    rc = ::trusty::aidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr),
-                                   resp_payload.data(), resp_payload.size(),
-                                   nullptr, 0);
-    if (rc < 0) {
-      goto done;
-    }
-    if (static_cast<size_t>(rc) != sizeof(resp_hdr) + resp_payload.size()) {
-      rc = ::android::IO_ERROR;
-      goto done;
-    }
-    break;
-  }
-  default:
-    put_msg(chan, mi.id);
-    call_put_msg = false;
-    rc = ::android::UNKNOWN_TRANSACTION;
-    goto send_rc;
-    break;
-  }
-  rc = ::android::OK;
-done:
-  if (call_put_msg) {
-    put_msg(chan, mi.id);
-  }
-  bn_impl->free_payload_buffer(std::move(req_payload));
-  bn_impl->free_payload_buffer(std::move(resp_payload));
-  return rc;
-send_rc:
-  ::trusty::aidl::ResponseHeader resp_hdr = {.cmd = req_hdr.cmd | RESP_BIT,
-                                             .rc = rc};
-  rc = ::trusty::aidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr), nullptr, 0);
-  if (rc < 0) {
-    goto done;
-  }
-  if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-    rc = ::android::IO_ERROR;
-    goto done;
-  }
-  goto done;
-}
-} // namespace aidl
diff --git a/aidl/generated/BnCastAuth.h b/aidl/generated/BnCastAuth.h
deleted file mode 100644
index daab429..0000000
--- a/aidl/generated/BnCastAuth.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma once
-#include "ICastAuth.h"
-#include <algorithm>
-#include <uapi/trusty_uuid.h>
-namespace aidl {
-class BnCastAuth : public ::trusty::aidl::ipc::Service, public ICastAuth {
-public:
-  BnCastAuth() = delete;
-
-protected:
-  BnCastAuth(const char *, const ::trusty::aidl::ipc::Service::PortAcl *acl,
-             uint32_t maximum_payload_size);
-  virtual int get_instance(ICastAuth *&, const struct uuid *);
-
-private:
-  static int on_connect(const ::trusty::aidl::ipc::Service::Port *port,
-                        ::trusty::aidl::Handle chan, const struct uuid *peer,
-                        void **ctx_p);
-  static void on_channel_cleanup(void *ctx);
-  static int on_message(const ::trusty::aidl::ipc::Service::Port *port,
-                        ::trusty::aidl::Handle chan, void *ctx);
-  static ::trusty::aidl::ipc::Service::Ops kOps;
-};
-} // namespace aidl
diff --git a/aidl/generated/BpCastAuth.cpp b/aidl/generated/BpCastAuth.cpp
deleted file mode 100644
index 4f90e0e..0000000
--- a/aidl/generated/BpCastAuth.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "BpCastAuth.h"
-#include <cassert>
-namespace aidl {
-int BpCastAuth::ProvisionKey(const ::trusty::aidl::Payload &req_payload) {
-  ::trusty::aidl::RequestHeader req_hdr = {
-      .cmd = CMD_ProvisionKey,
-  };
-  Request_ProvisionKey req = {};
-  constexpr uint32_t req_num_handles =
-      ::trusty::aidl::HandleOps<Request_ProvisionKey>::num_handles;
-  ::trusty::aidl::Handle req_handles[req_num_handles];
-  ::trusty::aidl::Handle *hptr = req_handles;
-  req.send_handles(hptr);
-  assert(hptr == &req_handles[req_num_handles]);
-  int rc = ::trusty::aidl::ipc::send(
-      mChan.get(), &req_hdr, sizeof(req_hdr), &req, sizeof(req),
-      req_payload.data(), req_payload.size(), req_handles, req_num_handles);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) !=
-      sizeof(req_hdr) + sizeof(req) + static_cast<size_t>(req_payload.size())) {
-    return ::android::IO_ERROR;
-  }
-  uevent_t event = UEVENT_INITIAL_VALUE(event);
-  rc = wait(mChan.get(), &event, INFINITE_TIME);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  if (!(event.event & IPC_HANDLE_POLL_MSG)) {
-    return ::android::IO_ERROR;
-  }
-  ::trusty::aidl::ResponseHeader resp_hdr;
-  rc = ::trusty::aidl::ipc::recv(mChan.get(), sizeof(resp_hdr), &resp_hdr,
-                                 sizeof(resp_hdr), nullptr, 0);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) < sizeof(resp_hdr)) {
-    return ::android::NOT_ENOUGH_DATA;
-  }
-  if (resp_hdr.cmd != (CMD_ProvisionKey | RESP_BIT)) {
-    return ::android::IO_ERROR;
-  }
-  if (resp_hdr.rc != ::android::OK) {
-    if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-      return ::android::IO_ERROR;
-    }
-    return resp_hdr.rc;
-  }
-  if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-    return ::android::IO_ERROR;
-  }
-  return ::android::OK;
-}
-int BpCastAuth::SignHash(const ::trusty::aidl::Payload &req_payload,
-                         ::trusty::aidl::Payload *resp_payload) {
-  ::trusty::aidl::RequestHeader req_hdr = {
-      .cmd = CMD_SignHash,
-      .resp_payload_size = resp_payload->size(),
-  };
-  Request_SignHash req = {};
-  constexpr uint32_t req_num_handles =
-      ::trusty::aidl::HandleOps<Request_SignHash>::num_handles;
-  ::trusty::aidl::Handle req_handles[req_num_handles];
-  ::trusty::aidl::Handle *hptr = req_handles;
-  req.send_handles(hptr);
-  assert(hptr == &req_handles[req_num_handles]);
-  int rc = ::trusty::aidl::ipc::send(
-      mChan.get(), &req_hdr, sizeof(req_hdr), &req, sizeof(req),
-      req_payload.data(), req_payload.size(), req_handles, req_num_handles);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) !=
-      sizeof(req_hdr) + sizeof(req) + static_cast<size_t>(req_payload.size())) {
-    return ::android::IO_ERROR;
-  }
-  uevent_t event = UEVENT_INITIAL_VALUE(event);
-  rc = wait(mChan.get(), &event, INFINITE_TIME);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  if (!(event.event & IPC_HANDLE_POLL_MSG)) {
-    return ::android::IO_ERROR;
-  }
-  ::trusty::aidl::ResponseHeader resp_hdr;
-  rc = ::trusty::aidl::ipc::recv(mChan.get(), sizeof(resp_hdr), &resp_hdr,
-                                 sizeof(resp_hdr), resp_payload->data(),
-                                 resp_payload->size(), nullptr, 0);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) < sizeof(resp_hdr)) {
-    return ::android::NOT_ENOUGH_DATA;
-  }
-  if (resp_hdr.cmd != (CMD_SignHash | RESP_BIT)) {
-    return ::android::IO_ERROR;
-  }
-  if (resp_hdr.rc != ::android::OK) {
-    if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-      return ::android::IO_ERROR;
-    }
-    return resp_hdr.rc;
-  }
-  if (static_cast<size_t>(rc) !=
-      sizeof(resp_hdr) + static_cast<size_t>(resp_hdr.resp_payload_size)) {
-    return ::android::IO_ERROR;
-  }
-  resp_payload->resize(resp_hdr.resp_payload_size);
-  return ::android::OK;
-}
-int BpCastAuth::connect(std::optional<BpCastAuth> &out, const char *port,
-                        uint32_t flags) {
-  ::android::base::unique_fd fd;
-  int rc = ::trusty::aidl::ipc::connect(port, flags, fd);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  out = BpCastAuth(std::move(fd));
-  return ::android::OK;
-}
-} // namespace aidl
diff --git a/aidl/generated/BpCastAuth.h b/aidl/generated/BpCastAuth.h
deleted file mode 100644
index 4234af3..0000000
--- a/aidl/generated/BpCastAuth.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-#include <optional>
-
-#include "ICastAuth.h"
-#include "lib/binder/android-base/unique_fd.h"
-namespace aidl {
-class BpCastAuth : public ICastAuth {
-public:
-  BpCastAuth() = delete;
-  int ProvisionKey(const ::trusty::aidl::Payload &req_payload) override;
-  int SignHash(const ::trusty::aidl::Payload &req_payload,
-               ::trusty::aidl::Payload *resp_payload) override;
-  static int connect(std::optional<BpCastAuth> &, const char *, uint32_t);
-
-private:
-  BpCastAuth(::android::base::unique_fd chan) : mChan(std::move(chan)) {}
-  ::android::base::unique_fd mChan;
-};
-} // namespace aidl
diff --git a/aidl/generated/ICastAuth.cpp b/aidl/generated/ICastAuth.cpp
index dd0c8ca..86100d0 100644
--- a/aidl/generated/ICastAuth.cpp
+++ b/aidl/generated/ICastAuth.cpp
@@ -1,346 +1,356 @@
-#include "BpCastAuth.h"
-#include <cassert>
-namespace aidl {
-int BpCastAuth::ProvisionKey(const ::trusty::aidl::Payload &req_payload) {
-  ::trusty::aidl::RequestHeader req_hdr = {
-      .cmd = CMD_ProvisionKey,
-  };
-  Request_ProvisionKey req = {};
-  constexpr uint32_t req_num_handles =
-      ::trusty::aidl::HandleOps<Request_ProvisionKey>::num_handles;
-  ::trusty::aidl::Handle req_handles[req_num_handles];
-  ::trusty::aidl::Handle *hptr = req_handles;
-  req.send_handles(hptr);
-  assert(hptr == &req_handles[req_num_handles]);
-  int rc = ::trusty::aidl::ipc::send(
-      mChan.get(), &req_hdr, sizeof(req_hdr), &req, sizeof(req),
-      req_payload.data(), req_payload.size(), req_handles, req_num_handles);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) !=
-      sizeof(req_hdr) + sizeof(req) + static_cast<size_t>(req_payload.size())) {
-    return ::android::IO_ERROR;
-  }
-  uevent_t event = UEVENT_INITIAL_VALUE(event);
-  rc = wait(mChan.get(), &event, INFINITE_TIME);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  if (!(event.event & IPC_HANDLE_POLL_MSG)) {
-    return ::android::IO_ERROR;
-  }
-  ::trusty::aidl::ResponseHeader resp_hdr;
-  rc = ::trusty::aidl::ipc::recv(mChan.get(), sizeof(resp_hdr), &resp_hdr,
-                                 sizeof(resp_hdr), nullptr, 0);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) < sizeof(resp_hdr)) {
-    return ::android::NOT_ENOUGH_DATA;
-  }
-  if (resp_hdr.cmd != (CMD_ProvisionKey | RESP_BIT)) {
-    return ::android::IO_ERROR;
-  }
-  if (resp_hdr.rc != ::android::OK) {
-    if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-      return ::android::IO_ERROR;
+#include <BpCastAuth.h>
+int BpCastAuth::ProvisionKey(const ::tidl::Payload& req_payload) {
+    if (!mChan.ok()) {
+        return ERR_INVALID_ARGS;
     }
-    return resp_hdr.rc;
-  }
-  if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-    return ::android::IO_ERROR;
-  }
-  return ::android::OK;
-}
-int BpCastAuth::SignHash(const ::trusty::aidl::Payload &req_payload,
-                         ::trusty::aidl::Payload *resp_payload) {
-  ::trusty::aidl::RequestHeader req_hdr = {
-      .cmd = CMD_SignHash,
-      .resp_payload_size = resp_payload->size(),
-  };
-  Request_SignHash req = {};
-  constexpr uint32_t req_num_handles =
-      ::trusty::aidl::HandleOps<Request_SignHash>::num_handles;
-  ::trusty::aidl::Handle req_handles[req_num_handles];
-  ::trusty::aidl::Handle *hptr = req_handles;
-  req.send_handles(hptr);
-  assert(hptr == &req_handles[req_num_handles]);
-  int rc = ::trusty::aidl::ipc::send(
-      mChan.get(), &req_hdr, sizeof(req_hdr), &req, sizeof(req),
-      req_payload.data(), req_payload.size(), req_handles, req_num_handles);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) !=
-      sizeof(req_hdr) + sizeof(req) + static_cast<size_t>(req_payload.size())) {
-    return ::android::IO_ERROR;
-  }
-  uevent_t event = UEVENT_INITIAL_VALUE(event);
-  rc = wait(mChan.get(), &event, INFINITE_TIME);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  if (!(event.event & IPC_HANDLE_POLL_MSG)) {
-    return ::android::IO_ERROR;
-  }
-  ::trusty::aidl::ResponseHeader resp_hdr;
-  rc = ::trusty::aidl::ipc::recv(mChan.get(), sizeof(resp_hdr), &resp_hdr,
-                                 sizeof(resp_hdr), resp_payload->data(),
-                                 resp_payload->size(), nullptr, 0);
-  if (rc < 0) {
-    return rc;
-  }
-  if (static_cast<size_t>(rc) < sizeof(resp_hdr)) {
-    return ::android::NOT_ENOUGH_DATA;
-  }
-  if (resp_hdr.cmd != (CMD_SignHash | RESP_BIT)) {
-    return ::android::IO_ERROR;
-  }
-  if (resp_hdr.rc != ::android::OK) {
-    if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-      return ::android::IO_ERROR;
+    ::tidl::RequestHeader req_hdr = {
+            .cmd = CMD_ProvisionKey,
+    };
+    Request_ProvisionKey req = {};
+    constexpr uint32_t req_num_handles =
+            ::tidl::HandleOps<Request_ProvisionKey>::num_handles;
+    ::tidl::Handle req_handles[req_num_handles];
+    ::tidl::Handle* hptr = req_handles;
+    req.send_handles(hptr);
+    assert(hptr == &req_handles[req_num_handles]);
+    int rc =
+            ::tidl::ipc::send(mChan.get(), &req_hdr, sizeof(req_hdr), &req,
+                              sizeof(req), req_payload.data(),
+                              req_payload.size(), req_handles, req_num_handles);
+    if (rc < 0) {
+        return rc;
     }
-    return resp_hdr.rc;
-  }
-  if (static_cast<size_t>(rc) !=
-      sizeof(resp_hdr) + static_cast<size_t>(resp_hdr.resp_payload_size)) {
-    return ::android::IO_ERROR;
-  }
-  resp_payload->resize(resp_hdr.resp_payload_size);
-  return ::android::OK;
+    if (static_cast<size_t>(rc) !=
+        sizeof(req_hdr) + sizeof(req) +
+                static_cast<size_t>(req_payload.size())) {
+        return ERR_BAD_LEN;
+    }
+    rc = ::tidl::ipc::wait_for_msg(mChan.get());
+    if (rc != NO_ERROR) {
+        return rc;
+    }
+    ::tidl::ResponseHeader resp_hdr;
+    rc = ::tidl::ipc::recv(mChan.get(), sizeof(resp_hdr), &resp_hdr,
+                           sizeof(resp_hdr), nullptr, 0);
+    if (rc < 0) {
+        return rc;
+    }
+    if (static_cast<size_t>(rc) < sizeof(resp_hdr)) {
+        return ERR_BAD_LEN;
+    }
+    if (resp_hdr.cmd != (CMD_ProvisionKey | RESP_BIT)) {
+        return ERR_CMD_UNKNOWN;
+    }
+    if (resp_hdr.rc != NO_ERROR) {
+        if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
+            return ERR_BAD_LEN;
+        }
+        return resp_hdr.rc;
+    }
+    if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
+        return ERR_BAD_LEN;
+    }
+    return NO_ERROR;
 }
-int BpCastAuth::connect(std::optional<BpCastAuth> &out, const char *port,
-                        uint32_t flags) {
-  ::android::base::unique_fd fd;
-  int rc = ::trusty::aidl::ipc::connect(port, flags, fd);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  out = BpCastAuth(std::move(fd));
-  return ::android::OK;
+int BpCastAuth::SignHash(const ::tidl::Payload& req_payload,
+                         ::tidl::Payload* resp_payload) {
+    if (!mChan.ok()) {
+        return ERR_INVALID_ARGS;
+    }
+    ::tidl::RequestHeader req_hdr = {
+            .cmd = CMD_SignHash,
+            .resp_payload_size = resp_payload->size(),
+    };
+    Request_SignHash req = {};
+    constexpr uint32_t req_num_handles =
+            ::tidl::HandleOps<Request_SignHash>::num_handles;
+    ::tidl::Handle req_handles[req_num_handles];
+    ::tidl::Handle* hptr = req_handles;
+    req.send_handles(hptr);
+    assert(hptr == &req_handles[req_num_handles]);
+    int rc =
+            ::tidl::ipc::send(mChan.get(), &req_hdr, sizeof(req_hdr), &req,
+                              sizeof(req), req_payload.data(),
+                              req_payload.size(), req_handles, req_num_handles);
+    if (rc < 0) {
+        return rc;
+    }
+    if (static_cast<size_t>(rc) !=
+        sizeof(req_hdr) + sizeof(req) +
+                static_cast<size_t>(req_payload.size())) {
+        return ERR_BAD_LEN;
+    }
+    rc = ::tidl::ipc::wait_for_msg(mChan.get());
+    if (rc != NO_ERROR) {
+        return rc;
+    }
+    ::tidl::ResponseHeader resp_hdr;
+    rc = ::tidl::ipc::recv(mChan.get(), sizeof(resp_hdr), &resp_hdr,
+                           sizeof(resp_hdr), resp_payload->data(),
+                           resp_payload->size(), nullptr, 0);
+    if (rc < 0) {
+        return rc;
+    }
+    if (static_cast<size_t>(rc) < sizeof(resp_hdr)) {
+        return ERR_BAD_LEN;
+    }
+    if (resp_hdr.cmd != (CMD_SignHash | RESP_BIT)) {
+        return ERR_CMD_UNKNOWN;
+    }
+    if (resp_hdr.rc != NO_ERROR) {
+        if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
+            return ERR_BAD_LEN;
+        }
+        return resp_hdr.rc;
+    }
+    if (static_cast<size_t>(rc) !=
+        sizeof(resp_hdr) + static_cast<size_t>(resp_hdr.resp_payload_size)) {
+        return ERR_BAD_LEN;
+    }
+    resp_payload->resize(resp_hdr.resp_payload_size);
+    return NO_ERROR;
 }
-} // namespace aidl
-#include "home/cast-auth/trusty/common/BnCastAuth.h"
-namespace aidl {
-struct __PACKED Request {
-  ::trusty::aidl::RequestHeader hdr;
-  union __PACKED {
-    BnCastAuth::Request_ProvisionKey ProvisionKey;
-    BnCastAuth::Request_SignHash SignHash;
-  } req;
+int BpCastAuth::connect(const char* port, uint32_t flags) {
+    if (mChan.ok()) {
+        return ERR_INVALID_ARGS;
+    }
+    return ::tidl::ipc::connect(port, flags, mChan);
+}
+
+bool BpCastAuth::is_connected() {
+    return (mChan.ok());
+}
+void BpCastAuth::reset() {
+    mChan.reset();
+}
+#if !defined(__QL_TIPC__)
+#include <BnCastAuth.h>
+struct TIDL_PACKED_ATTR Request {
+    ::tidl::RequestHeader hdr;
+    union TIDL_PACKED_ATTR {
+        BnCastAuth::Request_ProvisionKey ProvisionKey;
+        BnCastAuth::Request_SignHash SignHash;
+    } req;
 };
-struct __PACKED Response {
-  ::trusty::aidl::ResponseHeader hdr;
-  union __PACKED {
-  } resp;
+struct TIDL_PACKED_ATTR Response {
+    ::tidl::ResponseHeader hdr;
+    union TIDL_PACKED_ATTR {
+    } resp;
 };
-union __PACKED LongestMessage {
-  Request req;
-  Response resp;
+union TIDL_PACKED_ATTR LongestMessage {
+    Request req;
+    Response resp;
 };
-BnCastAuth::BnCastAuth(const char *port,
-                       const ::trusty::aidl::ipc::Service::PortAcl *acl,
+BnCastAuth::BnCastAuth(const char* port,
+                       const ::tidl::Service::PortAcl* acl,
                        uint32_t maximum_payload_size)
-    : Service("BnCastAuth", port, sizeof(LongestMessage) + maximum_payload_size,
-              acl, &kOps) {}
-int BnCastAuth::get_instance(ICastAuth *&instance, const struct uuid *) {
-  instance = this;
-  return ::android::OK;
+        : Service("BnCastAuth",
+                  port,
+                  sizeof(LongestMessage) + maximum_payload_size,
+                  acl,
+                  &kOps) {}
+int BnCastAuth::get_instance(ICastAuth*& instance, const struct uuid*) {
+    instance = this;
+    return NO_ERROR;
 }
-::trusty::aidl::ipc::Service::Ops BnCastAuth::kOps = {
-    .on_connect = BnCastAuth::on_connect,
-    .on_message = BnCastAuth::on_message,
-    .on_channel_cleanup = BnCastAuth::on_channel_cleanup,
+::tidl::Service::Ops BnCastAuth::kOps = {
+        .on_connect = BnCastAuth::on_connect,
+        .on_message = BnCastAuth::on_message,
+        .on_channel_cleanup = BnCastAuth::on_channel_cleanup,
 };
-int BnCastAuth::on_connect(const ::trusty::aidl::ipc::Service::Port *port,
-                           ::trusty::aidl::Handle chan, const struct uuid *peer,
-                           void **ctx_p) {
-  auto *bn_impl = static_cast<BnCastAuth *>(
-      reinterpret_cast<Service *>(const_cast<void *>(port->priv)));
-  assert(bn_impl);
-  ICastAuth *instance;
-  int rc = bn_impl->get_instance(instance, peer);
-  if (rc != ::android::OK) {
-    return rc;
-  }
-  *ctx_p = instance;
-  return ::android::OK;
+int BnCastAuth::on_connect(const ::tidl::Service::Port* port,
+                           ::tidl::Handle chan,
+                           const struct uuid* peer,
+                           void** ctx_p) {
+    auto* bn_impl = static_cast<BnCastAuth*>(
+            reinterpret_cast<Service*>(const_cast<void*>(port->priv)));
+    assert(bn_impl);
+    ICastAuth* instance;
+    int rc = bn_impl->get_instance(instance, peer);
+    if (rc != NO_ERROR) {
+        return rc;
+    }
+    *ctx_p = instance;
+    return NO_ERROR;
 }
-void BnCastAuth::on_channel_cleanup(void *ctx) {
-  auto *impl = reinterpret_cast<ICastAuth *>(ctx);
-  assert(impl);
-  impl->destroy();
+void BnCastAuth::on_channel_cleanup(void* ctx) {
+    auto* impl = reinterpret_cast<ICastAuth*>(ctx);
+    assert(impl);
+    impl->destroy();
 }
-int BnCastAuth::on_message(const ::trusty::aidl::ipc::Service::Port *port,
-                           ::trusty::aidl::Handle chan, void *ctx) {
-  auto *impl = reinterpret_cast<ICastAuth *>(ctx);
-  auto *bn_impl = static_cast<BnCastAuth *>(
-      reinterpret_cast<Service *>(const_cast<void *>(port->priv)));
-  assert(impl);
-  assert(bn_impl);
-  ::trusty::aidl::Payload req_payload;
-  ::trusty::aidl::Payload resp_payload;
-  ipc_msg_info_t mi;
-  int rc = get_msg(chan, &mi);
-  if (rc != ::android::OK) {
+int BnCastAuth::on_message(const ::tidl::Service::Port* port,
+                           ::tidl::Handle chan,
+                           void* ctx) {
+    auto* impl = reinterpret_cast<ICastAuth*>(ctx);
+    auto* bn_impl = static_cast<BnCastAuth*>(
+            reinterpret_cast<Service*>(const_cast<void*>(port->priv)));
+    assert(impl);
+    assert(bn_impl);
+    ::tidl::Payload req_payload;
+    ::tidl::Payload resp_payload;
+    ipc_msg_info_t mi;
+    int rc = get_msg(chan, &mi);
+    if (rc != NO_ERROR) {
+        return rc;
+    }
+    bool call_put_msg = true;
+    ::tidl::RequestHeader req_hdr;
+    struct iovec req_hdr_iov = {.iov_base = &req_hdr,
+                                .iov_len = sizeof(req_hdr)};
+    ipc_msg_t req_hdr_msg = {.num_iov = 1,
+                             .iov = &req_hdr_iov,
+                             .num_handles = 0,
+                             .handles = nullptr};
+    rc = read_msg(chan, mi.id, 0, &req_hdr_msg);
+    if (rc < 0) {
+        goto done;
+    }
+    if (static_cast<size_t>(rc) < sizeof(req_hdr)) {
+        rc = ERR_BAD_LEN;
+        goto done;
+    }
+    switch (req_hdr.cmd) {
+    case CMD_ProvisionKey: {
+        Request_ProvisionKey req;
+        constexpr uint32_t min_msg_len = sizeof(req_hdr) + sizeof(req);
+        if (mi.len < min_msg_len) {
+            rc = ERR_BAD_LEN;
+            goto send_rc;
+        }
+        rc = bn_impl->get_payload_buffer(req_payload, mi.len - min_msg_len,
+                                         false);
+        if (rc != NO_ERROR) {
+            goto send_rc;
+        }
+        constexpr uint32_t req_num_handles = Request_ProvisionKey::num_handles;
+        ::tidl::Handle req_handles[req_num_handles];
+        struct iovec req_iov[] = {
+                {.iov_base = &req, .iov_len = sizeof(req)},
+                {.iov_base = req_payload.data(), .iov_len = req_payload.size()},
+        };
+        ipc_msg_t req_msg = {.num_iov = countof(req_iov),
+                             .iov = req_iov,
+                             .num_handles = req_num_handles,
+                             .handles = req_handles};
+        rc = read_msg(chan, mi.id, sizeof(req_hdr), &req_msg);
+        if (rc < 0) {
+            goto done;
+        }
+        if (static_cast<size_t>(rc) <
+            sizeof(req) + static_cast<size_t>(req_payload.size())) {
+            rc = ERR_BAD_LEN;
+            goto send_rc;
+        }
+        put_msg(chan, mi.id);
+        call_put_msg = false;
+        ::tidl::Handle* hptr = req_handles;
+        req.recv_handles(hptr);
+        assert(hptr == &req_handles[req_num_handles]);
+        rc = impl->ProvisionKey(req_payload);
+        if (rc != NO_ERROR) {
+            goto send_rc;
+        }
+        ::tidl::ResponseHeader resp_hdr = {
+                .cmd = req_hdr.cmd | RESP_BIT,
+                .rc = rc,
+        };
+        rc = ::tidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr), nullptr, 0);
+        if (rc < 0) {
+            goto done;
+        }
+        if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
+            rc = ERR_BAD_LEN;
+            goto done;
+        }
+        break;
+    }
+    case CMD_SignHash: {
+        Request_SignHash req;
+        constexpr uint32_t min_msg_len = sizeof(req_hdr) + sizeof(req);
+        if (mi.len < min_msg_len) {
+            rc = ERR_BAD_LEN;
+            goto send_rc;
+        }
+        rc = bn_impl->get_payload_buffer(req_payload, mi.len - min_msg_len,
+                                         false);
+        if (rc != NO_ERROR) {
+            goto send_rc;
+        }
+        rc = bn_impl->get_payload_buffer(resp_payload,
+                                         req_hdr.resp_payload_size, true);
+        if (rc != NO_ERROR) {
+            goto send_rc;
+        }
+        constexpr uint32_t req_num_handles = Request_SignHash::num_handles;
+        ::tidl::Handle req_handles[req_num_handles];
+        struct iovec req_iov[] = {
+                {.iov_base = &req, .iov_len = sizeof(req)},
+                {.iov_base = req_payload.data(), .iov_len = req_payload.size()},
+        };
+        ipc_msg_t req_msg = {.num_iov = countof(req_iov),
+                             .iov = req_iov,
+                             .num_handles = req_num_handles,
+                             .handles = req_handles};
+        rc = read_msg(chan, mi.id, sizeof(req_hdr), &req_msg);
+        if (rc < 0) {
+            goto done;
+        }
+        if (static_cast<size_t>(rc) <
+            sizeof(req) + static_cast<size_t>(req_payload.size())) {
+            rc = ERR_BAD_LEN;
+            goto send_rc;
+        }
+        put_msg(chan, mi.id);
+        call_put_msg = false;
+        ::tidl::Handle* hptr = req_handles;
+        req.recv_handles(hptr);
+        assert(hptr == &req_handles[req_num_handles]);
+        rc = impl->SignHash(req_payload, &resp_payload);
+        if (rc != NO_ERROR) {
+            goto send_rc;
+        }
+        ::tidl::ResponseHeader resp_hdr = {
+                .cmd = req_hdr.cmd | RESP_BIT,
+                .resp_payload_size = resp_payload.size(),
+                .rc = rc,
+        };
+        rc = ::tidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr),
+                               resp_payload.data(), resp_payload.size(),
+                               nullptr, 0);
+        if (rc < 0) {
+            goto done;
+        }
+        if (static_cast<size_t>(rc) != sizeof(resp_hdr) + resp_payload.size()) {
+            rc = ERR_BAD_LEN;
+            goto done;
+        }
+        break;
+    }
+    default:
+        put_msg(chan, mi.id);
+        call_put_msg = false;
+        rc = ERR_CMD_UNKNOWN;
+        goto send_rc;
+        break;
+    }
+    rc = NO_ERROR;
+done:
+    if (call_put_msg) {
+        put_msg(chan, mi.id);
+    }
+    bn_impl->free_payload_buffer(tidl::move(req_payload));
+    bn_impl->free_payload_buffer(tidl::move(resp_payload));
     return rc;
-  }
-  bool call_put_msg = true;
-  ::trusty::aidl::RequestHeader req_hdr;
-  struct iovec req_hdr_iov = {.iov_base = &req_hdr, .iov_len = sizeof(req_hdr)};
-  ipc_msg_t req_hdr_msg = {
-      .num_iov = 1, .iov = &req_hdr_iov, .num_handles = 0, .handles = nullptr};
-  rc = read_msg(chan, mi.id, 0, &req_hdr_msg);
-  if (rc < 0) {
-    goto done;
-  }
-  if (static_cast<size_t>(rc) < sizeof(req_hdr)) {
-    rc = ::android::NOT_ENOUGH_DATA;
-    goto done;
-  }
-  switch (req_hdr.cmd) {
-  case CMD_ProvisionKey: {
-    Request_ProvisionKey req;
-    constexpr uint32_t min_msg_len = sizeof(req_hdr) + sizeof(req);
-    if (mi.len < min_msg_len) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    rc = bn_impl->get_payload_buffer(req_payload, mi.len - min_msg_len, false);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    constexpr uint32_t req_num_handles = Request_ProvisionKey::num_handles;
-    ::trusty::aidl::Handle req_handles[req_num_handles];
-    struct iovec req_iov[] = {
-        {.iov_base = &req, .iov_len = sizeof(req)},
-        {.iov_base = req_payload.data(), .iov_len = req_payload.size()},
-    };
-    ipc_msg_t req_msg = {.num_iov = countof(req_iov),
-                         .iov = req_iov,
-                         .num_handles = req_num_handles,
-                         .handles = req_handles};
-    rc = read_msg(chan, mi.id, sizeof(req_hdr), &req_msg);
+send_rc:
+    ::tidl::ResponseHeader resp_hdr = {.cmd = req_hdr.cmd | RESP_BIT, .rc = rc};
+    rc = ::tidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr), nullptr, 0);
     if (rc < 0) {
-      goto done;
-    }
-    if (static_cast<size_t>(rc) <
-        sizeof(req) + static_cast<size_t>(req_payload.size())) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    put_msg(chan, mi.id);
-    call_put_msg = false;
-    ::trusty::aidl::Handle *hptr = req_handles;
-    req.recv_handles(hptr);
-    assert(hptr == &req_handles[req_num_handles]);
-    rc = impl->ProvisionKey(req_payload);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    ::trusty::aidl::ResponseHeader resp_hdr = {
-        .cmd = req_hdr.cmd | RESP_BIT,
-        .rc = rc,
-    };
-    rc = ::trusty::aidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr), nullptr,
-                                   0);
-    if (rc < 0) {
-      goto done;
+        goto done;
     }
     if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-      rc = ::android::IO_ERROR;
-      goto done;
+        rc = ERR_BAD_LEN;
+        goto done;
     }
-    break;
-  }
-  case CMD_SignHash: {
-    Request_SignHash req;
-    constexpr uint32_t min_msg_len = sizeof(req_hdr) + sizeof(req);
-    if (mi.len < min_msg_len) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    rc = bn_impl->get_payload_buffer(req_payload, mi.len - min_msg_len, false);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    rc = bn_impl->get_payload_buffer(resp_payload, req_hdr.resp_payload_size,
-                                     true);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    constexpr uint32_t req_num_handles = Request_SignHash::num_handles;
-    ::trusty::aidl::Handle req_handles[req_num_handles];
-    struct iovec req_iov[] = {
-        {.iov_base = &req, .iov_len = sizeof(req)},
-        {.iov_base = req_payload.data(), .iov_len = req_payload.size()},
-    };
-    ipc_msg_t req_msg = {.num_iov = countof(req_iov),
-                         .iov = req_iov,
-                         .num_handles = req_num_handles,
-                         .handles = req_handles};
-    rc = read_msg(chan, mi.id, sizeof(req_hdr), &req_msg);
-    if (rc < 0) {
-      goto done;
-    }
-    if (static_cast<size_t>(rc) <
-        sizeof(req) + static_cast<size_t>(req_payload.size())) {
-      rc = ::android::NOT_ENOUGH_DATA;
-      goto send_rc;
-    }
-    put_msg(chan, mi.id);
-    call_put_msg = false;
-    ::trusty::aidl::Handle *hptr = req_handles;
-    req.recv_handles(hptr);
-    assert(hptr == &req_handles[req_num_handles]);
-    rc = impl->SignHash(req_payload, &resp_payload);
-    if (rc != ::android::OK) {
-      goto send_rc;
-    }
-    ::trusty::aidl::ResponseHeader resp_hdr = {
-        .cmd = req_hdr.cmd | RESP_BIT,
-        .resp_payload_size = resp_payload.size(),
-        .rc = rc,
-    };
-    rc = ::trusty::aidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr),
-                                   resp_payload.data(), resp_payload.size(),
-                                   nullptr, 0);
-    if (rc < 0) {
-      goto done;
-    }
-    if (static_cast<size_t>(rc) != sizeof(resp_hdr) + resp_payload.size()) {
-      rc = ::android::IO_ERROR;
-      goto done;
-    }
-    break;
-  }
-  default:
-    put_msg(chan, mi.id);
-    call_put_msg = false;
-    rc = ::android::UNKNOWN_TRANSACTION;
-    goto send_rc;
-    break;
-  }
-  rc = ::android::OK;
-done:
-  if (call_put_msg) {
-    put_msg(chan, mi.id);
-  }
-  bn_impl->free_payload_buffer(std::move(req_payload));
-  bn_impl->free_payload_buffer(std::move(resp_payload));
-  return rc;
-send_rc:
-  ::trusty::aidl::ResponseHeader resp_hdr = {.cmd = req_hdr.cmd | RESP_BIT,
-                                             .rc = rc};
-  rc = ::trusty::aidl::ipc::send(chan, &resp_hdr, sizeof(resp_hdr), nullptr, 0);
-  if (rc < 0) {
     goto done;
-  }
-  if (static_cast<size_t>(rc) != sizeof(resp_hdr)) {
-    rc = ::android::IO_ERROR;
-    goto done;
-  }
-  goto done;
 }
-} // namespace aidl
+#endif  // #if !defined(__QL_TIPC__)
diff --git a/aidl/generated/ICastAuth.h b/aidl/generated/ICastAuth.h
deleted file mode 100644
index 0967275..0000000
--- a/aidl/generated/ICastAuth.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#pragma once
-// #include <array>
-#include <stdint.h>
-#include <string.h>
-#include <sys/types.h>
-#ifdef __TRUSTY__
-#include <lk/compiler.h>
-#else
-#define __PACKED __attribute__((packed))
-#endif
-
-#include "lib/binder/Binder.h"
-#include "lib/binder/Errors.h"
-namespace aidl {
-class ICastAuth {
-public:
-  virtual ~ICastAuth() {}
-  virtual int ProvisionKey(const ::trusty::aidl::Payload &req_payload) = 0;
-  virtual int SignHash(const ::trusty::aidl::Payload &req_payload,
-                       ::trusty::aidl::Payload *resp_payload) = 0;
-  static constexpr char PORT[] = "com.android.trusty.cast_auth";
-  enum : uint32_t {
-    REQ_SHIFT = 1,
-    RESP_BIT = 1,
-    CMD_ProvisionKey = (0 << REQ_SHIFT),
-    CMD_SignHash = (1 << REQ_SHIFT),
-  };
-  struct __PACKED Request_ProvisionKey {
-    static constexpr uint32_t num_handles = 0U;
-    void send_handles(::trusty::aidl::Handle *&ptr) {}
-    void recv_handles(::trusty::aidl::Handle *&ptr) {}
-  };
-  struct __PACKED Request_SignHash {
-    static constexpr uint32_t num_handles = 0U;
-    void send_handles(::trusty::aidl::Handle *&ptr) {}
-    void recv_handles(::trusty::aidl::Handle *&ptr) {}
-  };
-  virtual void destroy() {}
-};
-} // namespace aidl
diff --git a/aidl/generated/ICastAuth_CBp.cpp b/aidl/generated/ICastAuth_CBp.cpp
new file mode 100644
index 0000000..bcaa2cf
--- /dev/null
+++ b/aidl/generated/ICastAuth_CBp.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define TLOG_TAG "cast_auth_client"
+
+#include <assert.h>
+#include <lib/tipc/tipc.h>
+#include <string.h>
+#include <trusty_log.h>
+#include <uapi/err.h>
+
+#include <BpCastAuth.h>
+#include <lib/tidl/lk_strerror.h>
+
+/**
+ * cast_auth_connect()
+ * @param cast_auth reference to the proxy instance
+ *
+ * Return: 0 on success, or an error code < 0 on failure.
+ */
+int cast_auth_connect(BpCastAuth& cast_auth) {
+    int rc;
+    rc = cast_auth.connect(ICastAuth::PORT, IPC_CONNECT_WAIT_FOR_PORT);
+    if (rc < 0) {
+        TLOGE("Failed to connect to %s: %d\n", ICastAuth::PORT, rc);
+        return rc;
+    }
+    return rc;
+}
+
+/**
+ * cast_auth_ProvisionKey()
+ *
+ * @param req_payload
+ *
+ * @return: 0 on success, or an error code < 0 on failure.
+ */
+extern "C" int cast_auth_ProvisionKey(const ::tidl::Payload& req_payload) {
+    int rc;
+    BpCastAuth cast_auth;
+    rc = cast_auth_connect(cast_auth);
+    if (rc < 0) {
+        return rc;
+    }
+
+    rc = cast_auth.ProvisionKey(req_payload);
+    if (rc != NO_ERROR) {
+        TLOGE("ProvisionKey failed - %s(%d).\n", lk_strerror(rc), rc);
+        return rc;
+    }
+    return rc;
+}
+
+/**
+ * cast_auth_SignHash()
+ *
+ * @param req_payload
+ * @param[out] resp_payload
+ * @param[out] resp_payload_buf_size: size of the output resp_payload array
+ * @param[out] resp_payload_size: number of bytes written into the output array
+ *
+ * @return: 0 on success, or an error code < 0 on failure.
+ */
+extern "C" int cast_auth_SignHash(const ::tidl::Payload& req_payload,
+                                  uint8_t* resp_payload,
+                                  size_t resp_payload_buf_size,
+                                  size_t* resp_payload_size) {
+    int rc;
+    BpCastAuth cast_auth;
+    rc = cast_auth_connect(cast_auth);
+    if (rc < 0) {
+        return rc;
+    }
+
+    tidl::Payload resp_payload_payload{
+            const_cast<uint8_t*>(resp_payload),
+            static_cast<uint32_t>(resp_payload_buf_size)};
+    rc = cast_auth.SignHash(req_payload, &resp_payload_payload);
+    if (rc != NO_ERROR) {
+        TLOGE("SignHash failed - %s(%d).\n", lk_strerror(rc), rc);
+        return rc;
+    }
+    *resp_payload_size = resp_payload_payload.size();
+    return rc;
+}
diff --git a/aidl/generated/include/BnCastAuth.h b/aidl/generated/include/BnCastAuth.h
new file mode 100644
index 0000000..9433b3b
--- /dev/null
+++ b/aidl/generated/include/BnCastAuth.h
@@ -0,0 +1,23 @@
+#pragma once
+#include <ICastAuth.h>
+class BnCastAuth : public ::tidl::Service, public ICastAuth {
+public:
+    BnCastAuth() = delete;
+
+protected:
+    BnCastAuth(const char*,
+               const ::tidl::Service::PortAcl* acl,
+               uint32_t maximum_payload_size);
+    virtual int get_instance(ICastAuth*&, const struct uuid*);
+
+private:
+    static int on_connect(const ::tidl::Service::Port* port,
+                          ::tidl::Handle chan,
+                          const struct uuid* peer,
+                          void** ctx_p);
+    static void on_channel_cleanup(void* ctx);
+    static int on_message(const ::tidl::Service::Port* port,
+                          ::tidl::Handle chan,
+                          void* ctx);
+    static ::tidl::Service::Ops kOps;
+};
diff --git a/aidl/generated/include/BpCastAuth.h b/aidl/generated/include/BpCastAuth.h
new file mode 100644
index 0000000..b335155
--- /dev/null
+++ b/aidl/generated/include/BpCastAuth.h
@@ -0,0 +1,19 @@
+#pragma once
+#include <ICastAuth.h>
+class BpCastAuth : public ICastAuth {
+public:
+    BpCastAuth() : mChan() {}
+    int ProvisionKey(const ::tidl::Payload& req_payload) override;
+    int SignHash(const ::tidl::Payload& req_payload,
+                 ::tidl::Payload* resp_payload) override;
+    int connect(const char*, uint32_t);
+    bool is_connected();
+    void reset();
+
+private:
+#if !defined(__QL_TIPC__)
+    ::android::base::unique_fd mChan;
+#else
+    ::tidl::handle mChan;
+#endif  // #if !defined(__QL_TIPC__)
+};
diff --git a/aidl/generated/include/ICastAuth.h b/aidl/generated/include/ICastAuth.h
new file mode 100644
index 0000000..5bd2546
--- /dev/null
+++ b/aidl/generated/include/ICastAuth.h
@@ -0,0 +1,27 @@
+#pragma once
+#include <lib/tidl/tidl.h>
+class ICastAuth {
+public:
+    virtual ~ICastAuth() {}
+    virtual int ProvisionKey(const ::tidl::Payload& req_payload) = 0;
+    virtual int SignHash(const ::tidl::Payload& req_payload,
+                         ::tidl::Payload* resp_payload) = 0;
+    static constexpr char PORT[] = "com.android.trusty.cast_auth";
+    enum : uint32_t {
+        REQ_SHIFT = 1,
+        RESP_BIT = 1,
+        CMD_ProvisionKey = (0 << REQ_SHIFT),
+        CMD_SignHash = (1 << REQ_SHIFT),
+    };
+    struct TIDL_PACKED_ATTR Request_ProvisionKey {
+        static constexpr uint32_t num_handles = 0U;
+        void send_handles(::tidl::Handle*& ptr) {}
+        void recv_handles(::tidl::Handle*& ptr) {}
+    };
+    struct TIDL_PACKED_ATTR Request_SignHash {
+        static constexpr uint32_t num_handles = 0U;
+        void send_handles(::tidl::Handle*& ptr) {}
+        void recv_handles(::tidl::Handle*& ptr) {}
+    };
+    virtual void destroy() {}
+};
diff --git a/aidl/generated/include/cast_auth.h b/aidl/generated/include/cast_auth.h
new file mode 100644
index 0000000..d0ac0f0
--- /dev/null
+++ b/aidl/generated/include/cast_auth.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+#pragma once
+
+#define CAST_AUTH_PORT "com.android.trusty.cast_auth"
+
+__BEGIN_CDECLS
+
+/**
+ * cast_auth_ProvisionKey()
+ *
+ * @param req_payload
+ *
+ * @return: 0 on success, or an error code < 0 on failure.
+ */
+int cast_auth_ProvisionKey(const ::tidl::Payload& req_payload);
+
+/**
+ * cast_auth_SignHash()
+ *
+ * @param req_payload
+ * @param[out] resp_payload
+ * @param[out] resp_payload_buf_size: size of the output resp_payload array
+ * @param[out] resp_payload_size: number of bytes written into the output array
+ *
+ * @return: 0 on success, or an error code < 0 on failure.
+ */
+int cast_auth_SignHash(const ::tidl::Payload& req_payload,
+                       uint8_t* resp_payload,
+                       size_t resp_payload_buf_size,
+                       size_t* resp_payload_size);
+
+__END_CDECLS
diff --git a/aidl/rules.mk b/aidl/rules.mk
deleted file mode 100644
index ed6e952..0000000
--- a/aidl/rules.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-LOCAL_DIR := $(GET_LOCAL_DIR)
-
-MODULE := $(LOCAL_DIR)
-
-MODULE_AIDLS := \
-    $(LOCAL_DIR)/ICastAuth.aidl \
-
-include make/aidl.mk
diff --git a/app/cast_auth_impl.cc b/app/cast_auth_impl.cc
index 1383b6b..21e94e7 100644
--- a/app/cast_auth_impl.cc
+++ b/app/cast_auth_impl.cc
@@ -22,7 +22,7 @@
 const int PAYLOAD_MAX_BYTES = WRAPPED_KEY_MAX_BYTES;
 
 bool is_plaintext_rsa_2048_private_key(
-    const ::trusty::aidl::Payload &req_payload) {
+    const ::tidl::Payload &req_payload) {
   bssl::UniquePtr<BIO> bio(
       BIO_new_mem_buf(req_payload.data(), req_payload.size()));
   if (!bio) {
@@ -55,7 +55,7 @@
 
 CastAuthImpl::CastAuthImpl() : BnCastAuth(PORT, &kAcl, PAYLOAD_MAX_BYTES) {}
 
-int CastAuthImpl::ProvisionKey(const ::trusty::aidl::Payload &req_payload) {
+int CastAuthImpl::ProvisionKey(const ::tidl::Payload &req_payload) {
   uint8_t unwrapped[UNWRAPPED_KEY_MAX_BYTES];
   size_t unwrapped_size = sizeof(unwrapped);
   if (!system_state_provisioning_allowed()) {
@@ -92,8 +92,8 @@
   return SaveKey(unwrapped, unwrapped_size);
 }
 
-int CastAuthImpl::SignHash(const ::trusty::aidl::Payload &req_payload,
-                           ::trusty::aidl::Payload *resp_payload) {
+int CastAuthImpl::SignHash(const ::tidl::Payload &req_payload,
+                           ::tidl::Payload *resp_payload) {
   uint8_t key[UNWRAPPED_KEY_MAX_BYTES];
   size_t key_size = sizeof(key);
   int rc = LoadKey(key, &key_size);
@@ -209,18 +209,18 @@
   return NO_ERROR;
 }
 
-int CastAuthImpl::get_payload_buffer(::trusty::aidl::Payload &payload,
+int CastAuthImpl::get_payload_buffer(::tidl::Payload &payload,
                                      uint32_t size, bool) {
   if (size > PAYLOAD_MAX_BYTES) {
     return ERR_NOT_ENOUGH_BUFFER;
   }
 
   uint8_t *buffer = new uint8_t[PAYLOAD_MAX_BYTES];
-  payload = ::trusty::aidl::Payload{buffer, size};
+  payload = ::tidl::Payload{buffer, size};
   return NO_ERROR;
 }
 
-void CastAuthImpl::free_payload_buffer(::trusty::aidl::Payload payload) {
+void CastAuthImpl::free_payload_buffer(::tidl::Payload payload) {
   delete[] payload.data();
   // Note that payload is passed by copy, so will be destroyed here, no
   // need to nullify the data member.
diff --git a/app/cast_auth_impl.h b/app/cast_auth_impl.h
index fb127cf..f1b11fd 100644
--- a/app/cast_auth_impl.h
+++ b/app/cast_auth_impl.h
@@ -5,12 +5,12 @@
 
 #include "BnCastAuth.h"
 
-class CastAuthImpl : public aidl::BnCastAuth {
+class CastAuthImpl : public BnCastAuth {
 public:
   CastAuthImpl();
-  int ProvisionKey(const ::trusty::aidl::Payload &req_payload) override;
-  int SignHash(const ::trusty::aidl::Payload &req_payload,
-               ::trusty::aidl::Payload *resp_payload) override;
+  int ProvisionKey(const ::tidl::Payload &req_payload) override;
+  int SignHash(const ::tidl::Payload &req_payload,
+               ::tidl::Payload *resp_payload) override;
 
 private:
   static constexpr struct tipc_port_acl kAcl = {
@@ -18,7 +18,7 @@
       .uuid_num = 0};
   int SaveKey(const uint8_t *key, size_t length);
   int LoadKey(uint8_t *key, size_t *length);
-  int get_payload_buffer(::trusty::aidl::Payload &payload, uint32_t size,
+  int get_payload_buffer(::tidl::Payload &payload, uint32_t size,
                          bool) override;
-  void free_payload_buffer(::trusty::aidl::Payload payload) override;
+  void free_payload_buffer(::tidl::Payload payload) override;
 };
diff --git a/app/rules.mk b/app/rules.mk
index 85c71fe..987d0a1 100644
--- a/app/rules.mk
+++ b/app/rules.mk
@@ -3,8 +3,6 @@
 
 TRUSTY_APP_NAME := cast_auth
 
-CAST_AUTH_USE_PREBUILTS := 1
-
 MODULE := $(LOCAL_DIR)
 
 MODULE_INCLUDES += \
@@ -16,30 +14,16 @@
 	$(LOCAL_DIR)/main.cc \
 	$(LOCAL_DIR)/cast_auth_impl.cc \
 
-ifeq ($(CAST_AUTH_USE_PREBUILTS),1)
-
-MODULE_INCLUDES += \
-	$(LOCAL_DIR)/../aidl/generated \
-
-MODULE_SRCS += \
-	$(LOCAL_DIR)/../aidl/generated/BnCastAuth.cpp \
-
-endif
-
 MODULE_LIBRARY_DEPS += \
 	trusty/user/base/lib/libstdc++-trusty \
 	external/boringssl \
 	trusty/user/base/lib/keybox/client \
 	trusty/user/base/lib/storage \
 	trusty/user/base/lib/system_state \
-	trusty/user/base/experimental/lib/binder-paidl \
+	trusty/user/base/experimental/lib/tidl \
 	trusty/user/base/lib/keybox/client \
 
-ifneq ($(CAST_AUTH_USE_PREBUILTS),1)
-
 MODULE_LIBRARY_DEPS += \
-	trusty/user/app/cast-auth/aidl \
-
-endif
+	trusty/user/app/cast-auth/aidl/Bn \
 
 include make/trusted_app.mk
diff --git a/app/test-app/README.md b/app/test-app/README.md
index 08eb9c5..0ddf25b 100644
--- a/app/test-app/README.md
+++ b/app/test-app/README.md
@@ -1,2 +1,3 @@
-build-root/build-qemu-generic-arm64-test-debug/run --shell-command --verbose \
-"/vendor/bin/trusty-ut-ctrl -D /dev/trusty-ipc-dev0 com.android.trusty.cast_auth.test" --headless
+build-root/build-qemu-generic-arm64-test-debug/run --shell-command \
+"/vendor/bin/trusty-ut-ctrl -D /dev/trusty-ipc-dev0 com.android.trusty.cast_auth.test" \
+--headless --verbose
diff --git a/app/test-app/main.cc b/app/test-app/main.cc
index d1f2190..fed2d8a 100644
--- a/app/test-app/main.cc
+++ b/app/test-app/main.cc
@@ -207,8 +207,8 @@
 
 TEST(CastAuthTest, ProvisionAndSignHash) {
   int rc;
-  std::optional<aidl::BpCastAuth> cast_auth;
-  rc = aidl::BpCastAuth::connect(cast_auth, aidl::ICastAuth::PORT,
+  BpCastAuth cast_auth;
+  rc = cast_auth.connect(ICastAuth::PORT,
                                  IPC_CONNECT_WAIT_FOR_PORT);
   ASSERT_EQ(NO_ERROR, rc, "connect");
 
@@ -217,16 +217,16 @@
   keybox_wrap_for_test(test_pkcs1_der, sizeof(test_pkcs1_der), wrapped_keybox,
                        sizeof(wrapped_keybox), &wrapped_keybox_len);
   {
-    ::trusty::aidl::Payload prov_req(wrapped_keybox, wrapped_keybox_len);
-    rc = cast_auth->ProvisionKey(prov_req);
+    ::tidl::Payload prov_req(wrapped_keybox, wrapped_keybox_len);
+    rc = cast_auth.ProvisionKey(prov_req);
     ASSERT_EQ(NO_ERROR, rc, "ProvisionKey");
   }
 
   {
-    ::trusty::aidl::Payload sign_req(test_hash, sizeof(test_hash));
+    ::tidl::Payload sign_req(test_hash, sizeof(test_hash));
     uint8_t signature[256];
-    ::trusty::aidl::Payload sign_resp(signature, sizeof(signature));
-    rc = cast_auth->SignHash(sign_req, &sign_resp);
+    ::tidl::Payload sign_resp(signature, sizeof(signature));
+    rc = cast_auth.SignHash(sign_req, &sign_resp);
     ASSERT_EQ(NO_ERROR, rc, "SignHash");
     ASSERT_EQ(sign_resp.size(), sizeof(test_signature), "signature size");
     for (unsigned int i = 0; i < sign_resp.size(); ++i) {
@@ -239,22 +239,22 @@
 
 TEST(CastAuthTest, ProvisionUnwrappedAndSignHash) {
   int rc;
-  std::optional<aidl::BpCastAuth> cast_auth;
-  rc = aidl::BpCastAuth::connect(cast_auth, aidl::ICastAuth::PORT,
+  BpCastAuth cast_auth;
+  rc = cast_auth.connect(ICastAuth::PORT,
                                  IPC_CONNECT_WAIT_FOR_PORT);
   ASSERT_EQ(NO_ERROR, rc, "connect");
 
   {
-    ::trusty::aidl::Payload prov_req(test_pkcs1_der, sizeof(test_pkcs1_der));
-    rc = cast_auth->ProvisionKey(prov_req);
+    ::tidl::Payload prov_req(test_pkcs1_der, sizeof(test_pkcs1_der));
+    rc = cast_auth.ProvisionKey(prov_req);
     ASSERT_EQ(NO_ERROR, rc, "ProvisionKey");
   }
 
   {
-    ::trusty::aidl::Payload sign_req(test_hash, sizeof(test_hash));
+    ::tidl::Payload sign_req(test_hash, sizeof(test_hash));
     uint8_t signature[256];
-    ::trusty::aidl::Payload sign_resp(signature, sizeof(signature));
-    rc = cast_auth->SignHash(sign_req, &sign_resp);
+    ::tidl::Payload sign_resp(signature, sizeof(signature));
+    rc = cast_auth.SignHash(sign_req, &sign_resp);
     ASSERT_EQ(NO_ERROR, rc, "SignHash");
     ASSERT_EQ(sign_resp.size(), sizeof(test_signature), "signature size");
     for (unsigned int i = 0; i < sign_resp.size(); ++i) {
diff --git a/app/test-app/rules.mk b/app/test-app/rules.mk
index a42bcc8..02fc000 100644
--- a/app/test-app/rules.mk
+++ b/app/test-app/rules.mk
@@ -3,8 +3,6 @@
 
 TRUSTY_APP_NAME := cast_auth_test
 
-CAST_AUTH_USE_PREBUILTS := 1
-
 MODULE := $(LOCAL_DIR)
 
 MODULE_INCLUDES += \
@@ -15,27 +13,13 @@
 MODULE_SRCS += \
 	$(LOCAL_DIR)/main.cc
 
-ifeq ($(CAST_AUTH_USE_PREBUILTS),1)
-
-MODULE_INCLUDES += \
-	$(LOCAL_DIR)/../../aidl/generated \
-
-MODULE_SRCS += \
-	$(LOCAL_DIR)/../../aidl/generated/BpCastAuth.cpp \
-
-endif
-
 MODULE_LIBRARY_DEPS += \
 	trusty/user/base/lib/libstdc++-trusty \
 	trusty/user/base/lib/libc-trusty \
 	trusty/user/base/lib/unittest \
-	trusty/user/base/experimental/lib/binder-paidl \
-
-ifneq ($(CAST_AUTH_USE_PREBUILTS),1)
+	trusty/user/base/experimental/lib/tidl \
 
 MODULE_LIBRARY_DEPS += \
-	trusty/user/app/cast-auth/aidl \
-
-endif
+	trusty/user/app/cast-auth/aidl/Bp \
 
 include make/trusted_app.mk
diff --git a/build-config-usertests b/build-config-usertests
new file mode 100644
index 0000000..6204885
--- /dev/null
+++ b/build-config-usertests
@@ -0,0 +1,27 @@
+# Copyright (C) 2020 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+#  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This file lists userspace tests
+
+[
+    # Storage tests which require a nonsecure file
+    # These need Android or a similar resource to run, simple RPMB
+    # in testrunner is insufficient.
+    needs(
+        [
+            porttest("com.android.trusty.cast_auth.test"),
+        ],
+        storage_full=True,
+    ),
+]