From 882d3ed07518e36027491bac73a8f644551a6beb Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 13 Oct 2021 22:00:06 +0000 Subject: [PATCH 1/5] Added an oemcrypto test for OPK versioning Merge from Widevine repo of http://go/wvgerrit/125645 bug: 158857733 test: opk_linux_ipc_ta Change-Id: Ibcbb143fa0eb7d2b4e14e3cc9afbe3a219c7c727 --- .../core/src/oemcrypto_adapter_dynamic.cpp | 18 +++ .../oemcrypto_serialization_version_test.cpp | 107 ++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 libwvdrmengine/oemcrypto/test/oemcrypto_serialization_version_test.cpp diff --git a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp index 8d57fb3e..bc70903b 100644 --- a/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp +++ b/libwvdrmengine/cdm/core/src/oemcrypto_adapter_dynamic.cpp @@ -319,6 +319,10 @@ typedef OEMCryptoResult (*L1_LoadProvisioning_t)( size_t signature_length, uint8_t* wrapped_private_key, size_t* wrapped_private_key_length); typedef uint32_t (*L1_MinorAPIVersion_t)(); +typedef OEMCryptoResult (*L1_OPK_SerializationVersion_t)(uint32_t* ree_major, + uint32_t* ree_minor, + uint32_t* tee_major, + uint32_t* tee_minor); typedef OEMCryptoResult (*L1_GenerateOTARequest_t)(OEMCrypto_SESSION session, uint8_t* buffer, size_t* buffer_length, @@ -411,6 +415,7 @@ struct FunctionPointers { L1_MaximumUsageTableHeaderSize_t MaximumUsageTableHeaderSize; L1_LoadProvisioning_t LoadProvisioning; L1_MinorAPIVersion_t MinorAPIVersion; + L1_OPK_SerializationVersion_t OPK_SerializationVersion; L1_LoadKeys_V8_t LoadKeys_V8; L1_GenerateRSASignature_V8_t GenerateRSASignature_V8; @@ -961,6 +966,7 @@ class Adapter { LOOKUP_ALL(16, MaximumUsageTableHeaderSize, OEMCrypto_MaximumUsageTableHeaderSize); LOOKUP_ALL(16, LoadProvisioning, OEMCrypto_LoadProvisioning); LOOKUP_ALL(16, MinorAPIVersion, OEMCrypto_MinorAPIVersion); + LOOKUP_ALL(16, OPK_SerializationVersion, OEMCrypto_OPK_SerializationVersion); LOOKUP_ALL(16, GenerateOTARequest, OEMCrypto_GenerateOTARequest); LOOKUP_ALL(16, ProcessOTAKeybox, OEMCrypto_ProcessOTAKeybox); // clang-format on @@ -2873,6 +2879,18 @@ extern "C" OEMCryptoResult OEMCrypto_FreeSecureBuffer( return pair.fcn->FreeSecureBuffer(pair.session, output_descriptor, secure_fd); } +extern "C" OEMCryptoResult OEMCrypto_OPK_SerializationVersion( + uint32_t* ree_major, uint32_t* ree_minor, uint32_t* tee_major, + uint32_t* tee_minor) { + if (!gAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE; + const FunctionPointers* fcn = gAdapter->GetFunctionPointers(kLevelDefault); + if (!fcn || fcn->OPK_SerializationVersion == nullptr) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; + } + return fcn->OPK_SerializationVersion(ree_major, ree_minor, tee_major, + tee_minor); +} + extern "C" OEMCryptoResult OEMCrypto_GenerateOTARequest( OEMCrypto_SESSION session, uint8_t* buffer, size_t* buffer_length, uint32_t use_test_key) { diff --git a/libwvdrmengine/oemcrypto/test/oemcrypto_serialization_version_test.cpp b/libwvdrmengine/oemcrypto/test/oemcrypto_serialization_version_test.cpp new file mode 100644 index 00000000..31bfacb5 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/oemcrypto_serialization_version_test.cpp @@ -0,0 +1,107 @@ +// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine +// License Agreement. +// + +#include + +#include + +#include "OEMCryptoCENC.h" +#include "log.h" +#include "oec_test_data.h" + +using namespace std; + +namespace wvoec { + +class OEMCryptoTest : public ::testing::Test { + protected: + OEMCryptoTest() {} + + void SetUp() override { + ::testing::Test::SetUp(); + const ::testing::TestInfo* const test_info = + ::testing::UnitTest::GetInstance()->current_test_info(); + LOGD("Running test %s.%s", test_info->test_case_name(), test_info->name()); + OEMCrypto_SetSandbox(kTestSandbox, sizeof(kTestSandbox)); + ASSERT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize()); + } + + void TearDown() override { + OEMCrypto_Terminate(); + ::testing::Test::TearDown(); + } +}; + +TEST_F(OEMCryptoTest, OPK_SerializationVersion) { + uint32_t ree_major = 0; + uint32_t ree_minor = 0; + uint32_t tee_major = 0; + uint32_t tee_minor = 0; + OEMCryptoResult sts = OEMCrypto_OPK_SerializationVersion( + &ree_major, &ree_minor, &tee_major, &tee_minor); + if (sts != OEMCrypto_ERROR_NOT_IMPLEMENTED) { + EXPECT_EQ(OEMCrypto_SUCCESS, sts); + cout << "OPK REE serialization version is " << ree_major << "." << ree_minor + << "\n"; + cout << "OPK TEE serialization version is " << tee_major << "." << tee_minor + << "\n"; + EXPECT_NE(ree_major, 0u); + EXPECT_NE(tee_major, 0u); + + const uint32_t orig_ree_major = ree_major; + const uint32_t orig_ree_minor = ree_minor; + const uint32_t orig_tee_major = tee_major; + const uint32_t orig_tee_minor = tee_minor; + + /* test requiring a specific version, should create incompatibility */ + ree_major = 100; + ree_minor = 1; + sts = OEMCrypto_OPK_SerializationVersion(&ree_major, &ree_minor, &tee_major, + &tee_minor); + EXPECT_EQ(OPK_ERROR_INCOMPATIBLE_VERSION, sts); + EXPECT_EQ(ree_major, 100u); + EXPECT_EQ(ree_minor, 1u); + + /* now OEMCrypto_Initialize should fail with incompatible version */ + OEMCrypto_Terminate(); + EXPECT_EQ(OPK_ERROR_INCOMPATIBLE_VERSION, OEMCrypto_Initialize()); + + /* restore the default versions */ + ree_major = 0; + ree_minor = 0; + sts = OEMCrypto_OPK_SerializationVersion(&ree_major, &ree_minor, &tee_major, + &tee_minor); + EXPECT_EQ(OEMCrypto_SUCCESS, sts); + EXPECT_EQ(ree_major, orig_ree_major); + EXPECT_EQ(ree_minor, orig_ree_minor); + EXPECT_EQ(tee_major, orig_tee_major); + EXPECT_EQ(tee_minor, orig_tee_minor); + + /* OEMCrypto_Initialize should work now */ + OEMCrypto_Terminate(); + EXPECT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize()); + + /* changing minor version shouldn't create incompatibility */ + ree_minor++; + sts = OEMCrypto_OPK_SerializationVersion(&ree_major, &ree_minor, &tee_major, + &tee_minor); + EXPECT_EQ(ree_minor, orig_ree_minor + 1); + EXPECT_EQ(OEMCrypto_SUCCESS, sts); + + /* OEMCrypto_Initialize should still work */ + OEMCrypto_Terminate(); + EXPECT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize()); + + /* remove the REE version override so subsequent tests work */ + ree_major = 0; + ree_minor = 0; + sts = OEMCrypto_OPK_SerializationVersion(&ree_major, &ree_minor, &tee_major, + &tee_minor); + EXPECT_EQ(OEMCrypto_SUCCESS, sts); + EXPECT_EQ(OEMCrypto_SUCCESS, OEMCrypto_Initialize()); + } +} + +} // namespace wvoec From c7e237eb00c5781a6259e59d7b4ce5ab4cf7e28a Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 13 Oct 2021 22:02:15 +0000 Subject: [PATCH 2/5] Update fuzz tests Several updates to fuzz tests, including http://go/wvgerrit/124043 Add documentation for partners to run fuzzing http://go/wvgerrit/128224 Fix generic verify fuzz script http://go/wvgerrit/120507 Fuzzing: Add fuzzer for reportusage API http://go/wvgerrit/120503 Fuzzing: Add fuzzer for deactivate usageentry API http://go/wvgerrit/120463 Fuzzing: Add logic to exit fuzzer script http://go/wvgerrit/120444 Fuzzing: Add fuzzer for loadusageentry API Bug: 183154879 Bug: 202994773 Bug: 186785830 Test: test only code Change-Id: I877681461824c51bc82f0766a9973378aafadba7 --- .../oemcrypto/test/fuzz_tests/README.md | 34 +++- .../test/fuzz_tests/build_clusterfuzz.md | 174 ++++++++++++++++++ .../test/fuzz_tests/build_oemcrypto_fuzztests | 6 +- .../build_partner_oemcrypto_fuzztests | 15 ++ .../1970fbbb5d20902996167f3309fbd38a6850b147 | Bin 0 -> 296 bytes .../5812ad7753622d9177a1b3dd71c6c4a008ff54eb | Bin 0 -> 296 bytes .../10da8c370429a6a450d5ad0ee563653d18dbfeb8 | Bin 0 -> 140 bytes .../1ae600c50a9a0bca685d7b83004fa3135901ded2 | Bin 0 -> 204 bytes .../21d16dc13d2b8103c7943a5bd960ebc77dfefde4 | Bin 0 -> 204 bytes .../38d4821122ddf0e84dba312f444bfbef5b81cc9d | Bin 0 -> 204 bytes .../3cdf5d3cd5937b78d2560970a0ccce14fb0d0230 | Bin 0 -> 588 bytes .../3cf22dc963d6705061004cb0fad32bdebc86ffc9 | Bin 0 -> 140 bytes .../3d891464eace6f7d3c716830e6051f7e90b90610 | Bin 0 -> 140 bytes .../6f65463040c50e026e252e7544dff41babbc4604 | Bin 0 -> 140 bytes .../737cd5853708e2d2732e4c54dc944bc54d522406 | Bin 0 -> 428 bytes .../d775f9b5597e76cbf380ad74fea86c307c224309 | Bin 0 -> 140 bytes .../e9c4232d40cbc76f71220641ea9f8740bfedd306 | Bin 0 -> 204 bytes .../eaf3adf2980f1f1f021aafe465ec04d2bbf5d1ce | Bin 0 -> 140 bytes .../f6c28150e2e1a1390516a09d453d33cb9a1337b4 | Bin 0 -> 204 bytes .../1315634022 | Bin 0 -> 66 bytes .../6c6a072aa58399454ee759bac539109a20f7e97f | Bin 0 -> 188 bytes .../75ae4c5769c9568d631452df3b3702d876e4863a | Bin 0 -> 178 bytes .../9bdb356ec50807b86c807c09c780267101fd1a0b | Bin 0 -> 178 bytes .../4114e243c6726f2d6dd11baefc4ad43fbd2b3595 | Bin 0 -> 178 bytes .../424ad879ed92e646707f53a2cd963910ffbb5c08 | Bin 0 -> 188 bytes .../f5d513d7333b92263ad849759db52a0cb4f383cd | Bin 0 -> 168 bytes .../374d2a1ab0be81451653b26a0ff99c2f20351700 | Bin 0 -> 176 bytes .../7a883f7628e57eb5fe48d660fed48ac5da2f5d21 | Bin 0 -> 176 bytes .../a591b11c7ff1f45e8edb1a055a3255edb247576d | Bin 0 -> 176 bytes .../c182ac7556d1cd1ed73da74882dee807381f3ee0 | Bin 0 -> 176 bytes .../3f58051d431ac575d0b804b2d512e46d7e8b4cda | Bin 0 -> 78 bytes .../4e2fef7ad945773dd77eb37d7d08dd2368ad4b89 | Bin 0 -> 78 bytes .../6f8b954fb7f8be2c3632f931aaf55e3d1a6c58d8 | Bin 0 -> 676 bytes .../7997b5673d5a9402b2f8acc43f92cdf6ad1f913d | Bin 0 -> 676 bytes .../8196b2365ca56224853dfeeddde216b4f467f0dd | Bin 0 -> 676 bytes .../81ac6d013d80da7f67fe6fbb5e8c15a35a0d8134 | Bin 0 -> 676 bytes .../0567e5f52c00fed0ad7858164434b02d8e629064 | Bin 0 -> 6648 bytes .../0f5cc252aaf43eaa1570ca07d174a0f96333c592 | Bin 0 -> 6648 bytes .../0fdcae4df7bc325099fb4b3b01a1c9290229f86c | Bin 0 -> 6648 bytes .../134a0d85fbcbe367e66d69127114bece71add806 | Bin 0 -> 6648 bytes .../1ee4b9ce1a4acc41e912487383ad77f3ccaa97fb | Bin 0 -> 6648 bytes .../2d7246bd48ed8b68599445c98bb822c87f86acd1 | Bin 0 -> 6648 bytes .../2f64b8ffa25844924fe24678067feee9be80f4ec | Bin 0 -> 6648 bytes .../3acf30d485a4370ceb8e64785094a50b768e1ca4 | Bin 0 -> 6648 bytes .../461c08228ae6a0eaa191d24eea1823b46f4a9d67 | Bin 0 -> 6648 bytes .../4b69b92f45febc4dbf5b8fb9a216a290ba51d478 | Bin 0 -> 6648 bytes .../5db53de009652f61b1ed21ee988d0156ce287033 | Bin 0 -> 6648 bytes .../618cdf5927b2b092d9d7b5e93c30af8708270f11 | Bin 0 -> 6648 bytes .../78e527f05b03c2ecd8a0ffc2baeb5dab57088934 | Bin 0 -> 6648 bytes .../7dcdad1c2df1656678947b2009a9fcea44f4025d | Bin 0 -> 6648 bytes .../7e120b1ec852c448490b9b060a5f35deb486c360 | Bin 0 -> 6648 bytes .../7f701c0f31e68192bc8c829f343fa2326aa4d3dc | Bin 0 -> 6648 bytes .../8243212a7a7160c91e2f9717b855b568f9a34233 | Bin 0 -> 6648 bytes .../85bff933def1ce530a1febd93ef2890ed4bcdcb5 | Bin 0 -> 6648 bytes .../a06905d0b9421966c527b5ef2ac68bdce1e0cfe5 | Bin 0 -> 6648 bytes .../b452f7b6c615035d63a9825c5c17e049f54648ef | Bin 0 -> 6648 bytes .../bb8c2201cf10fd7d24fc0c8009a44525f426b033 | Bin 0 -> 6648 bytes .../c7a7cd07925450628efa677165d403510d89bf51 | Bin 0 -> 6648 bytes ...mcrypto_load_license_fuzz-5919435528601600 | Bin 0 -> 6652 bytes ...mcrypto_load_license_fuzz-6406770604638208 | Bin 0 -> 6648 bytes .../d7014f417415314dd83162570bcafd7935875f00 | Bin 0 -> 6648 bytes .../e26757270b3d149d1ce10bef32ed0b3a5794977c | Bin 0 -> 6648 bytes .../e598a949c6b14e1a3f96bcdf1b3d9335b07a6085 | Bin 0 -> 6648 bytes .../2f194a24b3b2f2e096403926fca6b2fda4883e7c | Bin 0 -> 4096 bytes .../4b31607722adad1f28555bc9b07cd17100a90df6 | Bin 0 -> 4096 bytes .../543f332b627f3891b3f15c6227f4f946cba81886 | Bin 0 -> 4096 bytes .../6a33ae6e95eb1b9fbf116359df679265376b308b | Bin 0 -> 4096 bytes .../a98f2da86c01706159e32fc37c1a6b2df779395a | Bin 0 -> 4096 bytes .../dc6e941489e6164e349a9dd0a80713f57645b0db | Bin 0 -> 4096 bytes .../fb7a84cdab0bff7dabb339c7fc35eb2ea3c2eb9c | Bin 0 -> 4096 bytes .../f00652aa0e80e90257bfa28a63e623a92e25d4d8 | Bin 0 -> 3992 bytes .../f2f45ab615736936405ec6c8df9ab92dbc91017b | Bin 0 -> 3992 bytes .../6ee38ff02d14cae0565cd26553cde5f898444014 | Bin 0 -> 146 bytes .../2e120b916a62c00addf137d7e7733620394009b8 | Bin 0 -> 58 bytes .../oemcrypto_deactivate_usage_entry_fuzz.cc | 30 +++ .../fuzz_tests/oemcrypto_decrypt_cenc_fuzz.cc | 8 +- .../test/fuzz_tests/oemcrypto_fuzz_helper.cc | 41 +++++ .../test/fuzz_tests/oemcrypto_fuzz_helper.h | 42 ++++- .../test/fuzz_tests/oemcrypto_fuzz_structs.h | 31 ++++ .../oemcrypto_generate_rsa_signature_fuzz.cc | 34 ++++ .../oemcrypto_generic_decrypt_fuzz.cc | 61 ++++++ .../oemcrypto_generic_encrypt_fuzz.cc | 61 ++++++ .../fuzz_tests/oemcrypto_generic_sign_fuzz.cc | 55 ++++++ .../oemcrypto_generic_verify_fuzz.cc | 67 +++++++ .../oemcrypto_load_usage_entry_fuzz.cc | 61 ++++++ .../oemcrypto_load_usage_table_header_fuzz.cc | 36 ++++ ...zz.cc => oemcrypto_opk_dispatcher_fuzz.cc} | 45 ++--- .../fuzz_tests/oemcrypto_report_usage_fuzz.cc | 46 +++++ .../test/oec_decrypt_fallback_chain.cpp | 14 +- .../test/oec_decrypt_fallback_chain.h | 1 + 90 files changed, 806 insertions(+), 56 deletions(-) create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/build_clusterfuzz.md create mode 100755 libwvdrmengine/oemcrypto/test/fuzz_tests/build_partner_oemcrypto_fuzztests create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_copy_buffer_fuzz_seed_corpus/1970fbbb5d20902996167f3309fbd38a6850b147 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_copy_buffer_fuzz_seed_corpus/5812ad7753622d9177a1b3dd71c6c4a008ff54eb create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/10da8c370429a6a450d5ad0ee563653d18dbfeb8 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/1ae600c50a9a0bca685d7b83004fa3135901ded2 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/21d16dc13d2b8103c7943a5bd960ebc77dfefde4 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/38d4821122ddf0e84dba312f444bfbef5b81cc9d create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/3cdf5d3cd5937b78d2560970a0ccce14fb0d0230 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/3cf22dc963d6705061004cb0fad32bdebc86ffc9 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/3d891464eace6f7d3c716830e6051f7e90b90610 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/6f65463040c50e026e252e7544dff41babbc4604 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/737cd5853708e2d2732e4c54dc944bc54d522406 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/d775f9b5597e76cbf380ad74fea86c307c224309 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/e9c4232d40cbc76f71220641ea9f8740bfedd306 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/eaf3adf2980f1f1f021aafe465ec04d2bbf5d1ce create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/f6c28150e2e1a1390516a09d453d33cb9a1337b4 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generate_rsa_signature_fuzz_seed_corpus/1315634022 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/6c6a072aa58399454ee759bac539109a20f7e97f create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/75ae4c5769c9568d631452df3b3702d876e4863a create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/9bdb356ec50807b86c807c09c780267101fd1a0b create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_encrypt_fuzz_seed_corpus/4114e243c6726f2d6dd11baefc4ad43fbd2b3595 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_encrypt_fuzz_seed_corpus/424ad879ed92e646707f53a2cd963910ffbb5c08 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_sign_fuzz_seed_corpus/f5d513d7333b92263ad849759db52a0cb4f383cd create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/374d2a1ab0be81451653b26a0ff99c2f20351700 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/7a883f7628e57eb5fe48d660fed48ac5da2f5d21 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/a591b11c7ff1f45e8edb1a055a3255edb247576d create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/c182ac7556d1cd1ed73da74882dee807381f3ee0 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_license_request_fuzz_seed_corpus/3f58051d431ac575d0b804b2d512e46d7e8b4cda create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_license_request_fuzz_seed_corpus/4e2fef7ad945773dd77eb37d7d08dd2368ad4b89 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/6f8b954fb7f8be2c3632f931aaf55e3d1a6c58d8 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/7997b5673d5a9402b2f8acc43f92cdf6ad1f913d create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/8196b2365ca56224853dfeeddde216b4f467f0dd create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/81ac6d013d80da7f67fe6fbb5e8c15a35a0d8134 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/0567e5f52c00fed0ad7858164434b02d8e629064 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/0f5cc252aaf43eaa1570ca07d174a0f96333c592 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/0fdcae4df7bc325099fb4b3b01a1c9290229f86c create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/134a0d85fbcbe367e66d69127114bece71add806 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/1ee4b9ce1a4acc41e912487383ad77f3ccaa97fb create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/2d7246bd48ed8b68599445c98bb822c87f86acd1 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/2f64b8ffa25844924fe24678067feee9be80f4ec create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/3acf30d485a4370ceb8e64785094a50b768e1ca4 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/461c08228ae6a0eaa191d24eea1823b46f4a9d67 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/4b69b92f45febc4dbf5b8fb9a216a290ba51d478 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/5db53de009652f61b1ed21ee988d0156ce287033 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/618cdf5927b2b092d9d7b5e93c30af8708270f11 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/78e527f05b03c2ecd8a0ffc2baeb5dab57088934 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/7dcdad1c2df1656678947b2009a9fcea44f4025d create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/7e120b1ec852c448490b9b060a5f35deb486c360 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/7f701c0f31e68192bc8c829f343fa2326aa4d3dc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/8243212a7a7160c91e2f9717b855b568f9a34233 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/85bff933def1ce530a1febd93ef2890ed4bcdcb5 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/a06905d0b9421966c527b5ef2ac68bdce1e0cfe5 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/b452f7b6c615035d63a9825c5c17e049f54648ef create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/bb8c2201cf10fd7d24fc0c8009a44525f426b033 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/c7a7cd07925450628efa677165d403510d89bf51 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/clusterfuzz-testcase-minimized-oemcrypto_load_license_fuzz-5919435528601600 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/clusterfuzz-testcase-minimized-oemcrypto_load_license_fuzz-6406770604638208 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/d7014f417415314dd83162570bcafd7935875f00 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/e26757270b3d149d1ce10bef32ed0b3a5794977c create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/e598a949c6b14e1a3f96bcdf1b3d9335b07a6085 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/2f194a24b3b2f2e096403926fca6b2fda4883e7c create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/4b31607722adad1f28555bc9b07cd17100a90df6 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/543f332b627f3891b3f15c6227f4f946cba81886 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/6a33ae6e95eb1b9fbf116359df679265376b308b create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/a98f2da86c01706159e32fc37c1a6b2df779395a create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/dc6e941489e6164e349a9dd0a80713f57645b0db create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/fb7a84cdab0bff7dabb339c7fc35eb2ea3c2eb9c create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_renewal_fuzz_seed_corpus/f00652aa0e80e90257bfa28a63e623a92e25d4d8 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_renewal_fuzz_seed_corpus/f2f45ab615736936405ec6c8df9ab92dbc91017b create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_provisioning_request_fuzz_seed_corpus/6ee38ff02d14cae0565cd26553cde5f898444014 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_renewal_request_fuzz_seed_corpus/2e120b916a62c00addf137d7e7733620394009b8 create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_deactivate_usage_entry_fuzz.cc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_rsa_signature_fuzz.cc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_decrypt_fuzz.cc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_encrypt_fuzz.cc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_sign_fuzz.cc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_verify_fuzz.cc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_entry_fuzz.cc create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_table_header_fuzz.cc rename libwvdrmengine/oemcrypto/test/fuzz_tests/{oemcrypto_odkitee_dispatcher_fuzz.cc => oemcrypto_opk_dispatcher_fuzz.cc} (50%) create mode 100644 libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_report_usage_fuzz.cc diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/README.md b/libwvdrmengine/oemcrypto/test/fuzz_tests/README.md index 8c163fb1..3f664446 100644 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/README.md +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/README.md @@ -1,5 +1,9 @@ # OEMCRYPTO Fuzzing +Refer to [Setting up Clusterfuzz](build_clusterfuzz.md) if you are interested +in setting up a local instance of cluster fuzz to run fuzzing on your own +OEMCrypto implementations on linux. + ## Objective * Run fuzzing on OEMCrypto public APIs on linux using google supported @@ -76,13 +80,31 @@ $ export PATH_TO_CDM_DIR=.. $ gyp --format=ninja --depth=$(pwd) oemcrypto/oemcrypto_unittests.gyp $ ninja -C out/Default/ - $ ./out/Default/oemcrypto_unittests --generate_corpus + $ mkdir oemcrypto/test/fuzz_tests/corpus/_seed_corpus + # Generate corpus by excluding buffer overflow tests. + $ ./out/Default/oemcrypto_unittests --generate_corpus \ + --gtest_filter=-"*Huge*" ``` -* To avoid uploading huge binary files to git repository, the corpus files - will be saved in fuzzername_seed_corpus.zip format in blockbuster project's - oemcrypto_fuzzing_corpus GCS bucket using gsutil. If you need permissions - for blockbuster project, contact widevine-engprod@google.com. +* There can be lot of duplicate corpus files that are generated from unit + tests. We can minimize the corpus files to only a subset of files that + cover unique paths within the API when run using fuzzer. Run following + command to minimize corpus. + + ```shell + $ cd /path/to/cdm/repo + # build fuzzer binaries + $ ./oemcrypto/test/fuzz_tests/build_oemcrypto_fuzztests + $ mkdir /tmp/minimized_corpus + # minimize corpus + $ ./out/Default/ -merge=1 /tmp/minimized_corpus \ + + ``` + +* To avoid uploading huge binary files to git repository, the minimized corpus + files will be saved in fuzzername_seed_corpus.zip format in blockbuster + project's oemcrypto_fuzzing_corpus GCS bucket using gsutil. If you need + permissions for blockbuster project, contact widevine-engprod@google.com. ```shell $ gsutil cp gs://oemcrypto_fuzzing_corpus/ \ @@ -106,7 +128,7 @@ * Build and test fuzz scripts locally using following commands. The build script builds fuzz binaries for both oemcrypto reference implementation - as well as odkitee implementation. + as well as opk implementation. ```shell $ cd PATH_TO_CDM_DIR diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/build_clusterfuzz.md b/libwvdrmengine/oemcrypto/test/fuzz_tests/build_clusterfuzz.md new file mode 100644 index 00000000..f3a0108b --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/build_clusterfuzz.md @@ -0,0 +1,174 @@ +# OEMCRYPTO Fuzzing - Build clustefuzz and run fuzzing + +## Objective + +* Run fuzzing on OEMCrypto public APIs on linux by building open sourced + clusterfuzz source code in order to find security vulnerabilities. + + [Clusterfuzz][1] + +* Partners who implement OEMCrypto can follow these instructions to build + clusterfuzz, the fuzzing framework and run fuzzing using fuzzer scripts + provided by the Widevine team at Google. + +## Glossary + +* Fuzzing - Fuzzing is a methodology where random, interesting, unexpected + inputs are fed to APIs in order to crash those, thereby catching any + security vulnerabilities with the code. + +* Fuzzing engines - [libfuzzer][4], afl, honggfuzz are the actual fuzzing + engines that get the coverage information from API, use that to generate + more interesting inputs which can be passed to fuzzer. + +* Seed corpus - Fuzzing engine trying to generate interesting inputs from an + empty file is not efficient. Seed corpus is the initial input that a fuzzer + can accept and call the API with that. Fuzzing engine can then mutate this + seed corpus to generate more inputs to fuzzer. + +* Clusterfuzz - ClusterFuzz is a scalable fuzzing infrastructure that finds + security and stability issues in software. Google uses ClusterFuzz to fuzz + all Google products. Clusterfuzz provides us with the capability, tools to + upload fuzz binaries and make use of the fuzzing engines to run fuzzing, + find crashes and organizes the information. Clusterfuzz framework is open + sourced, the source code can be downloaded and framework can be built + locally or by using google cloud. + +* Fuzzing output - Fuzzing is used to pass random inputs to API in order to + ensure that API is crash resistant. We are not testing functionality via + fuzzing. Fuzz scripts run continuously until they find a crash with the API + under test. + +## Building fuzz scripts + +This section outlines the steps to build fuzz binaries that can be run +continuously using clusterfuzz. + +> **Note:** All the directories mentioned below are relative to cdm repository +> root directory. + +1. Fuzz scripts for OEMCrypto APIs are provided by the Widevine team at Google + located under `oemcrypto/test/fuzz_tests` directory. + +> **Note:** Prerequisites to run the following step are [here][10]. We also need +> to install ninja. + +2. Build a static library of your OEMCrypto implementation. + * Compile and link your OEMCrypto implementation source with + `-fsanitize=address,fuzzer` flag as per these [instructions][9] when + building a static library. + + * Run `./oemcrypto/test/fuzz_tests/build_partner_oemcrypto_fuzztests + ` script from cdm repository root + directory. + + * This will generate fuzz binaries under the `out/Default` directory. + + + +> **Note:** Alternatively, you can use your own build systems, for which you +> will need to define your own build files with the OEMCrypto fuzz source files +> included. You can find the the fuzz source files in +> `oemcrypto/test/fuzz_tests/partner_oemcrypto_fuzztests.gyp` and +> `oemcrypto/test/fuzz_tests/partner_oemcrypto_fuzztests.gypi`. + +3. Seed corpus for each fuzz script can be found under + `oemcrypto/test/fuzz_tests/corpus` directory. Some fuzzers are simple and do + not have seed corpus associated with them. + +4. Create a zip file `oemcrypto_fuzzers_yyyymmddhhmmss.zip` with fuzz binaries + and respective seed corpus zip files. Structure of a sample zip file with + fuzzer binaries and seed corpus would look like following: + + ``` + * fuzzerA + * fuzzerA_seed_corpus.zip + * fuzzerB + * fuzzerB_seed_corpus.zip + * fuzzerC (fuzzerC doesn't have seed corpus associated with it) + ``` + +## Building clusterfuzz + +* OEMCrypto implementation can be fuzzed by building clusterfuzz code which is + open sourced and using it to run fuzzing. Use a Linux VM to build + clusterfuzz. + +> **Note:** You may see some issues with python modules missing, please install +> those modules if you see errors. If you have multiple versions of python on +> the VM, then use `python -m pipenv shell` when you are at [this][3] +> step. + +* Follow these [instructions][2] in order to download clusterfuzz repository, + build it locally or create a continuous fuzz infrastructure setup using + google cloud. + +## Running fuzzers on local clusterfuzz instance + +* If you prefer to run fuzzing on a local machine instead of having a + production setup using google cloud, then follow these [instructions][6] to + add a job to the local clusterfuzz instance. + +> **Note:** Job name should have a fuzzing engine and sanitizer as part of it. A +> libfuzzer and asan jobs should have libfuzzer_asan in the job name. + +* Create a job e:g:`libfuzzer_asan_oemcrypto` and upload previously created + `oemcrypto_fuzzers_yyyymmddhhmmss.zip` as a custom build. Future uploads of + zip file should have a name greater than current name. Following the above + naming standard will ensure zip file names are always in ascending order. + +* Once the job is added and clusterfuzz bot is running, fuzzing should be up + and running. Results can be monitored as mentioned [here][6]. + +* On a local clusterfuzz instance, only one fuzzer is being fuzzed at a time. + +> **Note:** Fuzzing is time consuming. Finding issues as well as clusterfuzz +> regressing and fixing the issues can take time. We need fuzzing to run at +> least for a couple of weeks to have good coverage. + +## Finding fuzz crashes + +Once the clusterfuzz finds an issue, it logs crash information such as the +build, test case and stack trace for the crash. + +* Test cases tab should show the fuzz crash and test case that caused the + crash. Run `./fuzz_binary ` in order to debug the crash locally. + +More information about different types of logs is as below: + +* [Bot logs][7] will show information related to fuzzing, number of crashes + that a particular fuzzer finds, number of new crashes, number of known + crashes etc. + +* [Local GCS][8] in your clusterfuzz checkout folder will store the fuzz + binaries that are being fuzzed, seed corpus etc. + +* `local_gcs/test-fuzz-logs-bucket` will store information related to fuzz + crashes if any were found by the fuzzing engine. It will store crash + information categorized by fuzzer and by each day. It will also store test + case that caused the crash. + +* `/path/to/my-bot/clusterfuzz/log.txt` will have any log information from + fuzzer script and OEMCrypto implementation. + +## Fixing issues + +* Once you are able to debug using the crash test case, apply fix to the + implementation, create `oemcrypto_fuzzers_yyyymmddhhmmss.zip` with latest + fuzz binaries. + +* Upload the latest fuzz binary to the fuzz job that was created earlier. + Fuzzer will recognize the fix and mark the crash as fixed in test cases tab + once the regression finishes. You do not need to update crashes as fixed, + clusterfuzz will do that. + +[1]: https://google.github.io/clusterfuzz/ +[2]: https://google.github.io/clusterfuzz/getting-started/ +[3]: https://google.github.io/clusterfuzz/getting-started/prerequisites/#loading-pipenv +[4]: https://llvm.org/docs/LibFuzzer.html +[5]: https://google.github.io/clusterfuzz/setting-up-fuzzing/libfuzzer-and-afl/ +[6]: https://google.github.io/clusterfuzz/setting-up-fuzzing/libfuzzer-and-afl/#checking-results +[7]: https://google.github.io/clusterfuzz/getting-started/local-instance/#viewing-logs +[8]: https://google.github.io/clusterfuzz/getting-started/local-instance/#local-google-cloud-storage +[9]: https://google.github.io/clusterfuzz/setting-up-fuzzing/libfuzzer-and-afl/#libfuzzer +[10]: https://google.github.io/clusterfuzz/setting-up-fuzzing/libfuzzer-and-afl/#prerequisites diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/build_oemcrypto_fuzztests b/libwvdrmengine/oemcrypto/test/fuzz_tests/build_oemcrypto_fuzztests index f30cacd0..41c9b62d 100755 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/build_oemcrypto_fuzztests +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/build_oemcrypto_fuzztests @@ -10,10 +10,10 @@ export PYTHONPATH="$PYTHONPATH:$PATH_TO_CDM_DIR/third_party" python3 $PATH_TO_CDM_DIR/third_party/gyp/__init__.py --format=ninja \ --depth=$(pwd) oemcrypto/test/fuzz_tests/oemcrypto_fuzztests.gyp ninja -C out/Default -# oemcrypto_odkitee_fuzztests.gypi has flags to instrument all the gyp targets +# oemcrypto_opk_fuzztests.gypi has flags to instrument all the gyp targets # with fuzzer flags. python3 $PATH_TO_CDM_DIR/third_party/gyp/__init__.py --format=ninja \ --depth=$(pwd) \ - --include=oemcrypto/test/fuzz_tests/oemcrypto_odkitee_fuzztests.gypi \ - oemcrypto/test/fuzz_tests/oemcrypto_odkitee_fuzztests.gyp + --include=oemcrypto/test/fuzz_tests/oemcrypto_opk_fuzztests.gypi \ + oemcrypto/test/fuzz_tests/oemcrypto_opk_fuzztests.gyp ninja -C out/Default \ No newline at end of file diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/build_partner_oemcrypto_fuzztests b/libwvdrmengine/oemcrypto/test/fuzz_tests/build_partner_oemcrypto_fuzztests new file mode 100755 index 00000000..b320a8fc --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/build_partner_oemcrypto_fuzztests @@ -0,0 +1,15 @@ +#!/bin/bash +set -ex + +# For use by partners to generate fuzz binaries for their OEMCrypto +# implementation on linux. + +export CXX=clang++ +export CC=clang +export GYP_DEFINES="$GYP_DEFINES clang=1 oemcrypto_static_library=$1" +export PATH_TO_CDM_DIR=. +export PYTHONPATH="$PYTHONPATH:$PATH_TO_CDM_DIR/third_party" + +python3 $PATH_TO_CDM_DIR/third_party/gyp/__init__.py --format=ninja \ + --depth=$(pwd) oemcrypto/test/fuzz_tests/partner_oemcrypto_fuzztests.gyp +ninja -C out/Default \ No newline at end of file diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_copy_buffer_fuzz_seed_corpus/1970fbbb5d20902996167f3309fbd38a6850b147 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_copy_buffer_fuzz_seed_corpus/1970fbbb5d20902996167f3309fbd38a6850b147 new file mode 100644 index 0000000000000000000000000000000000000000..3c2447f9bc18bbd1d1a67eb6f627fa63d0a0bb3b GIT binary patch literal 296 zcmZQzU|?7g3M62F5ypVf%#-%q|6k9*u%P=?8Au&7P`;Fzf#HJ>gx_Fv5-c7J)iw!A zBO61E`AW`=G{(TRLX!so?|>Dy literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/21d16dc13d2b8103c7943a5bd960ebc77dfefde4 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/21d16dc13d2b8103c7943a5bd960ebc77dfefde4 new file mode 100644 index 0000000000000000000000000000000000000000..f3c738d5c182c46c9066c79b0499ee5dec4c9436 GIT binary patch literal 204 zcmZQ%U|?_zV_;wf(jWk%8CuHsg2Wj%uzBnETP) Mw*V>+qtX2b04+9IT>t<8 literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/3cf22dc963d6705061004cb0fad32bdebc86ffc9 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/3cf22dc963d6705061004cb0fad32bdebc86ffc9 new file mode 100644 index 0000000000000000000000000000000000000000..30e88100f034feaf1c32bfdf2d3846267ab7bb9f GIT binary patch literal 140 zcmZQzU|?_z0}^P!;Cb0zkoX2P@q~Wt;ycba{9kf6_BH>;{?pYb*L61ZLew!r_3OsR U#lwt(naP|TJM&LHOq78E0Csa3rT_o{ literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/3d891464eace6f7d3c716830e6051f7e90b90610 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/3d891464eace6f7d3c716830e6051f7e90b90610 new file mode 100644 index 0000000000000000000000000000000000000000..66ff92c3df8a93cf6e458b560fa1356254b7919f GIT binary patch literal 140 zcmZQ%U|?_zV_;wg(jdSNp%@mNE!ztcXJCX1K&ggz*v0>&f`17nBaE*@?YRFF9rjW8BRbsP?|9-cIF?D9Wa0<&oIK}nb7r;-r`G(GY{pC1CxGQ2n~` Vaq%#tU}iFB$Ikpy4-;iz002S36#xJL literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/e9c4232d40cbc76f71220641ea9f8740bfedd306 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/e9c4232d40cbc76f71220641ea9f8740bfedd306 new file mode 100644 index 0000000000000000000000000000000000000000..d586f1009fe1439a68fbd3c2f8638df7c855adf1 GIT binary patch literal 204 zcmZQzU|?_z0}^P!!L)oYNPGzsnnW;m@yo?Y%J-S7<#v9Tvis-yP&Poe1gxJKs$Dle iE?yGKUI3*TvtnodsfTialo5={2xXwjqw8lvlLr7E-y4bm literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/eaf3adf2980f1f1f021aafe465ec04d2bbf5d1ce b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_decrypt_cenc_fuzz_seed_corpus/eaf3adf2980f1f1f021aafe465ec04d2bbf5d1ce new file mode 100644 index 0000000000000000000000000000000000000000..a7dc6140db763b9ce814b5d16502e98374a428cc GIT binary patch literal 140 zcmZQ%U|?_zV_@I{(#Sxep=d8ioPiNplz{=4_yhj&C~$GfZGaF^e%PcIKaY6d?!)rVd^H1XL}QW!dx}lY}L1QC(k{8=k+$i Nd+%{U-3SprZU9jU7Lfn| literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/6c6a072aa58399454ee759bac539109a20f7e97f b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/6c6a072aa58399454ee759bac539109a20f7e97f new file mode 100644 index 0000000000000000000000000000000000000000..411b41ca5a2a5cf7e4965520d1f59023d63af9ef GIT binary patch literal 188 zcmV;t07L%(00000000000RjUA1qKHQ2?`4g4Gs@2UtV8V_Zx-D%mg2(+jwVHyp@dh zsOkJ=1s|U;*bKWo3~*w7Oq~~Kv2Rv;G6XQulcx3sMCzdNT9S)gfd+f_qH6thL+0z- zPj+dzC}qrGwq?>aiNmQv{JdgDw^}L`i_9y70Qq}bo79)Z?3T<3rf5n69V}LU9EP=8 qIR)tG_`iWwyDw!NymCQ`T3y1@g71D_rdQ1p6g#@B*7^1cH*s$~&ry~D literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/75ae4c5769c9568d631452df3b3702d876e4863a b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/75ae4c5769c9568d631452df3b3702d876e4863a new file mode 100644 index 0000000000000000000000000000000000000000..dd245f4a4ddc00b1cca222904933b0b2db4fccf6 GIT binary patch literal 178 zcmV;j08Re@00000000000RjUA1qKHQ2?`4g4Gs@2UtV81ZJWNn?60@(_Rfmezi?9x zluA{Jv|QO|C{wh3MeG_J75+}A*O|BRh~s4{NSwpiF?h5>GW$E=wxdwv)R590me%*X zu-_V3iY5JtP^0o2Asy+uvY`HjEcth}>c7};Evn@aW4HVnI}t%I4T6gvyqUEmhkAf_ gsR)wr29dEWP(f$-0Iz6KxbVM0c%!9y;8r4t0d${H6aWAK literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/9bdb356ec50807b86c807c09c780267101fd1a0b b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_decrypt_fuzz_seed_corpus/9bdb356ec50807b86c807c09c780267101fd1a0b new file mode 100644 index 0000000000000000000000000000000000000000..ff53f68f159d0258d8fe2bba37ed9ba2913cb573 GIT binary patch literal 178 zcmV;j08Re@00000000000RjUA1qKHQ2?`4g4Gs@2UtV8_HXyT`fa^%*{7QpPTct;> zjg*qY;IF{pbl~8f7(jIOxb1rMY>C}jn>VaTJ_eul*D&hu5VaQhY;1tdsa=eqlB{i( zYG@zhx+RX}kb+gfzJS?5Vg~f)5uw6dwCEYrWdj8RV40|;A5Xscr;-Nqj@jCUR<;{A gBz%6$^aXOA%v2gJYFZ%mK!Kj-;94RS&8ga7YhK1tT>t<8 literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_encrypt_fuzz_seed_corpus/4114e243c6726f2d6dd11baefc4ad43fbd2b3595 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_encrypt_fuzz_seed_corpus/4114e243c6726f2d6dd11baefc4ad43fbd2b3595 new file mode 100644 index 0000000000000000000000000000000000000000..d42496e1617e7e69112fe582f495082699fa13cd GIT binary patch literal 178 zcmZQzfC5G)W)@a9b`DN1ZXRAfe%<)Ecr+maK_OugQ894|NhxU=Svh$HMI~hwRW)@D zO)YI5T|IpRLnC7oQ!{f5ODk&|TRVFPM<-_&S2uSLPcLsDUqAnVz@Xre(6I1`$f)R; z*tqzF#H8eu)U@=B%&hF3+`RmP!lL4m(z5c3%Bt#`+PeCN#-`?$*0%PJ&aUpB-oE|` L6DLicGIbgN(JL+g literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_encrypt_fuzz_seed_corpus/424ad879ed92e646707f53a2cd963910ffbb5c08 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_encrypt_fuzz_seed_corpus/424ad879ed92e646707f53a2cd963910ffbb5c08 new file mode 100644 index 0000000000000000000000000000000000000000..747df46b57506f42d64e5b1340b6309c28ef94ba GIT binary patch literal 188 zcmZQzfC5G)W)@a9b`DN1ZXRAfe%<)Ecr+maK_OugQ894|NhxU=Svh$HMI~hwRW)@D zO)YI5T|IpRLnC7oQ!{f5ODk&|TRVFPM<-_&S2uSLPcLsDUqAnVz@Xre(6I1`$f)R; z*tqzF#H8eu)U@=B%&hF3+`RmP!lL4m(z5c3%Bt#`+PeCN#-`?$*0%PJ&aUpB-oE|` W6DLicGIiSY88c_io-=pe`~?8MRWuR+ literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_sign_fuzz_seed_corpus/f5d513d7333b92263ad849759db52a0cb4f383cd b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_sign_fuzz_seed_corpus/f5d513d7333b92263ad849759db52a0cb4f383cd new file mode 100644 index 0000000000000000000000000000000000000000..4eb47bcce2e7a05cb7525a2e5d807b75e9dfefaf GIT binary patch literal 168 zcmZQzU|?VbVJ2o4RyKAHPA+a9UOs*SK_OugQ894|NhxU=Svh$HMI~hwRW)@DO)YI5 zT|IpRLnC7oQ!{f5ODk&|TRVFPM<-_&S2uSLPcLsDUqAnVz@Xre(6I1`$f)R;*tqzF z#H8eu)U@=B%&hF3+`RmP!lL4m(z5c3%Bt#`+PeCN#-`?$*0%PJ&aUpB-oE|`6DLic SGIiSY88c_io-=pe`~?7>!ZK0- literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/374d2a1ab0be81451653b26a0ff99c2f20351700 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/374d2a1ab0be81451653b26a0ff99c2f20351700 new file mode 100644 index 0000000000000000000000000000000000000000..561fce239d588473d524d83c007ec82eec9ec799 GIT binary patch literal 176 zcmZQzfB*$3&B(;e!pg?Z!O6wV!^_7nASfg(A}S^>At@y-BP%Dbps1v*qN=8@p{b>< zqpPQHU}$7)Vrph?VQFP;V{2#c;OOM+;_Bw^;pye=IRvK4a#r*>mR3o4)`6vnDce literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/7a883f7628e57eb5fe48d660fed48ac5da2f5d21 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/7a883f7628e57eb5fe48d660fed48ac5da2f5d21 new file mode 100644 index 0000000000000000000000000000000000000000..2f041f7076261bf210f58e1cc908fbde3a8dce64 GIT binary patch literal 176 zcmZQzU|?VbVtF720Y)Zf7FITP4o)s^9$r3v0YM>Q5m7O52}vnw8Cf}b1w|!g6;(BL z4NWa=9bG+r14AQY6H_yD3rj0&8(TYj2S+Do7gslT4^J;|A74NJfWV;OkkGL3h{&ku znAo`Zgv6xel+?8JjLfX;oZP(pg2JNWlG3vBipr|$n%cVhhQ_Amme#iRj?S*`p5DIx X2@@wxo-%dX^cgc}&7L!N-uwjsvnn!i literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/a591b11c7ff1f45e8edb1a055a3255edb247576d b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/a591b11c7ff1f45e8edb1a055a3255edb247576d new file mode 100644 index 0000000000000000000000000000000000000000..f5dc76e42e4ed468c4b7b003ec75455ceaebd131 GIT binary patch literal 176 zcmZQzU|?VbVnrYZ0Y)Zf7FITP4o)s^9$r3v0YM>Q5m7O52}vnw8Cf}b1w|!g6;(BL z4NWa=9bG+r14AQY6H_yD3rj0&8(TYj2S+Do7gslT4^J;|A74NJfWV;OkkGL3h{&ku znAo`Zgv6xel+?8JjLfX;oZP(pg2JNWlG3vBipr|$n%cVhhQ_Amme#iRj?S*`p5DIx X2@@wxo-%dX^cgc}&7L!N-uwjsw0bgg literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/c182ac7556d1cd1ed73da74882dee807381f3ee0 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_generic_verify_fuzz_seed_corpus/c182ac7556d1cd1ed73da74882dee807381f3ee0 new file mode 100644 index 0000000000000000000000000000000000000000..7a2af72516431ea8de5fcef709d3c821a3d53113 GIT binary patch literal 176 zcmZQzU|?VbVg(=u0Y)Zf7FITP4o)s^9$r3v0YM>Q5m7O52}vnw8Cf}b1w|!g6;(BL z4NWa=9bG+r14AQY6H_yD3rj0&8(TYj2S+Do7gslT4^J;|A74NJfWV;OkkGL3h{&ku znAo`Zgv6xel+?8JjLfX;oZP(pg2JNWlG3vBipr|$n%cVhhQ_Amme#iRj?S*`p5DIx X2@@wxo-%dX^cgc}&7L!N-uwjsv(hqh literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_license_request_fuzz_seed_corpus/3f58051d431ac575d0b804b2d512e46d7e8b4cda b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_license_request_fuzz_seed_corpus/3f58051d431ac575d0b804b2d512e46d7e8b4cda new file mode 100644 index 0000000000000000000000000000000000000000..40d44367c8642067288b6e9314ba09e4be578ff5 GIT binary patch literal 78 zcmZo*WB>yZ2*tp_$i&RT%Er#Y$;HjX%f~MuC?qT*Dkd%=DJ3ltEX>ZXk=_+YG!U>X=QC=3joM62l)U1 literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_license_request_fuzz_seed_corpus/4e2fef7ad945773dd77eb37d7d08dd2368ad4b89 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_license_request_fuzz_seed_corpus/4e2fef7ad945773dd77eb37d7d08dd2368ad4b89 new file mode 100644 index 0000000000000000000000000000000000000000..57fbaf097b4ccbe5f886c095b53c62f0c7299234 GIT binary patch literal 78 zcmZQzWB>yZ2*tp_$i&RT%Er#Y$;HjX%f~MuC?qT*Dkd%=DJ3ltEX>ZXk=_+YG!U>X=QC=3jm=q2YCPh literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/6f8b954fb7f8be2c3632f931aaf55e3d1a6c58d8 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/6f8b954fb7f8be2c3632f931aaf55e3d1a6c58d8 new file mode 100644 index 0000000000000000000000000000000000000000..baf0a05cde5b5839115e7a5081da7ae855f1d16d GIT binary patch literal 676 zcmZQzKm`I&?m;vF6F=AN+_-!^w3?Fw+^)0L;8YXaFW|*w-?7%08nv!OM@F{`Q)oz4XObYv+#}_+}ZL zV=_25<4&rD@ZQIMOP=2^SiXZbYu!vns6|X@0A}7{GyoG{`RT(vz3`&u2+g?(zUMbP zaBoQ|dBhm>y=d+W`D%X|^`6_zt1I^375Q(>q1~Ht_6if!9%eKEGw%o*fQiTN4-;#g z5EsN!HYdyJx1zsxv1i-&xc;AviD>a|6Z8ETJid|W&% z3}I$TKm}lY12ldB8b1S#-+;!SfyUo~#=n5Ze}TqlfCfIyJql=i3p9QJ8b1S#-+{&l E0LH+VHvj+t literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/7997b5673d5a9402b2f8acc43f92cdf6ad1f913d b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/7997b5673d5a9402b2f8acc43f92cdf6ad1f913d new file mode 100644 index 0000000000000000000000000000000000000000..4e600526090a3f5262c6080a76ef5d68f3965c6c GIT binary patch literal 676 zcmd1HkIzo6WPk%UDC-~^5P*uGO8RQ!HeL3>@uQWTQtO~nq5+tBhtL2_-2aHe)cNj42P<=~XUc~b@iB{CzWHfs zTHWKT=T6-$?0P$u-$F8C`C670PBSy@o^SPGgj&Re24LnLMguVMgJnz$D$jjVt5_HD zWqP_uY|}zN?!MT|lQfp46feDynw@K2e|p&kru@{07tL_wUmeFU3utD_2h{I(b#K&GA`Xy z{rR)i(m<}ws=u=mW;!DpfSGp)4Zy^$C0hfZp1gZ?*5%9R|4#bibyJr~cdz37d#kn! z=U@0Br@n5|7L_0D*6+iY^xa*cra6xhY7r9}fSGp~4Zy?~m#ggjx3_KLOhH*zrSFzE zyhZgxR&5MBv+kPXjU8Jb9^LdackjJRiJunc&5b?f?{tv~Y7a9SfSGp$4Zy^Ot6mBR z*(tMc70-Vtd4A(Lp~d0xhT+QDb23g!Z76?WT(b4tjlA#&6TQ|}KHw|OX=R4mqZ=O= z4+}$>SrSkI7~cSmAArWsK;t){@n@j%ccAevpz&Xz@fo0j4|9(K8s7qqAArWsK;w6y F@c|65oOA#H literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/81ac6d013d80da7f67fe6fbb5e8c15a35a0d8134 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_entitled_content_keys_fuzz_seed_corpus/81ac6d013d80da7f67fe6fbb5e8c15a35a0d8134 new file mode 100644 index 0000000000000000000000000000000000000000..16a14bc7a02dc9ac8c8949f97ee1cca59b5fab1f GIT binary patch literal 676 zcmZQzKm`I&?m;vF6EACjEb^V9(y4aA*0+;>o47MO9#2^96`dii*mJ?~;emLiJEl`_ zHP}C!XuW(@-bKl3nCXmY0A}7HGyoG{zHEBcM&%b<+HX$Wy`bvb+$S@N?p_c+WBw-M zcK7Br!II2=|C4P}VrH#1Vw)buf1`;JY7r9}fSGp~4Zy?=W^FuODgP|5YJ0iTwEr_^ z9j@}vj9*rN<;_`d<{dBFnBK%)eJXsRZ+jkp1rukSmM9a{9%eKEGw%o*fQkPQ{2j2X zY}W&uPog)LGe>cjww)>qP}C4lYl^q{>$hX`#MOJ3sIkk5{t(evlDCe-kr`@_ZhTxk zEDT|0Nk9c)d;>Io02)67jo*OApMl2TfyTdp#(#mvXMhGi%smQddV_odK+|<`$Rng%)r)tu2q;9=aiwJfIFZfW*Jp22?28-OU z-AnHum$vjcnOdN{=7r;Ieq8o4p#hkAOWWUW3k>nzFYJEvU)ZN7X~zVnZ;o-D^z)zH zM?2+Li{Sp<$gUV=zGLN=^u5Qd+?>v8$mPgz6`RJI7)w9ZD`h^!gv(xLGyt>LivMNE zl8nhw>3jf3$-&zI literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/0f5cc252aaf43eaa1570ca07d174a0f96333c592 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/0f5cc252aaf43eaa1570ca07d174a0f96333c592 new file mode 100644 index 0000000000000000000000000000000000000000..6f71c2eb7e064b0e76eaf8ee7a455334efba9119 GIT binary patch literal 6648 zcmWgOV*mpI2*qFk={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^a>n%v_cOKL{Av2v)|;)qAhJ{yWP&bLs-F*@4-~hK8WP;D7ia8%S}$0)`O{z|5P! z%6q%xtdDH28&|rrP3>=wzQB6C%B^9-IsRO|o6KK@VCphnK9|y;^hZ!euWL8i1L1r?VnR(?IQ8#!^A{jUubIT;n@C-^@_|R`jB` zH!Ob1eub$s>U8r}JgDnDLyy~P?#$yUQLJzBcB@P(NIqzI(=A#`4wt>mXaHv37wfGT z=Bw`R_1OL>hhP4xxy&E&$3Z1eSHJXm-s16_B^aiz^NpBv+9K|qZ+02p{39>(s5nT4d!h4h+4S~@R7!85Z5Eu=C(GVC7fzc2c4S~@R7!3jR5U_df zP!-+Gw@vWN+&+QIcUtK3^7f7l^CKR6oILY({ocbbHR|ug`mGB7pR($l1 zQ!#gTJ@e`2OUs4E=Sm%~)U8N=ay4Ye$7T16&+F8zaoi45r}^UcVqZt=$p;#KpS&X> z$uZsA^K<#l3jwF(rf6N2KhuwHFDycs&;ZQ53%UElg?KcLLM24Gcm551{{G-BXVuM3 z!W*3)q{eR)zY9~>`MI9KTyRly9h uJ9e5+&r_af_qXd^rq6b#jEG&qE$RICryJaTs3$Kv>B{_NAJEMk>3jgS0LJbB literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/134a0d85fbcbe367e66d69127114bece71add806 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/134a0d85fbcbe367e66d69127114bece71add806 new file mode 100644 index 0000000000000000000000000000000000000000..70ed9c599bbb1493946e95834b6261daecb9429d GIT binary patch literal 6648 zcmWgOV*mpI2*qFk4S~@R7!85Z5Eu=C(GVC70h)zCA_$n7TUZ(x8iAOwc1+j3A6xkn z=6jd@4_Oy0R5M#lynoVUn~RagGdAh*ChYQuwQu@D1Ni(iV(!-8@H=fgap`us1s~t< zmU!BHQ|;cBkJp_!vy%-?fsSV~==ypZNH@Sdl7t3e_C~FmxoxLd(SrVlovYOy6Qe&K z6Z*p2lVEJ}!0HCfL&gl#M0^T2#Vde1IvBjKkk9~iN-;;!R_KBZbL}B(mnO*Zr zF7!c-)k)ELulU**cvOdE3SBv#@H31#r-yE@^WiCBS7vaze$TM?I(a@Uvwt^S|pCV~oV zTaL+2-{8x9ji^?MP$5X2#extiI@z&I`Y|bBXB~GhtX8O!1aaa3O z5PInJ4!f%|SM_r4)qbvCzACV-vRH0Uo#yWg0_qPY{PNTPuJvb8c%SvjYrkRB0qDk# GSUv#s!UHA% literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/1ee4b9ce1a4acc41e912487383ad77f3ccaa97fb b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/1ee4b9ce1a4acc41e912487383ad77f3ccaa97fb new file mode 100644 index 0000000000000000000000000000000000000000..cab8c50243d8f18c07a90e2ab4c2f07144a0755d GIT binary patch literal 6648 zcmWgOV*mpI2*qFk={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^o)seL$wil0ijMA|;8~V5>y@(cV}%bNa!*`Z$Mp5VUsaeot0&TS z9PG6-n{M(lmif&7**fLJz6(W%_FCS!S^TSgo=SGIp%ExBH1{yS0a6^WfMG-fF!TN_ zdzYHLTyrKz_l&hYTJp>Iw^(l2SF&dJzPoe2-!2b(15N(86vmXYjg68$4a?wk0wq?n3Q<<{5{sPWsWd)3l`327c`oBWc&5&8!N6z1td;p z6fr;Sy(jPDu2h>tYs_%j3k&a2dNc$^Ltr!nMnhmU1V%$(Gz3ONU^E0qLtr!n&_iHW zaa1)w)0+y1JL*hX#5H^{th($1T_8$H2w`V z{s%O^0V6~J<{l0-z5^OR0F9r4#$SQPZ$RVkK;xf4<3pV{N{xoVXb6mkz-S1JhQMeD zjE2CF4FOoYDq!hvhDK(d0>y9ty>4fkZ;D-OJnt6&sT->;l2&`H-#Q(pt|I@o{N&7h z!@Qekw-q=VKNWm>seA3#*kwJee?os+#f4=j8=4^kqXEujL<2DMN_-LU0 zrg;6vo!#bH_a&C;?XL9cTOkzsixH;IQSqjyWvds_u=SsYTb)F5HlH*RhE#;(Wi^vG>%3b~l(ht5t=c zKLmBp7Acf_aBSyJ2kipyl1$x#I5FK`+iBeM<#E}|j0Rxly)k*IChL28yHCR1X zQ}WboqZv(ROp?z1wTJ&}3KvXWgzB*so>QLjzfjvKSbz2Hqg6c9rwcWI{$-;mq-l4_ z=rb;R;Q>C%7!85Z5Eu=C(GVC7fzc2c4S~@R7!85Z5Eu;sv=HbofBnx?+D!8k|NRw4 zEYqi=Ni*m!eX#J5Sm?9(o8N<oCoJX+xJV7Ev8kBw5g>$Qtk%npeO7TapZuzs`N hW&2M7UtirW+9vqpF{_J@UG}%T*U+aO(2XB)d;sKuwIToj literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/2f64b8ffa25844924fe24678067feee9be80f4ec b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/2f64b8ffa25844924fe24678067feee9be80f4ec new file mode 100644 index 0000000000000000000000000000000000000000..7aac2f96f5e80b8cb9ddfdefb6aed64c5ab82c0f GIT binary patch literal 6648 zcmWgOV*mpI2*qFkd6fbtcf>KxGI1JL*xX#5pu{01l=X5J1o`4eb-sI{Zi zXb6mkz-S1JhQMeDjE2By2n^W}fVHb)cc09H zffNT+8v`R6fZ3a9f8XoB%4a3!hrfkuA02;Rq0yYXFL7(eubX=;OgA{kDnJcLQ0{I} z`@G_0kh1Fc@Nj{tbzj7eei!ba`_r#_ujY_Pga%;t<|O>k`r~rV+I{k()9Pz_ zW?U%C;rO%sL9ooWY0avimEiVjosrB*a82&npt~naUoP;x#p6lStWlb`AvLS?6{FLwxTs4WOYS&TByE{3`x~9m`kkueszC920n__T#b_7T%-uXb6mkz-S1JhQMeDjE2By2#kin zXb6mkz-S1dhd|J^I-hSZcbs|oH$!;YrBwmw@~a$@RzFNz=VHp)%9p;w?{S{eb=OO? zj_-Yvqk3cF!MCD3|F-WocyFKWzOMRtiCw|FZ|DAQJG(d};p9p^r|qr3o}-&L()j>z C5yfQy literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/3acf30d485a4370ceb8e64785094a50b768e1ca4 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/3acf30d485a4370ceb8e64785094a50b768e1ca4 new file mode 100644 index 0000000000000000000000000000000000000000..57edbd78644324a1c06120bebafd52c513b89e6d GIT binary patch literal 6648 zcmWgOV*mpI2*qFkby~EGz3ON zU^E0qLtr!nMnhmU1cqz~z}i)zFJm;5HuOGhhBMN=%)GU;_9}9|wTxRN`*wZLF8ipjS7)3%z$M1H?w?E6e5n`vVd{F0FZC|)JMOsh zPj(4cOWO?o=O!HIxBrkZ-}7X-sN+5dT=p`d0hoF5cl^CP?!HW|xc4~oP*C8?zIw)k zdxK_7{J8y@#`KxJ#V~c7qULdAU+Cau=|8R=E6Z-t_(f&vrORA8#S^)`W^cZZ)4$AU z0A}8nBMh2npGsbQ>y>Dj_3R8sT+PF{tfM-UJodVLQ|Q~`3{yAB=IOMFc2Xe;%VpDj zU%rpK$`cySUAkvu&jYO!&XKcr;PNjlyhrKL5Eu=C(GVC7fzc2c4S~@R7!85Z5Eu=C z(GWln0gt(y@tvFB8(sY`-MOKm{Uy5mt+e;|PQ$YbdXPMzn_&CyI|jZ;6V z5iBZt_eQ?l?KF{s1^cY-Rq#tETz+RT;dDvJmf6d19m@}xvgMnq@IJ!@IX?oP+T8nJ SEEN{Wzpwi6e{}OkIv)TRT`2ni literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/4b69b92f45febc4dbf5b8fb9a216a290ba51d478 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/4b69b92f45febc4dbf5b8fb9a216a290ba51d478 new file mode 100644 index 0000000000000000000000000000000000000000..0a09fb4f2db749e74f6dfa473dccc96b3335f4e2 GIT binary patch literal 6648 zcmWgOV*mpI2*qFk1JL*hX#5H^{th($1T_8$H2w`V z{s%O^0V6~J<{l0xUjeGl0Zl#tjh}(WUxCJNfbwDH?Ld=1fyRegJ4%g)z-S1JhQMeD zjE2By2#kinkPQJ?yUN`++~@gB&F{8mC(##auW8mzXoor|Z3JedKZ#x-w{I#kR={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^FFC{1XI{5hn|{zj;Ji|gp5pNpj7N=F|M7Dln{ivMqzk4l|JLN4Vrfvm%U7A0A`-Y_ltH74hxL=`ev!;t8=rKc-UI&_qQ$ea=#aK zPB;MW-$j$86j!z`aGT(D+_YqyvXtF^(PeLWa!*wLXn2+MuzLrrH0UzqtoebW# zFjgXF?(ekhma|SjaoGzC?@@X*1V%$(Gz3ONU^E0qLtr!nMnhmU1V%$(Gz8E?AaGad zVZ~gl1TT&w6^jf%OQOpQyqng+#jr2x`?N(Tzn){VS8DhmBmJC3`QomBAxBhZpZ&h7 o-b?9;gNd$+bZ~5`zRtBUoyDtbXIDrj2JTz?reGnuc_W<<0DGyt={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^21hi{25YkKIF{Wexp!USxit^7jg4joTN%bpe;XOlSaR-d65ksT|8*g*;APdm%`9ns5HJ8mG2HZ)yS-h$t%^ zo?{MESF^SnTE6%R%k=x!Z$s^Q={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^8!IpEXL$AVo`zFH`Ob=+l1yA1o*b*67rf%HS?kl~OX6Yb>q^fSLEF zjbCW_e%|T_C0^UZ4{Cd@zx(Y#;g|Dg*D9pVQ%(%DnBC;;ZPhxa?&@12FSGIq)xioSmFA!?=5Wz}rygzGbqrlMSwAYzXb& z*nd~?Doow)ru}kuH{^7;1t+H=DWW{AKGa7)ICtVuX(lg#QxVORdgtU9-iZ@X04 p)+14gsZJi2t*jcy7arHR;1gVIRcu^%T=1&jkw5d7yj;C=GLm1R6g8jh}$VuYmGl=I=n0pMb_c zfyTdq#{YoEH(-Paz}&}y#&fVBfJ zuU@TRSCNy~B(?U!rcYj9=HGDYwqz2Y)tz2nA*AK&2y5SP1#2xR(VnE3r7xxRsh-11 zY>9wUtWfsv3sX|hRXG|i%}zEn13I3m_)_X&Al(4-2-w~v1c0>{7wp^-nSJ+;)XgJX ztah!mY*=#5AnD5^iBF5ooNC|jhk3&6owDYw@TMlqB^wv-ukD{w;_MkxNrAOLH_TbJ^yABQa#^eW zw!~bhv*vR261lW|Q_T7$vsj~aKFopHd+B0PKp&d2UcvFwR=iM{7n7~n`zw-R^N^;JpaNJW^XyK z?WY50?;T&s<>MT^%=w`Dt<8Pr&A(2~xRWidD3NT9%U)PKkJ6(dFd71*Aut*OqaiRF z0;3@?8UmvsFd71bHw0enN!(kqpwm8sb>>CoR^3i?msXuv&{@V)?YsN)KX$b_ujRj| z^NF1mj4YckA=y=Q`Tf=YgYI+HZZKY(S17wDKjq(zqi1+~8?)q#?UO??^f`Wep_@0- F`2bSU{Yd}- literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/7e120b1ec852c448490b9b060a5f35deb486c360 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/7e120b1ec852c448490b9b060a5f35deb486c360 new file mode 100644 index 0000000000000000000000000000000000000000..9bed2849f509f2b62223766474eb22f38547c80c GIT binary patch literal 6648 zcmWgOV*mpI2*qFk={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^UyEPW9_c)H=w0vK0CCks(bpKRYCRAhU{cRGf-eud9E#BU{K(I1q>q^fSD)t zY59xfrWFy+;$gBM1v5Ni#G;>^+U|MmYsd2g?>qJg!qmmW#NTiw0yyOXo z-_47dYyII*-0|FZ&$Mva3k&a2dNc$^Ltr!nMnhmU1V%$(Gz3ONU^E0qLtr!n&_m#H z{7uWlPr4ihssxVnGF}ivm%sP8&y(55bBaw@Du0^4lvvCwVWACA?k?#PS`s_w$ocf6 qz29E@cPw9c_rvqLro8h%{pTyrc^XmSw=Kh1JL*hX#5H^{th($1T_8$H2w`V z{s%O^0V6~J<{l0-z5^OR0F9r4#$SQPZ$RVkK;xf4<3pV{N{xoVXb6mkz-S1JhQMeD zjE2CF4FOoYYJqd>O8)P9`^+skzE|_)m~T4tR#fIF$Fa=^6E1r8g&D)t#YeC9>Xg|$ zUFoNA<9*eh`K`+9{-;MwU%uge!vhsD`!(6ghGww9aA4qqH#-^80L;7;HRXSuft#`y zc(=E#Vg0O<#xcKnn%g6mEwP;CyQ-tqVCov~d`$VYS^9YZ>*NVtn`CEQaQi9|UjOOP zqB-8&QYM8}xa?&@12FUM%n&d-9{Rr0>`?533AM9=IXB%qk|dY6_sq?=sqfO)+Q8I3 zj{VAb{@RSo`=Y0qF(h)WnAxYev*D)5tbN=!xAAVdoPx_RA^f1H|YVR@FreY4g6 zAhXyv+%Iw23k&;EdNc$^Ltr!nMnhmU1V%$(Gz3ONU^E0qLtr!n&_f{V_ExdV0FHAV zi3JR0v(gu!%im``@#S-*(4PHsAMorbd>5_Y`)1+AMyL0;{{4z>)SG|vApgRbrjvh^ jbZyly`yY66%iVJo`zP|0p4#}v?xOF>-*eH;8|i!iRwcdw literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/8243212a7a7160c91e2f9717b855b568f9a34233 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/8243212a7a7160c91e2f9717b855b568f9a34233 new file mode 100644 index 0000000000000000000000000000000000000000..352ae2edaeffd68ef558f7d4ca6237ac87ec8753 GIT binary patch literal 6648 zcmWgOV*mpI2*qFk$ z{0V6M6KMP!X#5Xod;_Q_VeaEV<2#`71JL*xX#5pu{021s4mAD=G(OaMqts{!jE2By z2#kinXb6mkz-R~z*${xWt8T`NZsghe`GJ+?3(2;{wngG9mv6G`Tkut{l``3TWNsZy zU6uF?7ltLu_l`eF=4T0iFWc*SX5aKQvaEbXxfpTY-k1wj3QfkR|W|$F+5dl9r`LD@zz> z1q)4blyGWU@gAn`*i((4>y2f8na!~i+uz^0;9~SPhZUE-%xC~+ zp3G})?&q%4(=!sby=9mnIN_wB>8xvge36%@u8Tcvf4Ul`E-Mf$hEtfZLC zANQ3Wa~d2hu!%Q&Ghb0fr3sh4u<#zGM?+vV1V%$(Gz3ONU^E0qLtr!nMnhmU1V%#u zJp>#=|D3E#^_i%`;b~jLx6T7yo=xO%*=hB(iC-7I*&i!!6cD$Pd+*xHP`={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^wPCwf+*50~tF?OaBA3lu;^yn^;G2;%&%f!J?-gBnd1IJ5bEZp8 zg4!$PP6!B9Pmfb%d-6S-`P*adPR8*0&wefR&dE+TGy?_3hQ8y#rk(>lTo};+%)C$P z4rM|c%CZ8p6!#bJlV&o~UvbWZ_14?(@)u70=eg$&Q>T02LruWiW&Uf{PcvHoJVr`J zB+t(__`R9NySsBfn9abHC^Lqwvt9CuPlUwiM1 z>YX_UVCwSQCO4+lWhm*qvEiS3v+hxcyP`Vkn?vE*7r s_x1x{S2#Lk9Lq_SbiQNL;(YC5CgY(Aa%HbM{{4;FQGzgOlm!X_0HoN&JOBUy literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/a06905d0b9421966c527b5ef2ac68bdce1e0cfe5 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/a06905d0b9421966c527b5ef2ac68bdce1e0cfe5 new file mode 100644 index 0000000000000000000000000000000000000000..02ccf56269424b74fef7466c30b53a8afac1a8ad GIT binary patch literal 6648 zcmWgOV*mpI2*qFkAkHS}NKD(f{zs01xcU7oDoKfud^Ajg_JlK|l1b2@r6^_fW5Vzw=N{T=qmyj@&$`uOL6c6AmL&pc}p{&y3mt}pqhcN+6&FZQ(? z-L8r$S)Xn%yQLo=be@529gmci5Id^93>`3gna}{tJdFzr|9DJvY zLpoo>l>S}1L0vQZf`k;H255bnHiaelW+u~ecFUI34ciWDcLltZS-3U4?yC%U+`LU_ z_IkkVWkv%qdow1V`4~~Fsjcayr@is;wK39WZ@09hEKGe-z z9G|z7@8snA`pu2pA{YLrd^kKw=7iqT(lrHW_G-ZF9i>M@U^E0qLtr!nMnhmU1V%$( zGz3ONU^E0qLjYF@eEr|H(Se)ymh8srGu;u|rReJJ$TqBXdKCPRzh?O!U-Jvi{Ji}; zUdA-1OQ{{3ej?ArY)PzixvtQU?sSWjhD)5{G%P+Qv20)Y@p7}Xi1Wp&4-M$%jdVT$ DDfPdR literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/b452f7b6c615035d63a9825c5c17e049f54648ef b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/b452f7b6c615035d63a9825c5c17e049f54648ef new file mode 100644 index 0000000000000000000000000000000000000000..c708d1e6ce556178e9792446507df009c6d8dcc5 GIT binary patch literal 6648 zcmWgOV*mpI2*qFk1JL*hX#5H^{th($1T_8$H2w`V z{s%O^0V6~J<{l0-z5^OR0F9r4#$SQPZ$RVkK;xf4<3pV{N{xoVXb6mkz-S1JhQMeD zjE2CF4FOoY%J*pV+J|rQ0>96^UD=w?{!yf5_JO8JelPc&4DnS`EcJt_^L+cO;N+xl zxi_~pImNM`uq>YY_|Fb@Oad_X#_=}$65nH#0uH$WhsoT5W_V|S}=^6A~kif234zDSflWBV_NIaB9QElk~pXo=VV*|PJ0`F8=nd0~dA6EGYVYUlQvtuG%sA`P!y~|KsrdI^>W&+R_xJoy l>)RT2`m`?Zic=o3a;8jI!&M3wIj1dYoOLt{-Mo>`2LQ$p#fbm_ literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/bb8c2201cf10fd7d24fc0c8009a44525f426b033 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/bb8c2201cf10fd7d24fc0c8009a44525f426b033 new file mode 100644 index 0000000000000000000000000000000000000000..8f98344fbcc9ade5a8048127d7760a48599a1042 GIT binary patch literal 6648 zcmWgOV*mpI2*qFk1JL*hX#5H^{th($1T_8$H2w`V z{s%O^0V6~J<{l0-z5^OR0F9r4#$SQPZ$RVkK;xf4<3pV{N{xoVXb6mkz-S1JhQMeD zjE2CF4FOoYO4)sT<9-d-XD6c)16dRGI6fcRDkOE7UFFYIy|=gQ?r(>wJEstym^kay z7xVe{@{<=IU$Jffrd5-354JDVlI3{#>Gj*}WJ6PIfx(CdVCEhAHK%jw)5C8|RILhn*Xu{1IJ1nm96gDUv zz9NDiDyHuy7rZf#+U)se;Sr;i>~fJ?4K}fhYq``sSCDMdTKC9{E5J45X literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/c7a7cd07925450628efa677165d403510d89bf51 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/c7a7cd07925450628efa677165d403510d89bf51 new file mode 100644 index 0000000000000000000000000000000000000000..5442bebbed3e79e4092a3bd863b445894417f5de GIT binary patch literal 6648 zcmWgOV*mpI2*qFk={9nkmzX#5N`{t7gH0~&t^8vg_uAL_hOYBU5!Ltr!nMnhmU z1V%$(Gz5lh2*BD^2`fLZEG(K-viq}Tp4(ael$#Pq+v>BQuYdfMH_~F=<3%ua9Jzi? zO@bER*{h`9-hX)O@5gBW(w;h#qqAluw5Bk$KFdxvGynxg5O+=?km7&^3?mwVnRifs zS498+9|cp7mYucCj^HeFy?wnyqpPs=WLMtAy_+||)Rkq3K7N1oW&Q2D&9BQFnkQ{E ze7|V*S5uGojNAUqR~L)IWiJyNfSFfNsBC7ipKq&jdzwtj(OJ_O*+Y5r??0)0x^CB7 zPvL7bVCrU?CeCVN+wm~%Q0f+q4Sc^P8d()%KQpi;9NrYVUZo-hm%Yqr0A^mnWrK!= zL762R_AH)LbV27zWw`LXq;3&OwHW`CD^9M`iUfJPWVP0Ai%JTkP9g83TADdcq^F}%!0Il-D;{X5v literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/clusterfuzz-testcase-minimized-oemcrypto_load_license_fuzz-5919435528601600 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/clusterfuzz-testcase-minimized-oemcrypto_load_license_fuzz-5919435528601600 new file mode 100644 index 0000000000000000000000000000000000000000..58dc14ffc1690766e9314712a4d8bfe1c6f2cf17 GIT binary patch literal 6652 zcmWgOV*mpI2*qFkNBCn)(Jb{th($2{ir#C?95?0yLmu z_WeLpZ-6H6fX0VwCr!4w7->9XlOAuvE`L}9r!O>s&p#vPZv73v)3y_r zZkJo|@%?Uzr_DFj?p^tK-I+5x+0Yais7wZ3Urz(+23P^7ig|{cc*yMrXf$k84H8879^6fIYy&i7P4`xjcE)rE&O6&BxA1{95 z=z8xHH>MnYi_7X{5P*8w*u>NfX0_Az8||Ib7x)FdKPbb>;j?3lIo}@p{uI9_3GwU` zKedR$>;-#aw4n%#$x(VV1V%$(Gz3ONU^E0qLtwau0H|#^+D-(=F0t*zC$no_$%Q_s zu{tR_?-gJB0*~sDOra~s6Mlv<=M=F#zlW=RngRmw_GwBAtbO`H%A`(zN1SKE?q;8V zPuEl&x%cJoo);QVcAcAarF*yMc3As#b;3Inu>zfBV^_7eA}%TAt}z8#{Xfl31Qpn} z9Fv{KjmzFtGyt#oy*==`OVMQ{Pb_1ueent^_`4)lhC$}&7Hz8roimIEqKRl z)gOk$Mq$H`rzE2?hig_C?*8JjKYaeHJKIHNk^1AQ)e*nZ{hN4eYFRetkGK-2)iyJI zW|X+A{V51Nbb5!~Rhg@LIrnNmS1(@`*j8CAx2I0?_XPp<2NQnz>3`SyvnagJ`sB6W Suqgp_V@c;Hk*;Mh>Hq*E0cK4A literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/clusterfuzz-testcase-minimized-oemcrypto_load_license_fuzz-6406770604638208 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/clusterfuzz-testcase-minimized-oemcrypto_load_license_fuzz-6406770604638208 new file mode 100644 index 0000000000000000000000000000000000000000..1a0f23cf40106786464045a4a169cdfadf12c930 GIT binary patch literal 6648 zcmWgOV*mpI2*qFk0B9 zcc95nK;xf4lh-7*_QIx5USHX5}(zbUSA=kY@!1g8~0Ia>Z zVCRm=?7MfQZXVfUwQHqi!;)(TNnajGd|GVgRQrZM%oAqslr?XKH#J!<*|>OrZU2-K zXBW{a3&p-?J(yVO^s<$IEf-#U?I8XI`5b26CXe$~KU0z{;X%Ts zVmr^1g%6AU9>Ub=v0N5SUU_F>{{GT;DT}vhJ#cxmd)K|w84UY{JDOzJpX0R`8qUTh zDJih_=Y~0}mVSJ>PA+S;-K9wKRU8hGve9c>zT5crobR1_ z?_uiFmm8}on7+y0TX0j;*ROxVfwL;QTLtFXF}0??h`G%F1(&@r`$y@~5Eu=C(GVC7 zfzc2c4S~@R7!85Z5Eu=C(GVEvArR5%e(`16os`^y30spB#LUsdLn?hEPs|3XsV37C zH-7kV<@{Cs{kt}=TW-d;^4zOph4qyT><3DcJ{$6B*|({5M`pM>x?Y}`-hF+t&D`2V NgNa7J(ajs_d;ncoaN+;} literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/e26757270b3d149d1ce10bef32ed0b3a5794977c b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/e26757270b3d149d1ce10bef32ed0b3a5794977c new file mode 100644 index 0000000000000000000000000000000000000000..d8911528a17ea420d0ec1a6c3155484faea6a355 GIT binary patch literal 6648 zcmWgOV*mpI2*qFkVfH#e#bJC2G=2aYKLL$jfyUo~#-D)3KY_-- zfyV!U#y4Pu2*BLOfyQ@0;|HMeGtl@e(D)5#{2gfg6KMPgXnX}|K*QYk15MrlP2K^G z5B2USH5vk=Aut*OqaiRF0;3@?8Ui#6fkZR_YqxAjUAXFn`4Isp&)rMju6Wa2bd@J{ z=8mt`!i;DBu(;e=2vb+K@BSOpvX5VEpZ%|>4Y?5illRhfw!FvtZ_J$)E7M)jnVoEC z26Q~r&ikSJfpi1RBS~lgW}e2!g+=)@GXJkWe2Hh#oC&jLc>R;vwCr!hRtt~!`){|SsYtrC@y4SUT1JOrZJWbZ@clLBeQl8{odQ!g zt$(eb?I^EtndTE(v++X9<-_k*GsjK-@p9A6yf9q$rlJ9udF5}*g!e{ut$4gi z_Qu|Jt?nD^!lz{9WOjs1?hW7c%}o}jZqF8#G>IP@*Q;-_m{9O$(TAqX6IRQtZ+-Zc zrA$(4Vct1h_QK+MlpYO%(GVC7fzc2c4S~@R7!85Z5Eu=C(GVECA@DSCrioSXhR9Q) zcRwG!dZq*2rHj9w^kTR<(Kkz>TsUCrDUoiaRaZCk%5Y8WHgkD(cJ?im(+={QdRtFS i+#x#a=+dLVl27q2GjaDRNpxsl&RTxyFuHjooeu!s*A_AW literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/e598a949c6b14e1a3f96bcdf1b3d9335b07a6085 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_license_fuzz_seed_corpus/e598a949c6b14e1a3f96bcdf1b3d9335b07a6085 new file mode 100644 index 0000000000000000000000000000000000000000..b54027c58647dbe9d102ecf7cfa0ec1c503d79bf GIT binary patch literal 6648 zcmWgOV*mpI2*qFk~_4RvT>JEw? z|EH33<%F@By2KuyhNE3iORkFQaqeYLb+CCGe2OJI+0YCW7}Z5O;=ra82P|M1(E!Z6 zNjsSrx}J(Z($n)kz(YBrxA(`nM9s@`m@4S}g^oa1V4_IlwojR}(%{7YJ7 zBg&at{i?$t^JUeC!d<$xF1YMvLIW`K{y(04{~~{3!kNcs>xJ$MX)@PZ#;$(vzhJWD z+>NFzfB0eQ%rt(bUOn*P|El|@oNYBfe=9KVi1^%kp+L_hPBJB@!v>eV%xC~+-aj#; z-@oS{Ze;6U$He#L@7#s*0^6QT#hkKId3vcLWr7GyU9IC}_L8KY=hng34XZwvP(wS;%8r%Lo(67GAhHl2YCo@6`JvO=fAWn!CmC z*Yd0@C#!-F`ptiA^4)g(Ndb3%ja&BT46FaL3B3NkZ_>~8zwI(^y^~7u`KDf1DIHLdVUpAi-wQg~LV z{_SGM16kcF%+osdO;6L>6MV9nEikGhRaoMQ)!XckiP1hM_Wucvgot?KT$T2$7h7RJlORc>@R`|s$(gV_}> zIHUU5`_qL!yOvkRR5e~Ke9oXK{3tY&uXG>hVgHpUGnDwI_jcxee9=*L@g`^NWsM3| zZW;Gt)ia9QZXHvJx?nEic6>_a6X$&Qdkn_D{Zos6WfY312}!l9e}7;1z%=5MZ@wwx zs%ejG1BKh>R9@J=E#*a9YQX+8>cR4XS5EEwdbhk_2LHPi)7ax(v#NNR=lE-WWBVK% zk>h@0+Dc~e-F_z(AFMfBQL*V?alIc z$DJt&J!Zl`br0dvvQML$BWFaq*UWf!^B!+o~@-^Zk7BywtyXtL9ysAN~&! zo_u|ddc$_PlzHEcwB0nn|B%S}?zPYR-Lwh)i^P<&&UmnuBskitG?uyLB&b&eSNe{V#)W{eIgVn7%S}bqLc`g=HDy!7E-lKi#mHsj(q_j#0B^ z`2XS!ohjYdK5*$iT5lkuHU0C1S*vGrOFLICSZ@1#U+O@ym2xuPn6{d$=y3EP0Bj&su@g?in>7 zp5ED!wYu;7d=4Gyu0=ch&%KFDTya*WJ;Cd+RQ&yRwPUAiGM{uavPCNWGVyL~w_(m@ z;wpb8dgJ`^47HqJ+Bch{ba|``WUhGZTh4WJ-<`ueipHDM{>w<8m{#^8-=$>FY?;~< zYZO=H0b`;;r)I5O>9Izd059B-@+TYQQ4g>k`o zwwBF)E&-*9)7reZX|MgTHvED)udHdn=}aX{&7D@4HIARtUSltB~A9wtTx170>xtu~Lg@4SqRjI0bSO)SfRGK+vR zOihf849gkJ5>oH%4T;in*z!Ql!&|cmdo4dJm}!mObkzt3#)sl-XCc)OKa8K zEq=e2XI(j26@1Wd{$rExw%bn%xch6|vOi~7{g+MP_4j>~ey;y*mvQTzREp1M%}>Si zEN^_vzp<&IsjzSBl23>1&T^gF#&UL+aCb;?h-ygBz8O{NYj17#+x)9(g;)BFu<($= zvqJT67c(Bn>Q-T%*0FDTn%17+lg(^_Q5~tm5>Kq&W`9hK_BkQ<<{gU8xb@HBH{&TibG~zT%i5dVxUI_j4-~QM)X$Y`i+-!Fd7pWD(tDT7(YCke#7S3M zZsE>l$=0tM`nPZ|qnz{k45u z=!@FV&#hy0L(sO&9`Bk}#mhX$U-KK= z=h%oG_Y2cjGK=r_JE{0!&Dn~IP5&A<1qLsZpW({X*vN3cxMyFkt1b_BY)npR#TiqN zZ8JXZOiAc*e%-p7Wm~OuVJX|ATP+!S^*)b_x7-W#-WJ$aec_q!=Zoj1{?%JG@7nzE ze~9qp>vPl_w#%i=`);J|ruqGcM9z1wectb;P3T`Frj&KYgRLalxn5n##YWdU>7&dR zb>mjG1P`&(?|+;%2f5*#sB@k-|4;k&!;Y@gH+mkDRBnHwB9rn|D{;g z3eFYJsK`w$NVZzI`SbE`31w$szd^*uc_qF{EyYE*{Us~*V@ZGUV!msO{BEDSM zR3h8g?sisWhuGS!dwFxFMv3iz8GP&a+vdRZm7%Lcn5HT$%McG<@yhw>hQ&;c4e4`? znk~cs7jNiH>Av=XOZU-w0~xL9pC`;(J)2wFxpKjB+vodw=e)kX*5U3-hK3yvH!sXl zo%FP& zsQK{p&W^0rec$JE=ty@h+Sz~ZOCORYJ76S*!KhzHLtr!nMnhmU1V%$(xQ9Skzve5D9|7tc BMJ50M literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/543f332b627f3891b3f15c6227f4f946cba81886 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/543f332b627f3891b3f15c6227f4f946cba81886 new file mode 100644 index 0000000000000000000000000000000000000000..b3788a28757225fa1aab9e2a4dffe0ab541cc10d GIT binary patch literal 4096 zcmZQzKm`|AAp8sL5Ly6L8qPClV%fvQ$Y8+B#;Mij(e|B}k&%&=fu)IM8Bk^sP==|A zk&$6JgIPlAoxLGZS`J$ticX0T^q&%O_ug`O8=VIooSKQ@>2YCo@6`JvO=fAWn!CmC z*Yd0@C#!-F`ptiA^4)g(Ndb3%ja&BT46FaL3B3NkZ_>~8zwI(^y^~7u`KDf1DIHLdVUpAi-wQg~LV z{_SGM16kcF%+osdO;6L>6MV9nEikGhRaoMQ)!XckiP1hM_Wucvgot?KT$T2$7h7RJlORc>@R`|s$(gV_}> zIHUU5`_qL!yOvkRR5e~Ke9oXK{3tY&uXG>hVgHpUGnDwI_jcxee9=*L@g`^NWsM3| zZW;Gt)ia9QZXHvJx?nEic6>_a6X$&Qdkn_D{Zos6WfY312}!l9e}7;1z%=5MZ@wwx zs%ejG1BKh>R9@J=E#*a9YQX+8>cR4XS5EEwdbhk_2LHPi)7ax(v#NNR=lE-WWBVK% zk>h@0+Dc~e-F_z(AFMfBQL*V?alIc z$DJt&J!Zl`br0dvvQML$BWFaq*UWf!^B!+o~@-^Zk7BywtyXtL9ysAN~&! zo_u|ddc$_PlzHEcwB0nn|B%S}?zPYR-Lwh)i^P<&&UmnuBskitG?uyLB&b&eSNe{V#)W{eIgVn7%S}bqLc`g=HDy!7E-lKi#mHsj(q_j#0B^ z`2XS!ohjYdK5*$iT5lkuHU0C1S*vGrOFLICSZ@1#U+O@ym2xuPn6{d$=y3EP0Bj&su@g?in>7 zp5ED!wYu;7d=4Gyu0=ch&%KFDTya*WJ;Cd+RQ&yRwPUAiGM{uavPCNWGVyL~w_(m@ z;wpb8dgJ`^47HqJ+Bch{ba|``WUhGZTh4WJ-<`ueipHDM{>w<8m{#^8-=$>FY?;~< zYZO=H0b`;;r)I5O>9Izd059B-@+TYQQ4g>k`o zwwBF)E&-*9)7reZX|MgTHvED)udHdn=}aX{&7D@4HIARtU2YCo@6`JvO=fAWn!CmC z*Yd0@C#!-F`ptiA^4)g(Ndb3%ja&BT46FaL3B3NkZ_>~8zwI(^y^~7u`KDf1DIHLdVUpAi-wQg~LV z{_SGM16kcF%+osdO;6L>6MV9nEikGhRaoMQ)!XckiP1hM_Wucvgot?KT$T2$7h7RJlORc>@R`|s$(gV_}> zIHUU5`_qL!yOvkRR5e~Ke9oXK{3tY&uXG>hVgHpUGnDwI_jcxee9=*L@g`^NWsM3| zZW;Gt)ia9QZXHvJx?nEic6>_a6X$&Qdkn_D{Zos6WfY312}!l9e}7;1z%=5MZ@wwx zs%ejG1BKh>R9@J=E#*a9YQX+8>cR4XS5EEwdbhk_2LHPi)7ax(v#NNR=lE-WWBVK% zk>h@0+Dc~e-F_z(AFMfBQL*V?alIc z$DJt&J!Zl`br0dvvQML$BWFaq*UWf!^B!+o~@-^Zk7BywtyXtL9ysAN~&! zo_u|ddc$_PlzHEcwB0nn|B%S}?zPYR-Lwh)i^P<&&UmnuBskitG?uyLB&b&eSNe{V#)W{eIgVn7%S}bqLc`g=HDy!7E-lKi#mHsj(q_j#0B^ z`2XS!ohjYdK5*$iT5lkuHU0C1S*vGrOFLICSZ@1#U+O@ym2xuPn6{d$=y3EP0Bj&su@g?in>7 zp5ED!wYu;7d=4Gyu0=ch&%KFDTya*WJ;Cd+RQ&yRwPUAiGM{uavPCNWGVyL~w_(m@ z;wpb8dgJ`^47HqJ+Bch{ba|``WUhGZTh4WJ-<`ueipHDM{>w<8m{#^8-=$>FY?;~< zYZO=H0b`;;r)I5O>9Izd059B-@+TYQQ4g>k`o zwwBF)E&-*9)7reZX|MgTHvED)udHdn=}aX{&7D@4HIARtUfBhh+g;kjsxzywT4dz`Xggp82F0kCM?+vV1V%$(Gz3ONVAzI0mR3VE$a4V0`9fU) literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/a98f2da86c01706159e32fc37c1a6b2df779395a b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/a98f2da86c01706159e32fc37c1a6b2df779395a new file mode 100644 index 0000000000000000000000000000000000000000..dfa20e2cbe211296940adb46ae8bfddfb9f8056d GIT binary patch literal 4096 zcmZQzKm`|AAp8sL5Ly6L8qPClV%ej?$Y8+B#;Mij(e|B}k&%&=fu)IM8Bk^s6C(pt z6C)$Tat5=6)H{1aqO=^gJQST0A?QCP;_kiW@-{jTIyf~G!_(u!>fWjMN1DviS~Yiz z->>CaS58(1AM~65*yOwI_LBnc{u;OJ&ly(#WfOS)ecz;?>wnv2+UFT&K3NoSh}y9a0>k8q%|GMpgRSTbunh|7u#{l|CaZJf!ff zQ2pD*j0dv1RhXxB?3MeI8DbLHBi->PfgXP%z)-sN(%?d>^n($$t* zxN}*uckkATKfk$(m5G^=fe{!I3~`mIo=eLrf3mvre_`Icq*n9lJ>%pXJJw8pZ66o< zqW1H1>lodTbhB%+ZeLI7c3aimakZ$dOD&9-iL2b`aQ5HPhX=DOSp51be{%h)+!(hx z;c-UwvG=D7eReIcjHzn8SooYlQTS14CSU13&cpsIPi83bP4Df@`}m@x>f%k#*vlFf zs@yW}#j0l%x7|9X5_Q2`#O?T$%qPzI?)Mmsefy^t{mLj5PZN@ASO5OL?ty8yJl7KGSBhX{Kob< zHX_IU!nBpl;=BD$Dn3|qwxVLwzs600!OP@lxH2_1GMq2&*_Z38%flTTlT%u8#?)im zjE_505_+6px2|T{Rx4dt%J%41ONL&(&*S1P_X54Q1-4aRc;@^0;(4im^;XThHb49y zB0Tx}9QB6naw+q^8)>^~e*Ynn^WAHo_q%Bm`WJ~QWu5V0D@k^)S66be(X~$cD6>V~ zxK%B|L+teXA7{-$Za63EoafE|)4u(%qwDmIo`)or+n=b&q&(F)?JOW7!Y6rp_wB!e zbHy_%auW-Ztrl+nygZuk|Mo<|kcl&&PBhYeZGXe=`<2s|7CRn%cWjdI>w2e%FBdkI z$o93nofX+3wsz}Y-khmXV*6hP-}?QwIWT=?=;{!rsS3+7#DiD7a(=pDF;inh`W&NX z%kclj8#+_EuYKUseYD;{Mr-=#3A0wu=9YG@T(I2s`M%ycuWzq)xVw^}VaLPG3v*N_ zJu%+2@3n7PoK2{r`4rOnZXYVX650?P|wP*JM8FW@L+0`eowX*lxp| z%fwawO!UV2DDydCBk*bk)#Ch3XhwydVQ+0xVJ~`f49k%!q?+fFC z^K31f{agY{6Q{L#Z_{4;VQu&Yb6#1~fYX^umYO@QE^8_?C466P;Bc$Y*R??H%Oc(j zDY5Q05?`(aO=VculI_09rs;A~@Vz3P?+2C4Zc2pxv(zwtaGO~G4ZsVwQO0NpjKC0B zuv+57`tm<*a&_AoIr81S-jYPET^edlFlWMpMvX<}Ih zlvxCnVQOMzWLVB%mXLa9Z%CAu!+Zt?rIJnPEIs^Eiu^Bc4CPufOk`^mF}hyNp}!q*8o7 zYkn%8XL;jW{*6ryO@)11mwY;8cb4naHkPxqgu6qELsUb0_RXkDUwdn_-{xOUE4#%)#Jf1rq6r+%(nTl8CX&HK#Llis^rj<&r$ zCr-NBatn7ZOZM*FI`QW>SFtiNGcqs&LxLf$GSzcwS>;bwSN<=|dzaK|UcG0Wd}GI& z>96hMLSNK=er_G38XvDuzcW^Q~SQ&EiahC|8B)J_ITHYtB|wZ2H%@DKL1M{0vv7#zuzo#Xb9SU3Gc5V`Fkk zE6$jDY@6|MXG%hk^Xt~tEZb_O3rpD^-D=6utM_?ayyae?_qM>c>I=_&KVLjA^{?Kl zdDrHL|3ic)U!SAiuw5=?-ghHyH_h)qByzrc?el&&Z9@MdF{P|C9&9Da&h_d_E;hQ> zNgrjls2jJcC3uLPe*fdFImiv?M4j`z`G4BCA9i$|zR~lLq;mTc6`7Q$8mFBFL`3)` zPw&3{S8%R)Mn!I7L9*4t&7YS?^ZnnRC>Szv=F^Ery07hT*nPip`qE;@gYS+_5`JCp z6!GQ4rV`n{cDJ)4JH*y*-OHOZHA-y%%ivqT-!=!PuMAxs!ZcN3S%!Ge<}V&Xo(6+dkjdJLmQ7wGMYzGBoUX zxOriY>ZB*eoA$l-Em4a%cb=0YUdGj^(6rD)N7wZZf0DD&?$?oyKTk!R^GXX2IiVpS z$5AMDgQ?Il;!4<=uNw^)zh!9U+;2M7QPV-P*;FMH=!8%K?laaaOKrs-t_vtjp5p1V zR^YUIM$Lz(cXnj0?)yHULr1!6(a!#JZ{iYHoRw)$@H#9Nf4^Pr*y)`D<1onbKTr`=P-|=@#eJuGSVlemA%M! zDcLhyruM`d#T9wLm}t_<> zU*dgXTyUPPWwW14KxyK%Ht%iPYd@?FzhKTQYZ`DmQ^`_ur`2UmWu}Dhs|_4(_4&FM zsC`+)dm$y(-A3Zem7u8%>sqqiH`z2@E(*R^r1SltlG#m(uz!{s#t&{Yb3g&SU>jwO zhQJ66f%E&GUgWsFNS8(K=%Lbcp&Tcm?SK&&6r)}q4S~@R7!85Z5Eu=CVH*P9Wa>OX Go&x~fibR(H literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/fb7a84cdab0bff7dabb339c7fc35eb2ea3c2eb9c b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_provisioning_fuzz_seed_corpus/fb7a84cdab0bff7dabb339c7fc35eb2ea3c2eb9c new file mode 100644 index 0000000000000000000000000000000000000000..eacb9d2b058f5b3d57fa8201f4ce4c17bf532a9d GIT binary patch literal 4096 zcmZQzfPmlsA>aZFgnxk@LJL6U(J6x_mOV_23kPQ5?UWR}*d zxm)~xEzi1gvMTtX-~7iW-)*;_6ma*~xMhFNu=+2X!0Ye(CjDIh+b-kQJE;_(&zhf# z=ULwPmVaYYLsMbj)+L_~*`4J&wT(>(+aQj8DZfe zg=dB8-!5i6kkzfiJgsBj^fawK!6%#90;4)og(aR?z0LlZ80~XH?#rQd9C5nwKZNQR z{n@Q3VQ}l8!*9k@dggrR?v}MTxp7;S_a7)?*QuW?*B1R&UGqNk^rZJLm!oZO&xw<+ zw%o#<%aXl&w@&=|%~h;S%!~|-z>r{wt4#G=T2}d!)s_DX^WG)3npf``C*RnyX8LRU zxX>51pPyUD=!T@5U6XbDdP=w3s_u@fMP*%TVZ2OSrdsz zxXlTVGpdihKV9gvYk6f%RpZ6N=M0L%k3uu~O80Rd_Fs82Ly2#CZ)e`e7adg>Z*s<7 z)~HbBmT@muJ)^ko)-jc+3+5tj$ERdIan5(Y$6)N+KegyrMxl6`kW{<+_xE)VOd~$| z=9@CEn)b*xP`GVQ<%R9rQeL#B2JAnh9xNYt<B3UBN4Hus^y+;c7jL;2=)Enlt@^?<-_IA%OZ}_2YTmW^ z;r|ff$=BzoH*A+nnfKjD+fDQP4~d-bUi-Y?O`FiaNK7f~j0amuvU9z7sTSdeVBaP#No(R}~6Cklp4ocVO3k?w2z8+PBXoW8W!@!-2-lZ0Q_J4JlC zu&G40uifpe$PTf!TlezjOpOxT|1$X2@3+l?=_^B5hcHc5Se79kyyBJf(+!K68XMB* z7&Tjl|1aLqnbLjj1DEcj^#(Fp(?3s`wR$$Uv~%Tx<+jiF_0D;Hd#%IWl?)9#9&TQk zqdMt{@uq#ReM{8h&7J4uh?j9SDl{$h(9w0h!=L1AwEK0WBAR>75-}tNXss=g^VvTC}tO+?%+>6=!AI6TA*f#oupNJ9fGz^GP=&Tcpx26Ys`$ z8|GXluJUK1H_k85P|NwHeX}`Am&dw5=8DI@T2rt<8Iz_Sz3?!!MZg%9;k8&Q!A0+-Y@LQ<*8@`)UJ+TYbK+1!`Xw z@m@%Yb+?iDawTXg!@8Di_f0lUmy3e$73q9GsAP6iBJ7`~hVg^j%mQcty?h(xkA}cV z3W5I@MG9OVbgsSl_PxG`X4HoR(00H`3WHIYwAz<>b*1`NCg1`n730RR91 literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_renewal_fuzz_seed_corpus/f2f45ab615736936405ec6c8df9ab92dbc91017b b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_load_renewal_fuzz_seed_corpus/f2f45ab615736936405ec6c8df9ab92dbc91017b new file mode 100644 index 0000000000000000000000000000000000000000..263e0606ad26dfadf7fc434b312095f2a39714eb GIT binary patch literal 3992 zcmeIuF%1AP2mnD+M+_+HSpPe?pu@d^PcCAoceCbvcJ8hO2oNAZfB*pk1PBlyK;RF7 E24D06Hvj+t literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_provisioning_request_fuzz_seed_corpus/6ee38ff02d14cae0565cd26553cde5f898444014 b/libwvdrmengine/oemcrypto/test/fuzz_tests/corpus/oemcrypto_provisioning_request_fuzz_seed_corpus/6ee38ff02d14cae0565cd26553cde5f898444014 new file mode 100644 index 0000000000000000000000000000000000000000..1eb62c38ce85df92ef251f94bf2a8ab38f14c182 GIT binary patch literal 146 zcmY#jfPe@n&A`aS%)-jX&cVsW&BM#bFCZu+EFvluA!-= zt)r`_Z(wL-Y+`C=ZeeL?c?j`9}pN691>Qk2+&sK|`~reP!Xlz#;u4Zl(lWAg@(PMd$||aA>Kd8=H?ISJ literal 0 HcmV?d00001 diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_deactivate_usage_entry_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_deactivate_usage_entry_fuzz.cc new file mode 100644 index 00000000..560a172d --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_deactivate_usage_entry_fuzz.cc @@ -0,0 +1,30 @@ +// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine Master +// License Agreement. + +#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(); + + 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 encrypted_usage_header; + session->UpdateUsageEntry(&encrypted_usage_header); + // LoadLicense sets the pst for usage entry. + entry.LoadLicense(); + + OEMCrypto_DeactivateUsageEntry(session->session_id(), data, size); + session->close(); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_decrypt_cenc_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_decrypt_cenc_fuzz.cc index 3f30ccb3..9a16086e 100644 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_decrypt_cenc_fuzz.cc +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_decrypt_cenc_fuzz.cc @@ -95,7 +95,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // Read subsamples from fuzzed data. vector subsamples; - while (fuzzed_subsample_data.remaining_bytes() > + while (fuzzed_subsample_data.remaining_bytes() >= sizeof(OEMCrypto_SubSampleDescription)) { OEMCrypto_SubSampleDescription subsample; fuzzed_subsample_data.ConsumeData(&subsample, @@ -138,9 +138,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { // Copy sub sample data. sample_descriptions[i].subsamples = &subsamples[input_subsample_index]; - if (AddOverflowUX(input_subsample_index, - sample_descriptions[i].subsamples_length, - &input_subsample_index)) { + if (OPK_AddOverflowUX(input_subsample_index, + sample_descriptions[i].subsamples_length, + &input_subsample_index)) { return 0; } if (input_subsample_index > subsamples.size()) return 0; diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.cc index 8939f118..f76fafae 100644 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.cc +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.cc @@ -22,4 +22,45 @@ std::vector> SplitInput(const uint8_t* data, size_t size) { } return result; } + +void OEMCryptoLicenseAPIFuzz::LoadLicense() { + license_messages_.SignAndVerifyRequest(); + license_messages_.CreateDefaultResponse(); + license_messages_.EncryptAndSignResponse(); + OEMCryptoResult sts = license_messages_.LoadResponse(); + CheckStatusAndExitFuzzerOnFailure(sts, OEMCrypto_SUCCESS); +} + +void OEMCryptoProvisioningAPIFuzz::LoadProvisioning() { + provisioning_messages_.SignAndVerifyRequest(); + provisioning_messages_.CreateDefaultResponse(); + provisioning_messages_.EncryptAndSignResponse(); + OEMCryptoResult sts = provisioning_messages_.LoadResponse(); + CheckStatusAndExitFuzzerOnFailure(sts, OEMCrypto_SUCCESS); +} + +void LicenseWithUsageEntryFuzz::CreateUsageTableHeader() { + size_t header_buffer_length = 0; + OEMCryptoResult sts = + OEMCrypto_CreateUsageTableHeader(nullptr, &header_buffer_length); + encrypted_usage_header_.resize(header_buffer_length); + sts = OEMCrypto_CreateUsageTableHeader(encrypted_usage_header_.data(), + &header_buffer_length); + CheckStatusAndExitFuzzerOnFailure(sts, OEMCrypto_SUCCESS); +} + +void LicenseWithUsageEntryFuzz::LoadLicense() { + license_messages_.SignAndVerifyRequest(); + license_messages_.CreateDefaultResponse(); + license_messages_.EncryptAndSignResponse(); + OEMCryptoResult sts = license_messages_.LoadResponse(); + CheckStatusAndExitFuzzerOnFailure(sts, OEMCrypto_SUCCESS); +} + +void CheckStatusAndExitFuzzerOnFailure(OEMCryptoResult result, + OEMCryptoResult expected_status) { + if (result != expected_status) { + abort(); + } +} } // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.h b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.h index 14c18f5c..2aa1f46c 100644 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.h +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_helper.h @@ -13,6 +13,16 @@ #include "oemcrypto_session_tests_helper.h" namespace wvoec { +// Forward-declare the libFuzzer's mutator callback. Mark it weak so that +// the program links successfully even outside of --config=asan-fuzzer +// (apparently the only config in which LLVM uses our custom mutator). +extern "C" size_t LLVMFuzzerMutate(uint8_t* Data, size_t Size, size_t MaxSize) + __attribute__((weak)); + +const size_t KB = 1024; +// Maximum signature length. If fuzzed signature length is greater that this, +// this value will be used for signature length. +const size_t MAX_FUZZ_SIGNATURE_LENGTH = 5 * KB; // Initial setup to create a valid OEMCrypto state such as initializing crypto // firmware/hardware, installing golden key box etc. in order to fuzz // OEMCrypto APIs. @@ -42,12 +52,7 @@ class OEMCryptoLicenseAPIFuzz : public InitializeFuzz { Session* session() { return &session_; } - void LoadLicense() { - license_messages_.SignAndVerifyRequest(); - license_messages_.CreateDefaultResponse(); - license_messages_.EncryptAndSignResponse(); - license_messages_.LoadResponse(); - } + void LoadLicense(); private: Session session_; @@ -64,9 +69,11 @@ class OEMCryptoProvisioningAPIFuzz : public InitializeFuzz { ~OEMCryptoProvisioningAPIFuzz() { session_.close(); } + void LoadProvisioning(); ProvisioningRoundTrip& provisioning_messages() { return provisioning_messages_; } + Session* session() { return &session_; } private: Session session_; @@ -85,6 +92,25 @@ class OEMCryptoRenewalAPIFuzz : public OEMCryptoLicenseAPIFuzz { RenewalRoundTrip renewal_messages_; }; +class LicenseWithUsageEntryFuzz : public InitializeFuzz { + public: + LicenseWithUsageEntryFuzz() : license_messages_(&session_) { + license_messages_.set_pst("my_pst"); + } + + void CreateUsageTableHeader(); + LicenseRoundTrip& license_messages() { return license_messages_; } + const vector& encrypted_usage_header() { + return encrypted_usage_header_; + } + void LoadLicense(); + + private: + vector encrypted_usage_header_; + LicenseRoundTrip license_messages_; + Session session_; +}; + // Convert data to valid enum value. template void ConvertDataToValidEnum(T max_enum_value, T* t) { @@ -99,6 +125,10 @@ void RedirectStdoutToFile(); // Function to split fuzzer input using delimiter "-_^_". std::vector> SplitInput(const uint8_t* data, size_t size); +// Check the status and exit fuzzer if arguments do not match. This is usually +// called to check status of APIs which are called to setup state for fuzzers. +void CheckStatusAndExitFuzzerOnFailure(OEMCryptoResult result, + OEMCryptoResult expected_status); } // namespace wvoec #endif // OEMCRYPTO_FUZZ_HELPER_H_ diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_structs.h b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_structs.h index 67dd588c..5a5febb3 100644 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_structs.h +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_fuzz_structs.h @@ -4,6 +4,9 @@ #ifndef OEMCRYPTO_FUZZ_STRUCTS_H_ #define OEMCRYPTO_FUZZ_STRUCTS_H_ +#include "core_message_types.h" +#include "odk.h" + namespace wvoec { struct OEMCrypto_Renewal_Response_Fuzz { // Timer limits in core license response needs to be fuzzed as load renewal @@ -37,6 +40,34 @@ struct OEMCrypto_Decrypt_Cenc_Fuzz { // Sample data and subsample data are of variable length and not included in // this structure. }; + +struct OEMCrypto_Generic_Api_Fuzz { + // Corpus format is as below, let | be separator. + // cipher_mode + algorithm + iv | buffer with actual data + OEMCryptoCipherMode cipher_mode; + OEMCrypto_Algorithm algorithm; + // iv and buffer data are of variable length and not included in + // this structure. +}; + +struct OEMCrypto_Generic_Verify_Fuzz { + // Corpus format is as belowr. + // cipher_mode + algorithm + signature_length + buffer with actual data + OEMCryptoCipherMode cipher_mode; + OEMCrypto_Algorithm algorithm; + size_t signature_length; + // Buffer data is of variable length and not included in + // this structure. +}; + +struct OEMCrypto_Generate_RSA_Signature_Fuzz { + // Corpus format is as below, let | be separator. + // padding_scheme + signature_length + input buffer + RSA_Padding_Scheme padding_scheme; + size_t signature_length; + // input buffer data is of variable length and not included in + // this structure. +}; } // namespace wvoec #endif // OEMCRYPTO_FUZZ_STRUCTS_H_ \ No newline at end of file diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_rsa_signature_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_rsa_signature_fuzz.cc new file mode 100644 index 00000000..872b302c --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generate_rsa_signature_fuzz.cc @@ -0,0 +1,34 @@ +// Copyright 2020 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(); + OEMCrypto_Generate_RSA_Signature_Fuzz fuzzed_structure; + if (size <= sizeof(OEMCrypto_Generate_RSA_Signature_Fuzz)) { + return 0; + } + + // Copy data to fuzzed structure. + memcpy(&fuzzed_structure, data, sizeof(fuzzed_structure)); + // Creates wrapped rsa key and calls load drm private key. + static OEMCryptoLicenseAPIFuzz license_api_fuzz; + // We cannot allocate buffers of random huge lengths in memory. + // This also slows down the fuzzer. + size_t signature_length = + std::min(MAX_FUZZ_SIGNATURE_LENGTH, fuzzed_structure.signature_length); + vector signature(signature_length); + OEMCrypto_GenerateRSASignature( + license_api_fuzz.session()->session_id(), data + sizeof(fuzzed_structure), + size - sizeof(fuzzed_structure), signature.data(), &signature_length, + fuzzed_structure.padding_scheme); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_decrypt_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_decrypt_fuzz.cc new file mode 100644 index 00000000..e36d5508 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_decrypt_fuzz.cc @@ -0,0 +1,61 @@ +// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine +// License Agreement. + +#include "FuzzedDataProvider.h" +#include "OEMCryptoCENC.h" +#include "log.h" +#include "oemcrypto_fuzz_helper.h" +#include "oemcrypto_fuzz_structs.h" +#include "oemcrypto_types.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(); + + // Split data using separator. + auto inputs = SplitInput(data, size); + if (inputs.size() < 2) { + return 0; + } + + OEMCrypto_Generic_Api_Fuzz fuzzed_structure; + if (inputs[0].size() < sizeof(fuzzed_structure)) { + return 0; + } + // Copy OEMCrypto_Generic_Api_Fuzz from input data. + memcpy(&fuzzed_structure, data, sizeof(fuzzed_structure)); + ConvertDataToValidEnum(OEMCrypto_CipherMode_MaxValue, + &fuzzed_structure.cipher_mode); + ConvertDataToValidEnum(OEMCrypto_Algorithm_MaxValue, + &fuzzed_structure.algorithm); + + // Copy iv from input data. + size_t iv_size = inputs[0].size() - sizeof(fuzzed_structure); + if (iv_size == 0) { + return 0; + } + vector iv(iv_size); + memcpy(iv.data(), data + sizeof(fuzzed_structure), iv_size); + + // Copy clear buffer from input data. + vector encrypted_buffer(inputs[1].size()); + vector clear_buffer(inputs[1].size()); + memcpy(encrypted_buffer.data(), inputs[1].data(), inputs[1].size()); + + OEMCryptoLicenseAPIFuzz license_api_fuzz; + 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_Generic_Decrypt(session->session_id(), encrypted_buffer.data(), + encrypted_buffer.size(), iv.data(), + fuzzed_structure.algorithm, clear_buffer.data()); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_encrypt_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_encrypt_fuzz.cc new file mode 100644 index 00000000..df0a35e9 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_encrypt_fuzz.cc @@ -0,0 +1,61 @@ +// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine +// License Agreement. + +#include "FuzzedDataProvider.h" +#include "OEMCryptoCENC.h" +#include "log.h" +#include "oemcrypto_fuzz_helper.h" +#include "oemcrypto_fuzz_structs.h" +#include "oemcrypto_types.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(); + + // Split data using separator. + auto inputs = SplitInput(data, size); + if (inputs.size() < 2) { + return 0; + } + + OEMCrypto_Generic_Api_Fuzz fuzzed_structure; + if (inputs[0].size() < sizeof(fuzzed_structure)) { + return 0; + } + // Copy OEMCrypto_Generic_Api_Fuzz from input data. + memcpy(&fuzzed_structure, data, sizeof(fuzzed_structure)); + ConvertDataToValidEnum(OEMCrypto_CipherMode_MaxValue, + &fuzzed_structure.cipher_mode); + ConvertDataToValidEnum(OEMCrypto_Algorithm_MaxValue, + &fuzzed_structure.algorithm); + + // Copy iv from input data. + size_t iv_size = inputs[0].size() - sizeof(fuzzed_structure); + if (iv_size == 0) { + return 0; + } + vector iv(iv_size); + memcpy(iv.data(), data + sizeof(fuzzed_structure), iv_size); + + // Copy clear buffer from input data. + vector clear_buffer(inputs[1].size()); + vector encrypted_buffer(inputs[1].size()); + memcpy(clear_buffer.data(), inputs[1].data(), inputs[1].size()); + + OEMCryptoLicenseAPIFuzz license_api_fuzz; + 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_Generic_Encrypt( + session->session_id(), clear_buffer.data(), clear_buffer.size(), + iv.data(), fuzzed_structure.algorithm, encrypted_buffer.data()); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_sign_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_sign_fuzz.cc new file mode 100644 index 00000000..d27415d1 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_sign_fuzz.cc @@ -0,0 +1,55 @@ +// Copyright 2020 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 "log.h" +#include "oemcrypto_fuzz_helper.h" +#include "oemcrypto_fuzz_structs.h" +#include "oemcrypto_types.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(); + + OEMCrypto_Generic_Api_Fuzz fuzzed_structure; + if (size < sizeof(fuzzed_structure)) { + return 0; + } + // Copy OEMCrypto_Generic_Api_Fuzz from input data. + memcpy(&fuzzed_structure, data, sizeof(fuzzed_structure)); + ConvertDataToValidEnum(OEMCrypto_CipherMode_MaxValue, + &fuzzed_structure.cipher_mode); + ConvertDataToValidEnum(OEMCrypto_Algorithm_MaxValue, + &fuzzed_structure.algorithm); + + size_t clear_buffer_size = size - sizeof(fuzzed_structure); + if (clear_buffer_size == 0) { + return 0; + } + // Copy clear buffer from input data. + vector clear_buffer(clear_buffer_size); + memcpy(clear_buffer.data(), data + sizeof(fuzzed_structure), + clear_buffer_size); + + OEMCryptoLicenseAPIFuzz license_api_fuzz; + 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); + size_t signature_length = 0; + OEMCrypto_Generic_Sign(session->session_id(), clear_buffer.data(), + clear_buffer.size(), fuzzed_structure.algorithm, + nullptr, &signature_length); + vector signature(signature_length); + OEMCrypto_Generic_Sign(session->session_id(), clear_buffer.data(), + clear_buffer.size(), fuzzed_structure.algorithm, + signature.data(), &signature_length); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_verify_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_verify_fuzz.cc new file mode 100644 index 00000000..076d3caa --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_generic_verify_fuzz.cc @@ -0,0 +1,67 @@ +// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine +// License Agreement. + +#include +#include + +#include "OEMCryptoCENC.h" +#include "log.h" +#include "oemcrypto_fuzz_helper.h" +#include "oemcrypto_fuzz_structs.h" +#include "oemcrypto_types.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(); + + OEMCrypto_Generic_Verify_Fuzz fuzzed_structure; + if (size < sizeof(fuzzed_structure)) { + return 0; + } + // Copy OEMCrypto_Generic_Verify_Fuzz from input data. + memcpy(&fuzzed_structure, data, sizeof(fuzzed_structure)); + ConvertDataToValidEnum(OEMCrypto_CipherMode_MaxValue, + &fuzzed_structure.cipher_mode); + ConvertDataToValidEnum(OEMCrypto_Algorithm_MaxValue, + &fuzzed_structure.algorithm); + + size_t in_buffer_size = size - sizeof(fuzzed_structure); + if (in_buffer_size == 0) { + return 0; + } + // Copy clear buffer from input data. + vector in_buffer(in_buffer_size); + memcpy(in_buffer.data(), data + sizeof(fuzzed_structure), in_buffer_size); + + OEMCryptoLicenseAPIFuzz license_api_fuzz; + Session* session = license_api_fuzz.session(); + // Load license and call generic_verify API. + license_api_fuzz.LoadLicense(); + OEMCrypto_SelectKey(session->session_id(), session->license().keys[0].key_id, + session->license().keys[0].key_id_length, + OEMCrypto_CipherMode_CTR); + // Calculate signature for in buffer. + size_t signature_length = 0; + OEMCrypto_Generic_Sign(session->session_id(), in_buffer.data(), + in_buffer.size(), fuzzed_structure.algorithm, nullptr, + &signature_length); + vector signature(signature_length); + OEMCrypto_Generic_Sign(session->session_id(), in_buffer.data(), + in_buffer.size(), fuzzed_structure.algorithm, + signature.data(), &signature_length); + + OEMCrypto_SelectKey(session->session_id(), session->license().keys[0].key_id, + session->license().keys[0].key_id_length, + fuzzed_structure.cipher_mode); + signature_length = + std::min(MAX_FUZZ_SIGNATURE_LENGTH, fuzzed_structure.signature_length); + signature.resize(signature_length); + OEMCrypto_Generic_Verify(session->session_id(), in_buffer.data(), + in_buffer.size(), fuzzed_structure.algorithm, + signature.data(), signature_length); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_entry_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_entry_fuzz.cc new file mode 100644 index 00000000..ed47b0b2 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_entry_fuzz.cc @@ -0,0 +1,61 @@ +// Copyright 2020 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; +// The custom mutator to mutate created encrypted usage entry. +extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* data, size_t size, + size_t max_size, unsigned int seed) { + entry.CreateUsageTableHeader(); + Session* s = entry.license_messages().session(); + s->open(); + entry.InstallTestRSAKey(s); + uint32_t usage_entry_number = 0; + memcpy(&usage_entry_number, data, sizeof(uint32_t)); + if (OEMCrypto_LoadUsageEntry(s->session_id(), usage_entry_number, + data + sizeof(uint32_t), + size - sizeof(uint32_t)) != OEMCrypto_SUCCESS) { + s->CreateNewUsageEntry(); + vector encrypted_usage_header; + s->UpdateUsageEntry(&encrypted_usage_header); + vector encrypted_usage_entry = s->encrypted_usage_entry(); + usage_entry_number = s->usage_entry_number(); + // Copy created usage entry number and usage entry to data and mutate it. + memcpy(data, &usage_entry_number, sizeof(uint32_t)); + memcpy(data + sizeof(uint32_t), encrypted_usage_entry.data(), + encrypted_usage_entry.size()); + size = sizeof(uint32_t) + encrypted_usage_entry.size(); + } + s->close(); + return LLVMFuzzerMutate(data, size, max_size); +} + +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; + } + + memcpy(&usage_entry_number, data, sizeof(usage_entry_number)); + const uint8_t* extra_data = data + sizeof(usage_entry_number); + size_t extra_data_size = size - sizeof(usage_entry_number); + if (extra_data_size == 0) { + return 0; + } + + Session s; + s.open(); + OEMCrypto_LoadUsageEntry(s.session_id(), usage_entry_number, extra_data, + extra_data_size); + s.close(); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_table_header_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_table_header_fuzz.cc new file mode 100644 index 00000000..8d3000af --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_load_usage_table_header_fuzz.cc @@ -0,0 +1,36 @@ +// Copyright 2020 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 { + +// The custom mutator to mutate created encrypted usage table header. +extern "C" size_t LLVMFuzzerCustomMutator(uint8_t* data, size_t size, + size_t max_size, unsigned int seed) { + LicenseWithUsageEntryFuzz entry; + if (OEMCrypto_LoadUsageTableHeader(data, size) != OEMCrypto_SUCCESS) { + entry.CreateUsageTableHeader(); + if (size < entry.encrypted_usage_header().size()) { + return 0; + } + // Copy created usage table header to data and mutate it. + memcpy(data, entry.encrypted_usage_header().data(), + entry.encrypted_usage_header().size()); + size = entry.encrypted_usage_header().size(); + } + return LLVMFuzzerMutate(data, size, max_size); +} + +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(); + // Initialize OEMCrypto and call API. + InitializeFuzz initialize_fuzz; + OEMCrypto_LoadUsageTableHeader(data, size); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_odkitee_dispatcher_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_opk_dispatcher_fuzz.cc similarity index 50% rename from libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_odkitee_dispatcher_fuzz.cc rename to libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_opk_dispatcher_fuzz.cc index 1a3c770b..3fae8e6c 100644 --- a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_odkitee_dispatcher_fuzz.cc +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_opk_dispatcher_fuzz.cc @@ -1,23 +1,15 @@ #include +#include -#include "dispatcher.h" -#include "marshaller_base.h" -#include "transport_interface.h" +#include "opk_dispatcher.h" +#include "opk_init.h" +#include "tos_transport_interface.h" namespace wvoec { -void InitializeODKMessage(ODK_Message* message, uint8_t* data, size_t size) { - ODK_Message_Impl* impl = (ODK_Message_Impl*)message; - impl->base = data; - impl->size = size; - impl->capacity = size; - impl->read_offset = 0; - impl->status = MESSAGE_STATUS_OK; -} - void OpenOEMCryptoTASession() { ODK_Message request; - ODK_Message* response = NULL; + ODK_Message response; uint8_t response_buffer[0x1000]; uint8_t request_body[] = { 0x06, // TAG_UINT32 @@ -26,16 +18,13 @@ void OpenOEMCryptoTASession() { 0x00, // value (false) 0x0a // TAG_EOM }; - - InitializeODKMessage(&request, request_body, sizeof(request_body)); - - ODK_DispatchMessage(&request, &response); - if (response != NULL) ODK_Transport_DeallocateMessage(response); + request = ODK_Message_Create(request_body, sizeof(request_body)); + OPK_DispatchMessage(&request, &response); } void InitializeOEMCryptoTA() { ODK_Message init_request; - ODK_Message* init_response = NULL; + ODK_Message init_response; uint8_t response_buffer[0x1000]; uint8_t init_request_body[] = { 0x06, // TAG_UINT32 @@ -43,15 +32,13 @@ void InitializeOEMCryptoTA() { 0x0a // TAG_EOM }; - InitializeODKMessage(&init_request, init_request_body, - sizeof(init_request_body)); - - ODK_DispatchMessage(&init_request, &init_response); - if (init_response != NULL) ODK_Transport_DeallocateMessage(init_response); + init_request = + ODK_Message_Create(init_request_body, sizeof(init_request_body)); + OPK_DispatchMessage(&init_request, &init_response); } extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { - ODK_InitializeDispatcher(); + OPK_Initialize(); InitializeOEMCryptoTA(); OpenOEMCryptoTASession(); return 0; @@ -59,16 +46,14 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { ODK_Message request; - ODK_Message* response = NULL; + ODK_Message response; unsigned char response_buffer[0x1000]; uint8_t* input = new uint8_t[size]; memcpy(input, data, size); - InitializeODKMessage(&request, input, size); - - ODK_DispatchMessage(&request, &response); - if (response != NULL) ODK_Transport_DeallocateMessage(response); + request = ODK_Message_Create(input, size); + OPK_DispatchMessage(&request, &response); delete[] input; return 0; diff --git a/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_report_usage_fuzz.cc b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_report_usage_fuzz.cc new file mode 100644 index 00000000..3b3813a8 --- /dev/null +++ b/libwvdrmengine/oemcrypto/test/fuzz_tests/oemcrypto_report_usage_fuzz.cc @@ -0,0 +1,46 @@ +// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine Master +// License Agreement. + +#include "oemcrypto_fuzz_helper.h" + +namespace wvoec { +const size_t MAX_FUZZ_PST_REPORT_BUFFER_LENGTH = 5 * MB; +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 encrypted_usage_header; + session->UpdateUsageEntry(&encrypted_usage_header); + // Sets pst for usage entry. + entry.LoadLicense(); + + memcpy(&pst_buffer_length, data, sizeof(pst_buffer_length)); + const uint8_t* extra_data = data + sizeof(pst_buffer_length); + size_t extra_data_size = size - sizeof(pst_buffer_length); + // We cannot allocate a huge buffer, hence limiting buffer size to + // MAX_FUZZ_PST_REPORT_BUFFER_LENGTH. + pst_buffer_length = + std::min(MAX_FUZZ_PST_REPORT_BUFFER_LENGTH, pst_buffer_length); + vector pst_report_buffer(pst_buffer_length); + // Call API with fuzzed pst_buffer_length, pst. + OEMCrypto_ReportUsage(session->session_id(), extra_data, extra_data_size, + pst_report_buffer.data(), &pst_buffer_length); + session->close(); + return 0; +} +} // namespace wvoec diff --git a/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.cpp b/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.cpp index b3d36dc5..9d59bd87 100644 --- a/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.cpp +++ b/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.cpp @@ -205,13 +205,13 @@ void WriteDecryptCencCorpus( const OEMCrypto_CENCEncryptPatternDesc* pattern, size_t samples_length) { const std::string file_name = GetFileName("oemcrypto_decrypt_cenc_fuzz_seed_corpus"); - // Cipher mode. - AppendToFile(file_name, reinterpret_cast(&cipher_mode), - sizeof(OEMCryptoCipherMode)); - - // Pattern. - AppendToFile(file_name, reinterpret_cast(pattern), - sizeof(OEMCrypto_CENCEncryptPatternDesc)); + OEMCrypto_Decrypt_Cenc_Fuzz decrypt_cenc_fuzz_struct; + decrypt_cenc_fuzz_struct.cipher_mode = cipher_mode; + decrypt_cenc_fuzz_struct.pattern = *pattern; + // Cipher mode and Pattern. + AppendToFile(file_name, + reinterpret_cast(&decrypt_cenc_fuzz_struct), + sizeof(OEMCrypto_Decrypt_Cenc_Fuzz)); // Sample data for all samples. for (size_t i = 0; i < samples_length; i++) { diff --git a/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.h b/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.h index 06ca62f8..aafbb071 100644 --- a/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.h +++ b/libwvdrmengine/oemcrypto/test/oec_decrypt_fallback_chain.h @@ -7,6 +7,7 @@ #include "OEMCryptoCENC.h" #include "disallow_copy_and_assign.h" +#include "oemcrypto_fuzz_structs.h" namespace wvoec { From 1a93b9f1cc1ea73c7ca7620c15dac2c3c4bf24d2 Mon Sep 17 00:00:00 2001 From: Fred Gylys-Colwell Date: Wed, 13 Oct 2021 22:06:56 +0000 Subject: [PATCH 3/5] Add timestamp when socket times out Merge from Widevine repo of http://go/wvgerrit/123407 and http://go/wvgerrit/130983 This should help us debug flaky tests. Bug: 186031735 Change-Id: I5229176c80dad5875b6ef01ea167e4e26d48506d --- libwvdrmengine/cdm/core/test/http_socket.cpp | 125 ++++++++++++------ libwvdrmengine/cdm/core/test/http_socket.h | 23 +++- .../cdm/core/test/http_socket_test.cpp | 6 +- libwvdrmengine/cdm/core/test/url_request.cpp | 10 +- 4 files changed, 114 insertions(+), 50 deletions(-) diff --git a/libwvdrmengine/cdm/core/test/http_socket.cpp b/libwvdrmengine/cdm/core/test/http_socket.cpp index 886ec687..eaff0520 100644 --- a/libwvdrmengine/cdm/core/test/http_socket.cpp +++ b/libwvdrmengine/cdm/core/test/http_socket.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #ifdef _WIN32 @@ -108,40 +109,6 @@ void ShowServerCertificate(const SSL* ssl) { } #endif -// Wait for a socket to be ready for reading or writing. -// Establishing a connection counts as "ready for write". -// Returns false on select error or timeout. -// Returns true when the socket is ready. -bool SocketWait(int fd, bool for_read, int timeout_in_ms) { - fd_set fds; - FD_ZERO(&fds); - FD_SET(fd, &fds); - - struct timeval tv; - tv.tv_sec = timeout_in_ms / 1000; - tv.tv_usec = (timeout_in_ms % 1000) * 1000; - - fd_set* read_fds = nullptr; - fd_set* write_fds = nullptr; - if (for_read) { - read_fds = &fds; - } else { - write_fds = &fds; - } - - int ret = select(fd + 1, read_fds, write_fds, nullptr, &tv); - if (ret == 0) { - LOGE("socket timed out"); - return false; - } else if (ret == -1) { - LOGE("select failed, errno = %d", errno); - return false; - } - - // socket ready. - return true; -} - int GetError() { #ifdef _WIN32 return WSAGetLastError(); @@ -228,6 +195,8 @@ HttpSocket::HttpSocket(const std::string& url) : socket_fd_(-1), ssl_(nullptr), ssl_ctx_(nullptr) { valid_url_ = ParseUrl(url, &scheme_, &secure_connect_, &domain_name_, &port_, &resource_path_); + create_time_ = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); InitSslLibrary(); } @@ -252,6 +221,16 @@ void HttpSocket::CloseSocket() { } } +bool HttpSocket::ConnectAndLogErrors(int timeout_in_ms) { + std::time_t start = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + bool result = Connect(timeout_in_ms); + std::time_t finish = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + if (!result) LogTime("socket connect error", start, finish); + return result; +} + bool HttpSocket::Connect(int timeout_in_ms) { if (!valid_url_) { LOGE("URL is invalid"); @@ -355,7 +334,7 @@ bool HttpSocket::Connect(int timeout_in_ms) { return false; } else { // in progress. block until timeout expired or connection established. - if (!SocketWait(socket_fd_, /* for_read */ false, timeout_in_ms)) { + if (!Wait(/* for_read */ false, timeout_in_ms)) { LOGE("cannot connect to %s", domain_name_.c_str()); CloseSocket(); return false; @@ -399,7 +378,7 @@ bool HttpSocket::Connect(int timeout_in_ms) { return false; } const bool for_read = (ssl_err == SSL_ERROR_WANT_READ); - if (!SocketWait(socket_fd_, for_read, timeout_in_ms)) { + if (!Wait(for_read, timeout_in_ms)) { LOGE("Cannot connect securely to %s", domain_name_.c_str()); CloseSocket(); return false; @@ -414,6 +393,16 @@ bool HttpSocket::Connect(int timeout_in_ms) { // Returns -1 for error, number of bytes read for success. // The timeout here only applies to the span between packets of data, for the // sake of simplicity. +int HttpSocket::ReadAndLogErrors(char* data, int len, int timeout_in_ms) { + std::time_t start = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + int result = Read(data, len, timeout_in_ms); + std::time_t finish = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + if (result < 0) LogTime("read error", start, finish); + return result; +} + int HttpSocket::Read(char* data, int len, int timeout_in_ms) { int total_read = 0; int to_read = len; @@ -423,8 +412,9 @@ int HttpSocket::Read(char* data, int len, int timeout_in_ms) { return -1; } while (to_read > 0) { - if (!SocketWait(socket_fd_, /* for_read */ true, timeout_in_ms)) { - LOGE("unable to read from %s", domain_name_.c_str()); + if (!Wait(/* for_read */ true, timeout_in_ms)) { + LOGE("unable to read from %s. len=%d, to_read=%d", domain_name_.c_str(), + len, to_read); return -1; } @@ -480,6 +470,17 @@ int HttpSocket::Read(char* data, int len, int timeout_in_ms) { // Returns -1 for error, number of bytes written for success. // The timeout here only applies to the span between packets of data, for the // sake of simplicity. +int HttpSocket::WriteAndLogErrors(const char* data, int len, + int timeout_in_ms) { + std::time_t start = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + int result = Write(data, len, timeout_in_ms); + std::time_t finish = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + if (result < 0) LogTime("write error", start, finish); + return result; +} + int HttpSocket::Write(const char* data, int len, int timeout_in_ms) { int total_sent = 0; int to_send = len; @@ -502,7 +503,7 @@ int HttpSocket::Write(const char* data, int len, int timeout_in_ms) { total_sent += sent; } else if (sent == 0) { // We filled up the pipe. Wait for room to write. - if (!SocketWait(socket_fd_, /* for_read */ false, timeout_in_ms)) { + if (!Wait(/* for_read */ false, timeout_in_ms)) { LOGE("unable to write to %s", domain_name_.c_str()); return -1; } @@ -515,4 +516,50 @@ int HttpSocket::Write(const char* data, int len, int timeout_in_ms) { return total_sent; } +bool HttpSocket::Wait(bool for_read, int timeout_in_ms) { + fd_set fds; + FD_ZERO(&fds); + FD_SET(socket_fd_, &fds); + + struct timeval tv; + tv.tv_sec = timeout_in_ms / 1000; + tv.tv_usec = (timeout_in_ms % 1000) * 1000; + + fd_set* read_fds = nullptr; + fd_set* write_fds = nullptr; + if (for_read) { + read_fds = &fds; + } else { + write_fds = &fds; + } + + const std::time_t start = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + int ret = select(socket_fd_ + 1, read_fds, write_fds, nullptr, &tv); + const std::time_t finish = + std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); + if (ret == 0) { + LogTime("socket select timeout", start, finish); + // TODO(b/186031735): Remove this when the bug is fixed. + LOGE("Timeout = %0.3f. Consider adding a comment to http://b/186031735", + 0.001 * timeout_in_ms); + return false; + } else if (ret == -1) { + LOGE("select failed, errno = %d", errno); + return false; + } + + // socket ready. + return true; +} + +void HttpSocket::LogTime(const char* note, const std::time_t& start, + const std::time_t& finish) { + std::string start_string = std::string(std::ctime(&start)); + start_string.pop_back(); // Remove new line character. + LOGE("%s: start = %s = create + %0.3f, end = start + %0.3f", note, + start_string.c_str(), difftime(start, create_time_), + difftime(finish, start)); +} + } // namespace wvcdm diff --git a/libwvdrmengine/cdm/core/test/http_socket.h b/libwvdrmengine/cdm/core/test/http_socket.h index 4c7bc305..f32612a1 100644 --- a/libwvdrmengine/cdm/core/test/http_socket.h +++ b/libwvdrmengine/cdm/core/test/http_socket.h @@ -7,6 +7,7 @@ #include +#include #include #include @@ -23,7 +24,7 @@ class HttpSocket { explicit HttpSocket(const std::string& url); ~HttpSocket(); - bool Connect(int timeout_in_ms); + bool ConnectAndLogErrors(int timeout_in_ms); void CloseSocket(); const std::string& scheme() const { return scheme_; } @@ -32,13 +33,25 @@ class HttpSocket { int port() const { return atoi(port_.c_str()); } const std::string& resource_path() const { return resource_path_; } - int Read(char* data, int len, int timeout_in_ms); - int Write(const char* data, int len, int timeout_in_ms); + int ReadAndLogErrors(char* data, int len, int timeout_in_ms); + int WriteAndLogErrors(const char* data, int len, int timeout_in_ms); private: static bool ParseUrl(const std::string& url, std::string* scheme, bool* secure_connect, std::string* domain_name, std::string* port, std::string* path); + // The following three functions do the work without logging errors. + bool Connect(int timeout_in_ms); + int Read(char* data, int len, int timeout_in_ms); + int Write(const char* data, int len, int timeout_in_ms); + // Log times with a note as an error. + void LogTime(const char* note, const std::time_t& start, + const std::time_t& finish); + // Wait for a socket to be ready for reading or writing. + // Establishing a connection counts as "ready for write". + // Returns false on select error or timeout. + // Returns true when the socket is ready. + bool Wait(bool for_read, int timeout_in_ms); FRIEND_TEST(HttpSocketTest, ParseUrlTest); std::string scheme_; @@ -52,6 +65,10 @@ class HttpSocket { SSL* ssl_; SSL_CTX* ssl_ctx_; + // When the socket was created. Logged on error to help debug flaky + // tests. e.g. b/186031735 + std::time_t create_time_; + CORE_DISALLOW_COPY_AND_ASSIGN(HttpSocket); }; diff --git a/libwvdrmengine/cdm/core/test/http_socket_test.cpp b/libwvdrmengine/cdm/core/test/http_socket_test.cpp index 34a9f375..974a1e38 100644 --- a/libwvdrmengine/cdm/core/test/http_socket_test.cpp +++ b/libwvdrmengine/cdm/core/test/http_socket_test.cpp @@ -36,7 +36,7 @@ class HttpSocketTest : public testing::Test { bool Connect(const std::string& server_url) { socket_.reset(new HttpSocket(server_url)); - if (socket_->Connect(kTimeout)) { + if (socket_->ConnectAndLogErrors(kTimeout)) { LOGD("connected to %s", socket_->domain_name().c_str()); return true; } else { @@ -73,7 +73,7 @@ class HttpSocketTest : public testing::Test { // append data request.append(data); - socket_->Write(request.c_str(), request.size(), kTimeout); + socket_->WriteAndLogErrors(request.c_str(), request.size(), kTimeout); LOGD("request: %s", request.c_str()); return true; @@ -81,7 +81,7 @@ class HttpSocketTest : public testing::Test { bool GetResponse(std::string* response) { char buffer[kHttpBufferSize]; - int bytes = socket_->Read(buffer, sizeof(buffer), kTimeout); + int bytes = socket_->ReadAndLogErrors(buffer, sizeof(buffer), kTimeout); if (bytes < 0) { LOGE("read error, errno = %d", errno); return false; diff --git a/libwvdrmengine/cdm/core/test/url_request.cpp b/libwvdrmengine/cdm/core/test/url_request.cpp index c2fb1ec9..42a4c126 100644 --- a/libwvdrmengine/cdm/core/test/url_request.cpp +++ b/libwvdrmengine/cdm/core/test/url_request.cpp @@ -87,7 +87,7 @@ UrlRequest::~UrlRequest() {} void UrlRequest::Reconnect() { for (uint32_t i = 0; i < kMaxConnectAttempts && !is_connected_; ++i) { socket_.CloseSocket(); - if (socket_.Connect(kConnectTimeoutMs)) { + if (socket_.ConnectAndLogErrors(kConnectTimeoutMs)) { is_connected_ = true; } else { LOGE("Failed to connect: url = %s, port = %d, attempt = %u", @@ -104,8 +104,8 @@ bool UrlRequest::GetResponse(std::string* message) { // non-blocking mode. while (true) { char read_buffer[kReadBufferSize]; - const int bytes = - socket_.Read(read_buffer, sizeof(read_buffer), kReadTimeoutMs); + const int bytes = socket_.ReadAndLogErrors(read_buffer, sizeof(read_buffer), + kReadTimeoutMs); if (bytes > 0) { response.append(read_buffer, bytes); } else if (bytes < 0) { @@ -203,8 +203,8 @@ bool UrlRequest::PostRequestWithPath(const std::string& path, request.append(data); - const int ret = - socket_.Write(request.c_str(), request.size(), kWriteTimeoutMs); + const int ret = socket_.WriteAndLogErrors(request.c_str(), request.size(), + kWriteTimeoutMs); LOGV("HTTP request: (%zu): %s", request.size(), b2a_hex(request).c_str()); return ret != -1; } From 21a021e800e95d440f19c9b89c01f97c355cab5f Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Wed, 3 Nov 2021 17:24:34 -0700 Subject: [PATCH 4/5] Ran clang-format on the metrics directory. [ Merge of http://go/wvgerrit/137809 ] Bug: 204946540 Test: Metric unit tests Change-Id: Ibd68db73ea9ee64664d33c2cb8e8bb7c56674c27 --- .../cdm/metrics/include/counter_metric.h | 24 +- .../cdm/metrics/include/event_metric.h | 51 ++-- .../cdm/metrics/include/metrics_collections.h | 54 ++-- .../cdm/metrics/include/pow2bucket.h | 4 +- .../cdm/metrics/include/value_metric.h | 12 +- .../cdm/metrics/src/attribute_handler.cpp | 50 ++-- .../cdm/metrics/src/counter_metric.cpp | 2 +- .../cdm/metrics/src/event_metric.cpp | 6 +- .../cdm/metrics/src/metrics_collections.cpp | 61 ++-- .../cdm/metrics/src/timer_metric.cpp | 8 +- .../cdm/metrics/src/value_metric.cpp | 59 ++-- .../metrics/test/counter_metric_unittest.cpp | 11 +- .../metrics/test/distribution_unittest.cpp | 1 - .../metrics/test/event_metric_unittest.cpp | 18 +- .../metrics/test/metrics_collections_test.cpp | 246 ++++++++-------- .../test/metrics_collections_unittest.cpp | 265 +++++++++--------- 16 files changed, 431 insertions(+), 441 deletions(-) diff --git a/libwvdrmengine/cdm/metrics/include/counter_metric.h b/libwvdrmengine/cdm/metrics/include/counter_metric.h index 7540759c..317c35ad 100644 --- a/libwvdrmengine/cdm/metrics/include/counter_metric.h +++ b/libwvdrmengine/cdm/metrics/include/counter_metric.h @@ -37,7 +37,7 @@ class BaseCounterMetric { // Increment will look for an existing instance of the field names and // add the new value to the existing value. If the instance does not exist, // this method will create it. - void Increment(const std::string &counter_key, int64_t value); + void Increment(const std::string& counter_key, int64_t value); private: friend class CounterMetricTest; @@ -99,14 +99,13 @@ class CounterMetric : public BaseCounterMetric { void Increment(int64_t value, F1 field1 = util::Unused(), F2 field2 = util::Unused(), F3 field3 = util::Unused(), F4 field4 = util::Unused()) { - std::string key = - attribute_handler_.GetSerializedAttributes(field1, field2, - field3, field4); + std::string key = attribute_handler_.GetSerializedAttributes( + field1, field2, field3, field4); BaseCounterMetric::Increment(key, value); } - void ToProto(::google::protobuf::RepeatedPtrField - *counters) const; + void ToProto(::google::protobuf::RepeatedPtrField* + counters) const; private: friend class CounterMetricTest; @@ -120,13 +119,12 @@ class CounterMetric : public BaseCounterMetric { template <> inline void CounterMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0, util::Unused>:: - ToProto(::google::protobuf::RepeatedPtrField - *counters) const { - + ToProto(::google::protobuf::RepeatedPtrField* + counters) const { const std::map* values = GetValues(); for (std::map::const_iterator it = values->begin(); it != values->end(); it++) { - drm_metrics::CounterMetric *new_counter = counters->Add(); + drm_metrics::CounterMetric* new_counter = counters->Add(); new_counter->set_count(it->second); } } @@ -134,12 +132,12 @@ inline void CounterMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0, template inline void CounterMetric::ToProto( - ::google::protobuf::RepeatedPtrField - *counters) const { + ::google::protobuf::RepeatedPtrField* counters) + const { const std::map* values = GetValues(); for (std::map::const_iterator it = values->begin(); it != values->end(); it++) { - drm_metrics::CounterMetric *new_counter = counters->Add(); + drm_metrics::CounterMetric* new_counter = counters->Add(); if (!new_counter->mutable_attributes()->ParseFromString(it->first)) { LOGE("Failed to parse the attributes from a string."); } diff --git a/libwvdrmengine/cdm/metrics/include/event_metric.h b/libwvdrmengine/cdm/metrics/include/event_metric.h index dfa717d8..a87f2541 100644 --- a/libwvdrmengine/cdm/metrics/include/event_metric.h +++ b/libwvdrmengine/cdm/metrics/include/event_metric.h @@ -36,12 +36,12 @@ class BaseEventMetric { // Record will look for an existing instance of the Distribution identified // by the distribution_key string and update it. If the instance does // not exist, this will create it. - void Record(const std::string &distribution_key, double value); + void Record(const std::string& distribution_key, double value); // value_map_ contains a mapping from the string key (attribute name/values) // to the distribution instance which holds the metric information // (min, max, sum, etc.). - std::map value_map_; + std::map value_map_; private: friend class EventMetricTest; @@ -90,34 +90,33 @@ template * GetDistributions() const { + const std::map* GetDistributions() const { return &value_map_; }; void ToProto( - ::google::protobuf::RepeatedPtrField - *distributions_proto) const; + ::google::protobuf::RepeatedPtrField* + distributions_proto) const; private: friend class EventMetricTest; AttributeHandler attribute_handler_; inline void SetDistributionValues( - const Distribution &distribution, - drm_metrics::DistributionMetric *metric_proto) const { + const Distribution& distribution, + drm_metrics::DistributionMetric* metric_proto) const { metric_proto->set_mean(distribution.Mean()); metric_proto->set_operation_count(distribution.Count()); if (distribution.Count() > 1) { @@ -138,13 +137,14 @@ template <> inline void EventMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0, util::Unused>:: ToProto( - ::google::protobuf::RepeatedPtrField - *distributions_proto) const { - const std::map* distributions - = GetDistributions(); - for (std::map::const_iterator it = - distributions->begin(); it != distributions->end(); it++) { - drm_metrics::DistributionMetric *new_metric = distributions_proto->Add(); + ::google::protobuf::RepeatedPtrField* + distributions_proto) const { + const std::map* distributions = + GetDistributions(); + for (std::map::const_iterator it = + distributions->begin(); + it != distributions->end(); it++) { + drm_metrics::DistributionMetric* new_metric = distributions_proto->Add(); SetDistributionValues(*it->second, new_metric); } } @@ -152,13 +152,14 @@ inline void EventMetric<0, util::Unused, 0, util::Unused, 0, util::Unused, 0, template inline void EventMetric::ToProto( - ::google::protobuf::RepeatedPtrField - *distributions_proto) const { - const std::map* distributions - = GetDistributions(); - for (std::map::const_iterator it = - distributions->begin(); it != distributions->end(); it++) { - drm_metrics::DistributionMetric *new_metric = distributions_proto->Add(); + ::google::protobuf::RepeatedPtrField* + distributions_proto) const { + const std::map* distributions = + GetDistributions(); + for (std::map::const_iterator it = + distributions->begin(); + it != distributions->end(); it++) { + drm_metrics::DistributionMetric* new_metric = distributions_proto->Add(); if (!new_metric->mutable_attributes()->ParseFromString(it->first)) { LOGE("Failed to parse the attributes from a string."); } diff --git a/libwvdrmengine/cdm/metrics/include/metrics_collections.h b/libwvdrmengine/cdm/metrics/include/metrics_collections.h index 1f556d89..9aaca0b9 100644 --- a/libwvdrmengine/cdm/metrics/include/metrics_collections.h +++ b/libwvdrmengine/cdm/metrics/include/metrics_collections.h @@ -73,8 +73,7 @@ const int kCdmSecurityLevelFieldNumber = ::drm_metrics::Attributes::kCdmSecurityLevelFieldNumber; const int kSecurityLevelFieldNumber = ::drm_metrics::Attributes::kSecurityLevelFieldNumber; -const int kLengthFieldNumber = - ::drm_metrics::Attributes::kLengthFieldNumber; +const int kLengthFieldNumber = ::drm_metrics::Attributes::kLengthFieldNumber; const int kEncryptAlgorithmFieldNumber = ::drm_metrics::Attributes::kEncryptionAlgorithmFieldNumber; const int kSigningAlgorithmFieldNumber = @@ -125,8 +124,8 @@ typedef enum OEMCryptoInitializationMode { // This class contains metrics for Crypto Session and OEM Crypto. class CryptoMetrics { public: - void Serialize(drm_metrics::WvCdmMetrics::CryptoMetrics *crypto_metrics) - const; + void Serialize( + drm_metrics::WvCdmMetrics::CryptoMetrics* crypto_metrics) const; /* CRYPTO SESSION */ // TODO(blueeyes): Convert this to crypto_session_default_security_level_. @@ -304,12 +303,12 @@ class SessionMetrics { // Sets the session id of the metrics group. This allows the session // id to be captured and reported as part of the collection of metrics. - void SetSessionId(const CdmSessionId &session_id) { + void SetSessionId(const CdmSessionId& session_id) { session_id_ = session_id; } // Returns the session id or an empty session id if it has not been set. - const CdmSessionId &GetSessionId() const { return session_id_; } + const CdmSessionId& GetSessionId() const { return session_id_; } // Marks the metrics object as completed and ready for serialization. void SetCompleted() { completed_ = true; } @@ -320,16 +319,16 @@ class SessionMetrics { // Returns a pointer to the crypto metrics belonging to the engine instance. // This instance retains ownership of the object. - CryptoMetrics *GetCryptoMetrics() { return &crypto_metrics_; } + CryptoMetrics* GetCryptoMetrics() { return &crypto_metrics_; } // Metrics collected at the session level. ValueMetric cdm_session_life_span_; // Milliseconds. EventMetric cdm_session_renew_key_; - CounterMetric + CounterMetric cdm_session_restore_offline_session_; - CounterMetric + CounterMetric cdm_session_restore_usage_session_; EventMetric @@ -342,12 +341,12 @@ class SessionMetrics { // Serialize the session metrics to the provided |metric_group|. // |metric_group| is owned by the caller and must not be null. - void Serialize(drm_metrics::WvCdmMetrics::SessionMetrics *session_metrics) - const; + void Serialize( + drm_metrics::WvCdmMetrics::SessionMetrics* session_metrics) const; private: void SerializeSessionMetrics( - drm_metrics::WvCdmMetrics::SessionMetrics *session_metrics) const; + drm_metrics::WvCdmMetrics::SessionMetrics* session_metrics) const; CdmSessionId session_id_; bool completed_; CryptoMetrics crypto_metrics_; @@ -375,8 +374,8 @@ class OemCryptoDynamicAdapterMetrics { // Serialize the session metrics to the provided |metric_group|. // |metric_group| is owned by the caller and must not be null. - void Serialize(drm_metrics::WvCdmMetrics::EngineMetrics *engine_metrics) - const; + void Serialize( + drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const; // Clears the existing metric values. void Clear(); @@ -397,7 +396,7 @@ class OemCryptoDynamicAdapterMetrics { // initialization is guaranteed to be threadsafe. We return the reference to // avoid non-guaranteed destructor order problems. Effectively, the destructor // is never run for the created instance. -OemCryptoDynamicAdapterMetrics &GetDynamicAdapterMetricsInstance(); +OemCryptoDynamicAdapterMetrics& GetDynamicAdapterMetricsInstance(); // This class contains engine-scoped metrics. All properties and // statistics related to operations within the engine, but outside @@ -428,18 +427,19 @@ class EngineMetrics { // Returns a pointer to the crypto metrics belonging to the engine instance. // The CryptoMetrics instance is still owned by this object and will exist // until this object is deleted. - CryptoMetrics *GetCryptoMetrics() { return &crypto_metrics_; } + CryptoMetrics* GetCryptoMetrics() { return &crypto_metrics_; } // Serialize engine and session metrics into a serialized WvCdmMetrics // instance and output that instance to the provided |engine_metrics|. // |engine_metrics| is owned by the caller and must NOT be null. - void Serialize(drm_metrics::WvCdmMetrics *engine_metrics) const; + void Serialize(drm_metrics::WvCdmMetrics* engine_metrics) const; - void SetAppPackageName(const std::string &app_package_name); + void SetAppPackageName(const std::string& app_package_name); // Metrics recorded at the engine level. - EventMetric cdm_engine_add_key_; + EventMetric + cdm_engine_add_key_; ValueMetric cdm_engine_cdm_version_; CounterMetric cdm_engine_close_session_; @@ -449,15 +449,15 @@ class EngineMetrics { cdm_engine_decrypt_; CounterMetric cdm_engine_find_session_for_key_; - EventMetric + EventMetric cdm_engine_generate_key_request_; EventMetric cdm_engine_get_provisioning_request_; CounterMetric cdm_engine_get_secure_stop_ids_; - EventMetric + EventMetric cdm_engine_get_usage_info_; EventMetric cdm_engine_handle_provisioning_response_; @@ -493,7 +493,7 @@ class EngineMetrics { std::string app_package_name_; void SerializeEngineMetrics( - drm_metrics::WvCdmMetrics::EngineMetrics *engine_metrics) const; + drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const; }; } // namespace metrics diff --git a/libwvdrmengine/cdm/metrics/include/pow2bucket.h b/libwvdrmengine/cdm/metrics/include/pow2bucket.h index 7ab06c00..bc5f3b6b 100644 --- a/libwvdrmengine/cdm/metrics/include/pow2bucket.h +++ b/libwvdrmengine/cdm/metrics/include/pow2bucket.h @@ -17,12 +17,12 @@ class Pow2Bucket { public: explicit Pow2Bucket(size_t value) : value_(GetLowerBucket(value)) {} - Pow2Bucket(const Pow2Bucket &value) : value_(value.value_) {} + Pow2Bucket(const Pow2Bucket& value) : value_(value.value_) {} size_t value() const { return value_; } // Support for converting to string. - friend std::ostream &operator<<(std::ostream &os, const Pow2Bucket &log) { + friend std::ostream& operator<<(std::ostream& os, const Pow2Bucket& log) { return os << log.value_; } diff --git a/libwvdrmengine/cdm/metrics/include/value_metric.h b/libwvdrmengine/cdm/metrics/include/value_metric.h index cd0f7048..abaa9056 100644 --- a/libwvdrmengine/cdm/metrics/include/value_metric.h +++ b/libwvdrmengine/cdm/metrics/include/value_metric.h @@ -19,7 +19,7 @@ namespace impl { // Helper function for setting a value in the proto. template -void SetValue(drm_metrics::ValueMetric *value_proto, const T &value); +void SetValue(drm_metrics::ValueMetric* value_proto, const T& value); } // namespace impl @@ -46,7 +46,7 @@ class ValueMetric { : error_code_(0), has_error_(false), has_value_(false) {} // Record the value of the metric. - void Record(const T &value) { + void Record(const T& value) { std::unique_lock lock(internal_lock_); value_ = value; has_value_ = true; @@ -65,7 +65,7 @@ class ValueMetric { std::unique_lock lock(internal_lock_); return has_value_; } - const T &GetValue() const { + const T& GetValue() const { std::unique_lock lock(internal_lock_); return value_; } @@ -88,14 +88,14 @@ class ValueMetric { // Returns a new ValueMetric proto containing the metric value or the // error code. If neither the error or value are set, it returns nullptr. - drm_metrics::ValueMetric *ToProto() const { + drm_metrics::ValueMetric* ToProto() const { std::unique_lock lock(internal_lock_); if (has_error_) { - drm_metrics::ValueMetric *value_proto = new drm_metrics::ValueMetric; + drm_metrics::ValueMetric* value_proto = new drm_metrics::ValueMetric; value_proto->set_error_code(error_code_); return value_proto; } else if (has_value_) { - drm_metrics::ValueMetric *value_proto = new drm_metrics::ValueMetric; + drm_metrics::ValueMetric* value_proto = new drm_metrics::ValueMetric; impl::SetValue(value_proto, value_); return value_proto; } diff --git a/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp b/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp index c7dc0d84..77c84631 100644 --- a/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp +++ b/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp @@ -15,97 +15,95 @@ namespace metrics { // template <> void SetAttributeField(const CdmResponseType &cdm_error, - drm_metrics::Attributes *attributes) { + CdmResponseType>(const CdmResponseType& cdm_error, + drm_metrics::Attributes* attributes) { attributes->set_error_code(cdm_error); } template <> void SetAttributeField( - const CdmSecurityLevel &cdm_security_level, - drm_metrics::Attributes *attributes) { + const CdmSecurityLevel& cdm_security_level, + drm_metrics::Attributes* attributes) { attributes->set_cdm_security_level(cdm_security_level); } template <> void SetAttributeField(const SecurityLevel &security_level, - drm_metrics::Attributes *attributes) { + SecurityLevel>(const SecurityLevel& security_level, + drm_metrics::Attributes* attributes) { attributes->set_security_level(security_level); } template <> void SetAttributeField(const bool &cdm_error, - drm_metrics::Attributes *attributes) { + bool>(const bool& cdm_error, + drm_metrics::Attributes* attributes) { attributes->set_error_code_bool(cdm_error); } template <> void SetAttributeField( - const OEMCryptoResult &oem_crypto_result, - drm_metrics::Attributes *attributes) { + const OEMCryptoResult& oem_crypto_result, + drm_metrics::Attributes* attributes) { attributes->set_oem_crypto_result(oem_crypto_result); } template <> void SetAttributeField( - const Pow2Bucket &pow2, drm_metrics::Attributes *attributes) { + const Pow2Bucket& pow2, drm_metrics::Attributes* attributes) { attributes->set_length(pow2.value()); } template <> void SetAttributeField( - const CdmEncryptionAlgorithm &encryption_algorithm, - drm_metrics::Attributes *attributes) { + const CdmEncryptionAlgorithm& encryption_algorithm, + drm_metrics::Attributes* attributes) { attributes->set_encryption_algorithm(encryption_algorithm); } template <> void SetAttributeField( - const CdmSigningAlgorithm &signing_algorithm, - drm_metrics::Attributes *attributes) { + const CdmSigningAlgorithm& signing_algorithm, + drm_metrics::Attributes* attributes) { attributes->set_signing_algorithm(signing_algorithm); } template <> void SetAttributeField( - const CdmKeyRequestType &key_request_type, - drm_metrics::Attributes *attributes) { + const CdmKeyRequestType& key_request_type, + drm_metrics::Attributes* attributes) { attributes->set_key_request_type(key_request_type); } template <> void SetAttributeField( - const CdmLicenseType &license_type, - drm_metrics::Attributes *attributes) { + CdmLicenseType>(const CdmLicenseType& license_type, + drm_metrics::Attributes* attributes) { attributes->set_license_type(license_type); } template <> void SetAttributeField( - const int32_t &error_detail, - drm_metrics::Attributes *attributes) { + int32_t>(const int32_t& error_detail, + drm_metrics::Attributes* attributes) { attributes->set_error_detail(error_detail); } template <> -void SetAttributeField<0, util::Unused>(const util::Unused &, - drm_metrics::Attributes *) { +void SetAttributeField<0, util::Unused>(const util::Unused&, + drm_metrics::Attributes*) { // Intentionally empty. } // Specializations only used by tests. template <> void SetAttributeField( - const int &cdm_error, drm_metrics::Attributes *attributes) { + const int& cdm_error, drm_metrics::Attributes* attributes) { attributes->set_error_code(cdm_error); } diff --git a/libwvdrmengine/cdm/metrics/src/counter_metric.cpp b/libwvdrmengine/cdm/metrics/src/counter_metric.cpp index 79390961..00fc27fe 100644 --- a/libwvdrmengine/cdm/metrics/src/counter_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/counter_metric.cpp @@ -10,7 +10,7 @@ namespace wvcdm { namespace metrics { -void BaseCounterMetric::Increment(const std::string &counter_key, +void BaseCounterMetric::Increment(const std::string& counter_key, int64_t value) { std::unique_lock lock(internal_lock_); diff --git a/libwvdrmengine/cdm/metrics/src/event_metric.cpp b/libwvdrmengine/cdm/metrics/src/event_metric.cpp index b6090292..d413cc3b 100644 --- a/libwvdrmengine/cdm/metrics/src/event_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/event_metric.cpp @@ -12,16 +12,16 @@ namespace metrics { BaseEventMetric::~BaseEventMetric() { std::unique_lock lock(internal_lock_); - for (std::map::iterator it = value_map_.begin(); + for (std::map::iterator it = value_map_.begin(); it != value_map_.end(); it++) { delete it->second; } } -void BaseEventMetric::Record(const std::string &key, double value) { +void BaseEventMetric::Record(const std::string& key, double value) { std::unique_lock lock(internal_lock_); - Distribution *distribution; + Distribution* distribution; if (value_map_.find(key) == value_map_.end()) { distribution = new Distribution(); diff --git a/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp b/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp index df02ec48..bf35be0f 100644 --- a/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp +++ b/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp @@ -16,12 +16,12 @@ namespace { // Helper struct for comparing session ids. struct CompareSessionIds { - const std::string &target_; + const std::string& target_; - CompareSessionIds(const wvcdm::CdmSessionId &target) : target_(target){}; + CompareSessionIds(const wvcdm::CdmSessionId& target) : target_(target){}; - bool operator()(const std::shared_ptr metrics) - const { + bool operator()( + const std::shared_ptr metrics) const { return metrics->GetSessionId() == target_; } }; @@ -31,8 +31,8 @@ struct CompareSessionIds { namespace wvcdm { namespace metrics { -void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics) - const { +void CryptoMetrics::Serialize( + WvCdmMetrics::CryptoMetrics* crypto_metrics) const { /* CRYPTO SESSION */ crypto_metrics->set_allocated_crypto_session_security_level( crypto_session_security_level_.ToProto()); @@ -182,8 +182,7 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics) crypto_metrics->mutable_oemcrypto_create_new_usage_entry()); oemcrypto_load_usage_entry_.ToProto( crypto_metrics->mutable_oemcrypto_load_usage_entry()); - oemcrypto_move_entry_.ToProto( - crypto_metrics->mutable_oemcrypto_move_entry()); + oemcrypto_move_entry_.ToProto(crypto_metrics->mutable_oemcrypto_move_entry()); oemcrypto_create_old_usage_entry_.ToProto( crypto_metrics->mutable_oemcrypto_create_old_usage_entry()); oemcrypto_copy_old_usage_entry_.ToProto( @@ -217,14 +216,14 @@ void CryptoMetrics::Serialize(WvCdmMetrics::CryptoMetrics *crypto_metrics) SessionMetrics::SessionMetrics() : session_id_(""), completed_(false) {} -void SessionMetrics::Serialize(WvCdmMetrics::SessionMetrics *session_metrics) - const { +void SessionMetrics::Serialize( + WvCdmMetrics::SessionMetrics* session_metrics) const { SerializeSessionMetrics(session_metrics); crypto_metrics_.Serialize(session_metrics->mutable_crypto_metrics()); } void SessionMetrics::SerializeSessionMetrics( - WvCdmMetrics::SessionMetrics *session_metrics) const { + WvCdmMetrics::SessionMetrics* session_metrics) const { // If the session id was set, add it to the metrics. It's possible that // it's not set in some circumstances such as when provisioning is needed. if (!session_id_.empty()) { @@ -287,15 +286,15 @@ void OemCryptoDynamicAdapterMetrics::SetL1MinApiVersion(uint32_t version) { } void OemCryptoDynamicAdapterMetrics::Serialize( - WvCdmMetrics::EngineMetrics *engine_metrics) const { + WvCdmMetrics::EngineMetrics* engine_metrics) const { std::unique_lock lock(adapter_lock_); engine_metrics->set_allocated_level3_oemcrypto_initialization_error( - level3_oemcrypto_initialization_error_.ToProto()); + oemcrypto_initialization_mode_.ToProto()); engine_metrics->set_allocated_oemcrypto_initialization_mode( oemcrypto_initialization_mode_.ToProto()); engine_metrics->set_allocated_previous_oemcrypto_initialization_failure( - previous_oemcrypto_initialization_failure_.ToProto()); + oemcrypto_initialization_mode_.ToProto()); engine_metrics->set_allocated_oemcrypto_l1_api_version( oemcrypto_l1_api_version_.ToProto()); engine_metrics->set_allocated_oemcrypto_l1_min_api_version( @@ -314,22 +313,20 @@ void OemCryptoDynamicAdapterMetrics::Clear() { // This method returns a reference. This means that the destructor is never // executed for the returned object. -OemCryptoDynamicAdapterMetrics &GetDynamicAdapterMetricsInstance() { +OemCryptoDynamicAdapterMetrics& GetDynamicAdapterMetricsInstance() { // This is safe in C++ 11 since the initialization is guaranteed to run // only once regardless of multi-threaded access. - static OemCryptoDynamicAdapterMetrics *adapter_metrics = + static OemCryptoDynamicAdapterMetrics* adapter_metrics = new OemCryptoDynamicAdapterMetrics(); return *adapter_metrics; } -EngineMetrics::EngineMetrics() { - life_span_internal_.Start(); -} +EngineMetrics::EngineMetrics() { life_span_internal_.Start(); } EngineMetrics::~EngineMetrics() { std::unique_lock lock(session_metrics_lock_); - if (!active_session_metrics_list_.empty() - || !completed_session_metrics_list_.empty()) { + if (!active_session_metrics_list_.empty() || + !completed_session_metrics_list_.empty()) { LOGV("Session counts: active = %zu, completed = %zu.", active_session_metrics_list_.size(), completed_session_metrics_list_.size()); @@ -358,19 +355,17 @@ void EngineMetrics::RemoveSession(wvcdm::CdmSessionId session_id) { void EngineMetrics::ConsolidateSessions() { auto completed_filter = - [] (const std::shared_ptr& session_metrics) { + [](const std::shared_ptr& session_metrics) { return session_metrics->IsCompleted(); }; std::unique_lock lock(session_metrics_lock_); - std::copy_if(active_session_metrics_list_.begin(), - active_session_metrics_list_.end(), - std::back_inserter(completed_session_metrics_list_), - completed_filter); + std::copy_if( + active_session_metrics_list_.begin(), active_session_metrics_list_.end(), + std::back_inserter(completed_session_metrics_list_), completed_filter); active_session_metrics_list_.erase( std::remove_if(active_session_metrics_list_.begin(), - active_session_metrics_list_.end(), - completed_filter), + active_session_metrics_list_.end(), completed_filter), active_session_metrics_list_.end()); // TODO(b/118664842): Add support to merge older metrics into one @@ -384,12 +379,12 @@ void EngineMetrics::ConsolidateSessions() { } } -void EngineMetrics::Serialize(WvCdmMetrics *wv_metrics) const { +void EngineMetrics::Serialize(WvCdmMetrics* wv_metrics) const { std::unique_lock lock(session_metrics_lock_); - WvCdmMetrics::EngineMetrics *engine_metrics = + WvCdmMetrics::EngineMetrics* engine_metrics = wv_metrics->mutable_engine_metrics(); // Serialize the most recent metrics from the OemCyrpto dynamic adapter. - OemCryptoDynamicAdapterMetrics &adapter_metrics = + OemCryptoDynamicAdapterMetrics& adapter_metrics = GetDynamicAdapterMetricsInstance(); adapter_metrics.Serialize(engine_metrics); if (!app_package_name_.empty()) { @@ -408,12 +403,12 @@ void EngineMetrics::Serialize(WvCdmMetrics *wv_metrics) const { } } -void EngineMetrics::SetAppPackageName(const std::string &app_package_name) { +void EngineMetrics::SetAppPackageName(const std::string& app_package_name) { app_package_name_ = app_package_name; } void EngineMetrics::SerializeEngineMetrics( - WvCdmMetrics::EngineMetrics *engine_metrics) const { + WvCdmMetrics::EngineMetrics* engine_metrics) const { // Set the engine lifespan at the time of serialization. engine_metrics->mutable_cdm_engine_life_span_ms()->set_int_value( life_span_internal_.AsMs()); diff --git a/libwvdrmengine/cdm/metrics/src/timer_metric.cpp b/libwvdrmengine/cdm/metrics/src/timer_metric.cpp index c87c20b7..f7aeb117 100644 --- a/libwvdrmengine/cdm/metrics/src/timer_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/timer_metric.cpp @@ -8,16 +8,14 @@ void TimerMetric::Start() { is_started_ = true; } -void TimerMetric::Clear() { - is_started_ = false; -} +void TimerMetric::Clear() { is_started_ = false; } double TimerMetric::AsMs() const { - return (clock_.now() - start_) / std::chrono::milliseconds(1); + return (clock_.now() - start_) / std::chrono::milliseconds(1); } double TimerMetric::AsUs() const { - return (clock_.now() - start_) / std::chrono::microseconds(1); + return (clock_.now() - start_) / std::chrono::microseconds(1); } } // namespace metrics diff --git a/libwvdrmengine/cdm/metrics/src/value_metric.cpp b/libwvdrmengine/cdm/metrics/src/value_metric.cpp index fe8be02e..97160e72 100644 --- a/libwvdrmengine/cdm/metrics/src/value_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/value_metric.cpp @@ -15,98 +15,95 @@ namespace wvcdm { namespace metrics { -namespace impl{ +namespace impl { template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const int &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, const int& value) { value_proto->set_int_value(value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const long &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, const long& value) { value_proto->set_int_value(value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const long long &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const long long& value) { value_proto->set_int_value(value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const unsigned int &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const unsigned int& value) { value_proto->set_int_value((int64_t)value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const unsigned short &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const unsigned short& value) { value_proto->set_int_value((int64_t)value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const unsigned long &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const unsigned long& value) { value_proto->set_int_value((int64_t)value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const unsigned long long &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const unsigned long long& value) { value_proto->set_int_value((int64_t)value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const bool &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, const bool& value) { value_proto->set_int_value(value); } template <> void SetValue( - drm_metrics::ValueMetric *value_proto, - const OEMCrypto_HDCP_Capability &value) { + drm_metrics::ValueMetric* value_proto, + const OEMCrypto_HDCP_Capability& value) { value_proto->set_int_value(value); } template <> void SetValue( - drm_metrics::ValueMetric *value_proto, - const OEMCrypto_ProvisioningMethod &value) { + drm_metrics::ValueMetric* value_proto, + const OEMCrypto_ProvisioningMethod& value) { value_proto->set_int_value(value); } template <> void SetValue( - drm_metrics::ValueMetric *value_proto, - const OEMCryptoInitializationMode &value) { + drm_metrics::ValueMetric* value_proto, + const OEMCryptoInitializationMode& value) { value_proto->set_int_value(value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const CdmSecurityLevel &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const CdmSecurityLevel& value) { value_proto->set_int_value(value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const CdmUsageSupportType &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const CdmUsageSupportType& value) { value_proto->set_int_value(value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const double &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const double& value) { value_proto->set_double_value(value); } template <> -void SetValue(drm_metrics::ValueMetric *value_proto, - const std::string &value) { +void SetValue(drm_metrics::ValueMetric* value_proto, + const std::string& value) { value_proto->set_string_value(value); } diff --git a/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp b/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp index ea760eb1..a8831ffe 100644 --- a/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp @@ -43,7 +43,8 @@ TEST(CounterMetricTest, NoFieldsSuccess) { TEST(CounterMetricTest, OneFieldSuccess) { wvcdm::metrics::CounterMetric metric; + int> + metric; metric.Increment(7); metric.Increment(10, 7); metric.Increment(13); @@ -61,7 +62,8 @@ TEST(CounterMetricTest, OneFieldSuccess) { TEST(CounterMetricTest, TwoFieldsSuccess) { CounterMetric metric; + drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket> + metric; metric.Increment(7, Pow2Bucket(23)); // Increment by one. metric.Increment(2, 7, Pow2Bucket(33)); @@ -93,7 +95,7 @@ TEST(CounterMetricTest, ThreeFieldsSuccess) { CounterMetric - metric; + metric; metric.Increment(7, Pow2Bucket(13), true); TestMetrics metric_proto; @@ -110,7 +112,8 @@ TEST(CounterMetricTest, FourFieldsSuccess) { drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket, drm_metrics::Attributes::kErrorCodeBoolFieldNumber, bool, drm_metrics::Attributes::kSecurityLevelFieldNumber, - SecurityLevel> metric; + SecurityLevel> + metric; metric.Increment(10LL, 7, Pow2Bucket(13), true, kLevel3); TestMetrics metric_proto; diff --git a/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp b/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp index 9a9ea92f..4b900dad 100644 --- a/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp @@ -44,4 +44,3 @@ TEST(DistributionTest, MultipleValuesRecorded) { } // namespace metrics } // namespace wvcdm - diff --git a/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp b/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp index 8441e4c3..5dbf5416 100644 --- a/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp @@ -71,7 +71,8 @@ TEST_F(EventMetricTest, OneFieldSuccess) { TEST_F(EventMetricTest, TwoFieldsSuccess) { EventMetric metric; + drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket> + metric; metric.Record(1, 7, Pow2Bucket(23)); metric.Record(2, 7, Pow2Bucket(33)); @@ -114,7 +115,8 @@ TEST_F(EventMetricTest, TwoFieldsSuccess) { TEST_F(EventMetricTest, ThreeFieldsSuccess) { EventMetric metric; + drm_metrics::Attributes::kErrorCodeBoolFieldNumber, bool> + metric; metric.Record(10LL, 7, Pow2Bucket(13), false); metric.Record(11LL, 8, Pow2Bucket(17), true); @@ -127,14 +129,16 @@ TEST_F(EventMetricTest, ThreeFieldsSuccess) { EXPECT_FALSE(metric_proto.test_distributions(0).has_variance()); EXPECT_EQ(7, metric_proto.test_distributions(0).attributes().error_code()); EXPECT_EQ(8u, metric_proto.test_distributions(0).attributes().length()); - EXPECT_FALSE(metric_proto.test_distributions(0).attributes().error_code_bool()); + EXPECT_FALSE( + metric_proto.test_distributions(0).attributes().error_code_bool()); EXPECT_EQ(1u, metric_proto.test_distributions(1).operation_count()); EXPECT_EQ(11LL, metric_proto.test_distributions(1).mean()); EXPECT_FALSE(metric_proto.test_distributions(1).has_variance()); EXPECT_EQ(8, metric_proto.test_distributions(1).attributes().error_code()); EXPECT_EQ(16u, metric_proto.test_distributions(1).attributes().length()); - EXPECT_TRUE(metric_proto.test_distributions(1).attributes().error_code_bool()); + EXPECT_TRUE( + metric_proto.test_distributions(1).attributes().error_code_bool()); } TEST_F(EventMetricTest, FourFieldsSuccess) { @@ -142,7 +146,8 @@ TEST_F(EventMetricTest, FourFieldsSuccess) { drm_metrics::Attributes::kLengthFieldNumber, Pow2Bucket, drm_metrics::Attributes::kErrorCodeBoolFieldNumber, bool, drm_metrics::Attributes::kCdmSecurityLevelFieldNumber, - CdmSecurityLevel> metric; + CdmSecurityLevel> + metric; metric.Record(10LL, 7, Pow2Bucket(13), true, kSecurityLevelL3); @@ -155,7 +160,8 @@ TEST_F(EventMetricTest, FourFieldsSuccess) { EXPECT_FALSE(metric_proto.test_distributions(0).has_variance()); EXPECT_EQ(7, metric_proto.test_distributions(0).attributes().error_code()); EXPECT_EQ(8u, metric_proto.test_distributions(0).attributes().length()); - EXPECT_TRUE(metric_proto.test_distributions(0).attributes().error_code_bool()); + EXPECT_TRUE( + metric_proto.test_distributions(0).attributes().error_code_bool()); EXPECT_EQ( 3u, metric_proto.test_distributions(0).attributes().cdm_security_level()); } diff --git a/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp b/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp index b0e00521..7cdd173e 100644 --- a/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp +++ b/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp @@ -22,8 +22,7 @@ namespace metrics { // TODO(blueeyes): Improve this implementation by supporting full message // API In CDM. That allows us to use MessageDifferencer. -class EngineMetricsTest : public ::testing::Test { -}; +class EngineMetricsTest : public ::testing::Test {}; TEST_F(EngineMetricsTest, AllEngineMetrics) { EngineMetrics engine_metrics; @@ -45,7 +44,8 @@ TEST_F(EngineMetricsTest, AllEngineMetrics) { engine_metrics.cdm_engine_release_usage_info_.Record(1.0, NO_ERROR); engine_metrics.cdm_engine_remove_keys_.Record(1.0, NO_ERROR); engine_metrics.cdm_engine_restore_key_.Record(1.0, NO_ERROR); - engine_metrics.cdm_engine_unprovision_.Record(1.0, NO_ERROR, kSecurityLevelL1); + engine_metrics.cdm_engine_unprovision_.Record(1.0, NO_ERROR, + kSecurityLevelL1); drm_metrics::MetricsGroup actual_metrics; engine_metrics.Serialize(&actual_metrics, true, false); @@ -73,10 +73,9 @@ TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) { engine_metrics.cdm_engine_close_session_.Record(1.0, NO_ERROR); CryptoMetrics* crypto_metrics = engine_metrics.GetCryptoMetrics(); - crypto_metrics->crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); - crypto_metrics->crypto_session_get_device_unique_id_ - .Record(4.0, false); + crypto_metrics->crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + crypto_metrics->crypto_session_get_device_unique_id_.Record(4.0, false); drm_metrics::MetricsGroup actual_metrics; engine_metrics.Serialize(&actual_metrics, true, false); @@ -124,8 +123,8 @@ TEST_F(EngineMetricsTest, EngineMetricsWithCompletedSessions) { SessionMetrics* session_metrics_2 = engine_metrics.AddSession(); session_metrics_2->SetSessionId("session_id_2"); // Record a CryptoMetrics metric in the session. - session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); session_metrics_2->SetSessionId("session_id_2"); // Mark only session 2 as completed. session_metrics_2->SetCompleted(); @@ -144,9 +143,10 @@ TEST_F(EngineMetricsTest, EngineMetricsWithCompletedSessions) { // Spot check some metrics. EXPECT_EQ("/drm/widevine/cdm_engine/add_key/time/count{error:2}", actual_metrics.metric(0).name()); - EXPECT_EQ("/drm/widevine/crypto_session/load_certificate_private_key" - "/time/count{success:1}", - actual_metrics.metric(2).name()); + EXPECT_EQ( + "/drm/widevine/crypto_session/load_certificate_private_key" + "/time/count{success:1}", + actual_metrics.metric(2).name()); EXPECT_EQ("/drm/widevine/cdm_session/session_id", actual_metrics.metric_sub_group(0).metric(0).name()); EXPECT_EQ( @@ -241,8 +241,7 @@ TEST_F(EngineMetricsTest, EngineMetricsRemoveSessions) { ASSERT_EQ(0, actual_metrics.metric_sub_group_size()); } -class SessionMetricsTest : public ::testing::Test { -}; +class SessionMetricsTest : public ::testing::Test {}; TEST_F(SessionMetricsTest, AllSessionMetrics) { SessionMetrics session_metrics; @@ -254,8 +253,8 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) { session_metrics.cdm_session_restore_usage_session_.Record(1.0, NO_ERROR); // Record a CryptoMetrics metric in the session. - session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); MetricsGroup actual_metrics; session_metrics.Serialize(&actual_metrics); @@ -271,9 +270,10 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) { EXPECT_EQ("/drm/widevine/cdm_session/renew_key/time/mean{error:0}", actual_metrics.metric(4).name()); EXPECT_EQ(1.0, actual_metrics.metric(4).value().double_value()); - EXPECT_EQ("/drm/widevine/crypto_session/generic_decrypt/time/count" - "{error:0&length:1024&encryption_algorithm:1}", - actual_metrics.metric(9).name()); + EXPECT_EQ( + "/drm/widevine/crypto_session/generic_decrypt/time/count" + "{error:0&length:1024&encryption_algorithm:1}", + actual_metrics.metric(9).name()); } TEST_F(SessionMetricsTest, EmptySessionMetrics) { @@ -290,134 +290,126 @@ TEST_F(SessionMetricsTest, EmptySessionMetrics) { EXPECT_EQ(0, actual_metrics.metric_sub_group_size()); } -class CryptoMetricsTest : public ::testing::Test { -}; +class CryptoMetricsTest : public ::testing::Test {}; TEST_F(CryptoMetricsTest, AllCryptoMetrics) { CryptoMetrics crypto_metrics; // Crypto session metrics. - crypto_metrics.crypto_session_delete_all_usage_reports_ - .Record(1.0, NO_ERROR); - crypto_metrics.crypto_session_delete_multiple_usage_information_ - .Record(1.0, NO_ERROR); - crypto_metrics.crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); - crypto_metrics.crypto_session_generic_encrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); - crypto_metrics.crypto_session_generic_sign_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); - crypto_metrics.crypto_session_generic_verify_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); + crypto_metrics.crypto_session_delete_all_usage_reports_.Record(1.0, NO_ERROR); + crypto_metrics.crypto_session_delete_multiple_usage_information_.Record( + 1.0, NO_ERROR); + crypto_metrics.crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + crypto_metrics.crypto_session_generic_encrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + crypto_metrics.crypto_session_generic_sign_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); + crypto_metrics.crypto_session_generic_verify_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); crypto_metrics.crypto_session_get_device_unique_id_.Record(1.0, true); - crypto_metrics.crypto_session_get_security_level_ - .Record(1.0, kSecurityLevelL1); + crypto_metrics.crypto_session_get_security_level_.Record(1.0, + kSecurityLevelL1); crypto_metrics.crypto_session_get_system_id_.Record(1.0, true, 1234); crypto_metrics.crypto_session_get_token_.Record(1.0, true); crypto_metrics.crypto_session_life_span_.Record(1.0); - crypto_metrics.crypto_session_load_certificate_private_key_ - .Record(1.0, true); + crypto_metrics.crypto_session_load_certificate_private_key_.Record(1.0, true); crypto_metrics.crypto_session_open_.Record(1.0, NO_ERROR, kLevelDefault); - crypto_metrics.crypto_session_update_usage_information_ - .Record(1.0, NO_ERROR); + crypto_metrics.crypto_session_update_usage_information_.Record(1.0, NO_ERROR); crypto_metrics.crypto_session_usage_information_support_.Record(1.0, true); // Oem crypto metrics. crypto_metrics.oemcrypto_api_version_.Record(1.0, 123, kLevelDefault); - crypto_metrics.oemcrypto_close_session_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_copy_buffer_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, - kLevelDefault, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_deactivate_usage_entry_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_decrypt_cenc_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_delete_usage_entry_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_delete_usage_table_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_derive_keys_from_session_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_force_delete_usage_entry_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_generate_derived_keys_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_generate_nonce_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_generate_rsa_signature_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generate_signature_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_decrypt_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_encrypt_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_sign_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_verify_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_get_device_id_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_get_hdcp_capability_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_get_key_data_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, - Pow2Bucket(1025), kLevelDefault); - crypto_metrics.oemcrypto_get_max_number_of_sessions_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_get_number_of_open_sessions_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_get_oem_public_certificate_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_close_session_.Record(1.0, + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_copy_buffer_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, + kLevelDefault, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_deactivate_usage_entry_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_decrypt_cenc_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_delete_usage_entry_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_delete_usage_table_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_derive_keys_from_session_key_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_force_delete_usage_entry_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_generate_derived_keys_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_generate_nonce_.Record(1.0, + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_generate_rsa_signature_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generate_signature_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_decrypt_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_encrypt_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_sign_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_verify_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_get_device_id_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_get_hdcp_capability_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_get_key_data_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025), kLevelDefault); + crypto_metrics.oemcrypto_get_max_number_of_sessions_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_get_number_of_open_sessions_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_get_oem_public_certificate_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_get_provisioning_method_ - .Record(1.0, OEMCrypto_Keybox, kLevelDefault); + crypto_metrics.oemcrypto_get_provisioning_method_.Record( + 1.0, OEMCrypto_Keybox, kLevelDefault); - crypto_metrics.oemcrypto_get_random_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_initialize_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_install_keybox_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_is_anti_rollback_hw_present_ - .Record(1.0, true, kLevelDefault); + crypto_metrics.oemcrypto_get_random_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, + Pow2Bucket(1025)); + crypto_metrics.oemcrypto_initialize_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_install_keybox_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_is_anti_rollback_hw_present_.Record(1.0, true, + kLevelDefault); - crypto_metrics.oemcrypto_is_keybox_valid_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_load_device_rsa_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_is_keybox_valid_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_load_device_rsa_key_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_load_keys_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_load_test_keybox_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_load_test_rsa_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_open_session_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_refresh_keys_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_report_usage_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_rewrap_device_rsa_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_security_level_ - .Record(1.0, kSecurityLevelL2, kLevelDefault); - crypto_metrics.oemcrypto_security_patch_level_ - .Record(1.0, 123, kLevelDefault); - crypto_metrics.oemcrypto_select_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_supports_usage_table_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); - crypto_metrics.oemcrypto_update_usage_table_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_wrap_keybox_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_load_test_keybox_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_load_test_rsa_key_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_open_session_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_refresh_keys_.Record(1.0, + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_report_usage_.Record(1.0, + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_rewrap_device_rsa_key_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_security_level_.Record(1.0, kSecurityLevelL2, + kLevelDefault); + crypto_metrics.oemcrypto_security_patch_level_.Record(1.0, 123, + kLevelDefault); + crypto_metrics.oemcrypto_select_key_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_supports_usage_table_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, kLevelDefault); + crypto_metrics.oemcrypto_update_usage_table_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_wrap_keybox_.Record(1.0, + OEMCrypto_ERROR_INIT_FAILED); // Internal OEMCrypto Metrics - crypto_metrics.oemcrypto_initialization_mode_ - .Record(1.0, OEMCrypto_INITIALIZED_FORCING_L3); + crypto_metrics.oemcrypto_initialization_mode_.Record( + 1.0, OEMCrypto_INITIALIZED_FORCING_L3); crypto_metrics.oemcrypto_l1_api_version_.Record(1.0, 12, 123); MetricsGroup actual_metrics; diff --git a/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp b/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp index 069c2109..f2b9082b 100644 --- a/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp @@ -28,8 +28,7 @@ namespace metrics { // TODO(blueeyes): Improve this implementation by supporting full message // API In CDM. That allows us to use MessageDifferencer. -class EngineMetricsTest : public ::testing::Test { -}; +class EngineMetricsTest : public ::testing::Test {}; TEST_F(EngineMetricsTest, AllEngineMetrics) { EngineMetrics engine_metrics; @@ -78,16 +77,16 @@ TEST_F(EngineMetricsTest, AllEngineMetrics) { EXPECT_GT(actual.engine_metrics().cdm_engine_decrypt_time_us_size(), 0); EXPECT_GT(actual.engine_metrics().cdm_engine_find_session_for_key_size(), 0); EXPECT_GT( - actual.engine_metrics() - .cdm_engine_generate_key_request_time_us_size(), 0); - EXPECT_GT( - actual.engine_metrics() - .cdm_engine_get_provisioning_request_time_us_size(), 0); + actual.engine_metrics().cdm_engine_generate_key_request_time_us_size(), + 0); + EXPECT_GT(actual.engine_metrics() + .cdm_engine_get_provisioning_request_time_us_size(), + 0); EXPECT_GT(actual.engine_metrics().cdm_engine_get_usage_info_time_us_size(), 0); - EXPECT_GT( - actual.engine_metrics() - .cdm_engine_handle_provisioning_response_time_us_size(), 0); + EXPECT_GT(actual.engine_metrics() + .cdm_engine_handle_provisioning_response_time_us_size(), + 0); EXPECT_GT(actual.engine_metrics().cdm_engine_open_key_set_session_size(), 0); EXPECT_GT(actual.engine_metrics().cdm_engine_open_session_size(), 0); EXPECT_GT(actual.engine_metrics().cdm_engine_query_key_status_time_us_size(), @@ -105,9 +104,9 @@ TEST_F(EngineMetricsTest, AllEngineMetrics) { actual.engine_metrics().app_package_name().string_value()); EXPECT_EQ("test cdm version", actual.engine_metrics().cdm_engine_cdm_version().string_value()); - EXPECT_EQ(100, - actual.engine_metrics() - .cdm_engine_creation_time_millis().int_value()); + EXPECT_EQ( + 100, + actual.engine_metrics().cdm_engine_creation_time_millis().int_value()); } TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) { @@ -120,8 +119,8 @@ TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) { CryptoMetrics* crypto_metrics = engine_metrics.GetCryptoMetrics(); crypto_metrics->crypto_session_get_device_unique_id_.Increment(NO_ERROR); - crypto_metrics->crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + crypto_metrics->crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); WvCdmMetrics actual_metrics; engine_metrics.Serialize(&actual_metrics); @@ -133,29 +132,38 @@ TEST_F(EngineMetricsTest, EngineAndCryptoMetrics) { ASSERT_EQ(1, actual_metrics.engine_metrics().cdm_engine_add_key_time_us_size()); EXPECT_EQ(2, actual_metrics.engine_metrics() - .cdm_engine_add_key_time_us(0) - .attributes().error_code()); - ASSERT_EQ(1, - actual_metrics.engine_metrics().cdm_engine_close_session_size()); + .cdm_engine_add_key_time_us(0) + .attributes() + .error_code()); + ASSERT_EQ(1, actual_metrics.engine_metrics().cdm_engine_close_session_size()); EXPECT_EQ(UNKNOWN_ERROR, actual_metrics.engine_metrics() - .cdm_engine_close_session(0) - .attributes().error_code()); - ASSERT_EQ(1, actual_metrics.engine_metrics().crypto_metrics() - .crypto_session_get_device_unique_id_size()); - EXPECT_EQ(1, actual_metrics.engine_metrics().crypto_metrics() - .crypto_session_get_device_unique_id(0) - .count()); - EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics().crypto_metrics() - .crypto_session_get_device_unique_id(0) - .attributes().error_code()); - ASSERT_EQ(1, actual_metrics.engine_metrics().crypto_metrics() - .crypto_session_generic_decrypt_time_us_size()); - EXPECT_EQ(2.0, actual_metrics.engine_metrics().crypto_metrics() - .crypto_session_generic_decrypt_time_us(0) - .mean()); - EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics().crypto_metrics() - .crypto_session_generic_decrypt_time_us(0) - .attributes().error_code()); + .cdm_engine_close_session(0) + .attributes() + .error_code()); + ASSERT_EQ(1, actual_metrics.engine_metrics() + .crypto_metrics() + .crypto_session_get_device_unique_id_size()); + EXPECT_EQ(1, actual_metrics.engine_metrics() + .crypto_metrics() + .crypto_session_get_device_unique_id(0) + .count()); + EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics() + .crypto_metrics() + .crypto_session_get_device_unique_id(0) + .attributes() + .error_code()); + ASSERT_EQ(1, actual_metrics.engine_metrics() + .crypto_metrics() + .crypto_session_generic_decrypt_time_us_size()); + EXPECT_EQ(2.0, actual_metrics.engine_metrics() + .crypto_metrics() + .crypto_session_generic_decrypt_time_us(0) + .mean()); + EXPECT_EQ(NO_ERROR, actual_metrics.engine_metrics() + .crypto_metrics() + .crypto_session_generic_decrypt_time_us(0) + .attributes() + .error_code()); } TEST_F(EngineMetricsTest, EmptyEngineMetrics) { @@ -186,8 +194,8 @@ TEST_F(EngineMetricsTest, EngineMetricsWithSessions) { engine_metrics.AddSession(); session_metrics_2->SetSessionId(kSessionId2); // Record a CryptoMetrics metric in the session. - session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + session_metrics_2->GetCryptoMetrics()->crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); WvCdmMetrics actual_metrics; engine_metrics.Serialize(&actual_metrics); @@ -201,7 +209,8 @@ TEST_F(EngineMetricsTest, EngineMetricsWithSessions) { actual_metrics.session_metrics(0).session_id().string_value()); EXPECT_EQ(kSessionId2, actual_metrics.session_metrics(1).session_id().string_value()); - EXPECT_EQ(1, actual_metrics.session_metrics(1).crypto_metrics() + EXPECT_EQ(1, actual_metrics.session_metrics(1) + .crypto_metrics() .crypto_session_generic_decrypt_time_us_size()); } @@ -259,8 +268,7 @@ TEST_F(EngineMetricsTest, EngineMetricsConsolidateSessionsNoSessions) { ASSERT_EQ(0, actual_metrics.session_metrics_size()); } -class SessionMetricsTest : public ::testing::Test { -}; +class SessionMetricsTest : public ::testing::Test {}; TEST_F(SessionMetricsTest, AllSessionMetrics) { SessionMetrics session_metrics; @@ -275,12 +283,13 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) { 2.0, kKeyRequestTypeInitial); session_metrics.oemcrypto_build_info_.Record("test build info"); session_metrics.license_sdk_version_.Record("test license sdk version"); - session_metrics.license_service_version_.Record("test license service version"); + session_metrics.license_service_version_.Record( + "test license service version"); session_metrics.drm_certificate_key_type_.Record(1); // Record a CryptoMetrics metric in the session. - session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + session_metrics.GetCryptoMetrics()->crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); WvCdmMetrics::SessionMetrics actual; session_metrics.Serialize(&actual); @@ -315,32 +324,30 @@ TEST_F(SessionMetricsTest, EmptySessionMetrics) { EXPECT_EQ(0, actual_metrics.cdm_session_restore_usage_session_size()); } -class CryptoMetricsTest : public ::testing::Test { -}; +class CryptoMetricsTest : public ::testing::Test {}; TEST_F(CryptoMetricsTest, AllCryptoMetrics) { CryptoMetrics crypto_metrics; // Crypto session metrics. crypto_metrics.crypto_session_delete_all_usage_reports_.Increment(NO_ERROR); - crypto_metrics.crypto_session_delete_multiple_usage_information_ - .Increment(NO_ERROR); - crypto_metrics.crypto_session_generic_decrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); - crypto_metrics.crypto_session_generic_encrypt_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); - crypto_metrics.crypto_session_generic_sign_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); - crypto_metrics.crypto_session_generic_verify_ - .Record(2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); + crypto_metrics.crypto_session_delete_multiple_usage_information_.Increment( + NO_ERROR); + crypto_metrics.crypto_session_generic_decrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + crypto_metrics.crypto_session_generic_encrypt_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kEncryptionAlgorithmAesCbc128); + crypto_metrics.crypto_session_generic_sign_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); + crypto_metrics.crypto_session_generic_verify_.Record( + 2.0, NO_ERROR, Pow2Bucket(1025), kSigningAlgorithmHmacSha256); crypto_metrics.crypto_session_get_device_unique_id_.Increment(NO_ERROR); crypto_metrics.crypto_session_get_token_.Increment(NO_ERROR); crypto_metrics.crypto_session_life_span_.Record(1.0); - crypto_metrics.crypto_session_load_certificate_private_key_ - .Record(1.0, NO_ERROR); + crypto_metrics.crypto_session_load_certificate_private_key_.Record(1.0, + NO_ERROR); crypto_metrics.crypto_session_open_.Record(1.0, NO_ERROR, kLevelDefault); - crypto_metrics.crypto_session_update_usage_information_ - .Record(1.0, NO_ERROR); + crypto_metrics.crypto_session_update_usage_information_.Record(1.0, NO_ERROR); crypto_metrics.crypto_session_usage_information_support_.Record(true); crypto_metrics.crypto_session_security_level_.Record(kSecurityLevelL2); @@ -359,87 +366,83 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) { // Oem crypto metrics. crypto_metrics.oemcrypto_api_version_.Record(123); - crypto_metrics.oemcrypto_close_session_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_copy_buffer_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_deactivate_usage_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_decrypt_cenc_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_delete_usage_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_delete_usage_table_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_derive_keys_from_session_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_force_delete_usage_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_generate_derived_keys_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_generate_nonce_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_generate_rsa_signature_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generate_signature_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_decrypt_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_encrypt_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_sign_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_generic_verify_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); - crypto_metrics.oemcrypto_get_device_id_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_get_key_data_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_close_session_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_copy_buffer_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED, + Pow2Bucket(1025)); + crypto_metrics.oemcrypto_deactivate_usage_entry_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_decrypt_cenc_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_delete_usage_entry_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_delete_usage_table_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_derive_keys_from_session_key_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_force_delete_usage_entry_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_generate_derived_keys_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_generate_nonce_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_generate_rsa_signature_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generate_signature_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_decrypt_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_encrypt_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_sign_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_generic_verify_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); + crypto_metrics.oemcrypto_get_device_id_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_get_key_data_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED, Pow2Bucket(1025)); crypto_metrics.oemcrypto_max_number_of_sessions_.Record(7); crypto_metrics.oemcrypto_number_of_open_sessions_.Record(5); - crypto_metrics.oemcrypto_get_oem_public_certificate_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_get_oem_public_certificate_.Increment( + OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_provisioning_method_.Record(OEMCrypto_Keybox); - crypto_metrics.oemcrypto_get_random_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_initialize_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_get_random_.Increment(OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_initialize_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_is_anti_rollback_hw_present_.Record(true); crypto_metrics.oemcrypto_is_keybox_valid_.Record(true); crypto_metrics.oemcrypto_load_device_drm_key_.Record( 1.0, OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_load_keys_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_refresh_keys_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_refresh_keys_.Record(1.0, + OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_report_usage_.Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_rewrap_device_rsa_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_rewrap_device_rsa_key_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_rewrap_device_rsa_key_30_.Record( + 1.0, OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_security_patch_level_.Record(123); - crypto_metrics.oemcrypto_select_key_ - .Record(1.0, OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_update_usage_table_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_create_usage_table_header_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_load_usage_table_header_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_shrink_usage_table_header_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_create_new_usage_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_load_usage_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_move_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_create_old_usage_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); - crypto_metrics.oemcrypto_copy_old_usage_entry_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_select_key_.Record(1.0, OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_update_usage_table_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_create_usage_table_header_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_load_usage_table_header_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_shrink_usage_table_header_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_create_new_usage_entry_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_load_usage_entry_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_move_entry_.Increment(OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_create_old_usage_entry_.Increment( + OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_copy_old_usage_entry_.Increment( + OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_set_sandbox_.Record("sandbox"); - crypto_metrics.oemcrypto_set_decrypt_hash_ - .Increment(OEMCrypto_ERROR_INIT_FAILED); + crypto_metrics.oemcrypto_set_decrypt_hash_.Increment( + OEMCrypto_ERROR_INIT_FAILED); crypto_metrics.oemcrypto_resource_rating_tier_.Record(123); crypto_metrics.oemcrypto_minor_api_version_.Record(234); crypto_metrics.oemcrypto_maximum_usage_table_header_size_.Record(321); From 1b95db51f1b43305f3cc092fef065b94c1cb5e29 Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Wed, 3 Nov 2021 17:28:00 -0700 Subject: [PATCH 5/5] Updated copyright notice and cleaned up includes. [ Merge of http://go/wvgerrit/137810 ] Bug: 204946540 Test: Metric unit tests Change-Id: I78f839fafd27604a2bb78c04d587c40919c5372d --- .../cdm/metrics/include/attribute_handler.h | 12 +++----- .../cdm/metrics/include/counter_metric.h | 10 +++---- .../cdm/metrics/include/distribution.h | 7 ++--- .../cdm/metrics/include/event_metric.h | 12 +++----- .../cdm/metrics/include/field_tuples.h | 9 ++---- .../cdm/metrics/include/metrics_collections.h | 30 +++++++++---------- .../cdm/metrics/include/pow2bucket.h | 8 ++--- .../cdm/metrics/include/timer_metric.h | 8 ++--- .../cdm/metrics/include/value_metric.h | 13 ++++---- .../cdm/metrics/src/attribute_handler.cpp | 8 +++-- .../cdm/metrics/src/counter_metric.cpp | 8 ++--- .../cdm/metrics/src/distribution.cpp | 6 ++-- .../cdm/metrics/src/event_metric.cpp | 12 ++------ .../cdm/metrics/src/metrics_collections.cpp | 16 ++++------ .../cdm/metrics/src/timer_metric.cpp | 5 ++-- .../cdm/metrics/src/value_metric.cpp | 11 ++----- .../cdm/metrics/src/wv_metrics.proto | 9 +++--- .../metrics/test/counter_metric_unittest.cpp | 17 +++++------ .../metrics/test/distribution_unittest.cpp | 12 ++++---- .../metrics/test/event_metric_unittest.cpp | 16 +++++----- .../metrics/test/metrics_collections_test.cpp | 15 ++++------ .../test/metrics_collections_unittest.cpp | 18 +++++------ .../metrics/test/value_metric_unittest.cpp | 13 ++++---- 23 files changed, 112 insertions(+), 163 deletions(-) diff --git a/libwvdrmengine/cdm/metrics/include/attribute_handler.h b/libwvdrmengine/cdm/metrics/include/attribute_handler.h index 52468076..35ae8716 100644 --- a/libwvdrmengine/cdm/metrics/include/attribute_handler.h +++ b/libwvdrmengine/cdm/metrics/include/attribute_handler.h @@ -1,21 +1,18 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the declarations for the EventMetric class and related // types. #ifndef WVCDM_METRICS_ATTRIBUTE_HANDLER_H_ #define WVCDM_METRICS_ATTRIBUTE_HANDLER_H_ +#include -#include "OEMCryptoCENC.h" -#include "field_tuples.h" #include "log.h" -#include "pow2bucket.h" -#include "value_metric.h" -#include "wv_cdm_types.h" #include "wv_metrics.pb.h" namespace wvcdm { namespace metrics { - // This method is used to set the value of a single proto field. // Specializations handle setting each value. template @@ -47,7 +44,6 @@ class AttributeHandler { return serialized_attributes; } }; - } // namespace metrics } // namespace wvcdm #endif // WVCDM_METRICS_ATTRIBUTE_HANDLER_H_ diff --git a/libwvdrmengine/cdm/metrics/include/counter_metric.h b/libwvdrmengine/cdm/metrics/include/counter_metric.h index 317c35ad..f07de2c9 100644 --- a/libwvdrmengine/cdm/metrics/include/counter_metric.h +++ b/libwvdrmengine/cdm/metrics/include/counter_metric.h @@ -1,23 +1,23 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the declarations for the Metric class and related // types. #ifndef WVCDM_METRICS_COUNTER_METRIC_H_ #define WVCDM_METRICS_COUNTER_METRIC_H_ -#include #include #include #include #include -#include #include "attribute_handler.h" #include "field_tuples.h" +#include "wv_metrics.pb.h" namespace wvcdm { namespace metrics { - class CounterMetricTest; // This base class provides the common defintion used by all templated @@ -144,8 +144,6 @@ inline void CounterMetric::ToProto( new_counter->set_count(it->second); } } - } // namespace metrics } // namespace wvcdm - #endif // WVCDM_METRICS_COUNTER_METRIC_H_ diff --git a/libwvdrmengine/cdm/metrics/include/distribution.h b/libwvdrmengine/cdm/metrics/include/distribution.h index 50ac97d4..85aae776 100644 --- a/libwvdrmengine/cdm/metrics/include/distribution.h +++ b/libwvdrmengine/cdm/metrics/include/distribution.h @@ -1,4 +1,6 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the definition of a Distribution class which computes // the distribution values of a series of samples. @@ -10,7 +12,6 @@ namespace wvcdm { namespace metrics { - // The Distribution class holds statistics about a series of values that the // client provides via the Record method. A caller will call Record once for // each of the values in a series. The Distribution instance will calculate the @@ -46,8 +47,6 @@ class Distribution { float mean_; double sum_squared_deviation_; }; - } // namespace metrics } // namespace wvcdm - #endif // WVCDM_METRICS_DISTRIBUTION_H_ diff --git a/libwvdrmengine/cdm/metrics/include/event_metric.h b/libwvdrmengine/cdm/metrics/include/event_metric.h index a87f2541..3f63207f 100644 --- a/libwvdrmengine/cdm/metrics/include/event_metric.h +++ b/libwvdrmengine/cdm/metrics/include/event_metric.h @@ -1,26 +1,24 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the declarations for the EventMetric class and related // types. #ifndef WVCDM_METRICS_EVENT_METRIC_H_ #define WVCDM_METRICS_EVENT_METRIC_H_ - -#include #include #include #include -#include -#include "OEMCryptoCENC.h" #include "attribute_handler.h" #include "distribution.h" +#include "field_tuples.h" #include "log.h" #include "pow2bucket.h" #include "wv_metrics.pb.h" namespace wvcdm { namespace metrics { - class EventMetricTest; // This base class provides the common defintion used by all templated @@ -166,8 +164,6 @@ inline void EventMetric::ToProto( SetDistributionValues(*it->second, new_metric); } } - } // namespace metrics } // namespace wvcdm - #endif // WVCDM_METRICS_EVENT_METRIC_H_ diff --git a/libwvdrmengine/cdm/metrics/include/field_tuples.h b/libwvdrmengine/cdm/metrics/include/field_tuples.h index 1031806b..bd5c8df6 100644 --- a/libwvdrmengine/cdm/metrics/include/field_tuples.h +++ b/libwvdrmengine/cdm/metrics/include/field_tuples.h @@ -1,17 +1,16 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the helper classes and methods for using field tuples // used by metrics classes to record variations of a single metric. #ifndef WVCDM_METRICS_FIELD_TUPLES_H_ #define WVCDM_METRICS_FIELD_TUPLES_H_ - #include -#include namespace wvcdm { namespace metrics { namespace util { - // TODO(blueeyes): Change to use C++ 11 support for variadic template args. // The C++ 03 pattern is no longer needed since we require C++11. b/68766426. @@ -23,9 +22,7 @@ struct Unused { return out; } }; - } // namespace util } // namespace metrics } // namespace wvcdm - #endif // WVCDM_METRICS_FIELD_TUPLES_H_ diff --git a/libwvdrmengine/cdm/metrics/include/metrics_collections.h b/libwvdrmengine/cdm/metrics/include/metrics_collections.h index 9aaca0b9..5598d5a6 100644 --- a/libwvdrmengine/cdm/metrics/include/metrics_collections.h +++ b/libwvdrmengine/cdm/metrics/include/metrics_collections.h @@ -1,15 +1,18 @@ -// Copyright 2016 Google Inc. All Rights Reserved. +// Copyright 2016 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains definitions for metrics being collected throughout the // CDM. - -#ifndef WVCDM_METRICS_METRICS_GROUP_H_ -#define WVCDM_METRICS_METRICS_GROUP_H_ - +#ifndef WVCDM_METRICS_METRICS_COLLECTIONS_H_ +#define WVCDM_METRICS_METRICS_COLLECTIONS_H_ #include #include + #include #include +#include +#include #include "OEMCryptoCENC.h" #include "counter_metric.h" @@ -58,9 +61,7 @@ namespace wvcdm { namespace metrics { - namespace { - // Short name definitions to ease AttributeHandler definitions. // Internal namespace to help simplify declarations. const int kErrorCodeFieldNumber = @@ -88,8 +89,7 @@ const int kKeyRequestTypeFieldNumber = ::drm_metrics::Attributes::kKeyRequestTypeFieldNumber; const int kLicenseTypeFieldNumber = ::drm_metrics::Attributes::kLicenseTypeFieldNumber; - -} // anonymous namespace +} // namespace // The maximum number of completed sessions that can be stored. More than this // will cause some metrics to be discarded. @@ -292,7 +292,7 @@ class CryptoMetrics { oemcrypto_load_provisioning_; ValueMetric oemcrypto_minor_api_version_; ValueMetric oemcrypto_maximum_usage_table_header_size_; -}; +}; // class CryptoMetrics // This class contains session-scoped metrics. All properties and // statistics related to operations within a single session are @@ -350,7 +350,7 @@ class SessionMetrics { CdmSessionId session_id_; bool completed_; CryptoMetrics crypto_metrics_; -}; +}; // class SessionMetrics // This class contains metrics for the OEMCrypto Dynamic Adapter. They are // separated from other metrics because they need to be encapsulated in a @@ -389,7 +389,7 @@ class OemCryptoDynamicAdapterMetrics { previous_oemcrypto_initialization_failure_; ValueMetric oemcrypto_l1_api_version_; ValueMetric oemcrypto_l1_min_api_version_; -}; +}; // class OemCryptoDynamicAdapterMetrics // This will fetch the singleton instance for dynamic adapter metrics. // This method is safe only if we use C++ 11. In C++ 11, static function-local @@ -494,9 +494,7 @@ class EngineMetrics { void SerializeEngineMetrics( drm_metrics::WvCdmMetrics::EngineMetrics* engine_metrics) const; -}; - +}; // class EngineMetrics } // namespace metrics } // namespace wvcdm - -#endif // WVCDM_METRICS_METRICS_GROUP_H_ +#endif // WVCDM_METRICS_METRICS_COLLECTIONS_H_ diff --git a/libwvdrmengine/cdm/metrics/include/pow2bucket.h b/libwvdrmengine/cdm/metrics/include/pow2bucket.h index bc5f3b6b..79552b3a 100644 --- a/libwvdrmengine/cdm/metrics/include/pow2bucket.h +++ b/libwvdrmengine/cdm/metrics/include/pow2bucket.h @@ -1,13 +1,13 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the declaration of the Pow2Bucket class which // is a convenient way to bucketize sampled values into powers of 2. #ifndef WVCDM_METRICS_POW2BUCKET_H_ #define WVCDM_METRICS_POW2BUCKET_H_ - namespace wvcdm { namespace metrics { - // This class converts the size_t value into the highest power of two // below the value. E.g. for 7, the value is 4. For 11, the value is 8. // This class is intended to simplify the use of EventMetric Fields that may @@ -43,8 +43,6 @@ class Pow2Bucket { size_t value_; }; - } // namespace metrics } // namespace wvcdm - #endif // WVCDM_METRICS_POW2BUCKET_H_ diff --git a/libwvdrmengine/cdm/metrics/include/timer_metric.h b/libwvdrmengine/cdm/metrics/include/timer_metric.h index cc5dbe10..01b9777d 100644 --- a/libwvdrmengine/cdm/metrics/include/timer_metric.h +++ b/libwvdrmengine/cdm/metrics/include/timer_metric.h @@ -1,11 +1,12 @@ +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. #ifndef WVCDM_METRICS_TIMER_METRIC_H_ #define WVCDM_METRICS_TIMER_METRIC_H_ - #include namespace wvcdm { namespace metrics { - class TimerMetric { public: // Constructs a new TimerMetric. @@ -28,7 +29,6 @@ class TimerMetric { std::chrono::time_point start_; bool is_started_; }; - } // namespace metrics } // namespace wvcdm -#endif +#endif // WVCDM_METRICS_TIMER_METRIC_H_ diff --git a/libwvdrmengine/cdm/metrics/include/value_metric.h b/libwvdrmengine/cdm/metrics/include/value_metric.h index abaa9056..5f943106 100644 --- a/libwvdrmengine/cdm/metrics/include/value_metric.h +++ b/libwvdrmengine/cdm/metrics/include/value_metric.h @@ -1,11 +1,13 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the declarations for the Metric class and related // types. #ifndef WVCDM_METRICS_VALUE_METRIC_H_ #define WVCDM_METRICS_VALUE_METRIC_H_ - #include + #include #include @@ -13,14 +15,11 @@ namespace wvcdm { namespace metrics { - // Internal namespace for helper methods. namespace impl { - // Helper function for setting a value in the proto. template void SetValue(drm_metrics::ValueMetric* value_proto, const T& value); - } // namespace impl // The ValueMetric class supports storing a single, overwritable value or an @@ -118,9 +117,7 @@ class ValueMetric { * in const methods. */ mutable std::mutex internal_lock_; -}; - +}; // class ValueMetric } // namespace metrics } // namespace wvcdm - #endif // WVCDM_METRICS_VALUE_METRIC_H_ diff --git a/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp b/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp index 77c84631..f1d3b842 100644 --- a/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp +++ b/libwvdrmengine/cdm/metrics/src/attribute_handler.cpp @@ -1,15 +1,18 @@ -// Copyright 2018 Google Inc. All Rights Reserved. +// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains implementations for the AttributeHandler. #include "attribute_handler.h" + #include "OEMCryptoCENC.h" +#include "field_tuples.h" #include "pow2bucket.h" #include "wv_cdm_types.h" namespace wvcdm { namespace metrics { - // // Specializations for setting attribute fields. // @@ -106,6 +109,5 @@ void SetAttributeField( const int& cdm_error, drm_metrics::Attributes* attributes) { attributes->set_error_code(cdm_error); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/src/counter_metric.cpp b/libwvdrmengine/cdm/metrics/src/counter_metric.cpp index 00fc27fe..0641f4cd 100644 --- a/libwvdrmengine/cdm/metrics/src/counter_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/counter_metric.cpp @@ -1,15 +1,14 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains implementations for the BaseCounterMetric, the base class // for CounterMetric. #include "counter_metric.h" -#include "wv_metrics.pb.h" - namespace wvcdm { namespace metrics { - void BaseCounterMetric::Increment(const std::string& counter_key, int64_t value) { std::unique_lock lock(internal_lock_); @@ -20,6 +19,5 @@ void BaseCounterMetric::Increment(const std::string& counter_key, value_map_[counter_key] = value_map_[counter_key] + value; } } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/src/distribution.cpp b/libwvdrmengine/cdm/metrics/src/distribution.cpp index 0a4cb882..b55bac67 100644 --- a/libwvdrmengine/cdm/metrics/src/distribution.cpp +++ b/libwvdrmengine/cdm/metrics/src/distribution.cpp @@ -1,4 +1,6 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the definitions for the Distribution class members. @@ -8,7 +10,6 @@ namespace wvcdm { namespace metrics { - Distribution::Distribution() : count_(0ULL), min_(FLT_MAX), @@ -26,6 +27,5 @@ void Distribution::Record(float value) { min_ = min_ < value ? min_ : value; max_ = max_ > value ? max_ : value; } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/src/event_metric.cpp b/libwvdrmengine/cdm/metrics/src/event_metric.cpp index d413cc3b..85b2f752 100644 --- a/libwvdrmengine/cdm/metrics/src/event_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/event_metric.cpp @@ -1,17 +1,14 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains implementations for the BaseEventMetric. - #include "event_metric.h" -using ::google::protobuf::RepeatedPtrField; - namespace wvcdm { namespace metrics { - BaseEventMetric::~BaseEventMetric() { std::unique_lock lock(internal_lock_); - for (std::map::iterator it = value_map_.begin(); it != value_map_.end(); it++) { delete it->second; @@ -20,9 +17,7 @@ BaseEventMetric::~BaseEventMetric() { void BaseEventMetric::Record(const std::string& key, double value) { std::unique_lock lock(internal_lock_); - Distribution* distribution; - if (value_map_.find(key) == value_map_.end()) { distribution = new Distribution(); value_map_[key] = distribution; @@ -32,6 +27,5 @@ void BaseEventMetric::Record(const std::string& key, double value) { distribution->Record(value); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp b/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp index bf35be0f..6ea4f32e 100644 --- a/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp +++ b/libwvdrmengine/cdm/metrics/src/metrics_collections.cpp @@ -1,5 +1,6 @@ -// Copyright 2016 Google Inc. All Rights Reserved. - +// Copyright 2016 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. #include "metrics_collections.h" #include @@ -7,13 +8,13 @@ #include "log.h" #include "wv_metrics.pb.h" +namespace wvcdm { +namespace metrics { using ::drm_metrics::Attributes; using ::drm_metrics::WvCdmMetrics; using ::google::protobuf::RepeatedPtrField; using ::wvcdm::metrics::EventMetric; - namespace { - // Helper struct for comparing session ids. struct CompareSessionIds { const std::string& target_; @@ -25,11 +26,7 @@ struct CompareSessionIds { return metrics->GetSessionId() == target_; } }; - -} // anonymous namespace - -namespace wvcdm { -namespace metrics { +} // namespace void CryptoMetrics::Serialize( WvCdmMetrics::CryptoMetrics* crypto_metrics) const { @@ -458,6 +455,5 @@ void EngineMetrics::SerializeEngineMetrics( crypto_metrics_.Serialize(engine_metrics->mutable_crypto_metrics()); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/src/timer_metric.cpp b/libwvdrmengine/cdm/metrics/src/timer_metric.cpp index f7aeb117..6c0a2541 100644 --- a/libwvdrmengine/cdm/metrics/src/timer_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/timer_metric.cpp @@ -1,8 +1,10 @@ +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. #include "timer_metric.h" namespace wvcdm { namespace metrics { - void TimerMetric::Start() { start_ = clock_.now(); is_started_ = true; @@ -17,6 +19,5 @@ double TimerMetric::AsMs() const { double TimerMetric::AsUs() const { return (clock_.now() - start_) / std::chrono::microseconds(1); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/src/value_metric.cpp b/libwvdrmengine/cdm/metrics/src/value_metric.cpp index 97160e72..81a2e654 100644 --- a/libwvdrmengine/cdm/metrics/src/value_metric.cpp +++ b/libwvdrmengine/cdm/metrics/src/value_metric.cpp @@ -1,11 +1,9 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains the specializations for helper methods for the // ValueMetric class. - -#include -#include - #include "value_metric.h" #include "OEMCryptoCENC.h" @@ -14,9 +12,7 @@ namespace wvcdm { namespace metrics { - namespace impl { - template <> void SetValue(drm_metrics::ValueMetric* value_proto, const int& value) { value_proto->set_int_value(value); @@ -106,7 +102,6 @@ void SetValue(drm_metrics::ValueMetric* value_proto, const std::string& value) { value_proto->set_string_value(value); } - } // namespace impl } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/src/wv_metrics.proto b/libwvdrmengine/cdm/metrics/src/wv_metrics.proto index 5fc59717..ab92d222 100644 --- a/libwvdrmengine/cdm/metrics/src/wv_metrics.proto +++ b/libwvdrmengine/cdm/metrics/src/wv_metrics.proto @@ -1,4 +1,6 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // This file contains a proto definition for serialization of metrics data. // @@ -15,10 +17,7 @@ option optimize_for = LITE_RUNTIME; // want to count all of the operations with a give error code. message Attributes { // Reserved for compatibility with logging proto. - // TODO(blueeyes): The reserved keyword is not supported in the older version - // of protoc in the CE CDM third_party directory. Uncomment the reserved - // line when we upgrade. b/67016366. - // reserved 8, 10 to 13; + reserved 8, 10 to 13; // The error code. See CdmResponseType in wv_cdm_types.h optional int32 error_code = 1; diff --git a/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp b/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp index a8831ffe..63d91fd7 100644 --- a/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/counter_metric_unittest.cpp @@ -1,19 +1,19 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // Unit tests for CounterMetric - #include "counter_metric.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" -#include "string_conversions.h" +#include -using drm_metrics::TestMetrics; -using testing::IsNull; -using testing::NotNull; +#include "pow2bucket.h" +#include "string_conversions.h" +#include "wv_cdm_types.h" namespace wvcdm { namespace metrics { +using drm_metrics::TestMetrics; TEST(CounterMetricTest, NoFieldsEmpty) { wvcdm::metrics::CounterMetric<> metric; @@ -126,6 +126,5 @@ TEST(CounterMetricTest, FourFieldsSuccess) { EXPECT_EQ(kLevel3, metric_proto.test_counters(0).attributes().security_level()); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp b/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp index 4b900dad..dd2483ba 100644 --- a/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/distribution_unittest.cpp @@ -1,16 +1,17 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // Unit tests for Distribution. -#include - #include "distribution.h" -#include "gtest/gtest.h" +#include + +#include namespace wvcdm { namespace metrics { - TEST(DistributionTest, NoValuesRecorded) { Distribution distribution; EXPECT_EQ(FLT_MAX, distribution.Min()); @@ -41,6 +42,5 @@ TEST(DistributionTest, MultipleValuesRecorded) { EXPECT_EQ(3u, distribution.Count()); EXPECT_NEAR(16.6667, distribution.Variance(), 0.0001); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp b/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp index 5dbf5416..7e2b978f 100644 --- a/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/event_metric_unittest.cpp @@ -1,19 +1,18 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // Unit tests for EventMetric - #include "event_metric.h" -#include "gmock/gmock.h" -#include "gtest/gtest.h" -#include "string_conversions.h" +#include -using drm_metrics::TestMetrics; -using testing::IsNull; -using testing::NotNull; +#include "string_conversions.h" +#include "wv_cdm_types.h" namespace wvcdm { namespace metrics { +using drm_metrics::TestMetrics; class EventMetricTest : public ::testing::Test { public: @@ -191,6 +190,5 @@ TEST_F(EventMetricTest, Pow2BucketTest) { value << Pow2Bucket(0x7FFFFFFF); EXPECT_EQ("1073741824", value.str()); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp b/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp index 7cdd173e..f5c5e646 100644 --- a/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp +++ b/libwvdrmengine/cdm/metrics/test/metrics_collections_test.cpp @@ -1,24 +1,20 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // Unit tests for the metrics collections, // EngineMetrics, SessionMetrics and CrytpoMetrics. - #include "metrics_collections.h" -#include +#include -#include "gmock/gmock.h" -#include "google/protobuf/text_format.h" -#include "gtest/gtest.h" #include "log.h" #include "wv_cdm_types.h" #include "wv_metrics.pb.h" -using drm_metrics::MetricsGroup; -using google::protobuf::TextFormat; - namespace wvcdm { namespace metrics { +using drm_metrics::MetricsGroup; // TODO(blueeyes): Improve this implementation by supporting full message // API In CDM. That allows us to use MessageDifferencer. @@ -432,6 +428,5 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) { // No subgroups should exist. EXPECT_EQ(0, actual_metrics.metric_sub_group_size()); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp b/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp index f2b9082b..494347cf 100644 --- a/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/metrics_collections_unittest.cpp @@ -1,30 +1,27 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // Unit tests for the metrics collections, // EngineMetrics, SessionMetrics and CryptoMetrics. - #include "metrics_collections.h" -#include +#include #include "device_files.h" -#include "gmock/gmock.h" -#include "google/protobuf/text_format.h" -#include "gtest/gtest.h" #include "log.h" #include "string_conversions.h" #include "wv_cdm_types.h" #include "wv_metrics.pb.h" +namespace wvcdm { +namespace metrics { using drm_metrics::WvCdmMetrics; namespace { const char kSessionId1[] = "session_id_1"; const char kSessionId2[] = "session_id_2"; -} // anonymous namespace - -namespace wvcdm { -namespace metrics { +} // namespace // TODO(blueeyes): Improve this implementation by supporting full message // API In CDM. That allows us to use MessageDifferencer. @@ -538,6 +535,5 @@ TEST_F(CryptoMetricsTest, AllCryptoMetrics) { EXPECT_EQ(321, actual.oemcrypto_maximum_usage_table_header_size().int_value()); } - } // namespace metrics } // namespace wvcdm diff --git a/libwvdrmengine/cdm/metrics/test/value_metric_unittest.cpp b/libwvdrmengine/cdm/metrics/test/value_metric_unittest.cpp index b593f2b4..6e86f0cc 100644 --- a/libwvdrmengine/cdm/metrics/test/value_metric_unittest.cpp +++ b/libwvdrmengine/cdm/metrics/test/value_metric_unittest.cpp @@ -1,19 +1,17 @@ -// Copyright 2017 Google Inc. All Rights Reserved. +// Copyright 2017 Google LLC. All Rights Reserved. This file and proprietary +// source code may only be used and distributed under the Widevine License +// Agreement. // // Unit tests for ValueMetric. +#include "value_metric.h" #include #include -#include "value_metric.h" - -#include "gmock/gmock.h" -#include "gtest/gtest.h" -#include "wv_metrics.pb.h" +#include namespace wvcdm { namespace metrics { - TEST(ValueMetricTest, StringValue) { ValueMetric metric; metric.Record("foo"); @@ -59,6 +57,5 @@ TEST(ValueMetricTest, SetError) { ASSERT_EQ(7, metric_proto->error_code()); ASSERT_FALSE(metric_proto->has_int_value()); } - } // namespace metrics } // namespace wvcdm