Regular sync.

Changes include:
1. Fix refreshkeys when handling renewal response.
2. Change ECM start detect method.
3. Fix signing key truncation.
4. Reformat C++ code.
5. Return license_id in LICENSE_CAS_READY payload.
6. Expose OEMCrypto API version in the license request.
7. Add support for newly added widevine cas ids.
8. Store content iv and encryption mode info to entitled key.
9. Upgrade ODK library to 16.4.
This commit is contained in:
huihli
2020-10-21 11:16:23 -07:00
parent 0f6db6f751
commit 2feec02df2
39 changed files with 703 additions and 546 deletions

View File

@@ -15,8 +15,6 @@ class CasMediaId {
virtual CasStatus initialize(const std::string& init_data) = 0;
virtual const std::string content_id() = 0;
virtual const std::string provider_id() = 0;
virtual const int group_ids_size() = 0;
virtual const std::string group_id() = 0;
};
} // namespace wvcas

View File

@@ -28,6 +28,7 @@ enum class CasStatusCode : int32_t {
kDeferedEcmProcessing = 14,
kAccessDeniedByParentalControl = 15,
kUnknownEvent = 16,
kOEMCryptoVersionMismatch = 17,
};
class CasStatus {

View File

@@ -7,9 +7,9 @@
#include <memory>
#if __cplusplus >= 201402L || \
(defined __cpp_lib_make_unique && __cpp_lib_make_unique >= 201304L) || \
(defined(_MSC_VER) && _MSC_VER >= 1900)
#if __cplusplus >= 201402L || \
(defined __cpp_lib_make_unique && __cpp_lib_make_unique >= 201304L) || \
(defined(_MSC_VER) && _MSC_VER >= 1900)
using std::make_unique;
#else
template <typename T, typename... Args>
@@ -18,4 +18,4 @@ std::unique_ptr<T> make_unique(Args&&... args) {
}
#endif
#endif //CAS_UTIL_H_
#endif // CAS_UTIL_H_

View File

@@ -9,15 +9,15 @@ namespace wvcas {
class CryptoKey {
public:
CryptoKey() {};
~CryptoKey() {};
CryptoKey(){};
~CryptoKey(){};
const std::string& key_id() const { return key_id_; }
const std::string& key_data() const { return key_data_; }
const std::string& key_data_iv() const { return key_data_iv_; }
const std::string& key_control() const { return key_control_; }
const std::string& key_control_iv() const { return key_control_iv_; }
const std::string& entitlement_key_id() const {return entitlement_key_id_;}
const std::string& entitlement_key_id() const { return entitlement_key_id_; }
const std::string& track_label() const { return track_label_; }
void set_key_id(const std::string& key_id) { key_id_ = key_id; }
void set_key_data(const std::string& key_data) { key_data_ = key_data; }

View File

@@ -37,7 +37,7 @@ typedef OEMCrypto_HDCP_Capability HdcpCapability;
class CryptoLock {
public:
CryptoLock() {};
CryptoLock(){};
// These methods should be used to take the various CryptoSession mutexes in
// preference to taking the mutexes directly.
//
@@ -75,18 +75,19 @@ class CryptoLock {
// of a single call into OEMCrypto) unless there is a compelling argument
// otherwise, such as making two calls into OEMCrypto immediately after each
// other.
template<class Func>
template <class Func>
static auto WithStaticFieldWriteLock(const char* tag, Func body)
-> decltype(body());
template<class Func>
-> decltype(body());
template <class Func>
static auto WithStaticFieldReadLock(const char* tag, Func body)
-> decltype(body());
template<class Func>
-> decltype(body());
template <class Func>
static auto WithOecWriteLock(const char* tag, Func body) -> decltype(body());
template<class Func>
template <class Func>
static auto WithOecReadLock(const char* tag, Func body) -> decltype(body());
template<class Func>
template <class Func>
auto WithOecSessionLock(const char* tag, Func body) -> decltype(body());
private:
// The locking methods above should be used in preference to taking these
// mutexes directly. If code takes these manually and needs to take more
@@ -161,9 +162,10 @@ class CryptoInterface {
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
const OEMCrypto_EntitledCasKeyObject* even_key,
const OEMCrypto_EntitledCasKeyObject* odd_key);
virtual OEMCryptoResult OEMCrypto_SelectKey(
OEMCrypto_SESSION session, const uint8_t* content_key_id,
size_t content_key_id_length, OEMCryptoCipherMode cipher_mode);
virtual OEMCryptoResult OEMCrypto_SelectKey(OEMCrypto_SESSION session,
const uint8_t* content_key_id,
size_t content_key_id_length,
OEMCryptoCipherMode cipher_mode);
virtual OEMCryptoResult OEMCrypto_GetHDCPCapability(
OEMCrypto_HDCP_Capability* current, OEMCrypto_HDCP_Capability* max);
virtual OEMCryptoResult OEMCrypto_RefreshKeys(
@@ -174,10 +176,10 @@ class CryptoInterface {
size_t* idLength);
virtual const char* OEMCrypto_SecurityLevel();
virtual OEMCryptoResult OEMCrypto_CreateEntitledKeySession(
OEMCrypto_SESSION session,
OEMCrypto_SESSION* entitled_key_session_id);
OEMCrypto_SESSION session, OEMCrypto_SESSION* entitled_key_session_id);
virtual OEMCryptoResult OEMCrypto_RemoveEntitledKeySession(
OEMCrypto_SESSION entitled_key_session_id);
virtual uint32_t OEMCrypto_APIVersion();
// This is the factory method used to enable the oemcrypto interface.
static OEMCryptoResult create(std::unique_ptr<CryptoInterface>* init) {
@@ -190,7 +192,7 @@ class CryptoInterface {
// This initializer factory method is templated to allow tests to pass in
// a mocked OEMCryptoInterface. The caller retains ownership of
// |oemcrypto_interface|.
template<typename CI>
template <typename CI>
static OEMCryptoResult create(std::unique_ptr<CryptoInterface>* init,
CI* oemcrypto_interface) {
return create_internal(oemcrypto_interface, init);
@@ -299,6 +301,7 @@ class CryptoSession {
OEMCrypto_SESSION* entitled_key_session_id);
virtual CasStatus RemoveEntitledKeySession(
OEMCrypto_SESSION entitled_key_session_id);
virtual CasStatus APIVersion(uint32_t* api_version);
CryptoSession(const CryptoSession&) = delete;
CryptoSession& operator=(const CryptoSession&) = delete;

View File

@@ -41,12 +41,13 @@ struct InputStreamParams {
bool is_encrypted;
InputStreamParams(){};
InputStreamParams(const uint8_t* data_addr, size_t data_length,
bool is_encrypted):data_addr(data_addr), data_length(data_length),
is_encrypted(is_encrypted){}
InputStreamParams(const uint8_t* data_addr, size_t data_length,
bool is_encrypted)
: data_addr(data_addr),
data_length(data_length),
is_encrypted(is_encrypted) {}
};
// Calls to oemcrypto are called via this object. The purpose of this object is
// to allow OEMCrypto to be mocked. The implementation of this object only wraps
// OEMCrypto methods adding limited additional functionality. Added
@@ -95,8 +96,8 @@ class OEMCryptoInterface {
OEMCrypto_SESSION session, uint8_t* public_cert,
size_t* public_cert_length) const;
virtual OEMCryptoResult OEMCrypto_LoadDRMPrivateKey(
OEMCrypto_SESSION session, OEMCrypto_PrivateKeyType key_type,
const uint8_t* wrapped_rsa_key, size_t wrapped_rsa_key_length) const;
OEMCrypto_SESSION session, OEMCrypto_PrivateKeyType key_type,
const uint8_t* wrapped_rsa_key, size_t wrapped_rsa_key_length) const;
virtual OEMCryptoResult OEMCrypto_GenerateRSASignature(
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
uint8_t* signature, size_t* signature_length,
@@ -142,6 +143,7 @@ class OEMCryptoInterface {
OEMCrypto_SESSION oec_session, OEMCrypto_SESSION* key_session);
virtual OEMCryptoResult OEMCrypto_RemoveEntitledKeySession(
OEMCrypto_SESSION key_session);
virtual uint32_t OEMCrypto_APIVersion() const;
OEMCryptoInterface(const OEMCryptoInterface&) = delete;
OEMCryptoInterface& operator=(const OEMCryptoInterface&) = delete;

View File

@@ -49,12 +49,13 @@ class WidevineCas : public wvutil::TimerHandler {
// Generates an entitlement license request in |entitlement_request| for the
// media described in |init_data|.
virtual CasStatus generateEntitlementRequest(
const std::string& init_data, std::string* entitlement_request);
virtual CasStatus generateEntitlementRequest(const std::string& init_data,
std::string* entitlement_request,
std::string& license_id);
// Processes the entitlement |response| to a entitlement license request.
virtual CasStatus handleEntitlementResponse(
const std::string& response, std::string& license_id);
virtual CasStatus handleEntitlementResponse(const std::string& response,
std::string& license_id);
// Generates an entitlement license request in |entitlement_request| for the
// media described in |init_data|.

View File

@@ -14,8 +14,8 @@ using android::CasPlugin;
using android::CasPluginCallback;
using android::CasPluginCallbackExt;
using android::CasPluginStatusCallback;
using android::status_t;
using android::CasSessionId;
using android::status_t;
using android::String8;
namespace wvcas {
@@ -91,8 +91,7 @@ class WidevineCasPlugin : public CasPlugin, public CasEventListener {
private:
virtual std::shared_ptr<CryptoSession> getCryptoSession();
// |sessionId| is nullptr if the event is not a session event.
virtual CasStatus processEvent(int32_t event,
int32_t arg,
virtual CasStatus processEvent(int32_t event, int32_t arg,
const CasData& eventData,
const CasSessionId* sessionId);
virtual CasStatus HandleIndividualizationResponse(const CasData& response);
@@ -116,12 +115,8 @@ class WidevineCasPlugin : public CasPlugin, public CasEventListener {
// Choose to use |callback_| or |callback_ext_| to send back information.
// |sessionId| is ignored if |callback_ext_| is null,
void CallBack(void* appData,
int32_t event,
int32_t arg,
uint8_t* data,
size_t size,
const CasSessionId* sessionId) const;
void CallBack(void* appData, int32_t event, int32_t arg, uint8_t* data,
size_t size, const CasSessionId* sessionId) const;
void* app_data_;
CasPluginCallback callback_;