Merge from Widevine repo of http://go/wvgerrit/121950 Remove term "Master" from "Widevine Master License Agreement". Bug: 168562298 Change-Id: I655babf1bc447f4872f6a0f849107262be42df7a
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
|
|
// 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_
|