Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e60fb412 authored by Cong Lin's avatar Cong Lin Committed by conglin
Browse files

DRM RKP interface to collect BCC signature (UdsCerts) and add to CSR

Flag: NONE Incremental updates for adding an optional field
Test: Manual test on Pixel 9
Bug: 355160637
Change-Id: I59e2485878b5e9f148ace501e315c747014fc0d4
parent 3eba0898
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@ using ::ndk::ScopedAStatus;
class DrmRemotelyProvisionedComponent : public BnRemotelyProvisionedComponent {
  public:
    DrmRemotelyProvisionedComponent(std::shared_ptr<IDrmPlugin> drm, std::string drmVendor,
                                    std::string drmDesc, std::vector<uint8_t> bcc);
                                    std::string drmDesc, std::vector<uint8_t> bcc,
                                    std::vector<uint8_t> bcc_signature);
    ScopedAStatus getHardwareInfo(RpcHardwareInfo* info) override;

    ScopedAStatus generateEcdsaP256KeyPair(bool testMode, MacedPublicKey* macedPublicKey,
@@ -60,6 +61,7 @@ class DrmRemotelyProvisionedComponent : public BnRemotelyProvisionedComponent {
    std::string mDrmVendor;
    std::string mDrmDesc;
    std::vector<uint8_t> mBcc;
    std::vector<uint8_t> mBccSignature;
};
}  // namespace android::mediadrm

+15 −9
Original line number Diff line number Diff line
@@ -28,11 +28,13 @@ namespace android::mediadrm {
DrmRemotelyProvisionedComponent::DrmRemotelyProvisionedComponent(std::shared_ptr<IDrmPlugin> drm,
                                                                 std::string drmVendor,
                                                                 std::string drmDesc,
                                                                 std::vector<uint8_t> bcc)
                                                                 std::vector<uint8_t> bcc,
                                                                 std::vector<uint8_t> bcc_signature)
    : mDrm(std::move(drm)),
      mDrmVendor(std::move(drmVendor)),
      mDrmDesc(std::move(drmDesc)),
      mBcc(std::move(bcc)) {}
      mBcc(std::move(bcc)),
      mBccSignature(std::move(bcc_signature)) {}

ScopedAStatus DrmRemotelyProvisionedComponent::getHardwareInfo(RpcHardwareInfo* info) {
    info->versionNumber = 3;
@@ -161,12 +163,16 @@ ScopedAStatus DrmRemotelyProvisionedComponent::generateCertificateRequestV2(
    }

    // assemble AuthenticatedRequest (definition in IRemotelyProvisionedComponent.aidl)
    *out = cppbor::Array()
                   .add(1 /* version */)
                   .add(cppbor::Map() /* UdsCerts */)
                   .add(cppbor::EncodedItem(mBcc))
                   .add(cppbor::EncodedItem(std::move(deviceSignedCsrPayload)))
                   .encode();
    cppbor::Array request_array = cppbor::Array().add(1 /* version */);
    if (!mBccSignature.empty()) {
        request_array.add(cppbor::EncodedItem(mBccSignature) /* UdsCerts */);
    } else {
        request_array.add(cppbor::Map() /* empty UdsCerts */);
    }
    request_array.add(cppbor::EncodedItem(mBcc))
            .add(cppbor::EncodedItem(std::move(deviceSignedCsrPayload)));
    *out = request_array.encode();

    return ScopedAStatus::ok();
}
}  // namespace android::mediadrm
 No newline at end of file
+10 −2
Original line number Diff line number Diff line
@@ -87,13 +87,21 @@ getDrmRemotelyProvisionedComponents() {
                          status.getDescription().c_str());
                    return;
                }

                std::vector<uint8_t> bcc_signature;
                status =
                        mDrm->getPropertyByteArray("bootCertificateChainSignature", &bcc_signature);
                if (!status.isOk()) {
                    ALOGW("mDrm->getPropertyByteArray(\"bootCertificateChainSignature\") failed."
                          "Detail: [%s].",
                          status.getDescription().c_str());
                    // bcc signature is optional, no need to return when it is unavailable.
                }
                std::string compName(instance);
                auto comps = static_cast<
                        std::map<std::string, std::shared_ptr<IRemotelyProvisionedComponent>>*>(
                        context);
                (*comps)[compName] = ::ndk::SharedRefBase::make<DrmRemotelyProvisionedComponent>(
                        mDrm, drmVendor, drmDesc, bcc);
                        mDrm, drmVendor, drmDesc, bcc, bcc_signature);
            });
    return comps;
}