am 36aeacde: Optimize Status Queries in WVCryptoPlugin By Deleting Them
* commit '36aeacde48f1f3eb68d17c3247e011e97058c2ff': Optimize Status Queries in WVCryptoPlugin By Deleting Them
This commit is contained in:
@@ -16,8 +16,7 @@ enum {
|
||||
kErrorIncorrectBufferSize = ERROR_DRM_VENDOR_MIN,
|
||||
kErrorCDMGeneric = ERROR_DRM_VENDOR_MIN + 1,
|
||||
kErrorUnsupportedCrypto = ERROR_DRM_VENDOR_MIN + 2,
|
||||
kErrorCannotGuaranteeSecurity = ERROR_DRM_VENDOR_MIN + 3,
|
||||
kErrorExpectedUnencrypted = ERROR_DRM_VENDOR_MIN + 4,
|
||||
kErrorExpectedUnencrypted = ERROR_DRM_VENDOR_MIN + 3,
|
||||
|
||||
// Used by crypto test mode
|
||||
kErrorTestMode = ERROR_DRM_VENDOR_MAX,
|
||||
|
||||
@@ -76,23 +76,6 @@ ssize_t WVCryptoPlugin::decrypt(bool secure, const uint8_t key[KEY_ID_SIZE],
|
||||
return kErrorUnsupportedCrypto;
|
||||
}
|
||||
|
||||
// If the caller requested secure decrypt, verify that we can comply.
|
||||
if (secure) {
|
||||
CdmQueryMap status;
|
||||
|
||||
CdmResponseType res = mCDM->QueryStatus(&status);
|
||||
|
||||
if (!isCdmResponseTypeSuccess(res)) {
|
||||
ALOGE("Error querying CDM status: %u", res);
|
||||
errorDetailMsg->setTo("Unable to verify ability to decode securely.");
|
||||
return kErrorCannotGuaranteeSecurity;
|
||||
} else if (status[QUERY_KEY_SECURITY_LEVEL] !=
|
||||
QUERY_VALUE_SECURITY_LEVEL_L1) {
|
||||
errorDetailMsg->setTo("Secure decode is not supported on this device.");
|
||||
return kErrorCannotGuaranteeSecurity;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert parameters to the form the CDM wishes to consume them in.
|
||||
const KeyId keyId(reinterpret_cast<const char*>(key), KEY_ID_SIZE);
|
||||
const vector<uint8_t> ivVector(iv, iv + KEY_IV_SIZE);
|
||||
|
||||
@@ -91,35 +91,6 @@ TEST_F(WVCryptoPluginTest, CorrectlyReportsSecureBuffers) {
|
||||
"WVCryptoPlugin incorrectly expects a secure audio decoder";
|
||||
}
|
||||
|
||||
TEST_F(WVCryptoPluginTest, RejectsSecureDecodeOnL3) {
|
||||
MockCDM cdm;
|
||||
WVCryptoPlugin plugin(sessionId, kSessionIdSize, &cdm);
|
||||
|
||||
CdmQueryMap l3Map;
|
||||
l3Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L3;
|
||||
|
||||
// Decrypt should not be called because we specified an unsupported
|
||||
// security level
|
||||
EXPECT_CALL(cdm, Decrypt(_, _, _, _, _, _, _, _))
|
||||
.Times(0);
|
||||
|
||||
EXPECT_CALL(cdm, QueryStatus(_))
|
||||
.WillOnce(DoAll(SetArgPointee<0>(l3Map),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
AString errorDetailMessage;
|
||||
|
||||
ssize_t res = plugin.decrypt(true, keyId, iv, CryptoPlugin::kMode_AES_CTR,
|
||||
in, subSamples, kSubSampleCount, out,
|
||||
&errorDetailMessage);
|
||||
|
||||
EXPECT_LT(res, 0) <<
|
||||
"WVCryptoPlugin allowed decryption to proceed despite being asked for an "
|
||||
"unsupported security level";
|
||||
EXPECT_GT(errorDetailMessage.size(), 0u) <<
|
||||
"WVCryptoPlugin did not report a detailed error message.";
|
||||
}
|
||||
|
||||
TEST_F(WVCryptoPluginTest, AttemptsToDecrypt) {
|
||||
MockCDM cdm;
|
||||
WVCryptoPlugin plugin(sessionId, kSessionIdSize, &cdm);
|
||||
|
||||
Reference in New Issue
Block a user