diff --git a/identity/Android.bp b/identity/Android.bp
index ecf667d..f4fcc0a 100644
--- a/identity/Android.bp
+++ b/identity/Android.bp
@@ -36,7 +36,6 @@
         "CredentialData.cpp",
         "CredentialStore.cpp",
         "CredentialStoreFactory.cpp",
-        "RemotelyProvisionedKey.cpp",
         "Session.cpp",
         "Util.cpp",
         "WritableCredential.cpp",
@@ -55,6 +54,7 @@
         "libhidlbase",
         "libkeymaster4support",
         "libkeystore-attestation-application-id",
+        "librkp_support",
         "libutils",
         "libutilscallstack",
         "libvintf",
diff --git a/identity/CredentialStore.cpp b/identity/CredentialStore.cpp
index e200cb5..cb2e8c7 100644
--- a/identity/CredentialStore.cpp
+++ b/identity/CredentialStore.cpp
@@ -24,12 +24,12 @@
 #include <android/hardware/security/keymint/RpcHardwareInfo.h>
 #include <binder/IPCThreadState.h>
 #include <binder/IServiceManager.h>
+#include <rkp/support/rkpd_client.h>
 #include <vintf/VintfObject.h>
 
 #include "Credential.h"
 #include "CredentialData.h"
 #include "CredentialStore.h"
-#include "RemotelyProvisionedKey.h"
 #include "Session.h"
 #include "Util.h"
 #include "WritableCredential.h"
