1 /* 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 #include <cppbor.h> 24 25 namespace android::mediadrm { 26 27 using ::aidl::android::hardware::drm::IDrmPlugin; 28 using ::aidl::android::hardware::security::keymint::BnRemotelyProvisionedComponent; 29 using ::aidl::android::hardware::security::keymint::DeviceInfo; 30 using ::aidl::android::hardware::security::keymint::MacedPublicKey; 31 using ::aidl::android::hardware::security::keymint::ProtectedData; 32 using ::aidl::android::hardware::security::keymint::RpcHardwareInfo; 33 using ::ndk::ScopedAStatus; 34 35 class DrmRemotelyProvisionedComponent : public BnRemotelyProvisionedComponent { 36 public: 37 DrmRemotelyProvisionedComponent(std::shared_ptr<IDrmPlugin> drm, std::string drmVendor, 38 std::string drmDesc, std::vector<uint8_t> bcc); 39 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: 56 ScopedAStatus getVerifiedDeviceInfo(cppbor::Map& deviceInfoMap); 57 ScopedAStatus getDeviceInfo(std::vector<uint8_t>* deviceInfo); 58 59 std::shared_ptr<IDrmPlugin> mDrm; 60 std::string mDrmVendor; 61 std::string mDrmDesc; 62 std::vector<uint8_t> mBcc; 63 }; 64 } // namespace android::mediadrm 65 66 #endif // DRM_RKP_COMPONENT_H_