// 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. // // Reference implementation of OEMCrypto APIs // #ifndef OEMCRYPTO_KEYBOX_REF_H_ #define OEMCRYPTO_KEYBOX_REF_H_ #include #include #include "OEMCryptoCENCCommon.h" #include "oemcrypto_types.h" namespace wvoec_ref { // Widevine keybox class WvKeybox { public: // Validates keybox data using the following rules: // 1. Data is not null // 2. Keybox size // 3. Matching magic // 4. CRC-32 check static OEMCryptoResult ValidateData(const uint8_t* keybox_data, size_t keybox_length); // Creates a keybox from the provided keybox data. // Provided keybox data must be the proper length, but does // not need to be valid. // Once created, keyboxes are immutable. static std::unique_ptr Create(const uint8_t* keybox_data, size_t keybox_length); // Gets the device ID from the keybox. // Similar to the expected behavior of OEMCrypto_GetDeviceID(). OEMCryptoResult GetDeviceId(uint8_t* device_id, size_t* device_id_length) const; // Returns the keybox device ID directly. Intended to be used // for core message generation. std::vector DeviceId() const; // Returns the keybox device key directly. Intended to be used // for key derivation. std::vector DeviceKey() const; // Gets the keybox data. // Similar to the expected behavior of OEMCrypto_GetKeyData(). OEMCryptoResult GetKeyData(uint8_t* key_data, size_t* key_data_length) const; // Checks the current keybox instantiation that it is valid. // Similar to the expected behavior of OEMCrypto_IsKeyboxValid(). OEMCryptoResult IsKeyboxValid() const; ~WvKeybox() {} private: WvKeybox() {} wvoec::WidevineKeybox raw_keybox_; }; } // namespace wvoec_ref #endif // OEMCRYPTO_KEYBOX_REF_H_