bug: 8601053
This import syncs to the widevine git repository change
commit 6a99ad1b59ad39495f62954b3065ddc22b78da49
It includes the following changes from the widevine git
repository, which complete the jb-mr2 features
Fix Unit Test Makefile
Adds support for device certificate provisioning.
Support application parameters
Certificate based licensing
Proto for client files
Implement Property Query API
Add Device Query For Unique ID
Implement Generic Crypto in DrmEngine
Do not validate Key IDs on clear playback
Allow OEMCrypto_DecryptCTR with clear content and no key
Add a case to the MediaDrm API test to repro b/8594163
Implement requiresSecureDecoderComponent
Implement Eventing API
Add end-to-end decryption test with vectors
Refactoring of properties class
Refactor OEMCrypto unittest.
Fix for b/8567853: License renewal doesn't renew license.
Add KEY_ERROR callback to WvContentDecryptionModule() ctor.
Merged certificate_provisioning.proto and
client_identification.proto to license_protocol.proto.
Fix nonce check failure after a malformed key in OEC Mock.
asynchronize decryption
Allow querying of control information
make debugging AddKey & Decrypt statuses easier
Revert "Revert "Send KEY_ERROR event to app on license
expiration or failure""
Revert "Send KEY_ERROR event to app on license expiration
or failure"
Send KEY_ERROR event to app on license expiration or failure
remove extra session id copy
use KeyError constants directly
replace variable-length arrays with std::vector and fixed-sized array
pass session ids as const references
refactor key extraction and update keys on renewal
Updates to enable renewals and signaling license expiration.
fix error constant in OEMCrypto_DecryptCTR
Change-Id: I5f7236c7bdff1d5ece6115fd2893f8a1e1e07c50
167 lines
5.4 KiB
C++
167 lines
5.4 KiB
C++
//
|
|
// Copyright 2013 Google Inc. All Rights Reserved.
|
|
//
|
|
|
|
#ifndef WV_DRM_PLUGIN_H_
|
|
#define WV_DRM_PLUGIN_H_
|
|
|
|
#include <map>
|
|
|
|
#include "media/drm/DrmAPI.h"
|
|
#include "media/stagefright/foundation/ABase.h"
|
|
#include "media/stagefright/foundation/AString.h"
|
|
#include "OEMCryptoCENC.h"
|
|
#include "utils/Errors.h"
|
|
#include "utils/KeyedVector.h"
|
|
#include "utils/List.h"
|
|
#include "utils/String8.h"
|
|
#include "utils/Vector.h"
|
|
#include "wv_cdm_event_listener.h"
|
|
#include "wv_content_decryption_module.h"
|
|
#include "WVGenericCryptoInterface.h"
|
|
|
|
namespace wvdrm {
|
|
|
|
using android::KeyedVector;
|
|
using android::List;
|
|
using android::status_t;
|
|
using android::String8;
|
|
using android::Vector;
|
|
using std::map;
|
|
using wvcdm::CdmEventType;
|
|
using wvcdm::CdmSessionId;
|
|
using wvcdm::CdmResponseType;
|
|
using wvcdm::WvContentDecryptionModule;
|
|
|
|
const OEMCrypto_Algorithm kInvalidCrytpoAlgorithm =
|
|
static_cast<OEMCrypto_Algorithm>(-1);
|
|
|
|
class WVDrmPlugin : public android::DrmPlugin,
|
|
public wvcdm::WvCdmEventListener {
|
|
public:
|
|
WVDrmPlugin(WvContentDecryptionModule* cdm,
|
|
WVGenericCryptoInterface* crypto);
|
|
|
|
virtual ~WVDrmPlugin();
|
|
|
|
virtual status_t openSession(Vector<uint8_t>& sessionId);
|
|
|
|
virtual status_t closeSession(const Vector<uint8_t>& sessionId);
|
|
|
|
virtual status_t getKeyRequest(
|
|
const Vector<uint8_t>& sessionId,
|
|
const Vector<uint8_t>& initData,
|
|
const String8& mimeType,
|
|
KeyType keyType,
|
|
const KeyedVector<String8, String8>& optionalParameters,
|
|
Vector<uint8_t>& request,
|
|
String8& defaultUrl);
|
|
|
|
virtual status_t provideKeyResponse(const Vector<uint8_t>& sessionId,
|
|
const Vector<uint8_t>& response,
|
|
Vector<uint8_t>& keySetId);
|
|
|
|
virtual status_t removeKeys(const Vector<uint8_t>& keySetId);
|
|
|
|
virtual status_t restoreKeys(const Vector<uint8_t>& sessionId,
|
|
const Vector<uint8_t>& keySetId);
|
|
|
|
virtual status_t queryKeyStatus(
|
|
const Vector<uint8_t>& sessionId,
|
|
KeyedVector<String8, String8>& infoMap) const;
|
|
|
|
virtual status_t getProvisionRequest(Vector<uint8_t>& request,
|
|
String8& defaultUrl);
|
|
|
|
virtual status_t provideProvisionResponse(const Vector<uint8_t>& response);
|
|
|
|
virtual status_t getSecureStops(List<Vector<uint8_t> >& secureStops);
|
|
|
|
virtual status_t releaseSecureStops(const Vector<uint8_t>& ssRelease);
|
|
|
|
virtual status_t getPropertyString(const String8& name, String8& value) const;
|
|
|
|
virtual status_t getPropertyByteArray(const String8& name,
|
|
Vector<uint8_t>& value) const;
|
|
|
|
virtual status_t setPropertyString(const String8& name, const String8& value);
|
|
|
|
virtual status_t setPropertyByteArray(const String8& name,
|
|
const Vector<uint8_t>& value);
|
|
|
|
virtual status_t setCipherAlgorithm(const Vector<uint8_t>& sessionId,
|
|
const String8& algorithm);
|
|
|
|
virtual status_t setMacAlgorithm(const Vector<uint8_t>& sessionId,
|
|
const String8& algorithm);
|
|
|
|
virtual status_t encrypt(const Vector<uint8_t>& sessionId,
|
|
const Vector<uint8_t>& keyId,
|
|
const Vector<uint8_t>& input,
|
|
const Vector<uint8_t>& iv,
|
|
Vector<uint8_t>& output);
|
|
|
|
virtual status_t decrypt(const Vector<uint8_t>& sessionId,
|
|
const Vector<uint8_t>& keyId,
|
|
const Vector<uint8_t>& input,
|
|
const Vector<uint8_t>& iv,
|
|
Vector<uint8_t>& output);
|
|
|
|
virtual status_t sign(const Vector<uint8_t>& sessionId,
|
|
const Vector<uint8_t>& keyId,
|
|
const Vector<uint8_t>& message,
|
|
Vector<uint8_t>& signature);
|
|
|
|
virtual status_t verify(const Vector<uint8_t>& sessionId,
|
|
const Vector<uint8_t>& keyId,
|
|
const Vector<uint8_t>& message,
|
|
const Vector<uint8_t>& signature,
|
|
bool& match);
|
|
|
|
virtual void onEvent(const CdmSessionId& cdmSessionId,
|
|
CdmEventType cdmEventType);
|
|
|
|
private:
|
|
DISALLOW_EVIL_CONSTRUCTORS(WVDrmPlugin);
|
|
|
|
struct CryptoSession {
|
|
public:
|
|
CryptoSession()
|
|
: mOecSessionId(-1),
|
|
mCipherAlgorithm(kInvalidCrytpoAlgorithm),
|
|
mMacAlgorithm(kInvalidCrytpoAlgorithm) {}
|
|
|
|
CryptoSession(OEMCrypto_SESSION sessionId)
|
|
: mOecSessionId(sessionId),
|
|
mCipherAlgorithm(kInvalidCrytpoAlgorithm),
|
|
mMacAlgorithm(kInvalidCrytpoAlgorithm) {}
|
|
|
|
OEMCrypto_SESSION oecSessionId() const { return mOecSessionId; }
|
|
|
|
OEMCrypto_Algorithm cipherAlgorithm() const { return mCipherAlgorithm; }
|
|
|
|
void setCipherAlgorithm(OEMCrypto_Algorithm newAlgorithm) {
|
|
mCipherAlgorithm = newAlgorithm;
|
|
}
|
|
|
|
OEMCrypto_Algorithm macAlgorithm() const { return mMacAlgorithm; }
|
|
|
|
void setMacAlgorithm(OEMCrypto_Algorithm newAlgorithm) {
|
|
mMacAlgorithm = newAlgorithm;
|
|
}
|
|
|
|
private:
|
|
OEMCrypto_SESSION mOecSessionId;
|
|
OEMCrypto_Algorithm mCipherAlgorithm;
|
|
OEMCrypto_Algorithm mMacAlgorithm;
|
|
};
|
|
|
|
WvContentDecryptionModule* mCDM;
|
|
WVGenericCryptoInterface* mCrypto;
|
|
map<CdmSessionId, CryptoSession> mCryptoSessions;
|
|
};
|
|
|
|
} // namespace wvdrm
|
|
|
|
#endif // WV_DRM_PLUGIN_H_
|