Source release v2.1.5-0-811 + third_party libs
Change-Id: Ic8eafba071e486e671257bc22a8208e86d68b08a
This commit is contained in:
@@ -83,8 +83,9 @@ class CdmSession {
|
||||
virtual void OnTimerEvent();
|
||||
virtual void OnKeyReleaseEvent(const CdmKeySetId& key_set_id);
|
||||
|
||||
virtual SecurityLevel GetRequestedSecurityLevel();
|
||||
virtual CdmSecurityLevel GetSecurityLevel();
|
||||
virtual SecurityLevel GetRequestedSecurityLevel() {
|
||||
return requested_security_level_; }
|
||||
virtual CdmSecurityLevel GetSecurityLevel() { return security_level_; }
|
||||
|
||||
virtual CdmResponseType UpdateUsageInformation();
|
||||
|
||||
@@ -119,7 +120,9 @@ class CdmSession {
|
||||
bool is_release_;
|
||||
bool is_usage_update_needed_;
|
||||
bool is_initial_decryption_;
|
||||
|
||||
CdmSecurityLevel security_level_;
|
||||
SecurityLevel requested_security_level_;
|
||||
|
||||
// information useful for offline and usage scenarios
|
||||
CdmKeyMessage key_request_;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace wvcdm {
|
||||
|
||||
bool BufferReader::Read1(uint8_t* v) {
|
||||
if (!HasBytes(1)) {
|
||||
LOGE("BufferReader::Read1 : Failure while parsing: Not enough bytes (1)");
|
||||
LOGW("BufferReader::Read1 : Failure while parsing: Not enough bytes (1)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ bool BufferReader::Read1(uint8_t* v) {
|
||||
// Internal implementation of multi-byte reads
|
||||
template<typename T> bool BufferReader::Read(T* v) {
|
||||
if (!HasBytes(sizeof(T))) {
|
||||
LOGE("BufferReader::Read<T> : Failure during parse: Not enough bytes (%u)",
|
||||
LOGW("BufferReader::Read<T> : Failure during parse: Not enough bytes (%u)",
|
||||
sizeof(T));
|
||||
return false;
|
||||
}
|
||||
@@ -42,7 +42,7 @@ bool BufferReader::Read8s(int64_t* v) { return Read(v); }
|
||||
|
||||
bool BufferReader::ReadString(std::string* str, int count) {
|
||||
if (!HasBytes(count)) {
|
||||
LOGE("BufferReader::ReadString : Parse Failure: Not enough bytes (%d)",
|
||||
LOGW("BufferReader::ReadString : Parse Failure: Not enough bytes (%d)",
|
||||
count);
|
||||
return false;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ bool BufferReader::ReadString(std::string* str, int count) {
|
||||
|
||||
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, int count) {
|
||||
if (!HasBytes(count)) {
|
||||
LOGE("BufferReader::ReadVec : Parse Failure: Not enough bytes (%d)", count);
|
||||
LOGW("BufferReader::ReadVec : Parse Failure: Not enough bytes (%d)", count);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ bool BufferReader::ReadVec(std::vector<uint8_t>* vec, int count) {
|
||||
|
||||
bool BufferReader::SkipBytes(int bytes) {
|
||||
if (!HasBytes(bytes)) {
|
||||
LOGE("BufferReader::SkipBytes : Parse Failure: Not enough bytes (%d)",
|
||||
LOGW("BufferReader::SkipBytes : Parse Failure: Not enough bytes (%d)",
|
||||
bytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -73,8 +73,12 @@ void CdmSession::Create(
|
||||
is_release_ = false;
|
||||
is_usage_update_needed_ = false;
|
||||
is_initial_decryption_ = true;
|
||||
security_level_ = crypto_session_.get()->GetSecurityLevel();
|
||||
if (cdm_client_property_set) {
|
||||
requested_security_level_ = kLevelDefault;
|
||||
if (NULL != cdm_client_property_set) {
|
||||
if (QUERY_VALUE_SECURITY_LEVEL_L3.compare(
|
||||
cdm_client_property_set->security_level()) == 0) {
|
||||
requested_security_level_ = kLevel3;
|
||||
}
|
||||
Properties::AddSessionPropertySet(session_id_, cdm_client_property_set);
|
||||
}
|
||||
}
|
||||
@@ -90,8 +94,9 @@ CdmResponseType CdmSession::Init() {
|
||||
LOGE("CdmSession::Init: Failed due to previous initialization");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
CdmResponseType sts = crypto_session_->Open(GetRequestedSecurityLevel());
|
||||
CdmResponseType sts = crypto_session_->Open(requested_security_level_);
|
||||
if (NO_ERROR != sts) return sts;
|
||||
security_level_ = crypto_session_->GetSecurityLevel();
|
||||
|
||||
std::string token;
|
||||
if (Properties::use_certificates_as_identification()) {
|
||||
@@ -271,7 +276,7 @@ CdmResponseType CdmSession::QueryStatus(CdmQueryMap* key_info) {
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
|
||||
switch (crypto_session_->GetSecurityLevel()) {
|
||||
switch (security_level_) {
|
||||
case kSecurityLevelL1:
|
||||
(*key_info)[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L1;
|
||||
break;
|
||||
@@ -530,23 +535,6 @@ void CdmSession::OnKeyReleaseEvent(const CdmKeySetId& key_set_id) {
|
||||
}
|
||||
}
|
||||
|
||||
SecurityLevel CdmSession::GetRequestedSecurityLevel() {
|
||||
std::string security_level;
|
||||
if (Properties::GetSecurityLevel(session_id_, &security_level) &&
|
||||
security_level == QUERY_VALUE_SECURITY_LEVEL_L3) {
|
||||
return kLevel3;
|
||||
}
|
||||
|
||||
return kLevelDefault;
|
||||
}
|
||||
|
||||
CdmSecurityLevel CdmSession::GetSecurityLevel() {
|
||||
if (NULL == crypto_session_.get())
|
||||
return kSecurityLevelUninitialized;
|
||||
|
||||
return crypto_session_.get()->GetSecurityLevel();
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::UpdateUsageInformation() {
|
||||
return crypto_session_->UpdateUsageInformation();
|
||||
}
|
||||
|
||||
@@ -168,13 +168,9 @@ bool CryptoSession::GetApiVersion(uint32_t* version) {
|
||||
if (!initialized_) {
|
||||
return false;
|
||||
}
|
||||
CdmSecurityLevel level = GetSecurityLevel();
|
||||
SecurityLevel security_level = kLevelDefault;
|
||||
if (kSecurityLevelL3 == level) security_level = kLevel3;
|
||||
|
||||
LOGV("CryptoSession::GetApiVersion: Lock");
|
||||
AutoLock auto_lock(crypto_lock_);
|
||||
*version = OEMCrypto_APIVersion(security_level);
|
||||
*version = OEMCrypto_APIVersion(requested_security_level_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,6 @@ bool Properties::GetSecurityLevel(const CdmSessionId& session_id,
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (NULL == property_set) {
|
||||
LOGE("Properties::GetSecurityLevel: cannot find property set for %s",
|
||||
session_id.c_str());
|
||||
return false;
|
||||
}
|
||||
*security_level = property_set->security_level();
|
||||
@@ -78,8 +76,6 @@ bool Properties::GetServiceCertificate(const CdmSessionId& session_id,
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (NULL == property_set) {
|
||||
LOGE("Properties::GetServiceCertificate: cannot find property set for %s",
|
||||
session_id.c_str());
|
||||
return false;
|
||||
}
|
||||
*service_certificate = property_set->service_certificate();
|
||||
@@ -90,8 +86,6 @@ bool Properties::UsePrivacyMode(const CdmSessionId& session_id) {
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (NULL == property_set) {
|
||||
LOGE("Properties::UsePrivacyMode: cannot find property set for %s",
|
||||
session_id.c_str());
|
||||
return false;
|
||||
}
|
||||
return property_set->use_privacy_mode();
|
||||
@@ -101,8 +95,6 @@ uint32_t Properties::GetSessionSharingId(const CdmSessionId& session_id) {
|
||||
const CdmClientPropertySet* property_set =
|
||||
GetCdmClientPropertySet(session_id);
|
||||
if (NULL == property_set) {
|
||||
LOGE("Properties::GetSessionSharingId: cannot find property set for %s",
|
||||
session_id.c_str());
|
||||
return 0;
|
||||
}
|
||||
return property_set->session_sharing_id();
|
||||
|
||||
@@ -91,6 +91,7 @@ using ::testing::Eq;
|
||||
using ::testing::NotNull;
|
||||
using ::testing::Return;
|
||||
using ::testing::SetArgPointee;
|
||||
using ::testing::Sequence;
|
||||
using ::testing::StrEq;
|
||||
|
||||
class MockDeviceFiles : public DeviceFiles {
|
||||
@@ -150,15 +151,20 @@ class CdmSessionTest : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
Sequence crypto_session_seq;
|
||||
CdmSecurityLevel level = kSecurityLevelL1;
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level));
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(NO_ERROR));
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel())
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(level));
|
||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<0>(kToken), SetArgPointee<1>(kWrappedKey),
|
||||
Return(true)));
|
||||
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*license_parser_,
|
||||
Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
@@ -171,11 +177,16 @@ TEST_F(CdmSessionTest, InitWithCertificate) {
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitWithKeybox) {
|
||||
Sequence crypto_session_seq;
|
||||
CdmSecurityLevel level = kSecurityLevelL1;
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level));
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(NO_ERROR));
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel())
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(level));
|
||||
EXPECT_CALL(*crypto_session_, GetToken(NotNull()))
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(DoAll(SetArgPointee<0>(kToken), Return(true)));
|
||||
EXPECT_CALL(*license_parser_,
|
||||
Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
@@ -188,15 +199,20 @@ TEST_F(CdmSessionTest, InitWithKeybox) {
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, ReInitFail) {
|
||||
Sequence crypto_session_seq;
|
||||
CdmSecurityLevel level = kSecurityLevelL1;
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level));
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(NO_ERROR));
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel())
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(level));
|
||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<0>(kToken), SetArgPointee<1>(kWrappedKey),
|
||||
Return(true)));
|
||||
EXPECT_CALL(*crypto_session_, LoadCertificatePrivateKey(StrEq(kWrappedKey)))
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(true));
|
||||
EXPECT_CALL(*license_parser_,
|
||||
Init(Eq(kToken), Eq(crypto_session_), Eq(policy_engine_)))
|
||||
@@ -211,7 +227,6 @@ TEST_F(CdmSessionTest, ReInitFail) {
|
||||
|
||||
TEST_F(CdmSessionTest, InitFailCryptoError) {
|
||||
CdmSecurityLevel level = kSecurityLevelL1;
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level));
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.WillOnce(Return(UNKNOWN_ERROR));
|
||||
|
||||
@@ -222,10 +237,14 @@ TEST_F(CdmSessionTest, InitFailCryptoError) {
|
||||
}
|
||||
|
||||
TEST_F(CdmSessionTest, InitNeedsProvisioning) {
|
||||
Sequence crypto_session_seq;
|
||||
CdmSecurityLevel level = kSecurityLevelL1;
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel()).WillOnce(Return(level));
|
||||
EXPECT_CALL(*crypto_session_, Open(Eq(kLevelDefault)))
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(NO_ERROR));
|
||||
EXPECT_CALL(*crypto_session_, GetSecurityLevel())
|
||||
.InSequence(crypto_session_seq)
|
||||
.WillOnce(Return(level));
|
||||
EXPECT_CALL(*file_handle_, Init(Eq(level))).WillOnce(Return(true));
|
||||
EXPECT_CALL(*file_handle_, RetrieveCertificate(NotNull(), NotNull()))
|
||||
.WillOnce(Return(false));
|
||||
|
||||
Reference in New Issue
Block a user