blob: f0467851169ad83c01f0b268d225dd3411b925bf [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>
Robert Shih1195d772023-07-10 11:54:57 -070023#include <cppbor.h>
Kyle Zhangde0a90b2023-06-15 00:16:42 +000024
25namespace android::mediadrm {
26
27using ::aidl::android::hardware::drm::IDrmPlugin;
28using ::aidl::android::hardware::security::keymint::BnRemotelyProvisionedComponent;
29using ::aidl::android::hardware::security::keymint::DeviceInfo;
30using ::aidl::android::hardware::security::keymint::MacedPublicKey;
31using ::aidl::android::hardware::security::keymint::ProtectedData;
32using ::aidl::android::hardware::security::keymint::RpcHardwareInfo;
33using ::ndk::ScopedAStatus;
34
35class DrmRemotelyProvisionedComponent : public BnRemotelyProvisionedComponent {
36 public:
37 DrmRemotelyProvisionedComponent(std::shared_ptr<IDrmPlugin> drm, std::string drmVendor,
Robert Shih569e8252023-07-12 12:50:41 -070038 std::string drmDesc, std::vector<uint8_t> bcc);
Kyle Zhangde0a90b2023-06-15 00:16:42 +000039 ScopedAStatus getHardwareInfo(RpcHardwareInfo* info) override;
40
41 ScopedAStatus generateEcdsaP256KeyPair(bool testMode, MacedPublicKey* macedPublicKey,
42 std::vector<uint8_t>* privateKeyHandle) override;
43
44 ScopedAStatus generateCertificateRequest(bool testMode,
45 const std::vector<MacedPublicKey>& keysToSign,
46 const std::vector<uint8_t>& endpointEncCertChain,
47 const std::vector<uint8_t>& challenge,
48 DeviceInfo* deviceInfo, ProtectedData* protectedData,
49 std::vector<uint8_t>* keysToSignMac) override;
50
51 ScopedAStatus generateCertificateRequestV2(const std::vector<MacedPublicKey>& keysToSign,
52 const std::vector<uint8_t>& challenge,
53 std::vector<uint8_t>* csr) override;
54
55 private:
Robert Shih1195d772023-07-10 11:54:57 -070056 ScopedAStatus getVerifiedDeviceInfo(cppbor::Map& deviceInfoMap);
57 ScopedAStatus getDeviceInfo(std::vector<uint8_t>* deviceInfo);
58
Kyle Zhangde0a90b2023-06-15 00:16:42 +000059 std::shared_ptr<IDrmPlugin> mDrm;
60 std::string mDrmVendor;
61 std::string mDrmDesc;
Robert Shih569e8252023-07-12 12:50:41 -070062 std::vector<uint8_t> mBcc;
Kyle Zhangde0a90b2023-06-15 00:16:42 +000063};
64} // namespace android::mediadrm
65
66#endif // DRM_RKP_COMPONENT_H_