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 std::vector<uint8_t> bcc_signature); 40 ScopedAStatus getHardwareInfo(RpcHardwareInfo* info) override; 41 42 ScopedAStatus generateEcdsaP256KeyPair(bool testMode, MacedPublicKey* macedPublicKey, 43 std::vector<uint8_t>* privateKeyHandle) override; 44 45 ScopedAStatus generateCertificateRequest(bool testMode, 46 const std::vector<MacedPublicKey>& keysToSign, 47 const std::vector<uint8_t>& endpointEncCertChain, 48 const std::vector<uint8_t>& challenge, 49 DeviceInfo* deviceInfo, ProtectedData* protectedData, 50 std::vector<uint8_t>* keysToSignMac) override; 51 52 ScopedAStatus generateCertificateRequestV2(const std::vector<MacedPublicKey>& keysToSign, 53 const std::vector<uint8_t>& challenge, 54 std::vector<uint8_t>* csr) override; 55 56 private: 57 ScopedAStatus getVerifiedDeviceInfo(cppbor::Map& deviceInfoMap); 58 ScopedAStatus getDeviceInfo(std::vector<uint8_t>* deviceInfo); 59 60 std::shared_ptr<IDrmPlugin> mDrm; 61 std::string mDrmVendor; 62 std::string mDrmDesc; 63 std::vector<uint8_t> mBcc; 64 std::vector<uint8_t> mBccSignature; 65 }; 66 } // namespace android::mediadrm 67 68 #endif // DRM_RKP_COMPONENT_H_