// 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 ECM_PARSER_H #define ECM_PARSER_H #include #include #include "cas_types.h" #include "media_cas.pb.h" namespace wvcas { enum class KeySlotId { kEvenKeySlot, kOddKeySlot }; // EcmParser allows random access to the fields of an ECM. class EcmParser { public: EcmParser() = default; virtual ~EcmParser() {} // The EcmParser factory method. // Validates the ecm. If validations is successful returns true and constructs // an EcmParser in |parser| using |ecm|. static std::unique_ptr Create(const CasEcm& ecm); // Accessor methods. virtual uint8_t version() const = 0; virtual CryptoMode crypto_mode() const = 0; virtual bool rotation_enabled() const = 0; virtual size_t content_iv_size() const = 0; virtual uint8_t age_restriction() const = 0; virtual std::vector entitlement_key_id(KeySlotId id) const = 0; virtual std::vector content_key_id(KeySlotId id) const = 0; virtual std::vector wrapped_key_data(KeySlotId id) const = 0; virtual std::vector wrapped_key_iv(KeySlotId id) const = 0; virtual std::vector content_iv(KeySlotId id) const = 0; // Process group content keys instead of the normal content keys. virtual bool set_group_id(const std::string& group_id) = 0; virtual bool has_fingerprinting() const = 0; virtual video_widevine::Fingerprinting fingerprinting() const = 0; virtual bool has_service_blocking() const = 0; virtual video_widevine::ServiceBlocking service_blocking() const = 0; // The serialized payload that the signature is calculated on. virtual std::string ecm_serialized_payload() const = 0; virtual std::string signature() const = 0; virtual bool is_entitlement_rotation_enabled() const = 0; virtual uint32_t entitlement_period_index() const = 0; virtual uint32_t entitlement_rotation_window_left() const = 0; }; } // namespace wvcas #endif // ECM_PARSER_H