[ 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
67 lines
2.0 KiB
C++
67 lines
2.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.
|
|
//
|
|
// Reference implementation of OEMCrypto APIs
|
|
//
|
|
#ifndef OEMCRYPTO_KEYBOX_REF_H_
|
|
#define OEMCRYPTO_KEYBOX_REF_H_
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#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<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() {}
|
|
|
|
private:
|
|
WvKeybox() {}
|
|
|
|
wvoec::WidevineKeybox raw_keybox_;
|
|
};
|
|
|
|
} // namespace wvoec_ref
|
|
|
|
#endif // OEMCRYPTO_KEYBOX_REF_H_
|