mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
drm@1.2 vts: force provision multiple security levels
Bug: 145112387 Bug: 145482532 Bug: 146190325 Bug: 146390725 Bug: 146401147 Bug: 146849109 Bug: 147314842 Bug: 147467803 Bug: 147704960 Test: DrmHalTest.OfflineLicenseTest Change-Id: I705507101b051ee6ac56fec36ca45d476bf82630
This commit is contained in:
@@ -176,6 +176,50 @@ hidl_array<uint8_t, 16> DrmHalTest::getVendorUUID() {
|
||||
return hidl_array<uint8_t, 16>(&uuid[0]);
|
||||
}
|
||||
|
||||
void DrmHalTest::provision() {
|
||||
hidl_string certificateType;
|
||||
hidl_string certificateAuthority;
|
||||
hidl_vec<uint8_t> provisionRequest;
|
||||
hidl_string defaultUrl;
|
||||
auto res = drmPlugin->getProvisionRequest_1_2(
|
||||
certificateType, certificateAuthority,
|
||||
[&](StatusV1_2 status, const hidl_vec<uint8_t>& request,
|
||||
const hidl_string& url) {
|
||||
if (status == StatusV1_2::OK) {
|
||||
EXPECT_NE(request.size(), 0u);
|
||||
provisionRequest = request;
|
||||
defaultUrl = url;
|
||||
} else if (status == StatusV1_2::ERROR_DRM_CANNOT_HANDLE) {
|
||||
EXPECT_EQ(0u, request.size());
|
||||
}
|
||||
});
|
||||
EXPECT_OK(res);
|
||||
|
||||
if (provisionRequest.size() > 0) {
|
||||
vector<uint8_t> response = vendorModule->handleProvisioningRequest(
|
||||
provisionRequest, defaultUrl);
|
||||
ASSERT_NE(0u, response.size());
|
||||
|
||||
auto res = drmPlugin->provideProvisionResponse(
|
||||
response, [&](StatusV1_0 status, const hidl_vec<uint8_t>&,
|
||||
const hidl_vec<uint8_t>&) {
|
||||
EXPECT_EQ(StatusV1_0::OK, status);
|
||||
});
|
||||
EXPECT_OK(res);
|
||||
}
|
||||
}
|
||||
|
||||
SessionId DrmHalTest::openSession(SecurityLevel level, StatusV1_0 *err) {
|
||||
SessionId sessionId;
|
||||
auto res = drmPlugin->openSession_1_1(level,
|
||||
[&](StatusV1_0 status, const hidl_vec<unsigned char> &id) {
|
||||
*err = status;
|
||||
sessionId = id;
|
||||
});
|
||||
EXPECT_OK(res);
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to open a session and verify that a non-empty
|
||||
* session ID is returned
|
||||
|
||||
@@ -36,14 +36,17 @@
|
||||
|
||||
using ::android::hardware::drm::V1_0::EventType;
|
||||
using ::android::hardware::drm::V1_0::KeyedVector;
|
||||
using KeyStatusV1_0 = ::android::hardware::drm::V1_0::KeyStatus;
|
||||
using ::android::hardware::drm::V1_0::KeyType;
|
||||
using ::android::hardware::drm::V1_0::Mode;
|
||||
using ::android::hardware::drm::V1_0::Pattern;
|
||||
using ::android::hardware::drm::V1_0::SessionId;
|
||||
using ::android::hardware::drm::V1_0::SubSample;
|
||||
|
||||
using KeyStatusV1_0 = ::android::hardware::drm::V1_0::KeyStatus;
|
||||
using StatusV1_0 = ::android::hardware::drm::V1_0::Status;
|
||||
|
||||
using ::android::hardware::drm::V1_1::ICryptoFactory;
|
||||
using ::android::hardware::drm::V1_1::SecurityLevel;
|
||||
|
||||
using StatusV1_2 = ::android::hardware::drm::V1_2::Status;
|
||||
|
||||
@@ -77,6 +80,8 @@ class DrmHalTest : public ::testing::TestWithParam<std::string> {
|
||||
|
||||
protected:
|
||||
hidl_array<uint8_t, 16> getVendorUUID();
|
||||
void provision();
|
||||
SessionId openSession(SecurityLevel level, StatusV1_0* err);
|
||||
SessionId openSession();
|
||||
void closeSession(const SessionId& sessionId);
|
||||
hidl_vec<uint8_t> loadKeys(const SessionId& sessionId,
|
||||
|
||||
@@ -48,6 +48,7 @@ static const char* const kDrmErrorTestKey = "drmErrorTest";
|
||||
static const char* const kDrmErrorInvalidState = "invalidState";
|
||||
static const char* const kDrmErrorResourceContention = "resourceContention";
|
||||
static const SecurityLevel kSwSecureCrypto = SecurityLevel::SW_SECURE_CRYPTO;
|
||||
static const SecurityLevel kHwSecureAll = SecurityLevel::HW_SECURE_ALL;
|
||||
|
||||
/**
|
||||
* Ensure drm factory supports module UUID Scheme
|
||||
@@ -97,35 +98,17 @@ TEST_P(DrmHalTest, BadMimeNotSupported) {
|
||||
* that is delivered back to the HAL.
|
||||
*/
|
||||
TEST_P(DrmHalTest, DoProvisioning) {
|
||||
hidl_string certificateType;
|
||||
hidl_string certificateAuthority;
|
||||
hidl_vec<uint8_t> provisionRequest;
|
||||
hidl_string defaultUrl;
|
||||
auto res = drmPlugin->getProvisionRequest_1_2(
|
||||
certificateType, certificateAuthority,
|
||||
[&](StatusV1_2 status, const hidl_vec<uint8_t>& request,
|
||||
const hidl_string& url) {
|
||||
if (status == StatusV1_2::OK) {
|
||||
EXPECT_NE(request.size(), 0u);
|
||||
provisionRequest = request;
|
||||
defaultUrl = url;
|
||||
} else if (status == StatusV1_2::ERROR_DRM_CANNOT_HANDLE) {
|
||||
EXPECT_EQ(0u, request.size());
|
||||
}
|
||||
});
|
||||
EXPECT_OK(res);
|
||||
|
||||
if (provisionRequest.size() > 0) {
|
||||
vector<uint8_t> response = vendorModule->handleProvisioningRequest(
|
||||
provisionRequest, defaultUrl);
|
||||
ASSERT_NE(0u, response.size());
|
||||
|
||||
auto res = drmPlugin->provideProvisionResponse(
|
||||
response, [&](Status status, const hidl_vec<uint8_t>&,
|
||||
const hidl_vec<uint8_t>&) {
|
||||
EXPECT_EQ(Status::OK, status);
|
||||
});
|
||||
EXPECT_OK(res);
|
||||
for (auto level : {kHwSecureAll, kSwSecureCrypto}) {
|
||||
StatusV1_0 err = StatusV1_0::OK;
|
||||
auto sid = openSession(level, &err);
|
||||
if (err == StatusV1_0::OK) {
|
||||
closeSession(sid);
|
||||
} else if (err == StatusV1_0::ERROR_DRM_CANNOT_HANDLE) {
|
||||
continue;
|
||||
} else {
|
||||
EXPECT_EQ(StatusV1_0::ERROR_DRM_NOT_PROVISIONED, err);
|
||||
provision();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,7 +399,6 @@ TEST_P(DrmHalTest, EncryptedAesCtrSegmentTestNoKeys) {
|
||||
* Ensure clearkey drm factory doesn't support security level higher than supported
|
||||
*/
|
||||
TEST_P(DrmHalClearkeyTest, BadLevelNotSupported) {
|
||||
const SecurityLevel kHwSecureAll = SecurityLevel::HW_SECURE_ALL;
|
||||
EXPECT_FALSE(drmFactory->isCryptoSchemeSupported_1_2(getVendorUUID(), kVideoMp4, kHwSecureAll));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user