Note that this version does not have Widevine Provisioning 4.0 support. It is only suitable for device upgrades. A new patch with provisioning 4.0 support will be made later.
86 lines
3.0 KiB
C++
86 lines
3.0 KiB
C++
// 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_V2_H
|
|
#define ECM_PARSER_V2_H
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "cas_types.h"
|
|
#include "ecm_parser.h"
|
|
|
|
namespace wvcas {
|
|
|
|
struct EcmKeyData;
|
|
|
|
// EcmParserV2 allows random access to the fields of an ECM version 2 and under.
|
|
// It should be initialized via EcmParser factory create only.
|
|
class EcmParserV2 : public EcmParser {
|
|
public:
|
|
~EcmParserV2() override = default;
|
|
EcmParserV2(const EcmParserV2&) = delete;
|
|
EcmParserV2& operator=(const EcmParserV2&) = delete;
|
|
|
|
// The EcmParserV2 factory method.
|
|
// |ecm| must be Widevine ECM v2 or under without section header.
|
|
// Validates the ecm. The only validation performed is to ensure that the ecm
|
|
// passed in is large enough to hold a single key entry. If validations is
|
|
// successful returns true and constructs an EcmParserV2 in |parser| using
|
|
// |ecm|.
|
|
static bool create(const CasEcm& cas_ecm,
|
|
std::unique_ptr<EcmParserV2>* parser);
|
|
|
|
// Accessor methods.
|
|
uint8_t version() const override;
|
|
CryptoMode crypto_mode() const override;
|
|
bool rotation_enabled() const override;
|
|
size_t content_iv_size() const override;
|
|
uint8_t age_restriction() const override;
|
|
std::vector<uint8_t> entitlement_key_id(KeySlotId id) const override;
|
|
std::vector<uint8_t> content_key_id(KeySlotId id) const override;
|
|
std::vector<uint8_t> wrapped_key_data(KeySlotId id) const override;
|
|
std::vector<uint8_t> wrapped_key_iv(KeySlotId id) const override;
|
|
std::vector<uint8_t> content_iv(KeySlotId id) const override;
|
|
|
|
// Group keys not supported in v2.
|
|
bool set_group_id(const std::string& group_id) override {
|
|
return group_id.empty();
|
|
};
|
|
|
|
// ECM v2 or under does not have these fields.
|
|
bool has_fingerprinting() const override { return false; }
|
|
video_widevine::Fingerprinting fingerprinting() const override {
|
|
video_widevine::Fingerprinting fingerprinting;
|
|
return fingerprinting;
|
|
}
|
|
bool has_service_blocking() const override { return false; };
|
|
video_widevine::ServiceBlocking service_blocking() const override {
|
|
video_widevine::ServiceBlocking service_blocking;
|
|
return service_blocking;
|
|
}
|
|
std::string ecm_serialized_payload() const override { return ""; }
|
|
std::string signature() const override { return ""; }
|
|
|
|
bool is_entitlement_rotation_enabled() const override { return false; }
|
|
uint32_t entitlement_period_index() const override { return 0; }
|
|
uint32_t entitlement_rotation_window_left() const override { return 0; }
|
|
|
|
private:
|
|
// Constructs an EcmParserV2 using |ecm|.
|
|
explicit EcmParserV2(const CasEcm& ecm);
|
|
|
|
size_t key_data_size() const;
|
|
// Returns false if the ecm used to construct the object is not a valid size.
|
|
// TODO(jfore): Add validation using the version field.
|
|
bool is_valid_size() const;
|
|
const EcmKeyData* key_slot_data(KeySlotId id) const;
|
|
|
|
CasEcm ecm_;
|
|
};
|
|
|
|
} // namespace wvcas
|
|
|
|
#endif // ECM_PARSER_V2_H
|