File util, generic crypto, and key query
This CL merges several CLs from the widevine repo: http://go/wvgerrit/18012 Add support for querying allowed usage for key. http://go/wvgerrit/17971 Add per-origin storage. http://go/wvgerrit/18152 Add OEMCrypto's generic crypto operations to CDM. http://go/wvgerrit/17911 QueryKeyControlInfo => QueryOemCryptoSessionId Note: numbering in wv_cdm_types.h was added in this CL and will be back ported to wvgerrit in a future CL. Change-Id: Idb9e9a67e94f62f25dc16c5307f75a08b3430b64
This commit is contained in:
@@ -36,7 +36,7 @@ using wvcdm::CdmSessionId;
|
||||
using wvcdm::CdmResponseType;
|
||||
using wvcdm::WvContentDecryptionModule;
|
||||
|
||||
const OEMCrypto_Algorithm kInvalidCrytpoAlgorithm =
|
||||
const OEMCrypto_Algorithm kInvalidCryptoAlgorithm =
|
||||
static_cast<OEMCrypto_Algorithm>(-1);
|
||||
|
||||
class WVDrmPlugin : public android::DrmPlugin,
|
||||
@@ -155,13 +155,13 @@ class WVDrmPlugin : public android::DrmPlugin,
|
||||
public:
|
||||
CryptoSession()
|
||||
: mOecSessionId(-1),
|
||||
mCipherAlgorithm(kInvalidCrytpoAlgorithm),
|
||||
mMacAlgorithm(kInvalidCrytpoAlgorithm) {}
|
||||
mCipherAlgorithm(kInvalidCryptoAlgorithm),
|
||||
mMacAlgorithm(kInvalidCryptoAlgorithm) {}
|
||||
|
||||
CryptoSession(OEMCrypto_SESSION sessionId)
|
||||
: mOecSessionId(sessionId),
|
||||
mCipherAlgorithm(kInvalidCrytpoAlgorithm),
|
||||
mMacAlgorithm(kInvalidCrytpoAlgorithm) {}
|
||||
mCipherAlgorithm(kInvalidCryptoAlgorithm),
|
||||
mMacAlgorithm(kInvalidCryptoAlgorithm) {}
|
||||
|
||||
OEMCrypto_SESSION oecSessionId() const { return mOecSessionId; }
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
|
||||
|
||||
// Construct a CryptoSession
|
||||
CdmQueryMap info;
|
||||
res = mCDM->QueryKeyControlInfo(cdmSessionId, &info);
|
||||
res = mCDM->QueryOemCryptoSessionId(cdmSessionId, &info);
|
||||
|
||||
if (isCdmResponseTypeSuccess(res) &&
|
||||
info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
|
||||
@@ -688,7 +688,7 @@ status_t WVDrmPlugin::encrypt(const Vector<uint8_t>& sessionId,
|
||||
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.cipherAlgorithm() == kInvalidCrytpoAlgorithm) {
|
||||
if (cryptoSession.cipherAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
return android::NO_INIT;
|
||||
}
|
||||
|
||||
@@ -726,7 +726,7 @@ status_t WVDrmPlugin::decrypt(const Vector<uint8_t>& sessionId,
|
||||
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.cipherAlgorithm() == kInvalidCrytpoAlgorithm) {
|
||||
if (cryptoSession.cipherAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
return android::NO_INIT;
|
||||
}
|
||||
|
||||
@@ -763,7 +763,7 @@ status_t WVDrmPlugin::sign(const Vector<uint8_t>& sessionId,
|
||||
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.macAlgorithm() == kInvalidCrytpoAlgorithm) {
|
||||
if (cryptoSession.macAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
return android::NO_INIT;
|
||||
}
|
||||
|
||||
@@ -817,7 +817,7 @@ status_t WVDrmPlugin::verify(const Vector<uint8_t>& sessionId,
|
||||
|
||||
const CryptoSession& cryptoSession = mCryptoSessions[cdmSessionId];
|
||||
|
||||
if (cryptoSession.macAlgorithm() == kInvalidCrytpoAlgorithm) {
|
||||
if (cryptoSession.macAlgorithm() == kInvalidCryptoAlgorithm) {
|
||||
return android::NO_INIT;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ class MockCDM : public WvContentDecryptionModule {
|
||||
MOCK_METHOD2(QueryKeyStatus, CdmResponseType(const CdmSessionId&,
|
||||
CdmQueryMap*));
|
||||
|
||||
MOCK_METHOD2(QueryKeyControlInfo, CdmResponseType(const CdmSessionId&,
|
||||
CdmQueryMap*));
|
||||
MOCK_METHOD2(QueryOemCryptoSessionId, CdmResponseType(const CdmSessionId&,
|
||||
CdmQueryMap*));
|
||||
|
||||
MOCK_METHOD5(GetProvisioningRequest, CdmResponseType(CdmCertificateType,
|
||||
const std::string&,
|
||||
@@ -197,7 +197,7 @@ TEST_F(WVDrmPluginTest, OpensSessions) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
@@ -454,7 +454,7 @@ TEST_F(WVDrmPluginTest, HandlesPrivacyCertCaseOfAddKey) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -968,7 +968,7 @@ TEST_F(WVDrmPluginTest, FailsGenericMethodsWithoutAnAlgorithmSet) {
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
@@ -1047,7 +1047,7 @@ TEST_F(WVDrmPluginTest, CallsGenericEncrypt) {
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
@@ -1107,7 +1107,7 @@ TEST_F(WVDrmPluginTest, CallsGenericDecrypt) {
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
@@ -1169,7 +1169,7 @@ TEST_F(WVDrmPluginTest, CallsGenericSign) {
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
@@ -1241,7 +1241,7 @@ TEST_F(WVDrmPluginTest, CallsGenericVerify) {
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
@@ -1274,7 +1274,7 @@ TEST_F(WVDrmPluginTest, RegistersForEvents) {
|
||||
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.Times(AtLeast(1))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
@@ -1308,10 +1308,10 @@ TEST_F(WVDrmPluginTest, UnregistersForAllEventsOnDestruction) {
|
||||
.WillOnce(DoAll(SetArgPointee<4>(cdmSessionId2),
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId1, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId1, _))
|
||||
.WillOnce(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId2, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId2, _))
|
||||
.WillOnce(Invoke(setSessionIdOnMap<5>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -1458,7 +1458,7 @@ TEST_F(WVDrmPluginTest, ProvidesExpectedDefaultPropertiesToCdm) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -1498,7 +1498,7 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -1535,7 +1535,7 @@ TEST_P(WVDrmPluginOriginTest, CanSetOrigin) {
|
||||
// Provide expected mock behavior
|
||||
{
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
// Provide expected behavior when plugin closes a session
|
||||
@@ -1585,7 +1585,7 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -1670,7 +1670,7 @@ TEST_F(WVDrmPluginTest, CanSetPrivacyMode) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -1727,7 +1727,7 @@ TEST_F(WVDrmPluginTest, CanSetServiceCertificate) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -1780,7 +1780,7 @@ TEST_F(WVDrmPluginTest, CanSetSessionSharing) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
@@ -1839,7 +1839,7 @@ TEST_F(WVDrmPluginTest, AllowsStoringOfSessionSharingId) {
|
||||
Return(wvcdm::NO_ERROR)));
|
||||
|
||||
// Provide expected behavior when plugin requests session control info
|
||||
EXPECT_CALL(*cdm, QueryKeyControlInfo(cdmSessionId, _))
|
||||
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
|
||||
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
|
||||
|
||||
EXPECT_CALL(*cdm, CloseSession(_))
|
||||
|
||||
Reference in New Issue
Block a user