1 /*
2  * Copyright 2021, 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 <cstdint>
20 #include <vector>
21 
22 #include <aidl/android/hardware/security/keymint/BnRemotelyProvisionedComponent.h>
23 #include <aidl/android/hardware/security/keymint/MacedPublicKey.h>
24 #include <aidl/android/hardware/security/keymint/RpcHardwareInfo.h>
25 #include <aidl/android/hardware/security/keymint/SecurityLevel.h>
26 
27 #include "KeyMintUtils.h"
28 #include "guest/hals/keymint/remote/remote_keymaster.h"
29 
30 namespace aidl::android::hardware::security::keymint {
31 
32 class RemoteRemotelyProvisionedComponent
33     : public BnRemotelyProvisionedComponent {
34  public:
35   explicit RemoteRemotelyProvisionedComponent(keymaster::RemoteKeymaster& impl);
36 
37   ndk::ScopedAStatus getHardwareInfo(RpcHardwareInfo* info) override;
38 
39   ndk::ScopedAStatus generateEcdsaP256KeyPair(
40       bool testMode, MacedPublicKey* macedPublicKey,
41       std::vector<uint8_t>* privateKeyHandle) override;
42 
43   ndk::ScopedAStatus generateCertificateRequest(
44       bool testMode, const std::vector<MacedPublicKey>& keysToSign,
45       const std::vector<uint8_t>& endpointEncCertChain,
46       const std::vector<uint8_t>& challenge, DeviceInfo* deviceInfo,
47       ProtectedData* protectedData,
48       std::vector<uint8_t>* keysToSignMac) override;
49 
50   ndk::ScopedAStatus generateCertificateRequestV2(
51       const std::vector<MacedPublicKey>& keysToSign,
52       const std::vector<uint8_t>& challenge,
53       std::vector<uint8_t>* csr) override;
54 
55  private:
56   keymaster::RemoteKeymaster& impl_;
57 };
58 
59 }  // namespace aidl::android::hardware::security::keymint
60