@@ -39,7 +39,8 @@
 namespace identity {
 namespace {
 
-using ::android::security::rkp::IRemoteProvisioning;
+using ::android::security::rkp::RemotelyProvisionedKey;
+using ::android::security::rkp::support::getRpcKey;
 
 }  // namespace
 
@@ -183,17 +184,7 @@
     LOG(INFO) << "Fetching attestation key from RKPD";
 
     uid_t callingUid = android::IPCThreadState::self()->getCallingUid();
-    auto rpcKeyFuture = getRpcKeyFuture(rpc_, callingUid);
-    if (!rpcKeyFuture) {
-        return Status::fromServiceSpecificError(ERROR_GENERIC, "Error in getRpcKeyFuture()");
-    }
-
-    if (rpcKeyFuture->wait_for(std::chrono::seconds(10)) != std::future_status::ready) {
-        return Status::fromServiceSpecificError(
-            ERROR_GENERIC, "Waiting for remotely provisioned attestation key timed out");
-    }
-
-    std::optional<::android::security::rkp::RemotelyProvisionedKey> key = rpcKeyFuture->get();
+    std::optional<RemotelyProvisionedKey> key = getRpcKey(rpc_, callingUid);
     if (!key) {
         return Status::fromServiceSpecificError(
             ERROR_GENERIC, "Failed to get remotely provisioned attestation key");
diff --git a/identity/CredentialStore.h b/identity/CredentialStore.h
index 32c9975..8bc02e8 100644
--- a/identity/CredentialStore.h
+++ b/identity/CredentialStore.h
@@ -22,7 +22,6 @@
 
 #include <android/hardware/identity/IIdentityCredentialStore.h>
 #include <android/security/identity/BnCredentialStore.h>
-#include <android/security/rkp/IRemoteProvisioning.h>
 
 namespace android {
 namespace security {
diff --git a/identity/RemotelyProvisionedKey.cpp b/identity/RemotelyProvisionedKey.cpp
deleted file mode 100644
index 784a680..0000000
--- a/identity/RemotelyProvisionedKey.cpp
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2019, 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 LOG_TAG "credstore"
-
-#include <atomic>
-
-#include <android-base/logging.h>
-#include <android/security/rkp/BnGetKeyCallback.h>
-#include <android/security/rkp/BnGetRegistrationCallback.h>
-#include <android/security/rkp/IGetKeyCallback.h>
-#include <android/security/rkp/IRemoteProvisioning.h>
-#include <binder/IServiceManager.h>
-#include <binder/Status.h>
-#include <vintf/VintfObject.h>
-
-#include "RemotelyProvisionedKey.h"
-
-namespace android {
-namespace security {
-namespace identity {
-namespace {
-
-using ::android::binder::Status;
-using ::android::hardware::security::keymint::IRemotelyProvisionedComponent;
-using ::android::hardware::security::keymint::RpcHardwareInfo;
-using ::android::security::rkp::BnGetKeyCallback;
-using ::android::security::rkp::BnGetRegistrationCallback;
-using ::android::security::rkp::IGetKeyCallback;
-using ::android::security::rkp::IRegistration;
-using ::android::security::rkp::IRemoteProvisioning;
-using ::android::security::rkp::RemotelyProvisionedKey;
-
-constexpr const char* kRemoteProvisioningServiceName = "remote_provisioning";
-
-std::optional<String16> findRpcNameById(std::string_view targetRpcId) {
-    auto deviceManifest = vintf::VintfObject::GetDeviceHalManifest();
-    auto instances = deviceManifest->getAidlInstances("android.hardware.security.keymint",
-                                                      "IRemotelyProvisionedComponent");
-    for (const std::string& instance : instances) {
-        auto rpcName =
-            IRemotelyProvisionedComponent::descriptor + String16("/") + String16(instance.c_str());
-        sp<IRemotelyProvisionedComponent> rpc =
-            android::waitForService<IRemotelyProvisionedComponent>(rpcName);
-
-        auto rpcId = getRpcId(rpc);
-        if (!rpcId) {
-            continue;
-        }
-        if (*rpcId == targetRpcId) {
-            return rpcName;
-        }
-    }
-
-    LOG(ERROR) << "Remotely provisioned component with given unique ID: " << targetRpcId
-               << " not found";
-    return std::nullopt;
-}
-
-std::optional<String16> getRpcName(const sp<IRemotelyProvisionedComponent>& rpc) {
-    std::optional<std::string> targetRpcId = getRpcId(rpc);
-    if (!targetRpcId) {
-        return std::nullopt;
-    }
-    return findRpcNameById(*targetRpcId);
-}
-
-class GetKeyCallback : public BnGetKeyCallback {
-  public:
-    GetKeyCallback(std::promise<std::optional<RemotelyProvisionedKey>> keyPromise)
-        : keyPromise_(std::move(keyPromise)), called_() {}
-
-    Status onSuccess(const RemotelyProvisionedKey& key) override {
-        if (called_.test_and_set()) {
-            return Status::ok();
-        }
-        keyPromise_.set_value(key);
-        return Status::ok();
-    }
-    Status onCancel() override {
-        if (called_.test_and_set()) {
-            return Status::ok();
-        }
-        LOG(ERROR) << "GetKeyCallback cancelled";
-        keyPromise_.set_value(std::nullopt);
-        return Status::ok();
-    }
-    Status onError(IGetKeyCallback::ErrorCode error, const String16& description) override {
-        if (called_.test_and_set()) {
-            return Status::ok();
-        }
-        LOG(ERROR) << "GetKeyCallback failed: " << static_cast<int>(error) << ", " << description;
-        keyPromise_.set_value(std::nullopt);
-        return Status::ok();
-    }
-
-  private:
-    std::promise<std::optional<RemotelyProvisionedKey>> keyPromise_;
-    // This callback can only be called into once
-    std::atomic_flag called_;
-};
-
-class GetRegistrationCallback : public BnGetRegistrationCallback {
-  public:
-    GetRegistrationCallback(std::promise<std::optional<RemotelyProvisionedKey>> keyPromise,
-                            uint32_t keyId)
-        : keyPromise_(std::move(keyPromise)), keyId_(keyId), called_() {}
-
-    Status onSuccess(const sp<IRegistration>& registration) override {
-        if (called_.test_and_set()) {
-            return Status::ok();
-        }
-        auto cb = sp<GetKeyCallback>::make(std::move(keyPromise_));
-        auto status = registration->getKey(keyId_, cb);
-        if (!status.isOk()) {
-            cb->onError(IGetKeyCallback::ErrorCode::ERROR_UNKNOWN,
-                        String16("Failed to register GetKeyCallback"));
-        }
-        return Status::ok();
-    }
-    Status onCancel() override {
-        if (called_.test_and_set()) {
-            return Status::ok();
-        }
-        LOG(ERROR) << "GetRegistrationCallback cancelled";
-        keyPromise_.set_value(std::nullopt);
-        return Status::ok();
-    }
-    Status onError(const String16& error) override {
-        if (called_.test_and_set()) {
-            return Status::ok();
-        }
-        LOG(ERROR) << "GetRegistrationCallback failed: " << error;
-        keyPromise_.set_value(std::nullopt);
-        return Status::ok();
-    }
-
-  private:
-    std::promise<std::optional<RemotelyProvisionedKey>> keyPromise_;
-    int32_t keyId_;
-    // This callback can only be called into once
-    std::atomic_flag called_;
-};
-
-}  // namespace
-
-std::optional<std::string> getRpcId(const sp<IRemotelyProvisionedComponent>& rpc) {
-    RpcHardwareInfo rpcHwInfo;
-    Status status = rpc->getHardwareInfo(&rpcHwInfo);
-    if (!status.isOk()) {
-        LOG(ERROR) << "Error getting remotely provisioned component hardware info: " << status;
-        return std::nullopt;
-    }
-
-    if (!rpcHwInfo.uniqueId) {
-        LOG(ERROR) << "Remotely provisioned component is missing a unique id, which is "
-                   << "required for credential key remotely provisioned attestation keys. "
-                   << "This is a bug in the vendor implementation.";
-        return std::nullopt;
-    }
-
-    return *rpcHwInfo.uniqueId;
-}
-
-std::optional<std::future<std::optional<RemotelyProvisionedKey>>>
-getRpcKeyFuture(const sp<IRemotelyProvisionedComponent>& rpc, int32_t keyId) {
-    std::promise<std::optional<RemotelyProvisionedKey>> keyPromise;
-    auto keyFuture = keyPromise.get_future();
-
-    auto rpcName = getRpcName(rpc);
-    if (!rpcName) {
-        LOG(ERROR) << "Failed to get IRemotelyProvisionedComponent name";
-        return std::nullopt;
-    }
-
-    sp<IRemoteProvisioning> remoteProvisioning =
-        android::waitForService<IRemoteProvisioning>(String16(kRemoteProvisioningServiceName));
-    if (!remoteProvisioning) {
-        LOG(ERROR) << "Failed to get IRemoteProvisioning HAL";
-        return std::nullopt;
-    }
-
-    auto cb = sp<GetRegistrationCallback>::make(std::move(keyPromise), keyId);
-    Status status = remoteProvisioning->getRegistration(*rpcName, cb);
-    if (!status.isOk()) {
-        LOG(ERROR) << "Failed getRegistration()";
-        return std::nullopt;
-    }
-
-    return keyFuture;
-}
-
-}  // namespace identity
-}  // namespace security
-}  // namespace android
diff --git a/identity/RemotelyProvisionedKey.h b/identity/RemotelyProvisionedKey.h
deleted file mode 100644
index e7ddfca..0000000
--- a/identity/RemotelyProvisionedKey.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-#pragma once
-
-#include <future>
-#include <optional>
-
-#include <android/hardware/security/keymint/IRemotelyProvisionedComponent.h>
-
-namespace android {
-namespace security {
-namespace identity {
-
-using ::android::hardware::security::keymint::IRemotelyProvisionedComponent;
-using ::android::security::rkp::RemotelyProvisionedKey;
-
-std::optional<std::string> getRpcId(const sp<IRemotelyProvisionedComponent>& rpc);
-
-std::optional<std::future<std::optional<RemotelyProvisionedKey>>>
-getRpcKeyFuture(const sp<IRemotelyProvisionedComponent>& rpc, int32_t keyId);
-
-}  // namespace identity
-}  // namespace security
-}  // namespace android
