This is the initial code drop of the reference implementation and test cases for the Widevine Whitebox API. In this drop, the full reference implementation for the AEAD white-box is provided and all test cases verifying the top-level behave have are enabled. Since the implementations can vary so much the testing is mostly left to verifying the return codes for specific parameter conditions. A full reference implementation for the license white-box is provided, however not all tests are implemented or enabled. A number of tests have been disabled as they required a loaded license and test licenses are still being worked on. The two license white-box API functions that are the further from competition are ProcessLicenseResponse() and MaskedDecryt(). ProcessLicenseResponse() is still being worked on and MaskedDecrypt() is waiting on Decrypt() to be fully functional. Most tests focus on verifying return code for specific parameter conditions, but as test licenses are created, tests looking to test the internal behaviour of license management will be added to ProcessLicenseResponse(), Decrypt(), and MaskedDecrypt().
43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
// Copyright 2020 Google LLC. All Rights Reserved.
|
|
|
|
#include "api/test_data.h"
|
|
|
|
#include <string>
|
|
|
|
#include "crypto_utils/rsa_test_keys.h"
|
|
|
|
std::vector<uint8_t> GetValidAeadInitData() {
|
|
// Valid init data for our AEAD implementation is any AES key, so it just
|
|
// needs to be 16 bytes.
|
|
return {
|
|
0x00, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x0,
|
|
0x00, 0x00, 0x00, 0x0, 0x00, 0x00, 0x00, 0x0,
|
|
};
|
|
}
|
|
|
|
std::vector<uint8_t> GetInvalidAeadInitData() {
|
|
// Valid init data would be any 16 bytes. To avoid returning a length of
|
|
// zero, just return one byte, that way we are still returning "some data".
|
|
return {0x00};
|
|
}
|
|
|
|
std::vector<uint8_t> GetLicenseInitData() {
|
|
// For the OpenSSL implementation |init_data| is simply a RSA 2048-bit
|
|
// private key. Matching public key is public_test_key_2_2048_bits().
|
|
widevine::RsaTestKeys key_generator;
|
|
std::string init_data = key_generator.private_test_key_2_2048_bits();
|
|
return std::vector<uint8_t>(init_data.begin(), init_data.end());
|
|
}
|
|
|
|
std::vector<uint8_t> GetMatchingLicensePublicKey() {
|
|
widevine::RsaTestKeys key_generator;
|
|
std::string init_data = key_generator.public_test_key_2_2048_bits();
|
|
return std::vector<uint8_t>(init_data.begin(), init_data.end());
|
|
}
|
|
|
|
std::vector<uint8_t> GetInvalidLicenseInitData() {
|
|
// For the OpenSSL implementation |init_data| is a private key. So a random
|
|
// collection of bytes should not be accepted.
|
|
return {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
|
}
|