Merge cdm changes to android repo
Bug: 251924225 Test: GtsMediaTestCases Change-Id: I1b4e64c0abf701fe1f5017f14dc72b72c3ea6770
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine
|
||||
// License Agreement.
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "oemcrypto_fuzz_helper.h"
|
||||
|
||||
namespace wvoec {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// Redirect printf and log statements from oemcrypto functions to a file to
|
||||
// reduce noise
|
||||
RedirectStdoutToFile();
|
||||
if (size < sizeof(ODK_ParsedLicense) + sizeof(MessageData)) {
|
||||
return 0;
|
||||
}
|
||||
OEMCryptoLicenseAPIFuzz license_api_fuzz;
|
||||
license_api_fuzz.license_messages().set_license_type(
|
||||
OEMCrypto_EntitlementLicense);
|
||||
license_api_fuzz.license_messages().SignAndVerifyRequest();
|
||||
// Interpreting input fuzz data as unencrypted (core_response + license
|
||||
// message data) from license server.
|
||||
license_api_fuzz.license_messages().InjectFuzzedResponseData(data, size);
|
||||
license_api_fuzz.license_messages().EncryptAndSignResponse();
|
||||
license_api_fuzz.license_messages().LoadResponse();
|
||||
|
||||
uint32_t key_session_id;
|
||||
OEMCrypto_CreateEntitledKeySession(license_api_fuzz.session_id(),
|
||||
&key_session_id);
|
||||
|
||||
OEMCrypto_RemoveEntitledKeySession(key_session_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace wvoec
|
||||
@@ -16,8 +16,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
Session* session = entry.license_messages().session();
|
||||
session->open();
|
||||
entry.InstallTestRSAKey(session);
|
||||
session->GenerateNonce();
|
||||
session->CreateNewUsageEntry();
|
||||
session->GenerateNonce();
|
||||
vector<uint8_t> encrypted_usage_header;
|
||||
session->UpdateUsageEntry(&encrypted_usage_header);
|
||||
// LoadLicense sets the pst for usage entry.
|
||||
|
||||
@@ -52,6 +52,8 @@ class OEMCryptoLicenseAPIFuzz : public InitializeFuzz {
|
||||
|
||||
Session* session() { return &session_; }
|
||||
|
||||
uint32_t session_id() { return session_.session_id(); }
|
||||
|
||||
void LoadLicense();
|
||||
|
||||
private:
|
||||
|
||||
@@ -49,10 +49,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
Session* session = license_api_fuzz.session();
|
||||
// Load license and call generic_decrypt API.
|
||||
license_api_fuzz.LoadLicense();
|
||||
OEMCryptoResult sts = OEMCrypto_SelectKey(
|
||||
session->session_id(), session->license().keys[0].key_id,
|
||||
session->license().keys[0].key_id_length, fuzzed_structure.cipher_mode);
|
||||
CheckStatusAndExitFuzzerOnFailure(sts, OEMCrypto_SUCCESS);
|
||||
OEMCrypto_SelectKey(session->session_id(), session->license().keys[0].key_id,
|
||||
session->license().keys[0].key_id_length,
|
||||
fuzzed_structure.cipher_mode);
|
||||
OEMCrypto_Generic_Decrypt(session->session_id(), encrypted_buffer.data(),
|
||||
encrypted_buffer.size(), iv.data(),
|
||||
fuzzed_structure.algorithm, clear_buffer.data());
|
||||
|
||||
@@ -49,10 +49,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
Session* session = license_api_fuzz.session();
|
||||
// Load license and call generic_encrypt API.
|
||||
license_api_fuzz.LoadLicense();
|
||||
OEMCryptoResult sts = OEMCrypto_SelectKey(
|
||||
session->session_id(), session->license().keys[0].key_id,
|
||||
session->license().keys[0].key_id_length, fuzzed_structure.cipher_mode);
|
||||
CheckStatusAndExitFuzzerOnFailure(sts, OEMCrypto_SUCCESS);
|
||||
OEMCrypto_SelectKey(session->session_id(), session->license().keys[0].key_id,
|
||||
session->license().keys[0].key_id_length,
|
||||
fuzzed_structure.cipher_mode);
|
||||
OEMCrypto_Generic_Encrypt(
|
||||
session->session_id(), clear_buffer.data(), clear_buffer.size(),
|
||||
iv.data(), fuzzed_structure.algorithm, encrypted_buffer.data());
|
||||
|
||||
@@ -38,10 +38,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
Session* session = license_api_fuzz.session();
|
||||
// Load license and call generic_sign API.
|
||||
license_api_fuzz.LoadLicense();
|
||||
OEMCryptoResult sts = OEMCrypto_SelectKey(
|
||||
session->session_id(), session->license().keys[0].key_id,
|
||||
session->license().keys[0].key_id_length, fuzzed_structure.cipher_mode);
|
||||
CheckStatusAndExitFuzzerOnFailure(sts, OEMCrypto_SUCCESS);
|
||||
OEMCrypto_SelectKey(session->session_id(), session->license().keys[0].key_id,
|
||||
session->license().keys[0].key_id_length,
|
||||
fuzzed_structure.cipher_mode);
|
||||
size_t signature_length = 0;
|
||||
OEMCrypto_Generic_Sign(session->session_id(), clear_buffer.data(),
|
||||
clear_buffer.size(), fuzzed_structure.algorithm,
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "oemcrypto_fuzz_helper.h"
|
||||
|
||||
namespace wvoec {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// Redirect printf and log statements from oemcrypto functions to a file to
|
||||
// reduce noise
|
||||
RedirectStdoutToFile();
|
||||
|
||||
size_t pst_buffer_length = 0;
|
||||
if (size <= sizeof(pst_buffer_length)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LicenseWithUsageEntryFuzz entry;
|
||||
entry.CreateUsageTableHeader();
|
||||
// Open a session, create a usage entry.
|
||||
Session* session = entry.license_messages().session();
|
||||
session->open();
|
||||
entry.InstallTestRSAKey(session);
|
||||
session->GenerateNonce();
|
||||
session->CreateNewUsageEntry();
|
||||
vector<uint8_t> encrypted_usage_header;
|
||||
session->UpdateUsageEntry(&encrypted_usage_header);
|
||||
std::vector<uint8_t> wrapped_private_key(size);
|
||||
memcpy(wrapped_private_key.data(), data, size);
|
||||
OEMCrypto_PrivateKeyType key_type = OEMCrypto_RSA_Private_Key;
|
||||
OEMCrypto_InstallOemPrivateKey(session->session_id(), key_type, wrapped_private_key.data(), size);
|
||||
session->close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "oemcrypto_fuzz_helper.h"
|
||||
|
||||
namespace wvoec {
|
||||
LicenseWithUsageEntryFuzz entry;
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// Redirect printf and log statements from oemcrypto functions to a file to
|
||||
// reduce noise
|
||||
RedirectStdoutToFile();
|
||||
|
||||
uint32_t usage_entry_number = 0;
|
||||
if (size < sizeof(usage_entry_number)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry.CreateUsageTableHeader();
|
||||
Session* s = entry.license_messages().session();
|
||||
s->open();
|
||||
entry.InstallTestRSAKey(s);
|
||||
memcpy(&usage_entry_number, data, sizeof(uint32_t));
|
||||
s->CreateNewUsageEntry();
|
||||
vector<uint8_t> encrypted_usage_header;
|
||||
s->UpdateUsageEntry(&encrypted_usage_header);
|
||||
OEMCrypto_MoveEntry(s->session_id(), usage_entry_number);
|
||||
s ->close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace wvoec
|
||||
@@ -22,8 +22,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
Session* session = entry.license_messages().session();
|
||||
session->open();
|
||||
entry.InstallTestRSAKey(session);
|
||||
session->GenerateNonce();
|
||||
session->CreateNewUsageEntry();
|
||||
session->GenerateNonce();
|
||||
vector<uint8_t> encrypted_usage_header;
|
||||
session->UpdateUsageEntry(&encrypted_usage_header);
|
||||
// Sets pst for usage entry.
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "oemcrypto_fuzz_helper.h"
|
||||
|
||||
namespace wvoec {
|
||||
LicenseWithUsageEntryFuzz entry;
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// Redirect printf and log statements from oemcrypto functions to a file to
|
||||
// reduce noise
|
||||
RedirectStdoutToFile();
|
||||
|
||||
uint32_t usage_entry_number = 0;
|
||||
if (size < sizeof(usage_entry_number)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry.CreateUsageTableHeader();
|
||||
Session* s = entry.license_messages().session();
|
||||
s->open();
|
||||
entry.InstallTestRSAKey(s);
|
||||
s->CreateNewUsageEntry();
|
||||
s->close();
|
||||
s->open();
|
||||
memcpy(&usage_entry_number, data, sizeof(uint32_t));
|
||||
OEMCrypto_ReuseUsageEntry(s->session_id(), usage_entry_number);
|
||||
s->close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace wvoec
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine
|
||||
// License Agreement.
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "oemcrypto_fuzz_helper.h"
|
||||
|
||||
namespace wvoec {
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
// Redirect printf and log statements from oemcrypto functions to a file to
|
||||
// reduce noise
|
||||
RedirectStdoutToFile();
|
||||
|
||||
if (size < sizeof(uint32_t)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LicenseWithUsageEntryFuzz entry;
|
||||
uint32_t new_entry_count = 0;
|
||||
memcpy(&new_entry_count, data, sizeof(uint32_t));
|
||||
std::vector<uint8_t> header_buffer(size - sizeof(uint32_t));
|
||||
size_t header_buffer_length = header_buffer.size();
|
||||
OEMCrypto_ShrinkUsageTableHeader(new_entry_count, header_buffer.data(),
|
||||
&header_buffer_length);
|
||||
|
||||
return 0;
|
||||
}
|
||||
} // namespace wvoec
|
||||
Reference in New Issue
Block a user