blob: 9879a941133009bab7ad0705f6961574d93c6035 [file] [log] [blame]
Max Bires01799e02021-04-19 18:58:04 -07001/*
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 <AndroidKeyMintDevice.h>
20#include <aidl/android/hardware/security/keymint/BnRemotelyProvisionedComponent.h>
21#include <aidl/android/hardware/security/keymint/RpcHardwareInfo.h>
22#include <aidl/android/hardware/security/keymint/SecurityLevel.h>
23#include <cppbor.h>
24#include <keymaster/UniquePtr.h>
25#include <keymaster/android_keymaster.h>
26
27namespace aidl::android::hardware::security::keymint {
28
29class AndroidRemotelyProvisionedComponentDevice : public BnRemotelyProvisionedComponent {
30 using ScopedAStatus = ::ndk::ScopedAStatus;
31
32 public:
33 explicit AndroidRemotelyProvisionedComponentDevice(
34 const std::shared_ptr<AndroidKeyMintDevice>& keymint);
35 virtual ~AndroidRemotelyProvisionedComponentDevice() = default;
36
37 ScopedAStatus getHardwareInfo(RpcHardwareInfo* info) override;
38
39 ScopedAStatus generateEcdsaP256KeyPair(bool testMode, MacedPublicKey* macedPublicKey,
40 std::vector<uint8_t>* privateKeyHandle) override;
41
42 ScopedAStatus generateCertificateRequest(bool testMode,
43 const std::vector<MacedPublicKey>& keysToSign,
44 const std::vector<uint8_t>& endpointEncCertChain,
45 const std::vector<uint8_t>& challenge,
46 DeviceInfo* deviceInfo, ProtectedData* protectedData,
47 std::vector<uint8_t>* keysToSignMac) override;
48
Tri Vo6cad4b42022-09-28 11:18:14 -070049 ScopedAStatus generateCertificateRequestV2(const std::vector<MacedPublicKey>& keysToSign,
50 const std::vector<uint8_t>& challenge,
51 std::vector<uint8_t>* csr) override;
52
Max Bires01799e02021-04-19 18:58:04 -070053 private:
54 std::shared_ptr<::keymaster::AndroidKeymaster> impl_;
55};
56
57} // namespace aidl::android::hardware::security::keymint