Integration tests to verify clear lead content plays successfully
Also added a unit test to verify that decryption without a license fails
with the correct error code. Also changed comment types for policy
integration tests and core integration tests to be picked up by Doxygen.
Bug: 320785945
Merged from https://widevine-internal-review.googlesource.com/194910
Change-Id: Ibdb70683003bb430dde9b4a1bd9fc9839bace342
(cherry picked from commit d05d3738b4)
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// Agreement.
|
||||
|
||||
#include "certificate_provisioning.h"
|
||||
#include "license_holder.h"
|
||||
#include "log.h"
|
||||
#include "provisioning_holder.h"
|
||||
#include "test_base.h"
|
||||
@@ -129,9 +130,11 @@ class CoreIntegrationTest : public WvCdmTestBaseWithEngine {
|
||||
}
|
||||
};
|
||||
|
||||
// Verify that SPOIDs and DRM certificate serial number are stable between
|
||||
// factory resets/provisioning attempts for the same app and different between
|
||||
// different apps. Test using two different apps and origins.
|
||||
/**
|
||||
* Verify that SPOIDs and DRM certificate serial number are stable between
|
||||
* factory resets/provisioning attempts for the same app and different between
|
||||
* different apps. Test using two different apps and origins.
|
||||
*/
|
||||
TEST_F(CoreIntegrationTest, ProvisioningStableSpoidTest) {
|
||||
std::string level;
|
||||
ASSERT_EQ(
|
||||
@@ -234,4 +237,44 @@ TEST_F(CoreIntegrationTest, ProvisioningStableSpoidTest) {
|
||||
ASSERT_NE(drm_cert_serial_number_app_1_origin_1[0],
|
||||
drm_cert_serial_number_app_1_origin_2[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* A clear lead without a license loaded.
|
||||
*/
|
||||
TEST_F(CoreIntegrationTest, ClearLead) {
|
||||
LicenseHolder holder("CDM_Streaming", &cdm_engine_, config_);
|
||||
const KeyId key_id = "";
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(holder.OpenSession());
|
||||
ASSERT_NO_FATAL_FAILURE(holder.FetchLicense());
|
||||
EXPECT_EQ(NO_ERROR, holder.DecryptClearLead(key_id));
|
||||
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
|
||||
}
|
||||
|
||||
/**
|
||||
* Playback clear lead with a license loaded. Playback should succeed.
|
||||
*/
|
||||
TEST_F(CoreIntegrationTest, ClearLeadAfterLicenseLoad) {
|
||||
LicenseHolder holder("CDM_Streaming", &cdm_engine_, config_);
|
||||
const KeyId key_id = "";
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(holder.OpenSession());
|
||||
ASSERT_NO_FATAL_FAILURE(holder.FetchLicense());
|
||||
ASSERT_NO_FATAL_FAILURE(holder.LoadLicense());
|
||||
EXPECT_EQ(NO_ERROR, holder.DecryptClearLead(key_id));
|
||||
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt without a license loaded. Decrypt should fail with a NEED_KEY error.
|
||||
*/
|
||||
TEST_F(CoreIntegrationTest, NeedKeyBeforeLicenseLoad) {
|
||||
LicenseHolder holder("CDM_Streaming", &cdm_engine_, config_);
|
||||
const KeyId key_id = "0000000000000000";
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(holder.OpenSession());
|
||||
ASSERT_NO_FATAL_FAILURE(holder.FetchLicense());
|
||||
EXPECT_EQ(NEED_KEY, holder.Decrypt(key_id));
|
||||
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
|
||||
}
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -114,6 +114,20 @@ CdmResponseType LicenseHolder::Decrypt(const std::string& key_id) {
|
||||
return cdm_engine_->DecryptV16(session_id_, params);
|
||||
}
|
||||
|
||||
CdmResponseType LicenseHolder::DecryptClearLead(const std::string& key_id) {
|
||||
constexpr size_t buffer_size = 500;
|
||||
const std::vector<uint8_t> input(buffer_size, 0);
|
||||
std::vector<uint8_t> output(buffer_size, 0);
|
||||
const std::vector<uint8_t> iv(KEY_IV_SIZE, 0);
|
||||
CdmDecryptionParametersV16 params(key_id);
|
||||
params.is_secure = false;
|
||||
CdmDecryptionSample sample(input.data(), output.data(), 0, input.size(), iv);
|
||||
CdmDecryptionSubsample subsample(input.size(), 0);
|
||||
sample.subsamples.push_back(subsample);
|
||||
params.samples.push_back(sample);
|
||||
return cdm_engine_->DecryptV16(session_id_, params);
|
||||
}
|
||||
|
||||
void LicenseHolder::DecryptSecure(const KeyId& key_id) {
|
||||
ASSERT_TRUE(wvoec::global_features.test_secure_buffers);
|
||||
constexpr size_t buffer_size = 500;
|
||||
|
||||
@@ -78,6 +78,9 @@ class LicenseHolder {
|
||||
// Try to decrypt some random data. This does not verify that the data is
|
||||
// decrypted correctly. Returns the result of the decrypt operation.
|
||||
CdmResponseType Decrypt(const std::string& key_id);
|
||||
// Try to copy the clear lead to a secure buffer. Returns the result of the
|
||||
// copy buffer operation.
|
||||
CdmResponseType DecryptClearLead(const std::string& key_id);
|
||||
// Try to decrypt some random data to a secure buffer. If the test harness
|
||||
// does not allow creating a secure buffer, then this function fails
|
||||
// immediately. Otherwise, a secure buffer is created and used for a
|
||||
|
||||
@@ -34,7 +34,9 @@ class CorePIGTest : public WvCdmTestBaseWithEngine {
|
||||
}
|
||||
};
|
||||
|
||||
// An offline license with nonce not required.
|
||||
/**
|
||||
* An offline license with nonce not required.
|
||||
*/
|
||||
TEST_F(CorePIGTest, OfflineNoNonce) {
|
||||
LicenseHolder holder("CDM_OfflineNoNonce", &cdm_engine_, config_);
|
||||
holder.set_can_persist(true);
|
||||
@@ -53,7 +55,9 @@ TEST_F(CorePIGTest, OfflineNoNonce) {
|
||||
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
|
||||
}
|
||||
|
||||
// An offline license with nonce and provider session token.
|
||||
/**
|
||||
* An offline license with nonce and provider session token.
|
||||
*/
|
||||
TEST_F(CorePIGTest, OfflineWithPST) {
|
||||
LicenseHolder holder("CDM_OfflineWithPST", &cdm_engine_, config_);
|
||||
holder.set_can_persist(true);
|
||||
|
||||
Reference in New Issue
Block a user