| Kyle Zhang | de0a90b | 2023-06-15 00:16:42 +0000 | [diff] [blame] | 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> |
| Robert Shih | 1195d77 | 2023-07-10 11:54:57 -0700 | [diff] [blame] | 23 | #include <cppbor.h> |
| Kyle Zhang | de0a90b | 2023-06-15 00:16:42 +0000 | [diff] [blame] | 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, |
| Robert Shih | 569e825 | 2023-07-12 12:50:41 -0700 | [diff] [blame] | 38 | std::string drmDesc, std::vector<uint8_t> bcc); |
| Kyle Zhang | de0a90b | 2023-06-15 00:16:42 +0000 | [diff] [blame] | 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: |
| Robert Shih | 1195d77 | 2023-07-10 11:54:57 -0700 | [diff] [blame] | 56 | ScopedAStatus getVerifiedDeviceInfo(cppbor::Map& deviceInfoMap); |
| 57 | ScopedAStatus getDeviceInfo(std::vector<uint8_t>* deviceInfo); |
| 58 | |
| Kyle Zhang | de0a90b | 2023-06-15 00:16:42 +0000 | [diff] [blame] | 59 | std::shared_ptr<IDrmPlugin> mDrm; |
| 60 | std::string mDrmVendor; |
| 61 | std::string mDrmDesc; |
| Robert Shih | 569e825 | 2023-07-12 12:50:41 -0700 | [diff] [blame] | 62 | std::vector<uint8_t> mBcc; |
| Kyle Zhang | de0a90b | 2023-06-15 00:16:42 +0000 | [diff] [blame] | 63 | }; |
| 64 | } // namespace android::mediadrm |
| 65 | |
| 66 | #endif // DRM_RKP_COMPONENT_H_ |