Files
android/libwvdrmengine/oemcrypto/odk/test/odk_test_helper.h
Googler 5f980424e2 Fix 12 IncludeCleaner findings:
* Used header "video/widevine/export/common/oemcrypto_core_message/odk/include/OEMCryptoCENCCommon.h" is not included directly (4 times)
* Used header "video/widevine/export/common/oemcrypto_core_message/odk/include/core_message_features.h" is not included directly (3 times)
* Used header "video/widevine/protos/public/certificate_provisioning.proto.h" is not included directly (2 times)
* Used header "video/widevine/export/common/oemcrypto_core_message/odk/include/odk_structs.h" is not included directly
* Used header "video/widevine/export/common/oemcrypto_core_message/odk/include/odk_target.h" is not included directly
* Used header "third_party/absl/log/log.h" is not included directly

* See go/include-cleaner for more information about the tool that generated this change.
* The global approvers for this change category are currently piloting the go/reviewbot tool so you may see global-review-bot-composite as the approver. Please contact code-health-team@google.com if you have any questions/concerns about the approval process.

See go/include-cleaner-lsc-approval for more information on why you've received this change and why it is important.

This CL looks good? Just LGTM and Approve it!
This CL doesn’t look good? This is what you can do:
* Revert this CL, by replying "REVERT: <provide reason>"
* File a bug under go/include-cleaner-bug for category IncludeCleaner if there's an issue with the CL content.
* File a bug under go/rosie-bug if there's an issue with how the CL was managed.
* For all other issues such as the formatting of the CL, please file a bug under
go/clrobot-bug.
* Revert this CL and not get a CL that cleans up these paths in the future by
replying "BLOCKLIST: <provide reason>". This is not reversible! We recommend to
opt out the respective paths in your CL Robot configuration instead:
go/clrobot-opt-out.

This CL was generated by CL Robot - a tool that cleans up code findings
(go/clrobot). The affected code paths have been enabled for CL Robot in //depot/google3/METADATA by
following go/clrobot#how-to-opt-in. Anything wrong with the signup? File a bug
at go/clrobot-bug.

#codehealth

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 605228343
Change-Id: I7f5f581b6b2e2b359317324df7097f9da101ab94
2024-02-22 17:11:57 -08:00

132 lines
4.1 KiB
C++

// Copyright 2019 Google LLC. This file and proprietary
// source code may only be used and distributed under the Widevine
// License Agreement.
#ifndef WIDEVINE_ODK_TEST_ODK_TEST_HELPER_H_
#define WIDEVINE_ODK_TEST_ODK_TEST_HELPER_H_
#include <cstdint>
#include <string>
#include <vector>
#include "OEMCryptoCENCCommon.h"
#include "odk_structs.h"
#include "odk_structs_priv.h"
namespace wvodk_test {
enum ODK_FieldType {
ODK_UINT8,
ODK_UINT16,
ODK_UINT32,
ODK_UINT64,
ODK_INT64,
ODK_SUBSTRING,
ODK_DEVICEID,
ODK_DEVICEINFO,
ODK_MESSAGECOUNTER,
ODK_RENEWALDATA,
ODK_HASH,
// The "stressable" types are the ones we can put in a stress test that packs
// and unpacks random data and can expect to get back the same thing.
ODK_LAST_STRESSABLE_TYPE = ODK_HASH,
// Put boolean after ODK_LAST_STRESSABLE_TYPE, so that we skip boolean type in
// SerializeFieldsStress because we unpack any nonzero to 'true'.
ODK_BOOL,
};
enum ODK_FieldMode {
ODK_READ,
ODK_WRITE,
ODK_DUMP,
};
struct ODK_Field {
ODK_FieldType type;
void* value;
std::string name;
};
// This structure contains all parameters available in message version v16
// through the current version.
struct ODK_LicenseResponseParams {
ODK_CoreMessage core_message;
bool initial_license_load;
bool usage_entry_present;
uint8_t request_hash[ODK_SHA256_HASH_SIZE];
ODK_TimerLimits timer_limits;
ODK_ClockValues clock_values;
ODK_ParsedLicense parsed_license;
std::vector<ODK_Field> extra_fields;
};
struct ODK_ReleaseResponseParams {
ODK_CoreMessage core_message;
uint32_t status;
uint32_t clock_security_level;
int64_t seconds_since_license_requested;
int64_t seconds_since_first_decrypt;
std::vector<ODK_Field> extra_fields;
};
struct ODK_RenewalResponseParams {
ODK_CoreMessage core_message;
uint64_t system_time;
uint64_t playback_clock;
uint64_t renewal_duration;
ODK_TimerLimits timer_limits;
ODK_ClockValues clock_values;
uint64_t playback_timer;
std::vector<ODK_Field> extra_fields;
};
struct ODK_ProvisioningResponseParams {
ODK_CoreMessage core_message;
uint8_t device_id[ODK_DEVICE_ID_LEN_MAX];
uint32_t device_id_length;
ODK_MessageCounterInfo counter_info;
ODK_ParsedProvisioning parsed_provisioning;
std::vector<ODK_Field> extra_fields;
};
struct ODK_Provisioning40ResponseParams {
ODK_CoreMessage core_message;
std::vector<ODK_Field> extra_fields;
};
// Default values in core_message for testing
void ODK_SetDefaultCoreFields(ODK_CoreMessage* core_message,
ODK_MessageType message_type);
void ODK_SetDefaultLicenseResponseParams(ODK_LicenseResponseParams* params,
uint32_t odk_major_version);
void ODK_SetDefaultReleaseResponseParams(ODK_ReleaseResponseParams* params);
void ODK_SetDefaultRenewalResponseParams(ODK_RenewalResponseParams* params);
void ODK_SetDefaultProvisioningResponseParams(
ODK_ProvisioningResponseParams* params, uint32_t odk_major_version);
void ODK_SetDefaultProvisioning40ResponseParams(
ODK_Provisioning40ResponseParams* params);
size_t ODK_FieldLength(ODK_FieldType type);
size_t ODK_AllocSize(ODK_FieldType type);
// Copy ODK_Field to buf
OEMCryptoResult ODK_WriteSingleField(uint8_t* buf, const ODK_Field* field);
// Load buf to ODK_Field
OEMCryptoResult ODK_ReadSingleField(const uint8_t* buf, const ODK_Field* field);
OEMCryptoResult ODK_DumpSingleField(const uint8_t* buf, const ODK_Field* field);
OEMCryptoResult ODK_IterFields(ODK_FieldMode mode, uint8_t* buf, size_t size_in,
size_t* size_out,
const std::vector<ODK_Field>& fields);
void ODK_ExpectEqualBuf(const void* s1, const void* s2, size_t n,
const std::vector<ODK_Field>& fields);
void ODK_ResetOdkFields(std::vector<ODK_Field>* fields);
// Serialize core_message and extra_fields into buf
void ODK_BuildMessageBuffer(ODK_CoreMessage* core_message,
const std::vector<ODK_Field>& extra_fields,
uint8_t** buf, uint32_t* buf_size);
} // namespace wvodk_test
#endif // WIDEVINE_ODK_TEST_ODK_TEST_HELPER_H_