This is the second code drop for the white-box api reference implementation and tests. This corrects the errors in the license white-box reference implementation and implements the remaining test cases. It should be noted that there is one test case missing, the test case for handling ChromeOS's unique policy settings. In order to make the tests easier to create and read, a license builder class was created and golden content and keys were wrapped in their own classes. How key errors are communicated was changed in the API. WB_RESULT_NO_SUCH_KEY and WB_RESULT_WRONG_KEY_TYPE were merged into WB_RESULT_KEY_UNAVAILABLE.
62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
// Copyright 2020 Google LLC. All Rights Reserved.
|
|
|
|
#ifndef WHITEBOX_API_GOLDEN_DATA_H_
|
|
#define WHITEBOX_API_GOLDEN_DATA_H_
|
|
|
|
#include <stdint.h>
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "cdm/protos/license_protocol.pb.h"
|
|
|
|
namespace widevine {
|
|
|
|
class GoldenData {
|
|
public:
|
|
struct Content {
|
|
std::vector<uint8_t> plaintext;
|
|
std::vector<uint8_t> ciphertext;
|
|
std::vector<uint8_t> key;
|
|
std::vector<uint8_t> iv;
|
|
};
|
|
|
|
struct Key {
|
|
video_widevine::License_KeyContainer_SecurityLevel level;
|
|
std::vector<uint8_t> id;
|
|
const Content* content;
|
|
};
|
|
|
|
GoldenData();
|
|
|
|
const Content& CBCContent() const { return cbc_content_; }
|
|
const Key& CBCCryptoKey() const { return cbc_crypto_key_; }
|
|
const Key& CBCDecodeKey() const { return cbc_decode_key_; }
|
|
const Key& CBCHardwareKey() const { return cbc_hardware_key_; }
|
|
|
|
const Content& CTRContent() const { return ctr_content_; }
|
|
const Key& CTRCryptoKey() const { return ctr_crypto_key_; }
|
|
const Key& CTRDecodeKey() const { return ctr_decode_key_; }
|
|
const Key& CTRHardwareKey() const { return ctr_hardware_key_; }
|
|
|
|
// When a test needs to define a key id that does not conflict with any key
|
|
// ids defined in the golden data, it should use this to update their key id
|
|
// by prepending a single byte to ensure it won't collide with any of the
|
|
// internal key ids.
|
|
void MakeKeyIdDifferent(std::vector<uint8_t>* key_id) const;
|
|
|
|
private:
|
|
Content cbc_content_;
|
|
Key cbc_crypto_key_;
|
|
Key cbc_decode_key_;
|
|
Key cbc_hardware_key_;
|
|
|
|
Content ctr_content_;
|
|
Key ctr_crypto_key_;
|
|
Key ctr_decode_key_;
|
|
Key ctr_hardware_key_;
|
|
};
|
|
|
|
} // namespace widevine
|
|
|
|
#endif // WHITEBOX_API_GOLDEN_DATA_H_
|