xref: /aosp_15_r20/frameworks/av/drm/libmediadrmrkp/include/DrmRemotelyProvisionedComponent.h (revision ec779b8e0859a360c3d303172224686826e6e0e1)
1*ec779b8eSAndroid Build Coastguard Worker /*
2*ec779b8eSAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
3*ec779b8eSAndroid Build Coastguard Worker  *
4*ec779b8eSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*ec779b8eSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*ec779b8eSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*ec779b8eSAndroid Build Coastguard Worker  *
8*ec779b8eSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*ec779b8eSAndroid Build Coastguard Worker  *
10*ec779b8eSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*ec779b8eSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*ec779b8eSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*ec779b8eSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*ec779b8eSAndroid Build Coastguard Worker  * limitations under the License.
15*ec779b8eSAndroid Build Coastguard Worker  */
16*ec779b8eSAndroid Build Coastguard Worker 
17*ec779b8eSAndroid Build Coastguard Worker #ifndef DRM_RKP_COMPONENT_H_
18*ec779b8eSAndroid Build Coastguard Worker #define DRM_RKP_COMPONENT_H_
19*ec779b8eSAndroid Build Coastguard Worker 
20*ec779b8eSAndroid Build Coastguard Worker #include <aidl/android/hardware/drm/IDrmPlugin.h>
21*ec779b8eSAndroid Build Coastguard Worker #include <aidl/android/hardware/security/keymint/BnRemotelyProvisionedComponent.h>
22*ec779b8eSAndroid Build Coastguard Worker #include <aidl/android/hardware/security/keymint/RpcHardwareInfo.h>
23*ec779b8eSAndroid Build Coastguard Worker #include <cppbor.h>
24*ec779b8eSAndroid Build Coastguard Worker 
25*ec779b8eSAndroid Build Coastguard Worker namespace android::mediadrm {
26*ec779b8eSAndroid Build Coastguard Worker 
27*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::hardware::drm::IDrmPlugin;
28*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::hardware::security::keymint::BnRemotelyProvisionedComponent;
29*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::hardware::security::keymint::DeviceInfo;
30*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::hardware::security::keymint::MacedPublicKey;
31*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::hardware::security::keymint::ProtectedData;
32*ec779b8eSAndroid Build Coastguard Worker using ::aidl::android::hardware::security::keymint::RpcHardwareInfo;
33*ec779b8eSAndroid Build Coastguard Worker using ::ndk::ScopedAStatus;
34*ec779b8eSAndroid Build Coastguard Worker 
35*ec779b8eSAndroid Build Coastguard Worker class DrmRemotelyProvisionedComponent : public BnRemotelyProvisionedComponent {
36*ec779b8eSAndroid Build Coastguard Worker   public:
37*ec779b8eSAndroid Build Coastguard Worker     DrmRemotelyProvisionedComponent(std::shared_ptr<IDrmPlugin> drm, std::string drmVendor,
38*ec779b8eSAndroid Build Coastguard Worker                                     std::string drmDesc, std::vector<uint8_t> bcc,
39*ec779b8eSAndroid Build Coastguard Worker                                     std::vector<uint8_t> bcc_signature);
40*ec779b8eSAndroid Build Coastguard Worker     ScopedAStatus getHardwareInfo(RpcHardwareInfo* info) override;
41*ec779b8eSAndroid Build Coastguard Worker 
42*ec779b8eSAndroid Build Coastguard Worker     ScopedAStatus generateEcdsaP256KeyPair(bool testMode, MacedPublicKey* macedPublicKey,
43*ec779b8eSAndroid Build Coastguard Worker                                            std::vector<uint8_t>* privateKeyHandle) override;
44*ec779b8eSAndroid Build Coastguard Worker 
45*ec779b8eSAndroid Build Coastguard Worker     ScopedAStatus generateCertificateRequest(bool testMode,
46*ec779b8eSAndroid Build Coastguard Worker                                              const std::vector<MacedPublicKey>& keysToSign,
47*ec779b8eSAndroid Build Coastguard Worker                                              const std::vector<uint8_t>& endpointEncCertChain,
48*ec779b8eSAndroid Build Coastguard Worker                                              const std::vector<uint8_t>& challenge,
49*ec779b8eSAndroid Build Coastguard Worker                                              DeviceInfo* deviceInfo, ProtectedData* protectedData,
50*ec779b8eSAndroid Build Coastguard Worker                                              std::vector<uint8_t>* keysToSignMac) override;
51*ec779b8eSAndroid Build Coastguard Worker 
52*ec779b8eSAndroid Build Coastguard Worker     ScopedAStatus generateCertificateRequestV2(const std::vector<MacedPublicKey>& keysToSign,
53*ec779b8eSAndroid Build Coastguard Worker                                                const std::vector<uint8_t>& challenge,
54*ec779b8eSAndroid Build Coastguard Worker                                                std::vector<uint8_t>* csr) override;
55*ec779b8eSAndroid Build Coastguard Worker 
56*ec779b8eSAndroid Build Coastguard Worker   private:
57*ec779b8eSAndroid Build Coastguard Worker     ScopedAStatus getVerifiedDeviceInfo(cppbor::Map& deviceInfoMap);
58*ec779b8eSAndroid Build Coastguard Worker     ScopedAStatus getDeviceInfo(std::vector<uint8_t>* deviceInfo);
59*ec779b8eSAndroid Build Coastguard Worker 
60*ec779b8eSAndroid Build Coastguard Worker     std::shared_ptr<IDrmPlugin> mDrm;
61*ec779b8eSAndroid Build Coastguard Worker     std::string mDrmVendor;
62*ec779b8eSAndroid Build Coastguard Worker     std::string mDrmDesc;
63*ec779b8eSAndroid Build Coastguard Worker     std::vector<uint8_t> mBcc;
64*ec779b8eSAndroid Build Coastguard Worker     std::vector<uint8_t> mBccSignature;
65*ec779b8eSAndroid Build Coastguard Worker };
66*ec779b8eSAndroid Build Coastguard Worker }  // namespace android::mediadrm
67*ec779b8eSAndroid Build Coastguard Worker 
68*ec779b8eSAndroid Build Coastguard Worker #endif  // DRM_RKP_COMPONENT_H_