Add Detail Error Messages

Reworks the error message reporting that was just added to WVCryptoPlugin so
that it reports detailed error messages to the app (because the error codes
cannot be relied upon to reach the app intact) and so that it always reports
custom errors so that the detailed error message is passed to the app.

Bug: 8621516

Merge of https://widevine-internal-review.googlesource.com/#/c/5031/ from
widevine git to android git.

Change-Id: Id7a517fb6e4e772ffea4c779a8ee52b357345a08
This commit is contained in:
Jeff Tinker
2013-04-18 13:47:28 -07:00
parent 0fc9bf9699
commit c1474b9912
3 changed files with 41 additions and 16 deletions

View File

@@ -107,12 +107,17 @@ TEST_F(WVCryptoPluginTest, RejectsSecureDecodeOnL3) {
.WillOnce(DoAll(SetArgPointee<0>(l3Map),
Return(wvcdm::NO_ERROR)));
ssize_t res = plugin.decrypt(true, keyId, iv, CryptoPlugin::kMode_AES_CTR,
in, subSamples, kSubSampleCount, out, NULL);
AString errorDetailMessage;
EXPECT_LT(res, static_cast<ssize_t>(0)) <<
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) {
@@ -144,9 +149,14 @@ TEST_F(WVCryptoPluginTest, AttemptsToDecrypt) {
.WillOnce(Return(wvcdm::NO_ERROR));
}
AString errorDetailMessage;
ssize_t res = plugin.decrypt(false, keyId, iv, CryptoPlugin::kMode_AES_CTR,
in, subSamples, kSubSampleCount, out, NULL);
in, subSamples, kSubSampleCount, out,
&errorDetailMessage);
EXPECT_EQ(static_cast<ssize_t>(kDataSize), res) <<
"WVCryptoPlugin decrypted the wrong number of bytes";
EXPECT_EQ(0u, errorDetailMessage.size()) <<
"WVCryptoPlugin reported a detailed error message.";
}