diff --git a/libwvdrmengine/cdm/core/include/content_key_session.h b/libwvdrmengine/cdm/core/include/content_key_session.h index c2f87cdf..729e8eda 100644 --- a/libwvdrmengine/cdm/core/include/content_key_session.h +++ b/libwvdrmengine/cdm/core/include/content_key_session.h @@ -1,7 +1,13 @@ +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine Master +// License Agreement. + #ifndef WVCDM_CORE_CONTENT_KEY_SESSSION_H_ #define WVCDM_CORE_CONTENT_KEY_SESSSION_H_ #include "key_session.h" +#include "metrics_collections.h" +#include "override.h" #include "timer_metric.h" namespace wvcdm { @@ -15,45 +21,49 @@ class ContentKeySession : public KeySession { cipher_mode_(kCipherModeCtr) {} virtual ~ContentKeySession() {} - KeySessionType Type() { return kDefault; } + virtual KeySessionType Type() OVERRIDE { return kDefault; } // Generate Derived Keys for ContentKeySession - bool GenerateDerivedKeys(const std::string& message); + virtual bool GenerateDerivedKeys(const std::string& message) OVERRIDE; // Generate Derived Keys (from session key) for ContentKeySession - bool GenerateDerivedKeys(const std::string& message, - const std::string& session_key); + virtual bool GenerateDerivedKeys(const std::string& message, + const std::string& session_key) OVERRIDE; // Load Keys for ContentKeySession - OEMCryptoResult LoadKeys(const std::string& message, - const std::string& signature, - const std::string& mac_key_iv, - const std::string& mac_key, - const std::vector& keys, - const std::string& provider_session_token, - CdmCipherMode* cipher_mode, - const std::string& srm_requirement); + virtual OEMCryptoResult LoadKeys(const std::string& message, + const std::string& signature, + const std::string& mac_key_iv, + const std::string& mac_key, + const std::vector& keys, + const std::string& provider_session_token, + CdmCipherMode* cipher_mode, + const std::string& srm_requirement) OVERRIDE; - OEMCryptoResult LoadEntitledContentKeys(const std::vector&) { + virtual OEMCryptoResult LoadEntitledContentKeys( + const std::vector&) OVERRIDE { return OEMCrypto_ERROR_INVALID_CONTEXT; } // Select Key for ContentKeySession - OEMCryptoResult SelectKey(const std::string& key_id, - CdmCipherMode cipher_mode); + virtual OEMCryptoResult SelectKey(const std::string& key_id, + CdmCipherMode cipher_mode) OVERRIDE; // Decrypt for ContentKeySession - OEMCryptoResult Decrypt(const CdmDecryptionParameters& params, - OEMCrypto_DestBufferDesc& buffer_descriptor, - OEMCrypto_CENCEncryptPatternDesc& pattern_descriptor); + virtual OEMCryptoResult Decrypt( + const CdmDecryptionParameters& params, + OEMCrypto_DestBufferDesc& buffer_descriptor, + OEMCrypto_CENCEncryptPatternDesc& pattern_descriptor) OVERRIDE; protected: - OEMCryptoResult LoadKeys( + virtual OEMCryptoResult LoadKeysAsLicenseType( const std::string& message, const std::string& signature, const std::string& mac_key_iv, const std::string& mac_key, const std::vector& keys, const std::string& provider_session_token, CdmCipherMode* cipher_mode, - const std::string& srm_requirement, OEMCrypto_LicenseType license_type); + const std::string& srm_requirement, + OEMCrypto_LicenseType license_type); + CryptoSessionId oec_session_id_; private: diff --git a/libwvdrmengine/cdm/core/include/entitlement_key_session.h b/libwvdrmengine/cdm/core/include/entitlement_key_session.h index ec3c2f42..1877d305 100644 --- a/libwvdrmengine/cdm/core/include/entitlement_key_session.h +++ b/libwvdrmengine/cdm/core/include/entitlement_key_session.h @@ -1,8 +1,13 @@ +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine Master +// License Agreement. + #ifndef WVCDM_CORE_ENTITLEMENT_KEY_SESSSION_H_ #define WVCDM_CORE_ENTITLEMENT_KEY_SESSSION_H_ #include "content_key_session.h" -#include "key_session.h" +#include "metrics_collections.h" +#include "override.h" namespace wvcdm { @@ -15,18 +20,16 @@ class EntitlementKeySession : public ContentKeySession { KeySessionType Type() { return kEntitlement; } // Load Keys for ContentKeySession - OEMCryptoResult LoadKeys(const std::string& message, - const std::string& signature, - const std::string& mac_key_iv, - const std::string& mac_key, - const std::vector& keys, - const std::string& provider_session_token, - CdmCipherMode* cipher_mode, - const std::string& srm_requirement); - OEMCryptoResult LoadEntitledContentKeys(const std::vector& keys); - - private: - std::vector keys_; + virtual OEMCryptoResult LoadKeys(const std::string& message, + const std::string& signature, + const std::string& mac_key_iv, + const std::string& mac_key, + const std::vector& keys, + const std::string& provider_session_token, + CdmCipherMode* cipher_mode, + const std::string& srm_requirement) OVERRIDE; + virtual OEMCryptoResult LoadEntitledContentKeys( + const std::vector& keys) OVERRIDE; }; } // namespace wvcdm diff --git a/libwvdrmengine/cdm/core/include/key_session.h b/libwvdrmengine/cdm/core/include/key_session.h index 285c60f3..f3e8de5a 100644 --- a/libwvdrmengine/cdm/core/include/key_session.h +++ b/libwvdrmengine/cdm/core/include/key_session.h @@ -1,3 +1,7 @@ +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine Master +// License Agreement. + #ifndef WVCDM_CORE_KEY_SESSSION_H_ #define WVCDM_CORE_KEY_SESSSION_H_ diff --git a/libwvdrmengine/cdm/core/src/content_key_session.cpp b/libwvdrmengine/cdm/core/src/content_key_session.cpp index dc9f22c0..7efc34ff 100644 --- a/libwvdrmengine/cdm/core/src/content_key_session.cpp +++ b/libwvdrmengine/cdm/core/src/content_key_session.cpp @@ -1,3 +1,7 @@ +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine Master +// License Agreement. + #include "content_key_session.h" #include "crypto_key.h" #include "crypto_session.h" @@ -65,9 +69,9 @@ OEMCryptoResult ContentKeySession::LoadKeys( const std::vector& keys, const std::string& provider_session_token, CdmCipherMode* cipher_mode, const std::string& srm_requirement) { - return LoadKeys(message, signature, mac_key_iv, mac_key, keys, - provider_session_token, cipher_mode, srm_requirement, - OEMCrypto_ContentLicense); + return LoadKeysAsLicenseType(message, signature, mac_key_iv, mac_key, keys, + provider_session_token, cipher_mode, + srm_requirement, OEMCrypto_ContentLicense); } // Select Key for ContentKeySession @@ -87,9 +91,9 @@ OEMCryptoResult ContentKeySession::SelectKey(const std::string& key_id, reinterpret_cast(cached_key_id_.data()); OEMCryptoResult sts; - M_TIME(sts = OEMCrypto_SelectKey( - oec_session_id_, key_id_string, cached_key_id_.size(), - ToOEMCryptoCipherMode(cipher_mode)), + M_TIME(sts = OEMCrypto_SelectKey(oec_session_id_, key_id_string, + cached_key_id_.size(), + ToOEMCryptoCipherMode(cipher_mode)), metrics_, oemcrypto_select_key_, sts); if (OEMCrypto_SUCCESS != sts) { @@ -113,7 +117,7 @@ OEMCryptoResult ContentKeySession::Decrypt( return sts; } -OEMCryptoResult ContentKeySession::LoadKeys( +OEMCryptoResult ContentKeySession::LoadKeysAsLicenseType( const std::string& message, const std::string& signature, const std::string& mac_key_iv, const std::string& mac_key, const std::vector& keys, @@ -127,7 +131,7 @@ OEMCryptoResult ContentKeySession::LoadKeys( enc_mac_key = msg + GetOffset(message, mac_key); enc_mac_key_iv = msg + GetOffset(message, mac_key_iv); } else { - LOGV("ContentKeySession::LoadKeys: enc_mac_key not set"); + LOGV("enc_mac_key not set"); } std::vector load_keys(keys.size()); for (size_t i = 0; i < keys.size(); ++i) { @@ -164,7 +168,7 @@ OEMCryptoResult ContentKeySession::LoadKeys( srm_req = const_cast(msg) + GetOffset(message, srm_requirement); } - LOGV("LoadKeys: id=%ld", (uint32_t)oec_session_id_); + LOGV("id=%ld", (uint32_t)oec_session_id_); OEMCryptoResult sts; M_TIME( sts = ::OEMCrypto_LoadKeys_Back_Compat( diff --git a/libwvdrmengine/cdm/core/src/entitlement_key_session.cpp b/libwvdrmengine/cdm/core/src/entitlement_key_session.cpp index 1db42ef0..393f920f 100644 --- a/libwvdrmengine/cdm/core/src/entitlement_key_session.cpp +++ b/libwvdrmengine/cdm/core/src/entitlement_key_session.cpp @@ -1,3 +1,7 @@ +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine Master +// License Agreement. + #include "entitlement_key_session.h" #include "crypto_key.h" @@ -13,8 +17,9 @@ OEMCryptoResult EntitlementKeySession::LoadKeys( const std::vector& keys, const std::string& provider_session_token, CdmCipherMode* cipher_mode, const std::string& srm_requirement) { - keys_.resize(keys.size()); - return ContentKeySession::LoadKeys( + // Call our superclass's LoadKeysAsLicenseType(), but set the license type to + // OEMCrypto_EntitlementLicense. + return ContentKeySession::LoadKeysAsLicenseType( message, signature, mac_key_iv, mac_key, keys, provider_session_token, cipher_mode, srm_requirement, OEMCrypto_EntitlementLicense); } @@ -51,4 +56,4 @@ OEMCryptoResult EntitlementKeySession::LoadEntitledContentKeys( return result; } -} // namespace wvcdm \ No newline at end of file +} // namespace wvcdm