Restructed reference root of trust (1/3 Keybox)
[ Merge of http://go/wvgerrit/115550 ] This change is the first part of a three part change for restructing the root of trust used by the reference implementation. The API of the AuthenticationRoot class has been updated to reflect the OEMCrypto functions that relate to the root of trust. This involves changing the keybox and DRM Cert methods and adding in new stubs for OEM Certificates. The WvKeybox now uses a RAII-like interface to ensure that keyboxes are provisioned correctly or not at all. Bug: 135283522 Test: oemcrypto_unittests ce_cdm_tests Change-Id: I3f2baf29c1022e1806b6196fa6650d761785c626
This commit is contained in:
@@ -7,38 +7,58 @@
|
||||
#ifndef OEMCRYPTO_KEYBOX_REF_H_
|
||||
#define OEMCRYPTO_KEYBOX_REF_H_
|
||||
|
||||
#include "oemcrypto_key_ref.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "OEMCryptoCENCCommon.h"
|
||||
#include "oemcrypto_types.h"
|
||||
|
||||
namespace wvoec_ref {
|
||||
|
||||
const int DEVICE_KEY_LENGTH = 16;
|
||||
typedef uint8_t WvKeyboxKey[DEVICE_KEY_LENGTH];
|
||||
|
||||
const int KEY_DATA_LENGTH = 72;
|
||||
typedef uint8_t WvKeyboxKeyData[KEY_DATA_LENGTH];
|
||||
|
||||
enum KeyboxError { NO_ERROR, BAD_CRC, BAD_MAGIC, OTHER_ERROR };
|
||||
|
||||
// Widevine keybox
|
||||
class WvKeybox {
|
||||
public:
|
||||
WvKeybox();
|
||||
// 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<WvKeybox> 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<uint8_t> DeviceId() const;
|
||||
|
||||
// Returns the keybox device key directly. Intended to be used
|
||||
// for key derivation.
|
||||
std::vector<uint8_t> 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() {}
|
||||
|
||||
KeyboxError Validate();
|
||||
const std::vector<uint8_t>& device_id() { return device_id_; }
|
||||
std::vector<uint8_t>& device_key() { return device_key_; }
|
||||
const WvKeyboxKeyData& key_data() { return key_data_; }
|
||||
size_t key_data_length() { return KEY_DATA_LENGTH; }
|
||||
bool InstallKeybox(const uint8_t* keybox, size_t keyBoxLength);
|
||||
|
||||
private:
|
||||
bool loaded_;
|
||||
std::vector<uint8_t> device_id_;
|
||||
std::vector<uint8_t> device_key_;
|
||||
WvKeyboxKeyData key_data_;
|
||||
uint8_t magic_[4];
|
||||
uint8_t crc_[4];
|
||||
WvKeybox() {}
|
||||
|
||||
wvoec::WidevineKeybox raw_keybox_;
|
||||
};
|
||||
|
||||
} // namespace wvoec_ref
|
||||
|
||||
Reference in New Issue
Block a user