// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary // source code may only be used and distributed under the Widevine License // Agreement. #ifndef WVCDM_CORE_CONTENT_KEY_SESSION_H_ #define WVCDM_CORE_CONTENT_KEY_SESSION_H_ #include "key_session.h" #include "metrics_collections.h" #include "timer_metric.h" #include "wv_class_utils.h" namespace wvcdm { class ContentKeySession : public KeySession { public: ContentKeySession() = delete; WVCDM_DISALLOW_COPY_AND_MOVE(ContentKeySession); ContentKeySession(RequestedSecurityLevel security_level, CryptoSessionId oec_session_id, metrics::CryptoMetrics* metrics) : KeySession(metrics), oec_session_id_(oec_session_id), security_level_(security_level), cipher_mode_(kCipherModeCtr) {} ~ContentKeySession() override {} KeySessionType Type() override { return kDefault; } // 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, const std::string& srm_requirement) override; 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) override; // Decrypt for ContentKeySession OEMCryptoResult Decrypt(const OEMCrypto_SampleDescription* samples, size_t samples_length, const OEMCrypto_CENCEncryptPatternDesc& pattern, bool is_any_subsample_protected) override; OEMCryptoResult GenericEncrypt(const std::string& in_buffer, const std::string& iv, OEMCrypto_Algorithm algorithm, std::string* out_buffer) override; OEMCryptoResult GenericDecrypt(const std::string& in_buffer, const std::string& iv, OEMCrypto_Algorithm algorithm, std::string* out_buffer) override; OEMCryptoResult GenericSign(const std::string& message, OEMCrypto_Algorithm algorithm, std::string* signature) override; OEMCryptoResult GenericVerify(const std::string& message, OEMCrypto_Algorithm algorithm, const std::string& signature) override; protected: 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, const std::string& srm_requirement, OEMCrypto_LicenseType license_type); OEMCryptoResult GetKeyHandle(CryptoSessionId session_id, const std::string& key_id, CdmCipherMode cipher_mode); CryptoSessionId oec_session_id_; private: RequestedSecurityLevel security_level_; KeyId cached_key_id_; CdmCipherMode cipher_mode_; std::vector key_handle_; }; // class ContentKeySession } // namespace wvcdm #endif // WVCDM_CORE_CONTENT_KEY_SESSION_H_