blob: 893f560a796fa2848cadb75ab98516ca8e8ef30b [file] [log] [blame]
Kyle Zhangde0a90b2023-06-15 00:16:42 +00001/*
2 * Copyright (C) 2023 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#ifndef DRM_RKP_COMPONENT_H_
18#define DRM_RKP_COMPONENT_H_
19
20#include <aidl/android/hardware/drm/IDrmPlugin.h>
21#include <aidl/android/hardware/security/keymint/BnRemotelyProvisionedComponent.h>
22#include <aidl/android/hardware/security/keymint/RpcHardwareInfo.h>
23
24namespace android::mediadrm {
25
26using ::aidl::android::hardware::drm::IDrmPlugin;
27using ::aidl::android::hardware::security::keymint::BnRemotelyProvisionedComponent;
28using ::aidl::android::hardware::security::keymint::DeviceInfo;
29using ::aidl::android::hardware::security::keymint::MacedPublicKey;
30using ::aidl::android::hardware::security::keymint::ProtectedData;
31using ::aidl::android::hardware::security::keymint::RpcHardwareInfo;
32using ::ndk::ScopedAStatus;
33
34class DrmRemotelyProvisionedComponent : public BnRemotelyProvisionedComponent {
35 public:
36 DrmRemotelyProvisionedComponent(std::shared_ptr<IDrmPlugin> drm, std::string drmVendor,
37 std::string drmDesc);
38 ScopedAStatus getHardwareInfo(RpcHardwareInfo* info) override;
39
40 ScopedAStatus generateEcdsaP256KeyPair(bool testMode, MacedPublicKey* macedPublicKey,
41 std::vector<uint8_t>* privateKeyHandle) override;
42
43 ScopedAStatus generateCertificateRequest(bool testMode,
44 const std::vector<MacedPublicKey>& keysToSign,
45 const std::vector<uint8_t>& endpointEncCertChain,
46 const std::vector<uint8_t>& challenge,
47 DeviceInfo* deviceInfo, ProtectedData* protectedData,
48 std::vector<uint8_t>* keysToSignMac) override;
49
50 ScopedAStatus generateCertificateRequestV2(const std::vector<MacedPublicKey>& keysToSign,
51 const std::vector<uint8_t>& challenge,
52 std::vector<uint8_t>* csr) override;
53
54 private:
55 std::shared_ptr<IDrmPlugin> mDrm;
56 std::string mDrmVendor;
57 std::string mDrmDesc;
58};
59} // namespace android::mediadrm
60
61#endif // DRM_RKP_COMPONENT_H_