1 /* 2 * Copyright (c) 2022, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <future> 20 #include <optional> 21 22 #include <android/hardware/security/keymint/IRemotelyProvisionedComponent.h> 23 #include <android/security/rkp/RemotelyProvisionedKey.h> 24 25 namespace android::security::rkp::support { 26 27 using ::android::hardware::security::keymint::IRemotelyProvisionedComponent; 28 using ::android::security::rkp::RemotelyProvisionedKey; 29 30 // Callers of getRpcKeyFuture() and getRpcKey() need at least two threads to 31 // retrieve the key, one to asynchronously handle binder callbacks and one to 32 // wait on the future. 33 std::optional<std::future<std::optional<RemotelyProvisionedKey>>> 34 getRpcKeyFuture(const sp<IRemotelyProvisionedComponent>& rpc, int32_t keyId); 35 36 std::optional<RemotelyProvisionedKey> getRpcKey(const sp<IRemotelyProvisionedComponent>& rpc, 37 int32_t keyId, int32_t timeout_sec = 10); 38 39 } // namespace android::security::rkp::support 40