Source release 18.6.0

This commit is contained in:
Alex Dale
2024-06-27 12:54:34 -07:00
parent 28ec8548c6
commit 20c0587dcb
56 changed files with 1191 additions and 35538 deletions

View File

@@ -149,6 +149,17 @@ void show_menu(const char* prog_name, const std::string& extra_help_text) {
std::cout << extra_help_text << std::endl;
}
// Increment counter for AES-CTR. The CENC spec specifies we increment only
// the low 64 bits of the IV counter, and leave the high 64 bits alone. This
// is different from the BoringSSL implementation, so we implement the CTR loop
// ourselves.
void ctr128_inc64(int64_t increaseBy, std::vector<uint8_t>& iv) {
uint64_t* counterBuffer = reinterpret_cast<uint64_t*>(&(iv[8]));
(*counterBuffer) =
wvutil::htonll64(wvutil::ntohll64(*counterBuffer) + increaseBy);
}
} // namespace
std::unique_ptr<ConfigTestEnv> WvCdmTestBase::default_config_;
@@ -162,6 +173,26 @@ void WvCdmTestBase::StripeBuffer(std::vector<uint8_t>* buffer, size_t size,
}
}
// Encrypt a block of data using CTR mode.
std::vector<uint8_t> WvCdmTestBase::Aes128CtrEncrypt(
const std::vector<uint8_t>& key, const std::vector<uint8_t>& starting_iv,
const std::vector<uint8_t>& in_buffer) {
AES_KEY aes_key;
AES_set_encrypt_key(key.data(), AES_BLOCK_SIZE * 8, &aes_key);
std::vector<uint8_t> out_buffer(in_buffer.size());
std::vector<uint8_t> iv = starting_iv;
size_t l = 0; // byte index into encrypted subsample.
while (l < in_buffer.size()) {
uint8_t aes_output[AES_BLOCK_SIZE];
AES_encrypt(iv.data(), aes_output, &aes_key);
for (size_t n = 0; n < AES_BLOCK_SIZE && l < in_buffer.size(); n++, l++) {
out_buffer[l] = aes_output[n] ^ in_buffer[l];
}
ctr128_inc64(1, iv);
}
return out_buffer;
}
std::string WvCdmTestBase::Aes128CbcEncrypt(std::vector<uint8_t> key,
const std::vector<uint8_t>& clear,
std::vector<uint8_t> iv) {
@@ -330,12 +361,6 @@ void WvCdmTestBase::Provision() {
}
void WvCdmTestBase::EnsureProvisioned() {
// TODO: b/305093063 - Remove when Drm Reprovisioning server is implemented.
if (wvoec::global_features.provisioning_method ==
OEMCrypto_DrmReprovisioning) {
GTEST_SKIP()
<< "Skipping until Drm Reprovisioning server support is implemented.";
}
CdmSessionId session_id;
std::unique_ptr<wvutil::FileSystem> file_system(CreateTestFileSystem());
// OpenSession will check if a DRM certificate exists, while