Add a static method to query security level
[ Merge of http://go/wvgerrit/70665 ] This allows one to be able to query for security level, from Crypto factory methods before the plugins and CdmEngine objects have been created. Bug: 117104043 Test: WV Unit/integration tests Change-Id: Id07f420c3cfb92166cd3bb3cf82148d52e10eb03
This commit is contained in:
@@ -151,6 +151,9 @@ class CdmEngine {
|
|||||||
virtual CdmResponseType QueryKeyStatus(const CdmSessionId& session_id,
|
virtual CdmResponseType QueryKeyStatus(const CdmSessionId& session_id,
|
||||||
CdmQueryMap* query_response);
|
CdmQueryMap* query_response);
|
||||||
|
|
||||||
|
// Query security level support
|
||||||
|
static bool IsSecurityLevelSupported(CdmSecurityLevel level);
|
||||||
|
|
||||||
// Query the types of usage permitted for the specified key.
|
// Query the types of usage permitted for the specified key.
|
||||||
virtual CdmResponseType QueryKeyAllowedUsage(const CdmSessionId& session_id,
|
virtual CdmResponseType QueryKeyAllowedUsage(const CdmSessionId& session_id,
|
||||||
const std::string& key_id,
|
const std::string& key_id,
|
||||||
|
|||||||
@@ -815,6 +815,25 @@ CdmResponseType CdmEngine::QueryOemCryptoSessionId(
|
|||||||
return session->QueryOemCryptoSessionId(query_response);
|
return session->QueryOemCryptoSessionId(query_response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CdmEngine::IsSecurityLevelSupported(CdmSecurityLevel level) {
|
||||||
|
LOGI("CdmEngine::IsSecurityLevelSupported");
|
||||||
|
metrics::CryptoMetrics alternate_crypto_metrics;
|
||||||
|
std::unique_ptr<CryptoSession> crypto_session(
|
||||||
|
CryptoSession::MakeCryptoSession(&alternate_crypto_metrics));
|
||||||
|
|
||||||
|
switch (level) {
|
||||||
|
case kSecurityLevelL1:
|
||||||
|
return
|
||||||
|
crypto_session->GetSecurityLevel(kLevelDefault) == kSecurityLevelL1;
|
||||||
|
case kSecurityLevelL3:
|
||||||
|
return crypto_session->GetSecurityLevel(kLevel3) == kSecurityLevelL3;
|
||||||
|
default:
|
||||||
|
LOGE("CdmEngine::IsSecurityLevelSupported: Invalid security level: %d",
|
||||||
|
level);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Composes a device provisioning request and output the request in JSON format
|
* Composes a device provisioning request and output the request in JSON format
|
||||||
* in *request. It also returns the default url for the provisioning server
|
* in *request. It also returns the default url for the provisioning server
|
||||||
|
|||||||
@@ -80,6 +80,9 @@ class WvContentDecryptionModule : public android::RefBase, public TimerHandler {
|
|||||||
virtual CdmResponseType QueryOemCryptoSessionId(
|
virtual CdmResponseType QueryOemCryptoSessionId(
|
||||||
const CdmSessionId& session_id, CdmQueryMap* response);
|
const CdmSessionId& session_id, CdmQueryMap* response);
|
||||||
|
|
||||||
|
// Query security level support
|
||||||
|
static bool IsSecurityLevelSupported(CdmSecurityLevel level);
|
||||||
|
|
||||||
// Provisioning related methods
|
// Provisioning related methods
|
||||||
virtual CdmResponseType GetProvisioningRequest(
|
virtual CdmResponseType GetProvisioningRequest(
|
||||||
CdmCertificateType cert_type, const std::string& cert_authority,
|
CdmCertificateType cert_type, const std::string& cert_authority,
|
||||||
|
|||||||
@@ -213,6 +213,11 @@ CdmResponseType WvContentDecryptionModule::QueryOemCryptoSessionId(
|
|||||||
return cdm_engine->QueryOemCryptoSessionId(session_id, response);
|
return cdm_engine->QueryOemCryptoSessionId(session_id, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||||
|
CdmSecurityLevel level) {
|
||||||
|
return CdmEngine::IsSecurityLevelSupported(level);
|
||||||
|
}
|
||||||
|
|
||||||
CdmResponseType WvContentDecryptionModule::GetProvisioningRequest(
|
CdmResponseType WvContentDecryptionModule::GetProvisioningRequest(
|
||||||
CdmCertificateType cert_type, const std::string& cert_authority,
|
CdmCertificateType cert_type, const std::string& cert_authority,
|
||||||
const CdmIdentifier& identifier, const std::string& service_certificate,
|
const CdmIdentifier& identifier, const std::string& service_certificate,
|
||||||
|
|||||||
@@ -4291,6 +4291,21 @@ TEST_F(WvCdmRequestLicenseTest, QueryOemCryptoSessionId) {
|
|||||||
decryptor_.CloseSession(session_id_);
|
decryptor_.CloseSession(session_id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(WvCdmRequestLicenseTest, IsSecurityLevelSupported) {
|
||||||
|
// Level 1 may either be or not be supported. Invoking the method without
|
||||||
|
// imposing any expecations to make sure it completes.
|
||||||
|
bool is_supported = WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||||
|
wvcdm::kSecurityLevelL1);
|
||||||
|
EXPECT_FALSE(WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||||
|
wvcdm::kSecurityLevelL2));
|
||||||
|
EXPECT_TRUE(WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||||
|
wvcdm::kSecurityLevelL3));
|
||||||
|
EXPECT_FALSE(WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||||
|
wvcdm::kSecurityLevelUnknown));
|
||||||
|
EXPECT_FALSE(WvContentDecryptionModule::IsSecurityLevelSupported(
|
||||||
|
wvcdm::kSecurityLevelUninitialized));
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(WvCdmRequestLicenseTest, DISABLED_OfflineLicenseDecryptionTest) {
|
TEST_F(WvCdmRequestLicenseTest, DISABLED_OfflineLicenseDecryptionTest) {
|
||||||
decryptor_.OpenSession(config_.key_system(), NULL, kDefaultCdmIdentifier, NULL,
|
decryptor_.OpenSession(config_.key_system(), NULL, kDefaultCdmIdentifier, NULL,
|
||||||
&session_id_);
|
&session_id_);
|
||||||
|
|||||||
Reference in New Issue
Block a user