From 98dfef4389cb9816bc9cb108490d9f8ea8e8f2a5 Mon Sep 17 00:00:00 2001 From: Cong Lin Date: Wed, 2 Apr 2025 09:49:07 -0700 Subject: [PATCH] OEMCrypto and OPK 19.5 --- CHANGELOG.md | 41 + oemcrypto/include/OEMCryptoCENC.h | 84 +- oemcrypto/include/level3.h | 10 + oemcrypto/odk/Android.bp | 1 + oemcrypto/odk/include/core_message_features.h | 4 +- oemcrypto/odk/include/odk_structs.h | 4 +- .../odk/src/core_message_deserialize.cpp | 3 +- oemcrypto/odk/src/core_message_features.cpp | 2 +- oemcrypto/odk/src/odk_timer.c | 2 +- oemcrypto/odk/test/odk_golden_v19.cpp | 4333 +++++++++++++++++ oemcrypto/odk/test/odk_test.cpp | 4 +- oemcrypto/odk/test/odk_test.gypi | 1 + oemcrypto/opk/build/Makefile.rules | 364 -- oemcrypto/opk/build/ree-sources.mk | 20 +- oemcrypto/opk/oemcrypto_ta/oemcrypto.c | 14 + .../opk/oemcrypto_ta/oemcrypto_api_macros.h | 4 +- .../opk/oemcrypto_ta/oemcrypto_usage_table.c | 113 +- .../oemcrypto_ta/wtpi/wtpi_cas_interface.h | 78 +- .../oemcrypto_ta/wtpi/wtpi_crc32_interface.h | 10 +- ...ypto_and_key_management_interface_layer2.h | 15 +- .../oemcrypto_ta/wtpi_reference/cose_util.c | 22 +- .../oemcrypto_ta/wtpi_reference/wtpi_crc32.c | 8 +- ...wtpi_crypto_and_key_management_layer1_hw.c | 4 +- .../wtpi_reference/wtpi_reference.gyp | 1 - .../ree/GEN_oemcrypto_tee_test_api.c | 4 +- .../wtpi_test/ree/GEN_ree_serializer.c | 18 +- .../wtpi_test/ree/GEN_ree_serializer.h | 2 +- .../opk/oemcrypto_ta/wtpi_test/settings.gypi | 7 + .../wtpi_test/tee/GEN_dispatcher.c | 16 +- .../wtpi_test/tee/GEN_tee_serializer.c | 32 +- .../wtpi_test/tee/GEN_tee_serializer.h | 2 +- .../opk/oemcrypto_ta/wtpi_useless/wtpi_cas.c | 25 + .../cas/tee/tee_simulator_cas/wtpi_cas.c | 25 + .../linux/common/test/shared_memory_test.gyp | 2 +- oemcrypto/opk/ports/linux/liboemcrypto.gyp | 2 +- .../ports/linux/oemcrypto_tee_simulator.gyp | 2 +- .../wtpi_impl/layer2_crypto_key_table.c | 5 +- ...wtpi_crypto_and_key_management_layer2_hw.c | 58 +- .../ta/common/wtpi_impl/wtpi_test_impl.gyp | 1 - .../ta/reference/interface_impls/opk_config.h | 16 + .../interface_impls/transport_interface.c | 8 +- .../interface_impls/wtpi_clock_layer2.c | 14 +- .../reference/interface_impls/wtpi_config.c | 126 + .../wtpi_initialize_terminate.c | 94 +- .../wtpi_persistent_storage_layer1.c | 118 +- .../interface_impls/wtpi_provisioning_4.c | 87 +- .../wtpi_root_of_trust_layer2.c | 220 +- .../wtpi_secure_buffer_access.c | 13 +- .../reference/liboemcrypto/libtrusty/trusty.c | 79 +- .../ta/reference/liboemcrypto/secure_buffer.c | 85 +- .../ta/reference/liboemcrypto/transport.c | 553 ++- .../ports/trusty/ta/reference/secure_buffer.c | 336 +- .../ports/trusty/ta/reference/secure_buffer.h | 1 + .../ta/reference/shared/shared_memory.c | 42 +- .../reference/shared/widevine_ipc_protocol.c | 107 +- .../ports/trusty/ta/reference/tee_context.c | 4 +- .../ports/trusty/ta/reference/widevine_app.c | 707 ++- .../wtpi_lib/impl/device_key/rules.mk | 5 + .../ta/reference/wtpi_lib/impl/other/rules.mk | 5 + .../ta/reference/wtpi_lib/test/wtpi_test.cpp | 1160 +++-- oemcrypto/opk/ports/trusty/ta/zuma/rules.mk | 22 - .../opk/ports/trusty/ta/zuma/wtpi_hdcp.c | 85 - oemcrypto/opk/serialization/defaults.gypi | 44 + .../opk/serialization/ree/GEN_oemcrypto_api.c | 71 + .../serialization/ree/GEN_ree_serializer.c | 76 + .../serialization/ree/GEN_ree_serializer.h | 10 + oemcrypto/opk/serialization/ree/ree.gyp | 2 +- oemcrypto/opk/serialization/settings.gypi | 44 +- .../opk/serialization/tee/GEN_dispatcher.c | 40 + .../serialization/tee/GEN_tee_serializer.c | 61 + .../serialization/tee/GEN_tee_serializer.h | 10 + oemcrypto/opk/serialization/tee/tee.gyp | 2 +- oemcrypto/opk/setup.sh | 4 +- oemcrypto/test/GEN_api_lock_file.c | 9 + oemcrypto/test/oemcrypto_basic_test.cpp | 4 +- .../test/oemcrypto_provisioning_test.cpp | 8 +- oemcrypto/util/include/cbor_validator.h | 1 + .../util/include/prov4_validation_helper.h | 14 +- oemcrypto/util/src/bcc_validator.cpp | 252 +- oemcrypto/util/src/cbor_validator.cpp | 8 + .../util/test/bcc_validator_unittest.cpp | 4 +- .../test/device_info_validator_unittest.cpp | 4 +- .../signed_csr_payload_validator_unittest.cpp | 4 +- util/test/file_store_unittest.cpp | 11 +- 84 files changed, 7325 insertions(+), 2588 deletions(-) create mode 100644 oemcrypto/odk/test/odk_golden_v19.cpp delete mode 100644 oemcrypto/opk/build/Makefile.rules create mode 100644 oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_config.c delete mode 100644 oemcrypto/opk/ports/trusty/ta/zuma/rules.mk delete mode 100644 oemcrypto/opk/ports/trusty/ta/zuma/wtpi_hdcp.c create mode 100644 oemcrypto/opk/serialization/defaults.gypi diff --git a/CHANGELOG.md b/CHANGELOG.md index 63013b6..77c1fd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,46 @@ [TOC] +## [Version 19.5][v19.5] + +This release adds new OEMCrypto APIs to support CAS PVR. It also includes test +fixes and OPK build updates. + +### Tests + +- Generated and added golden data tests for ODK v19, including Provisioning 4.0 + tests + +### API + +- Added new OEMCrypto API for CAS PVR: `OEMCrypto_GetPVRKey()` and + `OEMCrypto_LoadPVRKey()` + +### ODK + +- Fixed a bug in the ODK library by updating core message request + parsing to accept `ODK_Provisioning40_Request_Type` + +### OPK + +- Updated OPK reference implementation: + - Added more logging to usage table + - Saved the generation number when creating a new usage table header +- Updated WTPI reference implementation: + - Included "Widevine" in the BCC leaf certificate component name + - Updated HW reference implementation to work with the latest + `wtpi_crypto_and_key_management_interface` +- Updated OPK Trusty ports: + - Addressed clang-tidy findings + - Added missing WTPI config files and macros +- Fixed memory overflow in WTPI test serialization of + `WTPI_Crc32Cont_OutputBufferBasic()` +- Made WTPI interface tests use the same C++ standard as the base platform +- Added new WTPI for CAS PVR: `WTPI_SetCasUsage()`, `WTPI_GetCasUsage()`, + `WTPI_InstallPVRContentKey()` and `WTPI_InstallPVRContentIV()` +- Renamed OPK serialization `settings.gypi` to `defaults.gypi` + + ## [Version 19.4][v19.4] This release includes some Provisioning 4.0 updates and better verification @@ -733,3 +773,4 @@ Public release for OEMCrypto API and ODK library version 16.4. [v19.2]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v19.2 [v19.3]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v19.3 [v19.4]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v19.4 +[v19.5]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v19.5 diff --git a/oemcrypto/include/OEMCryptoCENC.h b/oemcrypto/include/OEMCryptoCENC.h index 559c42a..f2cf389 100644 --- a/oemcrypto/include/OEMCryptoCENC.h +++ b/oemcrypto/include/OEMCryptoCENC.h @@ -3,7 +3,7 @@ // License Agreement. /** - * @mainpage OEMCrypto API v19.4 + * @mainpage OEMCrypto API v19.5 * * OEMCrypto is the low level library implemented by the OEM to provide key and * content protection, usually in a separate secure memory or process space. The @@ -764,6 +764,8 @@ typedef enum OEMCrypto_SignatureHashAlgorithm { #define OEMCrypto_WrapClearPrivateKey _oecc154 #define OEMCrypto_SetSessionUsage _oecc155 #define OEMCrypto_GetBCCSignatureType _oecc156 +#define OEMCrypto_GetPVRKey _oecc157 +#define OEMCrypto_LoadPVRKey _oecc158 // clang-format on /// @addtogroup initcontrol @@ -1984,6 +1986,72 @@ OEMCryptoResult OEMCrypto_GetOEMKeyToken(OEMCrypto_SESSION key_session, OEMCryptoResult OEMCrypto_SetSessionUsage(OEMCrypto_SESSION session, uint32_t intent, uint32_t mode); +/** + * Retrieves the key used for Personal Video Recorder (PVR) re-encrypting + * recorded content. The returned key is encrypted by a device specific key for + * storage on the filesystem. The format of the wrapped key is + * platform-specific. This method is currently used exclusively by CAS with PVR + * support. + * + * @param[in] session: session id. + * @param[out] wrapped_pvr_key: pointer to a buffer where the wrapped PVR key + * will be stored. May be null on the first call to determine the required + * buffer size. + * @param[in,out] wrapped_pvr_key_length: length of the buffer for the wrapped + * PVR key, in bytes. + * + * @retval OEMCrypto_SUCCESS on success + * @retval OEMCrypto_ERROR_INVALID_SESSION + * @retval OEMCrypto_ERROR_SHORT_BUFFER + * @retval OEMCrypto_ERROR_UNKNOWN_FAILURE + * @retval OEMCrypto_ERROR_NOT_IMPLEMENTED + * + * @threading + * This is a "Session Function" and may be called simultaneously with session + * functions for other sessions but not simultaneously with other functions + * for this session. It is as if the CDM holds a write lock for this session, + * and a read lock on the OEMCrypto system. + * + * @version + * This method is new in API version 18. + */ +OEMCryptoResult OEMCrypto_GetPVRKey(OEMCrypto_SESSION session, + uint8_t* wrapped_pvr_key, + size_t* wrapped_pvr_key_length); + +/** + * Loads a wrapped PVR key into secure memory. This key is used for decrypting + * content that has been re-encrypted for PVR storage. The wrapped PVR key + * is typically obtained from persistent storage, having been previously + * retrieved using OEMCrypto_GetPVRKey(). This method is currently used + * exclusively by CAS with PVR support. + * + * @param[in] session: session id. + * @param[in] wrapped_pvr_key: Pointer to the buffer containing the wrapped PVR + * key. + * @param[in] wrapped_pvr_key_length: Length of the wrapped PVR key buffer, in + * bytes. + * + * @retval OEMCrypto_SUCCESS on success. + * @retval OEMCrypto_ERROR_INVALID_SESSION + * @retval OEMCrypto_ERROR_INVALID_KEY + * @retval OEMCrypto_ERROR_INSUFFICIENT_RESOURCES + * @retval OEMCrypto_ERROR_UNKNOWN_FAILURE + * @retval OEMCrypto_ERROR_NOT_IMPLEMENTED + * + * @threading + * This is a "Session Function" and may be called simultaneously with session + * functions for other sessions but not simultaneously with other functions + * for this session. It is as if the CDM holds a write lock for this session, + * and a read lock on the OEMCrypto system. + * + * @version + * This method is new in API version 18. + */ +OEMCryptoResult OEMCrypto_LoadPVRKey(OEMCrypto_SESSION session, + const uint8_t* wrapped_pvr_key, + size_t wrapped_pvr_key_length); + /// @} /// @addtogroup decryption @@ -5206,11 +5274,15 @@ OEMCryptoResult OEMCrypto_ShrinkUsageTableHeader(uint32_t new_entry_count, * @param[in,out] bcc_length - on input, size of the caller's bcc buffer. On * output, the number of bytes written into the buffer. * @param[out] additional_signature: pointer to the buffer that receives - * additional device key signature (certificate chain). This field is only - * used by the signing model where either a vendor certificate or a keybox is - * available on the device. Please work with your Widevine Partner Engineer - * before implementing this field to make sure the generated signature is in the - * expected format. + * additional device key signature (Unique Device Secret certificate chain). + * This field is used by (1) the signing model where either a vendor + * certificate or a keybox is available on the device, or (2) the + * Provisioning 4.0 phase 3 uploading model. For details on the format of + * additional_signature in the scenarios mentioned above, please refer to the + * definition of enum OEMCrypto_BCCSignatureType and + * OEMCrypto_GetBCCSignatureType(). Please work with your Widevine Partner + * Engineer before implementing this field to make sure the generated + * signature is in the expected format. * @param[in,out] additional_signature_length - on input, size of the caller's * additional_signature buffer. On output, the number of bytes written into * the buffer. diff --git a/oemcrypto/include/level3.h b/oemcrypto/include/level3.h index d4ad527..4efdb82 100644 --- a/oemcrypto/include/level3.h +++ b/oemcrypto/include/level3.h @@ -130,6 +130,8 @@ #define Level3_MarkOfflineSession _lcc153 #define Level3_SetSessionUsage _lcc155 #define Level3_GetBCCSignatureType _lcc156 +#define Level3_GetPVRKey _lcc157 +#define Level3_LoadPVRKey _lcc158 #else #define Level3_Initialize _oecc01 #define Level3_Terminate _oecc02 @@ -244,6 +246,8 @@ #define Level3_MarkOfflineSession _oecc153 #define Level3_SetSessionUsage _oecc155 #define Level3_GetBCCSignatureType _oecc156 +#define Level3_GetPVRKey _oecc157 +#define Level3_LoadPVRKey _oecc158 #endif #define Level3_GetInitializationState _oecl3o01 @@ -473,6 +477,12 @@ OEMCryptoResult Level3_GetOEMKeyToken(OEMCrypto_SESSION key_session, size_t* key_token_length); OEMCryptoResult Level3_SetSessionUsage(OEMCrypto_SESSION session, uint32_t intent, uint32_t mode); +OEMCryptoResult Level3_GetPVRKey(OEMCrypto_SESSION session, + uint8_t* wrapped_pvr_key, + size_t* wrapped_pvr_key_length); +OEMCryptoResult Level3_LoadPVRKey(OEMCrypto_SESSION session, + const uint8_t* wrapped_pvr_key, + size_t wrapped_pvr_key_length); OEMCryptoResult Level3_GetDeviceInformation(uint8_t* device_info, size_t* device_info_length); OEMCryptoResult Level3_GetDeviceSignedCsrPayload( diff --git a/oemcrypto/odk/Android.bp b/oemcrypto/odk/Android.bp index 90c4a6d..6b966ce 100644 --- a/oemcrypto/odk/Android.bp +++ b/oemcrypto/odk/Android.bp @@ -113,6 +113,7 @@ cc_test { "test/odk_golden_v16.cpp", "test/odk_golden_v17.cpp", "test/odk_golden_v18.cpp", + "test/odk_golden_v19.cpp", "test/odk_test.cpp", "test/odk_test_helper.cpp", "test/odk_timer_test.cpp", diff --git a/oemcrypto/odk/include/core_message_features.h b/oemcrypto/odk/include/core_message_features.h index 1d87cd9..3edfc02 100644 --- a/oemcrypto/odk/include/core_message_features.h +++ b/oemcrypto/odk/include/core_message_features.h @@ -26,9 +26,9 @@ struct CoreMessageFeatures { // This is the published version of the ODK Core Message library. The default // behavior is for the server to restrict messages to at most this version - // number. The default is 19.4. + // number. The default is 19.5. uint32_t maximum_major_version = 19; - uint32_t maximum_minor_version = 4; + uint32_t maximum_minor_version = 5; bool operator==(const CoreMessageFeatures &other) const; bool operator!=(const CoreMessageFeatures &other) const { diff --git a/oemcrypto/odk/include/odk_structs.h b/oemcrypto/odk/include/odk_structs.h index 6e1edc5..0b905aa 100644 --- a/oemcrypto/odk/include/odk_structs.h +++ b/oemcrypto/odk/include/odk_structs.h @@ -16,10 +16,10 @@ extern "C" { /* The version of this library. */ #define ODK_MAJOR_VERSION 19 -#define ODK_MINOR_VERSION 4 +#define ODK_MINOR_VERSION 5 /* ODK Version string. Date changed automatically on each release. */ -#define ODK_RELEASE_DATE "ODK v19.4 2024-11-04" +#define ODK_RELEASE_DATE "ODK v19.5 2025-03-11" /* The lowest version number for an ODK message. */ #define ODK_FIRST_VERSION 16 diff --git a/oemcrypto/odk/src/core_message_deserialize.cpp b/oemcrypto/odk/src/core_message_deserialize.cpp index c990101..e1cdbd0 100644 --- a/oemcrypto/odk/src/core_message_deserialize.cpp +++ b/oemcrypto/odk/src/core_message_deserialize.cpp @@ -77,7 +77,8 @@ bool ParseRequest(uint32_t message_type, !(message_type == ODK_Renewal_Request_Type && core_message.message_type == ODK_Release_Request_Type) && !(message_type == ODK_Provisioning_Request_Type && - core_message.message_type == ODK_Renewed_Provisioning_Request_Type)) { + (core_message.message_type == ODK_Renewed_Provisioning_Request_Type || + core_message.message_type == ODK_Provisioning40_Request_Type))) { return false; } // Verify that the amount of buffer we read, which is GetOffset, is not more diff --git a/oemcrypto/odk/src/core_message_features.cpp b/oemcrypto/odk/src/core_message_features.cpp index 0b4cfb6..3e8abf4 100644 --- a/oemcrypto/odk/src/core_message_features.cpp +++ b/oemcrypto/odk/src/core_message_features.cpp @@ -33,7 +33,7 @@ CoreMessageFeatures CoreMessageFeatures::DefaultFeatures( features.maximum_minor_version = 4; // 18.4 break; case 19: - features.maximum_minor_version = 4; // 19.4 + features.maximum_minor_version = 5; // 19.5 break; default: features.maximum_minor_version = 0; diff --git a/oemcrypto/odk/src/odk_timer.c b/oemcrypto/odk/src/odk_timer.c index ec9e25e..a1a9eb8 100644 --- a/oemcrypto/odk/src/odk_timer.c +++ b/oemcrypto/odk/src/odk_timer.c @@ -277,7 +277,7 @@ OEMCryptoResult ODK_InitializeSessionValues(ODK_TimerLimits* timer_limits, nonce_values->api_minor_version = 4; break; case 19: - nonce_values->api_minor_version = 4; + nonce_values->api_minor_version = 5; break; default: nonce_values->api_minor_version = 0; diff --git a/oemcrypto/odk/test/odk_golden_v19.cpp b/oemcrypto/odk/test/odk_golden_v19.cpp new file mode 100644 index 0000000..bee6c0d --- /dev/null +++ b/oemcrypto/odk/test/odk_golden_v19.cpp @@ -0,0 +1,4333 @@ +// Copyright 2024 Google LLC. This file and proprietary +// source code may only be used and distributed under the Widevine +// License Agreement. + +#include +#include +#include + +#include "OEMCryptoCENCCommon.h" +#include "core_message_deserialize.h" +#include "core_message_features.h" +#include "core_message_serialize.h" +#include "core_message_serialize_proto.h" +#include "core_message_types.h" +#include "gtest/gtest.h" +#include "odk.h" +#include "odk_structs.h" +#include "odk_structs_priv.h" + +namespace wvodk_test { + +namespace { + +using oemcrypto_core_message::ODK_LicenseRequest; +using oemcrypto_core_message::ODK_ProvisioningRequest; +using oemcrypto_core_message::ODK_RenewalRequest; + +using oemcrypto_core_message::deserialize::CoreLicenseRequestFromMessage; +using oemcrypto_core_message::deserialize::CoreProvisioningRequestFromMessage; +using oemcrypto_core_message::deserialize::CoreRenewalRequestFromMessage; +using oemcrypto_core_message::features::CoreMessageFeatures; +using oemcrypto_core_message::serialize::CreateCoreLicenseResponseFromProto; +using oemcrypto_core_message::serialize:: + CreateCoreProvisioningResponseFromProto; +using oemcrypto_core_message::serialize::CreateCoreRenewalResponse; + +class ODKGoldenProvisionV19 : public ::testing::Test { + protected: + void RunTest() { + ODK_ProvisioningRequest core_provisioning_request; + EXPECT_TRUE(CoreProvisioningRequestFromMessage(core_request_, + &core_provisioning_request)); + std::string generated_core_message; + const CoreMessageFeatures features = + CoreMessageFeatures::DefaultFeatures(ODK_MAJOR_VERSION); + EXPECT_TRUE(CreateCoreProvisioningResponseFromProto( + features, provisioning_response_, core_provisioning_request, + device_key_type_, &generated_core_message)); + EXPECT_EQ(core_response_, generated_core_message); + } + + OEMCrypto_PrivateKeyType device_key_type_ = OEMCrypto_RSA_Private_Key; + std::string core_request_; + std::string core_response_; + std::string provisioning_response_; +}; + +// The provisioning 4.0 response does not return a core message yet so we only +// check the request can be created from the golden data. In v20 this will +// change. +class ODKGoldenProvision40V19 : public ::testing::Test { + protected: + void RunTest() { + ODK_ProvisioningRequest core_provisioning_request; + EXPECT_TRUE(CoreProvisioningRequestFromMessage(core_request_, + &core_provisioning_request)); + } + std::string core_request_; +}; + +class ODKGoldenLicenseV19 : public ::testing::Test { + protected: + void RunTest() { + ODK_LicenseRequest core_license_request; + EXPECT_TRUE( + CoreLicenseRequestFromMessage(core_request_, &core_license_request)); + std::string generated_core_message; + const CoreMessageFeatures features = + CoreMessageFeatures::DefaultFeatures(ODK_MAJOR_VERSION); + EXPECT_TRUE(CreateCoreLicenseResponseFromProto( + features, serialized_license_, core_license_request, + core_request_sha256_, nonce_required_, uses_padding_, + &generated_core_message)); + EXPECT_EQ(core_response_, generated_core_message); + } + + bool nonce_required_ = true; + bool uses_padding_ = false; + std::string core_request_; + std::string core_response_; + std::string serialized_license_; + std::string core_request_sha256_; +}; + +class ODKGoldenRenewalV19 : public ::testing::Test { + protected: + void RunTest() { + ODK_RenewalRequest core_renewal_request; + EXPECT_TRUE( + CoreRenewalRequestFromMessage(core_request_, &core_renewal_request)); + std::string generated_core_message; + const CoreMessageFeatures features = + CoreMessageFeatures::DefaultFeatures(ODK_MAJOR_VERSION); + EXPECT_TRUE(CreateCoreRenewalResponse(features, core_renewal_request, + renewal_duration_seconds_, + &generated_core_message)); + EXPECT_EQ(core_response_, generated_core_message); + } + + uint64_t renewal_duration_seconds_; + std::string core_request_; + std::string core_response_; + std::string renewal_; +}; + +// README (for ODK maintainers): Set the environment variable +// DUMP_GOLDEN_DATA="yes" +// Then set the environment variable GTEST_FILTER to the test you want to run. +// Run the script for the platform we want. E.g. run_fake_l1_tests, +// run_prov30_tests or run_prov40_tests. Look for the autogenerated code in +// $CDM_DIR/out/testbed/debug/*_data.cpp. If you are updating the ODK +// library, and you have to change the code above, then you're fine. If you +// have to change the code below then there is probably a backwards +// compatibility problem. + +////////////////////////////////////////////////////////////////////// +// Provisioning tests. +// One provisioning example from each of fake-l1 (with keybox), prov20ecc +// and prov30. +// GTEST_FILTER='*CorePIGTest.OfflineNoNonce*" +////////////////////////////////////////////////////////////////////// +TEST_F(ODKGoldenProvisionV19, CorePIGTest_OfflineNoNonce_prov20) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x02, 0x00, 0x13, + 0x5e, 0x53, 0x0c, 0x3a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x02, 0x00, 0x13, + 0x5e, 0x53, 0x0c, 0x3a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x04, 0xd0, 0x00, 0x00, 0x04, 0xd5, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t provisioning_response_raw[] = { + 0x0a, 0xd0, 0x09, 0x6f, 0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0x24, + 0xb5, 0x91, 0xcf, 0x66, 0x93, 0xae, 0xd7, 0xad, 0x24, 0x58, 0xdf, 0x15, + 0x40, 0xf7, 0xa9, 0xbe, 0x78, 0x1c, 0x16, 0x68, 0x61, 0xeb, 0x10, 0x5f, + 0xf6, 0x45, 0x8e, 0xd5, 0x89, 0x85, 0xfb, 0x27, 0x8f, 0x7e, 0x6f, 0x46, + 0x97, 0x44, 0xba, 0x72, 0xbf, 0x68, 0xc8, 0x5b, 0xde, 0x25, 0x06, 0x95, + 0xd8, 0x3a, 0xbd, 0x3d, 0x1a, 0x71, 0xad, 0x1b, 0x3c, 0x31, 0x85, 0xea, + 0xe7, 0x43, 0xe6, 0xa3, 0x1a, 0xee, 0x69, 0x48, 0x35, 0x75, 0x15, 0xb4, + 0x38, 0x0f, 0xb6, 0x8d, 0x1b, 0x1c, 0x96, 0x49, 0x62, 0x04, 0xa7, 0x9a, + 0x86, 0xf9, 0xec, 0x37, 0xe8, 0x45, 0x39, 0xc4, 0x3f, 0x1c, 0x9c, 0x46, + 0xbd, 0x8f, 0xc0, 0xc0, 0x84, 0xf3, 0x02, 0x1f, 0x12, 0x66, 0x00, 0x10, + 0xd4, 0x3f, 0x35, 0x99, 0x13, 0x44, 0x34, 0x11, 0xe0, 0xba, 0x2a, 0x49, + 0x0c, 0xa7, 0xfd, 0xb3, 0xd6, 0x0a, 0x1a, 0xba, 0xaf, 0xb8, 0x44, 0xb1, + 0xe6, 0x61, 0x34, 0x74, 0xb8, 0x0b, 0x51, 0x67, 0x46, 0x70, 0x1c, 0x6c, + 0xb3, 0x1b, 0x76, 0xed, 0x0f, 0x7a, 0x0c, 0x06, 0x26, 0x91, 0xa4, 0x8b, + 0xc7, 0x25, 0xb2, 0xda, 0x6c, 0xe3, 0x8c, 0x15, 0x42, 0x1a, 0xe5, 0xd6, + 0xb5, 0x65, 0x2f, 0xc8, 0x7a, 0xdc, 0x2d, 0x1e, 0x4f, 0xb4, 0x37, 0x1a, + 0x76, 0x56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0xe4, 0xef, 0x37, 0x09, 0x16, 0x66, + 0xd4, 0x11, 0xc8, 0x2d, 0x8c, 0x70, 0x2d, 0x10, 0x52, 0xd0, 0x5f, 0x8d, + 0xfb, 0x09, 0x44, 0x54, 0x0b, 0xa4, 0xcb, 0x28, 0xed, 0x62, 0xe4, 0x5b, + 0x23, 0xbb, 0xbd, 0x6c, 0x91, 0xb9, 0x72, 0xb4, 0x1b, 0xaf, 0xb2, 0xd9, + 0x11, 0xcf, 0x8a, 0x50, 0x46, 0x7e, 0x9f, 0xc4, 0x01, 0x4c, 0x4f, 0xd1, + 0xb5, 0x2f, 0x3f, 0x84, 0x24, 0x2d, 0x5a, 0x43, 0x86, 0xef, 0xaa, 0x04, + 0xdf, 0x89, 0x21, 0xc5, 0xf2, 0x8c, 0xc1, 0x2b, 0x8c, 0x2b, 0xd6, 0x9d, + 0xbe, 0xda, 0x22, 0xf0, 0xfc, 0xa5, 0x86, 0xf0, 0xe6, 0x19, 0x07, 0xa0, + 0x4a, 0x10, 0x20, 0xae, 0xa9, 0x02, 0x03, 0x01, 0x00, 0x01, 0x28, 0xe8, + 0x3d, 0x3a, 0x0c, 0x77, 0x69, 0x64, 0x65, 0x76, 0x69, 0x6e, 0x65, 0x2e, + 0x63, 0x6f, 0x6d, 0x48, 0x01, 0x52, 0xaa, 0x01, 0x08, 0x01, 0x10, 0x00, + 0x1a, 0x81, 0x01, 0x04, 0x52, 0x3c, 0x52, 0xe4, 0xae, 0x73, 0x15, 0xa4, + 0x67, 0x5f, 0xaa, 0x7f, 0xaf, 0x0e, 0xae, 0x83, 0x8d, 0x79, 0xf0, 0x72, + 0x16, 0xe0, 0x40, 0xe1, 0x28, 0x39, 0x32, 0x64, 0x0a, 0x4e, 0xb4, 0x61, + 0x22, 0x10, 0xb1, 0x2e, 0x38, 0x7d, 0x28, 0x85, 0xb2, 0x53, 0xf0, 0xd5, + 0x30, 0xe4, 0x33, 0x6a, 0x26, 0x6e, 0x65, 0x46, 0x70, 0x15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, 0x0b, 0x23, 0x25, 0x1a, 0x08, 0x81, 0x36, 0xd6, 0xe8, 0xf4, 0x75, + 0x29, 0x9d, 0x2a, 0xfd, 0x46, 0xce, 0xa5, 0x1b, 0x5c, 0xbd, 0xf7, 0x89, + 0xa5, 0x72, 0x12, 0x5c, 0xd2, 0x4f, 0xbb, 0x81, 0x3b, 0x38, 0x7a, 0x10, + 0xcd, 0x2a, 0x30, 0xe3, 0x44, 0x76, 0x34, 0xab, 0x34, 0x08, 0xf9, 0x6b, + 0x9c, 0xf3, 0xd9, 0x88, 0x96, 0xd4, 0x05, 0xf3, 0xf5, 0x40, 0xd9, 0xc5, + 0x79, 0x62, 0x76, 0x0f, 0xcd, 0x17, 0x7c, 0xdd, 0x10, 0x1e, 0xb8, 0xa4, + 0x14, 0x8b, 0x9c, 0x29, 0xce, 0xd5, 0xea, 0xd6, 0x45, 0xa9, 0x5b, 0x69, + 0x8f, 0x1c, 0xdc, 0x6e, 0x1d, 0xb6, 0x67, 0x8b, 0x85, 0x07, 0x41, 0x86, + 0x08, 0x0d, 0x68, 0xd1, 0x3c, 0xd3, 0x7e, 0x07, 0xb1, 0x6d, 0xe3, 0x70, + 0xcd, 0x9a, 0xfb, 0x9b, 0x25, 0x56, 0x4a, 0x73, 0xa3, 0x0e, 0x2a, 0xf8, + 0x08, 0x5e, 0xa3, 0x7d, 0x31, 0x0c, 0x47, 0x4f, 0x0e, 0x67, 0xac, 0x00, + 0xca, 0x99, 0x2a, 0x52, 0x96, 0xfa, 0xed, 0xad, 0x7a, 0xa0, 0x6e, 0xcd, + 0x79, 0x0f, 0x1e, 0x3d, 0x42, 0x65, 0x58, 0xfa, 0x98, 0x38, 0x3e, 0x3c, + 0xd2, 0xed, 0x48, 0x30, 0x22, 0x04, 0x3a, 0x0c, 0x53, 0x5e, + }; + provisioning_response_ = + std::string(reinterpret_cast(provisioning_response_raw), + sizeof(provisioning_response_raw)); + device_key_type_ = OEMCrypto_RSA_Private_Key; + RunTest(); +} + +TEST_F(ODKGoldenProvisionV19, CorePIGTest_OfflineNoNonce_prov20ecc) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x02, 0x00, 0x13, + 0x73, 0xbe, 0x16, 0x6a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x02, 0x00, 0x13, + 0x73, 0xbe, 0x16, 0x6a, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x95, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t provisioning_response_raw[] = { + 0x0a, 0x90, 0x01, 0x88, 0xc8, 0xe1, 0xc7, 0xed, 0xec, 0x59, 0x9b, 0x0f, + 0x67, 0xa3, 0x96, 0x69, 0x28, 0xde, 0xc8, 0x3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, 0x13, 0x06, + 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x51, 0xfc, + 0xf6, 0xc7, 0xea, 0x42, 0x6c, 0x27, 0xa5, 0x1a, 0x92, 0x22, 0x4c, 0x83, + 0x30, 0xb6, 0x83, 0xc1, 0x6c, 0x05, 0x9f, 0xac, 0x0c, 0x6f, 0xcb, 0x99, + 0x3c, 0xb4, 0xd4, 0x5f, 0x7c, 0xb4, 0xc0, 0xcb, 0x45, 0x83, 0xa0, 0xa6, + 0x33, 0x4d, 0x86, 0xc5, 0x46, 0x50, 0xd9, 0x0f, 0x52, 0x87, 0x82, 0x5a, + 0x08, 0xd7, 0x29, 0x61, 0x28, 0xdf, 0xc7, 0x39, 0x5b, 0x36, 0x39, 0x7f, + 0x5d, 0x65, 0x28, 0xd9, 0xd4, 0x01, 0x3a, 0x0c, 0x77, 0x69, 0x64, 0x65, + 0x76, 0x69, 0x6e, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x48, 0x02, 0x52, 0xaa, + 0x01, 0x08, 0x01, 0x10, 0x00, 0x1a, 0x81, 0x01, 0x04, 0x61, 0x33, 0xee, + 0x22, 0xa5, 0xb7, 0x94, 0x63, 0x35, 0x42, 0xbb, 0xb0, 0x8c, 0x8f, 0x7e, + 0xeb, 0xa5, 0xb7, 0x8d, 0x70, 0x64, 0x58, 0x93, 0x95, 0x23, 0x8c, 0x2d, + 0xb2, 0xa0, 0x16, 0x38, 0x05, 0xf8, 0xcf, 0xe3, 0xb8, 0xe0, 0xee, 0xf5, + 0x15, 0xb7, 0xf7, 0xa4, 0xbc, 0xb3, 0xcd, 0x69, 0x08, 0xbb, 0x0b, 0xa1, + 0x9d, 0xdc, 0x43, 0x0e, 0x51, 0x16, 0x16, 0x4a, 0xaa, 0x10, 0x8e, 0xb7, + 0x5e, 0x5d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x4b, 0xb8, 0xe2, 0xf2, 0x5b, 0x9c, 0xe7, 0x6a, 0x4b, + 0x70, 0xe4, 0x86, 0x75, 0xe7, 0x47, 0x8f, 0xd3, 0x2e, 0xb2, 0x06, 0xb5, + 0x23, 0x1a, 0xa2, 0x04, 0x0a, 0x9a, 0x01, 0x08, 0x01, 0x12, 0x10, 0xc6, + 0x10, 0x80, 0x8e, 0xce, 0x58, 0x74, 0x5c, 0x0f, 0xb3, 0xda, 0x8c, 0xeb, + 0x33, 0x3d, 0x8a, 0x18, 0xed, 0xad, 0xab, 0x97, 0x06, 0x22, 0x78, 0x30, + 0x76, 0x30, 0x10, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, + 0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22, 0x03, 0x62, 0x00, 0x04, 0x0b, + 0x5c, 0xca, 0xda, 0x33, 0x99, 0x3b, 0xf6, 0xd9, 0xa7, 0xec, 0x5c, 0x91, + 0xb5, 0x1d, 0x07, 0x63, 0x38, 0x25, 0xad, 0x59, 0x2c, 0x14, 0x00, 0xf2, + 0xc7, 0x5f, 0x36, 0xec, 0xa0, 0x68, 0x21, 0xa2, 0xbd, 0x8a, 0xd3, 0xb2, + 0x0c, 0x76, 0x90, 0xef, 0x99, 0xe9, 0x57, 0xc6, 0x60, 0x1c, 0x3d, 0x89, + 0x03, 0xd6, 0xe1, 0xb3, 0x5d, 0x83, 0x94, 0xe9, 0x39, 0xea, 0xd5, 0xac, + 0x00, 0x5b, 0x4a, 0x14, 0xd7, 0xc2, 0x08, 0xa8, 0x1c, 0x05, 0xe2, 0x3b, + 0x50, 0xe9, 0x8c, 0x64, 0x32, 0x92, 0xa8, 0x5f, 0x7e, 0x33, 0xd6, 0x99, + 0xcd, 0x09, 0xe6, 0x18, 0x13, 0x2f, 0x16, 0x3a, 0x7e, 0xbf, 0xa8, 0x28, + 0xd9, 0xd4, 0x01, 0x48, 0x03, 0x12, 0x80, 0x03, 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c9, 0x3f, 0x86, 0xdb, + 0x5d, 0x98, 0x8e, 0xdb, 0x3c, 0x4a, 0x4f, 0xc6, 0x18, 0x73, 0x00, 0xf4, + 0xb3, 0x93, 0xec, 0x37, 0x16, 0x73, 0xbb, 0x74, 0x20, 0x03, 0x22, 0x04, + 0x6a, 0x16, 0xbe, 0x73, + }; + provisioning_response_ = + std::string(reinterpret_cast(provisioning_response_raw), + sizeof(provisioning_response_raw)); + device_key_type_ = OEMCrypto_ECC_Private_Key; + RunTest(); +} + +TEST_F(ODKGoldenProvisionV19, CorePIGTest_OfflineNoNonce_prov30) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x02, 0x00, 0x13, + 0xd9, 0x23, 0x34, 0x7d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x02, 0x00, 0x13, + 0xd9, 0x23, 0x34, 0x7d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x04, 0xd0, 0x00, 0x00, 0x04, 0xd5, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x09, 0xec, 0x00, 0x00, 0x01, 0x00, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t provisioning_response_raw[] = { + 0x0a, 0xd0, 0x09, 0x2c, 0x20, 0xf5, 0xa7, 0xf0, 0x55, 0x19, 0xac, 0x47, + 0x7c, 0xbf, 0x82, 0x94, 0x49, 0x5a, 0x93, 0xec, 0xcb, 0x94, 0x88, 0x0d, + 0x69, 0x9f, 0xc3, 0x68, 0x88, 0x5e, 0xa5, 0xd5, 0x0e, 0x43, 0x78, 0xd3, + 0xf5, 0xa3, 0xf8, 0xad, 0x9d, 0x07, 0xa5, 0x81, 0x0e, 0x58, 0xc5, 0x1b, + 0xb1, 0xba, 0xa9, 0x43, 0x73, 0x60, 0x51, 0xaf, 0x67, 0xb5, 0x26, 0xe7, + 0x70, 0x6a, 0x80, 0xf0, 0x47, 0xdf, 0xbd, 0xbf, 0x09, 0x3e, 0xd3, 0xd8, + 0xb3, 0xf1, 0xfb, 0xb2, 0xb6, 0x84, 0xfb, 0x3e, 0x34, 0xa4, 0x4c, 0x01, + 0xcd, 0x44, 0x2c, 0x5a, 0xd9, 0xd8, 0x69, 0x44, 0x31, 0xca, 0x92, 0x3f, + 0x98, 0x1b, 0x13, 0x90, 0xc3, 0x9d, 0x5c, 0x47, 0x76, 0xc0, 0x90, 0xc4, + 0x7c, 0x60, 0xda, 0xf2, 0x99, 0x8b, 0x2b, 0x9b, 0xef, 0x09, 0x60, 0x67, + 0x87, 0x78, 0x9d, 0x74, 0x85, 0x8f, 0xb1, 0x38, 0x51, 0x4a, 0xfe, 0x0e, + 0xee, 0xcd, 0xc0, 0xa1, 0x20, 0xb0, 0x21, 0x7e, 0xb9, 0xfd, 0x8f, 0x6f, + 0xa0, 0x93, 0xc5, 0x6e, 0x05, 0xff, 0xe0, 0x01, 0xdf, 0x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, 0xff, 0xd8, 0x52, 0x78, 0xc8, 0x11, 0x37, 0xc0, 0xbd, + 0x37, 0x89, 0x91, 0x83, 0xe4, 0x1d, 0xff, 0x29, 0xb1, 0x86, 0x6e, 0xcf, + 0x8d, 0x06, 0x08, 0x29, 0x29, 0x37, 0xcb, 0x6c, 0x4d, 0xc0, 0xd1, 0x61, + 0x15, 0xc2, 0x33, 0x37, 0xf9, 0xff, 0x24, 0x4d, 0xa5, 0xed, 0x2e, 0x6f, + 0xb8, 0xa9, 0x1d, 0x05, 0x19, 0x3e, 0x09, 0x82, 0x2b, 0x18, 0x29, 0x81, + 0x46, 0x14, 0xdd, 0x51, 0xb7, 0x79, 0x5a, 0x43, 0xbb, 0xe7, 0xd4, 0xf7, + 0xe2, 0x91, 0xbf, 0x02, 0x7e, 0x94, 0xf2, 0x09, 0xec, 0x55, 0x77, 0x13, + 0xab, 0xd9, 0x32, 0x3f, 0x66, 0x62, 0xdc, 0x14, 0x08, 0x40, 0x7d, 0xcc, + 0x06, 0x95, 0xce, 0x3e, 0x11, 0xbf, 0x56, 0x71, 0x5c, 0x25, 0x99, 0x33, + 0x4a, 0xdb, 0x8e, 0x0c, 0x4a, 0x33, 0x0d, 0x40, 0xfe, 0x49, 0x4d, 0x29, + 0xad, 0x12, 0x7a, 0x49, 0x50, 0x76, 0xfd, 0xb0, 0x0b, 0x89, 0xa8, 0xe6, + 0x2e, 0x48, 0xc8, 0xa6, 0x79, 0x3f, 0x79, 0x2a, 0xf6, 0x75, 0xef, 0x40, + 0xd4, 0x08, 0x3d, 0xa5, 0xbd, 0xe4, 0x8c, 0xea, 0xd3, 0x4b, 0x96, 0x12, + 0xc2, 0x5d, 0xca, 0x3e, 0x5d, 0x4c, 0x62, 0x89, 0xd4, 0xe1, 0x7f, 0x93, + 0x7f, 0x45, 0x82, 0x6f, 0xfb, 0x8a, 0xc6, 0xe9, 0x61, 0xe9, 0x7b, 0xf0, + 0x27, 0x22, 0x27, 0xcc, 0x96, 0x8b, 0x93, 0xc4, 0x88, 0x6e, 0xc3, 0x62, + 0x7a, 0xbd, 0x69, 0x9b, 0x7b, 0x60, 0x7a, 0xe5, 0x98, 0x85, 0x0b, 0x2b, + 0x6b, 0x06, 0xd5, 0x1d, 0x3b, 0xd1, 0xa8, 0x26, 0x21, 0x7b, 0xab, 0x17, + 0xd8, 0x55, 0xb0, 0x49, 0x92, 0x71, 0x41, 0x8f, 0x6f, 0xad, 0x4f, 0x60, + 0x39, 0x10, 0xfc, 0xdf, 0xff, 0x46, 0xb4, 0x22, 0x7c, 0xbb, 0x15, 0x6c, + 0x10, 0x59, 0x72, 0x4b, 0x05, 0xd9, 0x96, 0xd9, 0x46, 0x3e, 0xf0, 0xde, + 0x6c, 0x92, 0x83, 0xe0, 0x56, 0x29, 0x8f, 0x81, 0x86, 0x87, 0x41, 0x9c, + 0x6d, 0x67, 0x13, 0x17, 0x33, 0x91, 0x61, 0x5a, 0xa3, 0x34, 0x43, 0x88, + 0x9c, 0xf3, 0xe4, 0x22, 0x1f, 0xac, 0x89, 0x71, 0x21, 0x16, 0xfc, 0x39, + 0xfb, 0x49, 0x15, 0xc0, 0x04, 0x4a, 0x2b, 0x35, 0x0f, 0x12, 0xcd, 0x7d, + 0x31, 0x23, 0x62, 0x78, 0xd4, 0x6d, 0x7b, 0xa6, 0x61, 0xf1, 0x40, 0x0f, + 0x5d, 0xb2, 0x60, 0xd8, 0x19, 0xaa, 0x37, 0x7a, 0xd6, 0xf2, 0xd9, 0x0d, + 0x3f, 0xe4, 0x55, 0xb7, 0xe3, 0x2a, 0x41, 0x78, 0xd8, 0x3f, 0xf5, 0xa9, + 0x71, 0xce, 0xe4, 0xbb, 0x29, 0xc5, 0x65, 0xee, 0x0e, 0xe1, 0xb7, 0x19, + 0x5d, 0xbd, 0x44, 0x45, 0x6d, 0x5e, 0x67, 0x05, 0xdd, 0x59, 0x0c, 0x12, + 0x10, 0x11, 0x33, 0xe6, 0x8b, 0xb9, 0x73, 0x92, 0x43, 0x78, 0x23, 0x79, + 0x7c, 0x9a, 0x13, 0x74, 0x05, 0x1a, 0xfb, 0x09, 0x0a, 0xbe, 0x02, 0x08, + 0x02, 0x12, 0x10, 0x35, 0x7f, 0x7a, 0xfa, 0x7d, 0x33, 0x42, 0x33, 0x1c, + 0x8c, 0xd1, 0x07, 0xdd, 0xc7, 0x5a, 0x96, 0x18, 0xfd, 0x9c, 0xb0, 0xb5, + 0x06, 0x22, 0x8e, 0x02, 0x30, 0x82, 0x01, 0x0a, 0x02, 0x82, 0x01, 0x01, + 0x00, 0xb5, 0xac, 0x08, 0x86, 0xfa, 0x80, 0x26, 0xe2, 0xce, 0x65, 0x44, + 0x5a, 0x1a, 0x40, 0x52, 0x15, 0xdc, 0x68, 0x9d, 0x4a, 0xfc, 0x83, 0xb0, + 0x28, 0x24, 0xb3, 0x6e, 0x8d, 0x1c, 0x98, 0xa6, 0x39, 0x87, 0xe4, 0xa5, + 0x4d, 0x8d, 0xf2, 0x31, 0xe8, 0xb8, 0x89, 0xf4, 0xd8, 0xdc, 0x6a, 0xb1, + 0x70, 0x73, 0x3a, 0xc7, 0x49, 0xa9, 0x41, 0x95, 0x28, 0x70, 0xaf, 0x08, + 0x80, 0x3d, 0x71, 0xf6, 0x5f, 0x8d, 0xf3, 0x98, 0xef, 0x25, 0x2f, 0x27, + 0x31, 0x08, 0x41, 0x0c, 0xa2, 0x8e, 0x38, 0xe4, 0x85, 0x77, 0x89, 0xcb, + 0x06, 0xe0, 0x69, 0xaa, 0xf7, 0xad, 0x4c, 0xb1, 0xbc, 0xb4, 0x8b, 0x94, + 0xd3, 0x49, 0xfd, 0xc7, 0x06, 0xfb, 0xa6, 0xeb, 0x1c, 0xea, 0x27, 0x67, + 0xad, 0x6b, 0xa7, 0xd2, 0x99, 0x5f, 0x3c, 0xea, 0xdb, 0x68, 0xa9, 0x27, + 0x19, 0x9e, 0x77, 0x2b, 0x7e, 0xe1, 0x3d, 0xf1, 0xd1, 0xf8, 0x52, 0x63, + 0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+ 0x49, 0x72, 0x3f, 0x79, 0x30, 0x37, 0xc6, 0x4c, 0xd4, 0x7f, 0x8b, 0x18, + 0x88, 0x26, 0x15, 0xa7, 0x63, 0xd0, 0x1e, 0xac, 0xb3, 0x09, 0x5e, 0xe4, + 0x7c, 0x28, 0x42, 0x59, 0xa3, 0x71, 0x86, 0x8d, 0x5d, 0x02, 0x5b, 0x4b, + 0x30, 0x6d, 0x17, 0x7d, 0x38, 0xf2, 0x07, 0x51, 0x86, 0x85, 0xed, 0x46, + 0x3d, 0xd8, 0x0a, 0xe0, 0x46, 0x34, 0x13, 0x93, 0x78, 0x77, 0xfe, 0x6a, + 0xcd, 0x16, 0x4c, 0xda, 0xd6, 0xe1, 0xcd, 0xac, 0x04, 0x5a, 0xf4, 0xaf, + 0x79, 0xd6, 0x06, 0xb3, 0xf6, 0xe3, 0xc7, 0x20, 0xff, 0xc0, 0x49, 0x34, + 0x71, 0xc5, 0x7a, 0x4b, 0xb8, 0xb4, 0xb9, 0x55, 0xa6, 0x3b, 0x57, 0xcd, + }; + provisioning_response_ = + std::string(reinterpret_cast(provisioning_response_raw), + sizeof(provisioning_response_raw)); + device_key_type_ = OEMCrypto_RSA_Private_Key; + RunTest(); +} + +TEST_F(ODKGoldenProvision40V19, CorePIGTest_OfflineNoNonce_prov40) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x03, 0x5e, 0x00, 0x02, 0x00, 0x13, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xed, + 0xae, 0x65, 0x62, 0x72, 0x61, 0x6e, 0x64, 0x65, 0x62, 0x72, 0x61, 0x6e, + 0x64, 0x65, 0x66, 0x75, 0x73, 0x65, 0x64, 0x00, 0x65, 0x6d, 0x6f, 0x64, + 0x65, 0x6c, 0x63, 0x64, 0x65, 0x76, 0x66, 0x64, 0x65, 0x76, 0x69, 0x63, + 0x65, 0x66, 0x64, 0x65, 0x76, 0x69, 0x63, 0x65, 0x67, 0x70, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x67, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x68, 0x76, 0x62, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x65, 0x67, 0x72, + 0x65, 0x65, 0x6e, 0x6a, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x6a, 0x6f, 0x73, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x6c, 0x6d, 0x61, 0x6e, 0x75, 0x66, 0x61, 0x63, 0x74, 0x75, 0x72, + 0x65, 0x72, 0x68, 0x57, 0x69, 0x64, 0x65, 0x76, 0x69, 0x6e, 0x65, 0x6d, + 0x76, 0x62, 0x6d, 0x65, 0x74, 0x61, 0x5f, 0x64, 0x69, 0x67, 0x65, 0x73, + 0x74, 0x40, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x63, 0x74, 0x65, 0x65, 0x70, 0x62, 0x6f, + 0x6f, 0x74, 0x5f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6c, 0x65, 0x76, + 0x65, 0x6c, 0x00, 0x70, 0x62, 0x6f, 0x6f, 0x74, 0x6c, 0x6f, 0x61, 0x64, + 0x65, 0x72, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x68, 0x75, 0x6e, 0x6c, + 0x6f, 0x63, 0x6b, 0x65, 0x64, 0x72, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x5f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, + 0x00, 0x72, 0x76, 0x65, 0x6e, 0x64, 0x6f, 0x72, 0x5f, 0x70, 0x61, 0x74, + 0x63, 0x68, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + RunTest(); +} + +////////////////////////////////////////////////////////////////////// +// License tests. +// All license requests from fake_l1, +// GTEST_FILTER="*PIG*:*CdmUseCase*Case1*" +////////////////////////////////////////////////////////////////////// + +TEST_F(ODKGoldenLicenseV19, CorePIGTest_OfflineNoNonce) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x35, 0xee, 0x92, 0xc2, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x99, 0x00, 0x02, 0x00, 0x13, + 0x35, 0xee, 0x92, 0xc2, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6c, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x55, 0x0a, 0x20, 0x33, 0x32, 0x32, 0x45, 0x39, 0x37, 0x30, 0x45, + 0x42, 0x31, 0x36, 0x43, 0x46, 0x46, 0x34, 0x33, 0x30, 0x35, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x33, 0x32, 0x32, 0x45, 0x39, 0x37, 0x30, 0x45, 0x42, 0x31, + 0x36, 0x43, 0x46, 0x46, 0x34, 0x33, 0x30, 0x35, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x38, 0x90, 0x1c, 0x40, 0x00, 0x48, 0xd9, 0xc0, + 0xb4, 0xb5, 0x06, 0x12, 0x0f, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, + 0x90, 0x1c, 0x28, 0x00, 0x70, 0x00, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, + 0x13, 0xaf, 0x82, 0x69, 0xb0, 0xcd, 0x68, 0x91, 0x77, 0xe5, 0x99, 0x48, + 0x82, 0x30, 0x5e, 0x5c, 0x1a, 0x40, 0xdf, 0x04, 0xa3, 0xc0, 0xca, 0xc2, + 0xd5, 0xa7, 0x96, 0x83, 0x25, 0x96, 0xb2, 0x20, 0x14, 0x2c, 0x3e, 0xc4, + 0x10, 0xd0, 0xd9, 0x80, 0x41, 0xc9, 0xe0, 0x4a, 0x17, 0x59, 0x77, 0x83, + 0xfc, 0x72, 0x7a, 0x72, 0xc1, 0xb7, 0x2f, 0x15, 0x33, 0xe1, 0x7b, 0xd4, + 0xa6, 0x31, 0xf9, 0xc2, 0xce, 0x4e, 0xec, 0xf7, 0xfd, 0xd8, 0x94, 0x99, + 0x13, 0xee, 0x2c, 0xf7, 0xbc, 0x44, 0x55, 0x9a, 0x41, 0xb1, 0x20, 0x01, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x01, 0xb1, + 0x6d, 0x09, 0x5f, 0x65, 0x0d, 0xa6, 0x82, 0x79, 0x0e, 0x33, 0x9d, 0x16, + 0x56, 0x96, 0x1a, 0x10, 0x70, 0x55, 0x08, 0x48, 0xc4, 0x68, 0xcf, 0x06, + 0x56, 0xeb, 0x9c, 0xdb, 0x71, 0x2c, 0xd9, 0x3b, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, + 0x35, 0xee, 0x92, 0xc2, 0x80, 0x00, 0x00, 0x00, 0x62, 0x00, 0x20, 0xd9, + 0xc0, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = false; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, CorePIGTest_OfflineWithPST) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x96, 0x4f, 0xb1, 0x6b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x99, 0x00, 0x02, 0x00, 0x13, + 0x96, 0x4f, 0xb1, 0x6b, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x78, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x61, 0x0a, 0x20, 0x36, 0x31, 0x43, 0x44, 0x32, 0x46, 0x30, 0x39, + 0x30, 0x32, 0x44, 0x43, 0x46, 0x46, 0x30, 0x39, 0x30, 0x38, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x36, 0x31, 0x43, 0x44, 0x32, 0x46, 0x30, 0x39, 0x30, 0x32, + 0x44, 0x43, 0x46, 0x46, 0x30, 0x39, 0x30, 0x38, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0xe2, 0xbe, 0x5c, 0xcc, 0x7f, 0x2a, + 0xc1, 0xc0, 0x47, 0x0a, 0x38, 0x90, 0x1c, 0x40, 0x00, 0x48, 0xd9, 0xc0, + 0xb4, 0xb5, 0x06, 0x12, 0x0f, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, + 0x90, 0x1c, 0x28, 0x00, 0x70, 0x00, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, + 0x4a, 0xfb, 0xce, 0xc5, 0x6d, 0x87, 0xaa, 0x1d, 0xcf, 0xc7, 0xdf, 0xba, + 0x2d, 0x9d, 0xf3, 0x9d, 0x1a, 0x40, 0x29, 0x18, 0x87, 0x6a, 0x35, 0x08, + 0x05, 0xe1, 0x3d, 0x70, 0x49, 0x5e, 0x9c, 0xe2, 0xb3, 0x73, 0xc3, 0xef, + 0xe0, 0xeb, 0x8a, 0x1b, 0xd9, 0xd4, 0xce, 0x10, 0xe7, 0xcd, 0xeb, 0xcc, + 0xbd, 0x5c, 0xd5, 0x2b, 0xce, 0x0b, 0xa6, 0x67, 0x52, 0x3b, 0x6b, 0xc5, + 0x6d, 0x05, 0xfd, 0x3a, 0x2f, 0x8a, 0x8f, 0xe7, 0xdf, 0x23, 0xe8, 0x05, + 0x2f, 0xfb, 0x13, 0x4e, 0x34, 0xcb, 0xd2, 0xb1, 0xf4, 0x10, 0x20, 0x01, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x46, 0x45, + 0xce, 0x6d, 0xaa, 0xae, 0x83, 0xa5, 0x8e, 0x95, 0x80, 0x2b, 0xce, 0xf8, + 0x06, 0x96, 0x1a, 0x10, 0xe1, 0x32, 0x89, 0xde, 0x29, 0x88, 0xbd, 0x25, + 0x66, 0x80, 0xd6, 0x39, 0x9b, 0x76, 0x1b, 0x31, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, + 0x96, 0x4f, 0xb1, 0x6b, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x20, 0xd9, + 0xc0, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, CorePIGTest_OfflineHWSecureRequired) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x76, 0xdf, 0x62, 0xbd, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x02, 0x00, 0x13, + 0x76, 0xdf, 0x62, 0xbd, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x78, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x22, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x34, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x46, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x5e, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x61, 0x0a, 0x20, 0x42, 0x43, 0x41, 0x31, 0x46, 0x32, 0x32, 0x44, + 0x31, 0x43, 0x39, 0x35, 0x46, 0x46, 0x33, 0x31, 0x31, 0x37, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x42, 0x43, 0x41, 0x31, 0x46, 0x32, 0x32, 0x44, 0x31, 0x43, + 0x39, 0x35, 0x46, 0x46, 0x33, 0x31, 0x31, 0x37, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0xc7, 0x24, 0x8e, 0xd8, 0xda, 0x03, + 0x33, 0x4a, 0xc3, 0x32, 0x38, 0x90, 0x1c, 0x40, 0x00, 0x48, 0xd9, 0xc0, + 0xb4, 0xb5, 0x06, 0x12, 0x0f, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, + 0x90, 0x1c, 0x28, 0x00, 0x70, 0x00, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, + 0x21, 0x15, 0x3a, 0xfa, 0x32, 0x52, 0x91, 0x85, 0xaf, 0xcd, 0x70, 0x4a, + 0x5d, 0x0a, 0x94, 0x84, 0x1a, 0x40, 0x10, 0xf7, 0x28, 0xd6, 0x02, 0x0a, + 0x1f, 0x41, 0x92, 0x6d, 0x95, 0xc6, 0xcf, 0xbb, 0x11, 0xdf, 0x9b, 0xb4, + 0xd2, 0xb8, 0xf2, 0xa5, 0xde, 0x80, 0x5b, 0x92, 0xbe, 0x2d, 0xa2, 0x1f, + 0x0b, 0x29, 0x36, 0x5e, 0x1b, 0xf2, 0x55, 0xc2, 0x08, 0x09, 0xd3, 0xb5, + 0x4f, 0x5f, 0xab, 0x37, 0x42, 0xad, 0xa4, 0xda, 0xcc, 0x03, 0x66, 0xb1, + 0x6e, 0x42, 0x06, 0x3c, 0xc8, 0xd4, 0xbf, 0xfe, 0xd7, 0x2b, 0x20, 0x01, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xff, 0xe0, + 0xd5, 0x67, 0xb3, 0x65, 0xbb, 0x79, 0x09, 0x87, 0x8b, 0x98, 0xd3, 0x09, + 0x73, 0x34, 0x1a, 0x10, 0xc9, 0x31, 0x47, 0x5d, 0xd4, 0x9e, 0x75, 0xc0, + 0xed, 0xa7, 0x6f, 0xc7, 0xb2, 0x83, 0x04, 0x29, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, + 0x76, 0xdf, 0x62, 0xbd, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0xf1, 0x7f, 0xee, 0xf1, + 0x0f, 0x74, 0x4b, 0x99, 0xdf, 0xc2, 0xae, 0xf7, 0xbc, 0x42, 0x59, 0x42, + 0x1a, 0x10, 0x40, 0xd2, 0x8b, 0x06, 0xfa, 0x8a, 0x16, 0x62, 0xfe, 0x36, + 0x94, 0x42, 0x84, 0xb8, 0xc6, 0x95, 0x20, 0x02, 0x28, 0x05, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x76, 0xdf, + 0x62, 0xbd, 0x8c, 0x00, 0x40, 0x10, 0x62, 0x00, 0x20, 0xd9, 0xc0, 0xb4, + 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_Streaming_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x42, 0xdb, 0x35, 0x36, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x42, 0xdb, 0x35, 0x36, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x6a, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x45, 0x31, 0x31, 0x30, 0x36, 0x35, 0x32, 0x33, + 0x44, 0x45, 0x45, 0x35, 0x43, 0x45, 0x42, 0x30, 0x32, 0x31, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x45, 0x31, 0x31, 0x30, 0x36, 0x35, 0x32, 0x33, 0x44, 0x45, + 0x45, 0x35, 0x43, 0x45, 0x42, 0x30, 0x32, 0x31, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x28, 0x40, 0x00, 0x48, 0xe3, 0xc0, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x28, + 0x28, 0x00, 0x70, 0x01, 0x78, 0x00, 0x1a, 0x56, 0x12, 0x10, 0x80, 0xc6, + 0x22, 0x95, 0x14, 0x26, 0x74, 0x24, 0xd4, 0x4c, 0xc2, 0xfa, 0x68, 0xb8, + 0x83, 0x61, 0x1a, 0x40, 0xdd, 0x21, 0xdc, 0x75, 0xbe, 0x86, 0x35, 0xa2, + 0xe9, 0x6b, 0x6b, 0x8b, 0xc8, 0x7f, 0x48, 0xac, 0x1d, 0x5e, 0xd0, 0x37, + 0x5d, 0x8e, 0x71, 0x89, 0xf9, 0x1b, 0x7d, 0xd2, 0x54, 0x15, 0x67, 0x80, + 0x10, 0xbb, 0x94, 0xd6, 0x4b, 0x7e, 0x92, 0x73, 0x87, 0x95, 0xa3, 0x42, + 0x5f, 0xb8, 0x8b, 0x0c, 0x7b, 0x13, 0x87, 0x3e, 0x2e, 0xc2, 0x49, 0x5c, + 0x0f, 0xbd, 0xae, 0xb6, 0xc5, 0x4c, 0x1f, 0x0c, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x78, 0x14, 0xfe, 0xa7, + 0x53, 0x6c, 0x4e, 0x65, 0x24, 0x44, 0x28, 0xef, 0x0c, 0x63, 0xda, 0x1c, + 0x1a, 0x10, 0xfc, 0x4f, 0x6a, 0x17, 0xbf, 0x7c, 0x61, 0x1e, 0x91, 0xfb, + 0xee, 0xf4, 0xa2, 0xab, 0xd6, 0x1f, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x42, 0xdb, + 0x35, 0x36, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x00, 0x6a, 0x7f, 0xa1, 0x0f, 0xd9, + 0xf4, 0x73, 0xa2, 0x12, 0x31, 0x0f, 0x1d, 0xaa, 0xe1, 0x1c, 0x1a, 0x10, + 0xab, 0x9f, 0x31, 0xd5, 0x7d, 0x2e, 0x2d, 0x87, 0x2d, 0xc3, 0x2a, 0x2d, + 0x9e, 0x81, 0x27, 0x02, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x42, 0xdb, 0x35, 0x36, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x45, 0x66, 0xe7, 0x48, 0xb0, 0x40, 0xf1, 0xba, + 0xb7, 0x7b, 0x06, 0x6c, 0x4f, 0xff, 0xce, 0xaf, 0x1a, 0x10, 0x22, 0xe0, + 0xb1, 0x6f, 0xbe, 0xd0, 0x12, 0x1d, 0x9e, 0xa0, 0x4d, 0xdf, 0x67, 0x28, + 0x32, 0x32, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x42, 0xdb, 0x35, 0x36, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0xff, 0xc9, 0xdc, 0x60, 0x63, 0xb6, 0xba, 0x6f, 0xf6, 0x3c, + 0xec, 0x1b, 0x56, 0x09, 0x72, 0x10, 0x1a, 0x10, 0x0d, 0x34, 0x82, 0x16, + 0xef, 0x54, 0x19, 0x00, 0x19, 0x7c, 0x06, 0x6d, 0x33, 0x69, 0xc2, 0xbd, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x42, 0xdb, 0x35, 0x36, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0xf1, 0x90, 0xaa, 0x54, 0xe5, 0xd3, 0x0c, 0xc4, 0xd5, 0x9d, 0xfc, 0x10, + 0x00, 0x41, 0x70, 0x10, 0x1a, 0x10, 0x6c, 0x7a, 0x2a, 0x92, 0xca, 0x44, + 0xab, 0x7d, 0x06, 0x7b, 0x17, 0xa5, 0x53, 0x92, 0xf2, 0x4d, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0x42, 0xdb, 0x35, 0x36, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x20, 0xe3, 0xc0, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_Streaming_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xc2, 0xc9, 0xe1, 0x08, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xc2, 0xc9, 0xe1, 0x08, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x76, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x84, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x96, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x16, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x3a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x38, 0x32, 0x34, 0x35, 0x36, 0x37, 0x41, 0x34, + 0x43, 0x46, 0x45, 0x37, 0x44, 0x34, 0x35, 0x38, 0x32, 0x33, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x38, 0x32, 0x34, 0x35, 0x36, 0x37, 0x41, 0x34, 0x43, 0x46, + 0x45, 0x37, 0x44, 0x34, 0x35, 0x38, 0x32, 0x33, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0xce, 0x65, 0x93, 0x1e, 0xae, 0xdb, + 0xe4, 0x98, 0xdc, 0x46, 0x38, 0x28, 0x40, 0x00, 0x48, 0x89, 0xc1, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x28, + 0x28, 0x00, 0x70, 0x01, 0x78, 0x00, 0x1a, 0x56, 0x12, 0x10, 0x2c, 0xde, + 0x8c, 0x0c, 0x5a, 0x5c, 0x5e, 0x29, 0x91, 0x9c, 0x79, 0x5b, 0x70, 0x27, + 0xa4, 0x3a, 0x1a, 0x40, 0x6e, 0x4f, 0xbd, 0x5a, 0x5b, 0xb0, 0xa7, 0xda, + 0xb8, 0x6d, 0xf5, 0x20, 0x4d, 0xa3, 0xeb, 0x0d, 0x6c, 0x11, 0x97, 0x50, + 0x2f, 0x09, 0x60, 0xa0, 0x6d, 0x60, 0x5b, 0x76, 0xf1, 0x51, 0x66, 0x82, + 0x8a, 0x9e, 0x13, 0x84, 0x79, 0x6d, 0xf3, 0x3d, 0xe5, 0xbb, 0x1e, 0x1e, + 0xa2, 0x6f, 0xb4, 0x1c, 0x25, 0xcb, 0x50, 0x32, 0x13, 0x5e, 0x89, 0x8f, + 0x26, 0x5b, 0xbf, 0xd2, 0x6c, 0x2d, 0x87, 0x11, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xd8, 0x4f, 0x7a, 0x2c, + 0xf0, 0x3e, 0xf5, 0x08, 0x6f, 0x08, 0xf2, 0xbf, 0xce, 0xc6, 0x55, 0x03, + 0x1a, 0x10, 0xfe, 0xfd, 0x24, 0xe3, 0x78, 0x7b, 0x99, 0xe3, 0xb3, 0xf2, + 0x7a, 0x0a, 0xb3, 0xf2, 0xdf, 0x5b, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc9, + 0xe1, 0x08, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x95, 0x45, 0x8a, 0x51, 0xac, 0x42, + 0x59, 0xdb, 0x06, 0xdf, 0x75, 0x20, 0xdf, 0x4b, 0x1b, 0xbc, 0x1a, 0x10, + 0x2f, 0xfa, 0xac, 0x1a, 0x04, 0xfa, 0x77, 0x06, 0x7b, 0xcc, 0xcb, 0x60, + 0x30, 0x86, 0xed, 0xa6, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc9, 0xe1, 0x08, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0xbe, 0xa2, 0x23, 0x8b, 0xb4, 0x3d, 0xe3, 0x10, + 0x9c, 0x64, 0xae, 0xcf, 0x2f, 0x20, 0xac, 0xd1, 0x1a, 0x10, 0xdb, 0xbd, + 0x45, 0xba, 0xf5, 0x58, 0xa8, 0xf0, 0x5a, 0x57, 0xf5, 0xb1, 0xe6, 0x11, + 0x5d, 0x6a, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc9, 0xe1, 0x08, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0xe0, 0x79, 0xba, 0xc1, 0x78, 0x97, 0x47, 0x2d, 0xd9, 0x9d, + 0x2a, 0x9a, 0xe2, 0xf8, 0x87, 0xfb, 0x1a, 0x10, 0x85, 0xce, 0x11, 0x04, + 0x08, 0x5c, 0xac, 0xfa, 0xc1, 0xf8, 0xaf, 0x02, 0x15, 0x76, 0x5c, 0x7d, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0xc2, 0xc9, 0xe1, 0x08, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x91, 0x6f, 0x83, 0xb4, 0xf2, 0x32, 0x62, 0x07, 0x56, 0xbe, 0xc0, 0x6a, + 0x32, 0xf2, 0xed, 0x26, 0x1a, 0x10, 0x6d, 0x93, 0x1e, 0x82, 0x0c, 0x81, + 0xaa, 0x59, 0x2d, 0x63, 0x85, 0x0d, 0xe1, 0xe1, 0x57, 0x03, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0xc2, 0xc9, 0xe1, 0x08, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x20, 0x89, 0xc1, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_StreamingQuickStart_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x4d, 0x22, 0x22, 0xc1, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x4d, 0x22, 0x22, 0xc1, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x6a, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x42, 0x33, 0x37, 0x34, 0x39, 0x39, 0x43, 0x35, + 0x39, 0x32, 0x45, 0x44, 0x30, 0x30, 0x42, 0x33, 0x32, 0x35, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x42, 0x33, 0x37, 0x34, 0x39, 0x39, 0x43, 0x35, 0x39, 0x32, + 0x45, 0x44, 0x30, 0x30, 0x42, 0x33, 0x32, 0x35, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x14, 0x40, 0x28, 0x48, 0xaf, 0xc1, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x14, + 0x28, 0x28, 0x70, 0x00, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0x89, 0x04, + 0xf5, 0x65, 0xf1, 0xba, 0x7f, 0x0b, 0x29, 0x74, 0x99, 0xbb, 0x02, 0x8a, + 0x02, 0xea, 0x1a, 0x40, 0x36, 0x56, 0x84, 0x33, 0x48, 0x07, 0xb1, 0x14, + 0x58, 0x66, 0xb9, 0xe8, 0x6a, 0xbe, 0x7a, 0xed, 0x38, 0x31, 0xf4, 0x97, + 0xf9, 0x49, 0xb5, 0xf1, 0xa6, 0x3a, 0x24, 0xc8, 0x47, 0xf7, 0x7d, 0xf6, + 0xcf, 0xc5, 0x00, 0x43, 0xcc, 0x16, 0x66, 0x1d, 0x9d, 0xad, 0xf5, 0x13, + 0x95, 0x64, 0xc6, 0x6c, 0x74, 0xd4, 0x72, 0xdf, 0x78, 0x10, 0x1d, 0x78, + 0xc5, 0x2e, 0x08, 0x38, 0x68, 0xd7, 0x47, 0x46, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x3f, 0x34, 0x43, 0x9c, + 0xa4, 0x41, 0x3d, 0xd5, 0x16, 0x1a, 0x34, 0x73, 0xa7, 0x4c, 0x5b, 0x0e, + 0x1a, 0x10, 0xaa, 0xa4, 0x02, 0x95, 0x89, 0x94, 0x19, 0x83, 0x9f, 0x12, + 0xe5, 0x01, 0x2a, 0x5b, 0x04, 0xbc, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x22, + 0x22, 0xc1, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x43, 0x9d, 0x5d, 0x8c, 0xc8, 0x67, + 0x03, 0xec, 0xd5, 0xe5, 0x60, 0x5a, 0x57, 0x29, 0x78, 0xdb, 0x1a, 0x10, + 0xfd, 0x06, 0xda, 0x58, 0xfe, 0xa8, 0x55, 0x3d, 0xfd, 0x94, 0xf8, 0xe4, + 0x5f, 0xc3, 0x66, 0x32, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x22, 0x22, 0xc1, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x21, 0xed, 0x72, 0x8a, 0xbd, 0xd9, 0x02, 0x1e, + 0xcd, 0xe8, 0x26, 0xf1, 0x7a, 0x93, 0x38, 0xfc, 0x1a, 0x10, 0xdd, 0xf0, + 0xd9, 0x89, 0xa8, 0x38, 0x7e, 0xa9, 0xa1, 0xba, 0x83, 0xab, 0x1c, 0xcd, + 0x47, 0xbc, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x4d, 0x22, 0x22, 0xc1, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0xda, 0xc1, 0x10, 0x33, 0x14, 0x37, 0x44, 0x94, 0x92, 0x07, + 0xea, 0xf7, 0xcd, 0x9f, 0x34, 0x24, 0x1a, 0x10, 0xb0, 0xb3, 0x10, 0x7b, + 0xa7, 0xf3, 0x99, 0x2d, 0x9f, 0x68, 0x9f, 0x01, 0x95, 0x8c, 0x3f, 0x42, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x4d, 0x22, 0x22, 0xc1, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x18, 0x83, 0x96, 0xfa, 0x7f, 0xcb, 0x59, 0x29, 0xfa, 0xd6, 0x2b, 0xd3, + 0x2e, 0x4e, 0x40, 0x57, 0x1a, 0x10, 0xd2, 0xb0, 0x43, 0x77, 0xd3, 0x0f, + 0x54, 0x6f, 0x59, 0xe0, 0xeb, 0x56, 0x16, 0xc7, 0x51, 0x98, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0x4d, 0x22, 0x22, 0xc1, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x20, 0xaf, 0xc1, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_StreamingQuickStart_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x36, 0xea, 0xc3, 0x44, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x36, 0xea, 0xc3, 0x44, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x76, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x84, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x96, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x16, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x3a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x32, 0x46, 0x31, 0x33, 0x31, 0x32, 0x44, 0x36, + 0x37, 0x42, 0x31, 0x32, 0x45, 0x34, 0x31, 0x36, 0x32, 0x37, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x32, 0x46, 0x31, 0x33, 0x31, 0x32, 0x44, 0x36, 0x37, 0x42, + 0x31, 0x32, 0x45, 0x34, 0x31, 0x36, 0x32, 0x37, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0xdb, 0x44, 0xe5, 0x0a, 0xe8, 0x23, + 0xdd, 0x56, 0x96, 0x94, 0x38, 0x14, 0x40, 0x28, 0x48, 0xc3, 0xc1, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x14, + 0x28, 0x28, 0x70, 0x00, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0xa4, 0xc0, + 0x30, 0x2f, 0xfa, 0x45, 0x79, 0x36, 0x04, 0xe2, 0xe3, 0x8f, 0xe6, 0x06, + 0xe6, 0x47, 0x1a, 0x40, 0x9a, 0x49, 0xe7, 0xae, 0x7a, 0x1f, 0x35, 0x91, + 0xc7, 0x9b, 0x38, 0xfe, 0x99, 0xb8, 0x7b, 0x20, 0x62, 0x38, 0xcf, 0xf9, + 0xe7, 0x9c, 0xb9, 0xbd, 0xef, 0x21, 0x03, 0x18, 0x09, 0x39, 0xe3, 0x61, + 0xf0, 0x35, 0x95, 0xa1, 0x2c, 0x3a, 0x39, 0xbe, 0xf7, 0x0b, 0x17, 0x6a, + 0x4a, 0xa7, 0xc1, 0x6d, 0x84, 0xef, 0x37, 0x97, 0x91, 0x8f, 0x5f, 0x84, + 0xe8, 0xbd, 0xc4, 0xee, 0xcc, 0x66, 0x30, 0x4b, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x84, 0xdd, 0xb3, 0xe6, + 0x1f, 0x78, 0x56, 0x77, 0xa0, 0x19, 0x2a, 0x71, 0x46, 0xdf, 0x84, 0x40, + 0x1a, 0x10, 0x92, 0x75, 0x98, 0x04, 0xa8, 0x61, 0x96, 0xc1, 0xab, 0x68, + 0x5b, 0xba, 0x07, 0x56, 0xcc, 0x51, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x36, 0xea, + 0xc3, 0x44, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x2c, 0x7e, 0xd9, 0x48, 0x5c, 0x03, + 0x6c, 0x1b, 0x93, 0x2b, 0x77, 0xde, 0xea, 0x32, 0xc3, 0xae, 0x1a, 0x10, + 0x58, 0x58, 0x57, 0x36, 0xc6, 0x39, 0x72, 0xd7, 0x17, 0x9a, 0x02, 0x1c, + 0x0c, 0x53, 0x61, 0xd6, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x36, 0xea, 0xc3, 0x44, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0xc3, 0xa7, 0x4c, 0x56, 0xbd, 0x4b, 0xc1, 0x2a, + 0x88, 0x99, 0xaa, 0xa3, 0x86, 0x13, 0x20, 0xcc, 0x1a, 0x10, 0xbb, 0x08, + 0x16, 0x16, 0xed, 0xb7, 0x45, 0x7f, 0x4c, 0x28, 0x79, 0x52, 0xb7, 0x96, + 0x2e, 0xbb, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x36, 0xea, 0xc3, 0x44, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0x7f, 0x1a, 0xa2, 0xb8, 0x82, 0x3f, 0xcc, 0xac, 0x2c, 0xea, + 0x28, 0x35, 0x95, 0x0a, 0xa3, 0x06, 0x1a, 0x10, 0x07, 0xed, 0x73, 0x04, + 0xf4, 0x88, 0x06, 0xa2, 0x59, 0xcd, 0x54, 0x6f, 0xdc, 0x47, 0xf0, 0xca, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x36, 0xea, 0xc3, 0x44, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x09, 0x7e, 0x8d, 0x47, 0x1b, 0xc5, 0xa9, 0x96, 0xfa, 0x9e, 0xea, 0x0c, + 0xe0, 0x23, 0xc4, 0x70, 0x1a, 0x10, 0x8c, 0x53, 0x69, 0xf3, 0xe7, 0x84, + 0x04, 0xff, 0x39, 0x86, 0x88, 0xea, 0x3e, 0xe5, 0x3e, 0x56, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0x36, 0xea, 0xc3, 0x44, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x20, 0xc3, 0xc1, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenHardTwoHard_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x56, 0x23, 0x02, 0x1a, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x56, 0x23, 0x02, 0x1a, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x6a, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x32, 0x43, 0x43, 0x39, 0x41, 0x30, 0x34, 0x33, + 0x43, 0x30, 0x33, 0x35, 0x38, 0x32, 0x35, 0x32, 0x32, 0x39, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x32, 0x43, 0x43, 0x39, 0x41, 0x30, 0x34, 0x33, 0x43, 0x30, + 0x33, 0x35, 0x38, 0x32, 0x35, 0x32, 0x32, 0x39, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x64, 0x40, 0x32, 0x48, 0xd7, 0xc1, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x00, 0x78, 0x00, 0x1a, 0x56, 0x12, 0x10, 0x15, 0xf3, + 0xe7, 0xe3, 0x6f, 0x71, 0xea, 0xad, 0x55, 0x85, 0xaf, 0x56, 0x2e, 0x85, + 0x9b, 0x54, 0x1a, 0x40, 0x38, 0x88, 0x3b, 0x71, 0x96, 0xdb, 0x07, 0x65, + 0x19, 0x41, 0x3d, 0x65, 0x21, 0xfb, 0x9e, 0x2f, 0x8c, 0x88, 0x28, 0x12, + 0xb5, 0xec, 0x0a, 0xa5, 0x3b, 0xbb, 0x2a, 0x57, 0xb1, 0xbe, 0x23, 0x87, + 0xfa, 0xa1, 0x46, 0x0f, 0x30, 0xc6, 0x35, 0x75, 0x95, 0xda, 0x1e, 0x28, + 0x6d, 0x0d, 0xb3, 0x7a, 0xf7, 0xa0, 0xa7, 0xe2, 0xbd, 0x44, 0xdc, 0xfe, + 0x7d, 0x89, 0x7c, 0xc0, 0x35, 0x37, 0x73, 0x8c, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x08, 0xbc, 0x9e, 0x69, + 0xd9, 0x7d, 0x67, 0xc6, 0xef, 0x4f, 0xdb, 0x15, 0x16, 0x61, 0x54, 0xad, + 0x1a, 0x10, 0x49, 0x4f, 0xa1, 0xd8, 0x48, 0x2d, 0xa2, 0x6b, 0x61, 0xf8, + 0xb5, 0x87, 0xf9, 0x45, 0xae, 0xd3, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x56, 0x23, + 0x02, 0x1a, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0xf5, 0xbf, 0x0b, 0x71, 0xb4, 0x6f, + 0x95, 0xd0, 0x80, 0xb3, 0x67, 0x11, 0xbf, 0xeb, 0xf7, 0x42, 0x1a, 0x10, + 0x9d, 0x39, 0x72, 0xf2, 0x2b, 0xff, 0x24, 0xf8, 0x9a, 0xba, 0x8f, 0x4c, + 0xfd, 0x29, 0x51, 0x08, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x56, 0x23, 0x02, 0x1a, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x18, 0xa5, 0xf6, 0x05, 0x84, 0x99, 0x3f, 0x22, + 0x56, 0xbd, 0xcb, 0xa9, 0x2a, 0x97, 0xd4, 0x94, 0x1a, 0x10, 0x46, 0x52, + 0xc2, 0x42, 0x44, 0x60, 0xd8, 0xf6, 0x0b, 0xc4, 0x43, 0x7b, 0x18, 0xa2, + 0xf9, 0x44, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x56, 0x23, 0x02, 0x1a, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0xa1, 0x83, 0xb6, 0xf4, 0x39, 0x97, 0x95, 0x5c, 0x40, 0x22, + 0x35, 0x3f, 0xdf, 0x99, 0x22, 0xdb, 0x1a, 0x10, 0xdc, 0x95, 0x97, 0x74, + 0xe6, 0x5a, 0x9a, 0x61, 0x02, 0x55, 0x50, 0x00, 0xe4, 0xb1, 0x51, 0x77, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x56, 0x23, 0x02, 0x1a, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x98, 0xae, 0x15, 0x1a, 0x57, 0xc9, 0xac, 0x23, 0xc7, 0x67, 0xcd, 0xfb, + 0xda, 0x28, 0xbf, 0x88, 0x1a, 0x10, 0xdf, 0x0a, 0x94, 0x76, 0x84, 0xfb, + 0x0e, 0x71, 0x79, 0x64, 0x26, 0x06, 0xb4, 0xc8, 0x45, 0xee, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0x56, 0x23, 0x02, 0x1a, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x20, 0xd7, 0xc1, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenHardTwoHard_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x9a, 0xd0, 0x2f, 0x13, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x9a, 0xd0, 0x2f, 0x13, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x76, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x84, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x96, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x16, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x3a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x36, 0x42, 0x41, 0x41, 0x31, 0x30, 0x32, 0x41, + 0x37, 0x36, 0x42, 0x35, 0x36, 0x37, 0x43, 0x39, 0x32, 0x42, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x36, 0x42, 0x41, 0x41, 0x31, 0x30, 0x32, 0x41, 0x37, 0x36, + 0x42, 0x35, 0x36, 0x37, 0x43, 0x39, 0x32, 0x42, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x3f, 0xf5, 0x4f, 0xd4, 0xd5, 0x19, + 0x09, 0xfc, 0xdc, 0x16, 0x38, 0x64, 0x40, 0x32, 0x48, 0xef, 0xc1, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x00, 0x78, 0x00, 0x1a, 0x56, 0x12, 0x10, 0x9f, 0xc4, + 0x72, 0x05, 0x20, 0xaf, 0xc8, 0x26, 0x14, 0xdd, 0xb3, 0x9f, 0xd1, 0xb2, + 0x16, 0x82, 0x1a, 0x40, 0x03, 0x06, 0x1e, 0xd9, 0xb8, 0xea, 0x0c, 0x35, + 0x05, 0xb3, 0x52, 0x16, 0xbb, 0x8e, 0x9a, 0xf9, 0x1e, 0x92, 0xc5, 0xec, + 0x92, 0x50, 0xd7, 0x02, 0x9b, 0x4d, 0x9f, 0xe4, 0x0a, 0x3a, 0x52, 0xcd, + 0x79, 0x3f, 0xcb, 0xdd, 0xbb, 0xc3, 0x31, 0xd0, 0x9e, 0x4b, 0x9b, 0x50, + 0xf3, 0xef, 0xd5, 0xa5, 0xdd, 0x5c, 0x4a, 0x86, 0xb0, 0x78, 0x3d, 0xba, + 0x5f, 0xc3, 0xea, 0xff, 0x3e, 0xeb, 0x73, 0x70, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x5b, 0xcf, 0xf0, 0xf1, + 0xed, 0xdb, 0x1a, 0x55, 0xee, 0xa3, 0x38, 0x33, 0xc2, 0x93, 0xce, 0x0f, + 0x1a, 0x10, 0x98, 0x15, 0x11, 0x7b, 0x6a, 0x42, 0xd9, 0xe0, 0x95, 0xba, + 0xd0, 0xfe, 0x29, 0x38, 0x13, 0xe4, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xd0, + 0x2f, 0x13, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0xe7, 0x13, 0xcf, 0x46, 0x44, 0x78, + 0x6b, 0x2d, 0xe1, 0x9e, 0xa7, 0xd9, 0x01, 0x0d, 0x7f, 0x34, 0x1a, 0x10, + 0xb9, 0x1a, 0x52, 0xd4, 0xf1, 0x48, 0xdb, 0x57, 0x4f, 0x80, 0xe9, 0x3b, + 0x5e, 0xb6, 0x44, 0x61, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xd0, 0x2f, 0x13, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0xb0, 0x76, 0x8f, 0x65, 0x1d, 0x49, 0x85, 0x0c, + 0xbf, 0xb7, 0x72, 0x03, 0xf7, 0xe2, 0x4a, 0xe6, 0x1a, 0x10, 0xf6, 0xb6, + 0x98, 0x7d, 0xfb, 0x0c, 0xbb, 0x6b, 0xd5, 0x71, 0x33, 0xe2, 0x2c, 0x19, + 0x4f, 0x25, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x9a, 0xd0, 0x2f, 0x13, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0x06, 0x6a, 0x68, 0x67, 0xa6, 0x9f, 0xcb, 0x20, 0x38, 0x21, + 0x18, 0x47, 0xe5, 0xf8, 0x8c, 0x34, 0x1a, 0x10, 0x0c, 0x44, 0x65, 0x69, + 0xca, 0xe8, 0xb0, 0xb6, 0x25, 0xd6, 0x3f, 0xc2, 0x6e, 0x38, 0xe3, 0x52, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x9a, 0xd0, 0x2f, 0x13, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x13, 0xf1, 0x0f, 0x46, 0xb7, 0x72, 0x0c, 0x88, 0x22, 0x5a, 0xd8, 0xb3, + 0x88, 0xa0, 0x10, 0x31, 0x1a, 0x10, 0x36, 0x09, 0xd7, 0x5f, 0xf1, 0xd7, + 0x31, 0xe9, 0x2b, 0x2f, 0xf3, 0x8b, 0xdc, 0xc0, 0x91, 0x32, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0x9a, 0xd0, 0x2f, 0x13, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x20, 0xef, 0xc1, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenHardTwoSoft_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xf6, 0x1d, 0x0f, 0xd5, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xf6, 0x1d, 0x0f, 0xd5, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x6a, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x46, 0x46, 0x36, 0x34, 0x38, 0x36, 0x35, 0x35, + 0x38, 0x37, 0x41, 0x35, 0x30, 0x36, 0x32, 0x37, 0x32, 0x44, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x46, 0x46, 0x36, 0x34, 0x38, 0x36, 0x35, 0x35, 0x38, 0x37, + 0x41, 0x35, 0x30, 0x36, 0x32, 0x37, 0x32, 0x44, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x64, 0x40, 0x32, 0x48, 0x87, 0xc2, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x01, 0x78, 0x00, 0x1a, 0x56, 0x12, 0x10, 0xf9, 0x2f, + 0xc3, 0x8b, 0x4c, 0x85, 0xb4, 0xe4, 0x76, 0x03, 0x28, 0x1c, 0x20, 0x3d, + 0x78, 0x64, 0x1a, 0x40, 0x3c, 0x17, 0xfa, 0xf3, 0xf0, 0x71, 0x86, 0x26, + 0x95, 0x33, 0xa1, 0x13, 0x28, 0x9b, 0xab, 0x09, 0x83, 0xeb, 0x69, 0xfa, + 0x82, 0x45, 0xb2, 0xfb, 0xb5, 0x56, 0x3d, 0xc9, 0xb6, 0x65, 0xb6, 0x8b, + 0xec, 0x30, 0x31, 0x3d, 0x9a, 0xf5, 0xfd, 0x4d, 0x17, 0x05, 0x6e, 0x01, + 0x35, 0xc4, 0x12, 0xf7, 0xb3, 0xf0, 0x9c, 0xfd, 0xb4, 0x4d, 0x74, 0x46, + 0xb5, 0x69, 0xf9, 0x2f, 0xc0, 0xfc, 0xdb, 0x9e, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xe0, 0x77, 0x16, 0x54, + 0x87, 0x11, 0x51, 0x33, 0xf6, 0xc7, 0x9b, 0x7d, 0xfa, 0x66, 0xc4, 0x56, + 0x1a, 0x10, 0xf6, 0x3b, 0x5e, 0xf8, 0x2e, 0x1c, 0x20, 0xd8, 0x75, 0xb3, + 0x70, 0x61, 0xdb, 0x9b, 0x58, 0xcf, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x1d, + 0x0f, 0xd5, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x9e, 0x59, 0xe1, 0x64, 0x40, 0xca, + 0x5d, 0x11, 0xdd, 0xa8, 0xa1, 0x19, 0x1d, 0xe8, 0x72, 0xf4, 0x1a, 0x10, + 0x25, 0xbf, 0x22, 0x65, 0xac, 0x74, 0x7c, 0xbe, 0xd6, 0xe3, 0x2d, 0x84, + 0x78, 0x4e, 0x4e, 0x22, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x1d, 0x0f, 0xd5, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x97, 0x94, 0x6e, 0xd1, 0xcc, 0x8e, 0x4d, 0x80, + 0x3d, 0x69, 0x35, 0x7c, 0x90, 0x94, 0x5c, 0xd2, 0x1a, 0x10, 0xe3, 0xd8, + 0x24, 0x6a, 0xf5, 0xb7, 0xd8, 0x00, 0x51, 0x61, 0xe3, 0x0b, 0x8c, 0x08, + 0xd0, 0x0e, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x1d, 0x0f, 0xd5, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0xcc, 0xdc, 0xc4, 0x64, 0x09, 0x16, 0x22, 0x3e, 0xe1, 0xb8, + 0xf1, 0x7f, 0x50, 0x16, 0x99, 0xb2, 0x1a, 0x10, 0x4b, 0x02, 0xc7, 0x17, + 0x01, 0xa0, 0xfa, 0x88, 0x41, 0x05, 0x78, 0x4b, 0xc3, 0x0d, 0xfc, 0xd5, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0xf6, 0x1d, 0x0f, 0xd5, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x20, 0x37, 0xe4, 0x2e, 0x6f, 0x66, 0x91, 0xac, 0xdd, 0x74, 0x48, 0xb3, + 0xdf, 0xcb, 0x1c, 0x70, 0x1a, 0x10, 0x8b, 0x2f, 0x9d, 0x0c, 0x0c, 0x0f, + 0xa5, 0x51, 0xbf, 0x51, 0xec, 0x88, 0xb3, 0xa8, 0x3d, 0xda, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0xf6, 0x1d, 0x0f, 0xd5, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x20, 0x87, 0xc2, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenHardTwoSoft_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xc4, 0xa9, 0x47, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xc4, 0xa9, 0x47, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x76, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x84, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x96, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x16, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x3a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x34, 0x36, 0x37, 0x36, 0x36, 0x42, 0x32, 0x38, + 0x39, 0x31, 0x34, 0x38, 0x44, 0x45, 0x44, 0x32, 0x32, 0x46, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x34, 0x36, 0x37, 0x36, 0x36, 0x42, 0x32, 0x38, 0x39, 0x31, + 0x34, 0x38, 0x44, 0x45, 0x44, 0x32, 0x32, 0x46, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x7b, 0x52, 0xf2, 0x2f, 0x15, 0xec, + 0xfd, 0xcc, 0x8e, 0x9b, 0x38, 0x64, 0x40, 0x32, 0x48, 0x9f, 0xc2, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x01, 0x78, 0x00, 0x1a, 0x56, 0x12, 0x10, 0x58, 0xf9, + 0x4a, 0xd0, 0x7c, 0xe9, 0xa5, 0xd5, 0x7a, 0x9d, 0x3d, 0x90, 0x12, 0x20, + 0x39, 0x2b, 0x1a, 0x40, 0x6f, 0x9d, 0x0d, 0xa5, 0xe8, 0x72, 0xe4, 0xca, + 0x00, 0x00, 0x08, 0x38, 0xa6, 0xea, 0xfc, 0xd6, 0xf2, 0x52, 0x17, 0x41, + 0x27, 0x95, 0x9c, 0x6c, 0xfe, 0xdc, 0xe9, 0x93, 0xfb, 0xe9, 0xb9, 0xbe, + 0xc4, 0x8b, 0xef, 0xe7, 0xd9, 0xcc, 0x06, 0xbf, 0x7d, 0x7a, 0x50, 0x80, + 0xde, 0x53, 0x96, 0x96, 0xc2, 0xc2, 0x1b, 0xc6, 0xaa, 0x1c, 0x51, 0x4e, + 0xf2, 0x63, 0x8a, 0x04, 0xcb, 0xf1, 0x53, 0x2f, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xeb, 0xcb, 0x4d, 0xbc, + 0x6d, 0x2a, 0x94, 0x1f, 0x22, 0xb2, 0x2f, 0x43, 0xc5, 0xe4, 0x1b, 0xc4, + 0x1a, 0x10, 0x11, 0x8f, 0x18, 0x02, 0xda, 0x84, 0xf5, 0xbd, 0xce, 0xdf, + 0x92, 0x32, 0x25, 0x12, 0xa6, 0x47, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xa9, + 0x47, 0x06, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x03, 0xf9, 0x6d, 0xac, 0x2f, 0xaf, + 0x27, 0x52, 0x56, 0x92, 0xfc, 0x4d, 0x3d, 0x0a, 0x62, 0x37, 0x1a, 0x10, + 0x70, 0x8f, 0xfd, 0xcf, 0x92, 0xaa, 0x6e, 0xd5, 0x3b, 0x78, 0x1b, 0xa5, + 0xaa, 0x64, 0x0b, 0xf4, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xa9, 0x47, 0x06, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x8c, 0x20, 0xa7, 0x07, 0x4b, 0x79, 0x0c, 0x0c, + 0x8f, 0x39, 0x66, 0x24, 0x83, 0x4e, 0x1d, 0xc0, 0x1a, 0x10, 0xa4, 0xc3, + 0xd8, 0x42, 0x12, 0x91, 0xfc, 0x3f, 0xe8, 0x35, 0x8b, 0x09, 0xb9, 0x0f, + 0xa8, 0x8e, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xc4, 0xa9, 0x47, 0x06, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0x75, 0x61, 0x37, 0xb2, 0x1e, 0x97, 0x72, 0xad, 0x75, 0x9a, + 0x0a, 0x89, 0xb3, 0x99, 0x82, 0xb5, 0x1a, 0x10, 0x5a, 0xd3, 0xbc, 0x29, + 0xe8, 0x22, 0xfe, 0xb2, 0x42, 0xae, 0x64, 0x36, 0xe6, 0xff, 0xce, 0xcc, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0xc4, 0xa9, 0x47, 0x06, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x9e, 0xab, 0x8c, 0x29, 0x0a, 0xf7, 0xef, 0x4a, 0x12, 0x1f, 0xa0, 0x52, + 0x70, 0xc4, 0x92, 0x37, 0x1a, 0x10, 0x89, 0x8c, 0x27, 0x77, 0x59, 0x73, + 0x96, 0xd2, 0x54, 0x12, 0x34, 0xb5, 0x0c, 0x20, 0x79, 0xd1, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0xc4, 0xa9, 0x47, 0x06, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x20, 0x9f, 0xc2, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenSoftTwoHard_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xfe, 0x26, 0x49, 0x37, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xfe, 0x26, 0x49, 0x37, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x6a, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x35, 0x38, 0x42, 0x41, 0x46, 0x41, 0x39, 0x33, + 0x32, 0x35, 0x34, 0x37, 0x34, 0x42, 0x44, 0x34, 0x33, 0x31, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x35, 0x38, 0x42, 0x41, 0x46, 0x41, 0x39, 0x33, 0x32, 0x35, + 0x34, 0x37, 0x34, 0x42, 0x44, 0x34, 0x33, 0x31, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x64, 0x40, 0x32, 0x48, 0xb7, 0xc2, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x00, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0x31, 0x87, + 0x85, 0xa4, 0x3d, 0x8e, 0xf4, 0xff, 0xe6, 0x8c, 0xc9, 0xd0, 0x6e, 0x83, + 0xb3, 0x81, 0x1a, 0x40, 0xfc, 0xee, 0xb0, 0x11, 0x86, 0xec, 0xe2, 0x3b, + 0xdc, 0x68, 0x15, 0x4b, 0x61, 0xad, 0x78, 0xcb, 0xe6, 0x41, 0x7f, 0xdf, + 0x9e, 0xc7, 0xae, 0xdd, 0x46, 0x9c, 0xa4, 0x62, 0x97, 0x5b, 0xa9, 0xd5, + 0x79, 0x87, 0x82, 0x3e, 0x77, 0x51, 0x81, 0xc3, 0xe9, 0xa5, 0xd2, 0x00, + 0x4a, 0xb2, 0x8b, 0xbf, 0x00, 0x6d, 0x15, 0xde, 0x05, 0x79, 0xd9, 0x12, + 0xfc, 0x0b, 0x4c, 0x0f, 0xd4, 0x86, 0x79, 0x52, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xc2, 0xb7, 0x3a, 0x96, + 0x59, 0x22, 0x16, 0x94, 0xcd, 0x9c, 0xba, 0x5d, 0x3e, 0xe8, 0x14, 0xa3, + 0x1a, 0x10, 0x30, 0x06, 0x35, 0x2c, 0xd6, 0x34, 0x72, 0x7e, 0xc2, 0xd9, + 0x38, 0xad, 0xf3, 0xd4, 0x90, 0xf9, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x26, + 0x49, 0x37, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x03, 0x83, 0x49, 0xfa, 0xe8, 0xe0, + 0x8d, 0x4b, 0x38, 0x1f, 0x57, 0x55, 0x12, 0x84, 0x21, 0x83, 0x1a, 0x10, + 0xde, 0x57, 0x88, 0x7c, 0x41, 0xd4, 0x7f, 0xc9, 0xd3, 0x4c, 0x19, 0x9a, + 0x64, 0x38, 0x3d, 0xff, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x26, 0x49, 0x37, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0xf8, 0x96, 0xc8, 0x11, 0xcb, 0x0d, 0x92, 0x37, + 0x60, 0x9c, 0xb4, 0x19, 0x76, 0xd7, 0xf8, 0xcc, 0x1a, 0x10, 0xbd, 0x6d, + 0x48, 0xd8, 0xfc, 0x92, 0x0a, 0x30, 0x15, 0x69, 0x76, 0x68, 0x4b, 0x20, + 0xd7, 0xa0, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x26, 0x49, 0x37, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0x15, 0xd6, 0x7a, 0x12, 0x95, 0x00, 0x86, 0x6f, 0x5b, 0x2c, + 0xa8, 0x59, 0x9d, 0x50, 0xd9, 0x96, 0x1a, 0x10, 0x87, 0x6d, 0x38, 0x46, + 0x93, 0xf4, 0x32, 0xfc, 0x7e, 0xc2, 0x9b, 0x45, 0x88, 0x8e, 0x66, 0x9b, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x26, 0x49, 0x37, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x09, 0xc9, 0x2c, 0x7a, 0x9b, 0x09, 0x69, 0xbc, 0xbe, 0xd6, 0x93, 0xb6, + 0xaf, 0x5e, 0xf9, 0xdc, 0x1a, 0x10, 0x02, 0x1e, 0xcd, 0xc1, 0x2d, 0x83, + 0x57, 0xc8, 0xa2, 0xf4, 0xa3, 0xef, 0x74, 0x5b, 0xe8, 0xf7, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0xfe, 0x26, 0x49, 0x37, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x20, 0xb7, 0xc2, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenSoftTwoHard_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xd2, 0x89, 0x06, 0xc4, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xd2, 0x89, 0x06, 0xc4, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x76, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x84, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x96, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x16, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x3a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x41, 0x31, 0x36, 0x39, 0x38, 0x42, 0x38, 0x39, + 0x33, 0x38, 0x31, 0x32, 0x35, 0x41, 0x39, 0x38, 0x33, 0x33, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x41, 0x31, 0x36, 0x39, 0x38, 0x42, 0x38, 0x39, 0x33, 0x38, + 0x31, 0x32, 0x35, 0x41, 0x39, 0x38, 0x33, 0x33, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0xe7, 0xbd, 0x47, 0xad, 0xb1, 0x73, + 0xed, 0xa4, 0xc6, 0xa8, 0x38, 0x64, 0x40, 0x32, 0x48, 0xcf, 0xc2, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x00, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0xd9, 0xa9, + 0x20, 0xcc, 0xba, 0x89, 0xe3, 0x30, 0xe5, 0xce, 0xbb, 0x70, 0xd8, 0x7c, + 0x21, 0x5f, 0x1a, 0x40, 0x18, 0x7c, 0xa1, 0x8e, 0xdd, 0xb4, 0x7d, 0x7b, + 0x99, 0x23, 0xeb, 0x5e, 0x2c, 0xca, 0x52, 0xb4, 0xca, 0x65, 0x09, 0x24, + 0xfd, 0xd1, 0xc6, 0xc0, 0xeb, 0xdf, 0xf5, 0xc9, 0x88, 0xba, 0x8f, 0xb5, + 0x0d, 0xc2, 0x56, 0x79, 0x91, 0x67, 0x6d, 0x21, 0x90, 0x3c, 0x44, 0x06, + 0x58, 0x7a, 0x41, 0x5f, 0x55, 0xa4, 0x7d, 0x7b, 0xe9, 0x05, 0xa7, 0xcf, + 0xb3, 0x65, 0xa0, 0x6b, 0xfc, 0xe8, 0xf5, 0x1d, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xc6, 0x98, 0x5d, 0xa5, + 0xbb, 0xd0, 0x77, 0x6a, 0x39, 0x9a, 0x50, 0x00, 0xab, 0x14, 0xb7, 0x57, + 0x1a, 0x10, 0x24, 0xdf, 0xff, 0x03, 0x84, 0x08, 0xd5, 0xb5, 0x87, 0x42, + 0xba, 0x39, 0x01, 0x41, 0xdb, 0x71, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xd2, 0x89, + 0x06, 0xc4, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0xfa, 0xe4, 0x7c, 0x7b, 0x37, 0x24, + 0x86, 0x5d, 0x95, 0xb3, 0x9f, 0xb4, 0x71, 0x09, 0x79, 0xe9, 0x1a, 0x10, + 0x9a, 0x71, 0xad, 0x32, 0x77, 0x54, 0xe6, 0xef, 0x8b, 0xff, 0xc2, 0x71, + 0x6f, 0x2f, 0x56, 0xa7, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xd2, 0x89, 0x06, 0xc4, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x4b, 0x89, 0x87, 0xa2, 0x4e, 0xdb, 0x09, 0x15, + 0x50, 0xf6, 0x25, 0x77, 0x03, 0x6f, 0x93, 0x3a, 0x1a, 0x10, 0xd2, 0xfc, + 0xa8, 0x57, 0x6b, 0x1a, 0x89, 0x27, 0xfa, 0x0e, 0x89, 0x47, 0x36, 0xeb, + 0x0b, 0x80, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xd2, 0x89, 0x06, 0xc4, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0xfc, 0xa3, 0xcb, 0xe5, 0x15, 0x17, 0x2f, 0x1f, 0x97, 0x55, + 0xb4, 0x12, 0x6d, 0x66, 0x54, 0x5a, 0x1a, 0x10, 0x43, 0x0f, 0xc5, 0x31, + 0x04, 0xfb, 0xe1, 0x4c, 0x34, 0xb8, 0x8a, 0xc7, 0xa4, 0x13, 0xaf, 0x7c, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0xd2, 0x89, 0x06, 0xc4, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x3b, 0x44, 0x9c, 0xc4, 0x98, 0x68, 0x7b, 0x61, 0x45, 0xfa, 0x98, 0xd7, + 0xf4, 0x5b, 0xf5, 0x77, 0x1a, 0x10, 0x7e, 0xaa, 0x1e, 0x2a, 0x66, 0xc3, + 0x05, 0x57, 0x8c, 0xfa, 0x02, 0x61, 0xcf, 0x7c, 0x51, 0x55, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0xd2, 0x89, 0x06, 0xc4, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x20, 0xcf, 0xc2, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenSoftTwoSoft_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x1c, 0x3e, 0x57, 0x4f, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x1c, 0x3e, 0x57, 0x4f, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x6a, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x30, 0x43, 0x30, 0x39, 0x46, 0x34, 0x44, 0x31, + 0x39, 0x45, 0x33, 0x45, 0x34, 0x36, 0x35, 0x46, 0x33, 0x35, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x30, 0x43, 0x30, 0x39, 0x46, 0x34, 0x44, 0x31, 0x39, 0x45, + 0x33, 0x45, 0x34, 0x36, 0x35, 0x46, 0x33, 0x35, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x64, 0x40, 0x32, 0x48, 0xe7, 0xc2, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x01, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0x8c, 0xbd, + 0x57, 0x14, 0xce, 0xa1, 0x84, 0xe1, 0x5a, 0x43, 0xd1, 0xa0, 0x65, 0x14, + 0x75, 0xd3, 0x1a, 0x40, 0xcc, 0x1c, 0x2f, 0x5c, 0x2a, 0x6d, 0xc6, 0x2c, + 0xee, 0x18, 0x28, 0xf8, 0x77, 0x9c, 0x16, 0x5a, 0xaf, 0xb7, 0x5f, 0xbe, + 0x1a, 0x03, 0x75, 0x5e, 0x3f, 0x8e, 0x5a, 0x9a, 0xb7, 0xf2, 0x9f, 0x02, + 0xdd, 0x15, 0x5b, 0x49, 0x20, 0x5d, 0xf3, 0x24, 0x77, 0x3a, 0xb7, 0x7c, + 0x33, 0x04, 0x71, 0x2c, 0xdd, 0x8d, 0x9c, 0xd5, 0xf7, 0xd1, 0x83, 0x71, + 0x2f, 0x1c, 0xb9, 0xb1, 0xbb, 0x24, 0x3c, 0x34, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xdd, 0x68, 0xed, 0xce, + 0x2c, 0x16, 0x3e, 0x3e, 0xcb, 0x65, 0xe6, 0xb8, 0x08, 0x8e, 0x61, 0x24, + 0x1a, 0x10, 0x5e, 0x65, 0x9a, 0x2c, 0x17, 0xdc, 0x32, 0xab, 0x22, 0x88, + 0x21, 0xf4, 0x4e, 0x54, 0xa8, 0xd5, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x3e, + 0x57, 0x4f, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x70, 0x82, 0x5f, 0x81, 0x2f, 0xcc, + 0x93, 0x1d, 0x00, 0x12, 0xcc, 0x44, 0xfa, 0x48, 0xa0, 0xa1, 0x1a, 0x10, + 0x72, 0x99, 0xcc, 0x84, 0x28, 0x87, 0xf1, 0x7e, 0x35, 0x36, 0xe0, 0xff, + 0x5e, 0xbb, 0xee, 0xb7, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x3e, 0x57, 0x4f, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0xe1, 0xfc, 0x7a, 0x5e, 0xbd, 0x22, 0x50, 0xbf, + 0x07, 0xee, 0x70, 0xc9, 0x7f, 0x3f, 0xf8, 0xc2, 0x1a, 0x10, 0x1d, 0xa2, + 0xf1, 0x95, 0xb6, 0xcc, 0x3d, 0x7d, 0x1a, 0x65, 0xbb, 0x59, 0x38, 0x4a, + 0xe4, 0xc5, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x3e, 0x57, 0x4f, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0x9c, 0x12, 0xcc, 0x3f, 0x15, 0x47, 0x50, 0xa8, 0x71, 0x39, + 0xa0, 0x37, 0x4b, 0xf3, 0x2f, 0x59, 0x1a, 0x10, 0xec, 0x3f, 0x1a, 0x54, + 0x8f, 0x61, 0x53, 0xd3, 0xe3, 0x4f, 0x34, 0x54, 0xe7, 0xce, 0x22, 0x9a, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x1c, 0x3e, 0x57, 0x4f, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0xf2, 0x79, 0xb7, 0xb0, 0xde, 0x95, 0x7f, 0x69, 0x3a, 0x1b, 0xa5, 0xea, + 0x48, 0x02, 0x16, 0x31, 0x1a, 0x10, 0xca, 0x41, 0x02, 0xb9, 0xd0, 0xfe, + 0x14, 0xd0, 0x42, 0x71, 0xe0, 0x70, 0x9c, 0xa7, 0xdf, 0xa4, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0x1c, 0x3e, 0x57, 0x4f, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x20, 0xe7, 0xc2, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_SevenSoftTwoSoft_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x30, 0x9c, 0x5a, 0x82, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x30, 0x9c, 0x5a, 0x82, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x76, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x84, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x96, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x16, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x3a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x43, 0x36, 0x36, 0x39, 0x33, 0x44, 0x32, 0x37, + 0x38, 0x45, 0x41, 0x44, 0x30, 0x32, 0x45, 0x41, 0x33, 0x37, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x43, 0x36, 0x36, 0x39, 0x33, 0x44, 0x32, 0x37, 0x38, 0x45, + 0x41, 0x44, 0x30, 0x32, 0x45, 0x41, 0x33, 0x37, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x46, 0xd6, 0x38, 0x8a, 0xdf, 0x73, + 0x10, 0xbf, 0xac, 0x5a, 0x38, 0x64, 0x40, 0x32, 0x48, 0xff, 0xc2, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x64, + 0x28, 0x32, 0x70, 0x01, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0x5e, 0xe3, + 0x7d, 0x6b, 0x57, 0x70, 0x73, 0x9c, 0x18, 0xe1, 0x6e, 0x3e, 0x94, 0x01, + 0x83, 0xca, 0x1a, 0x40, 0xd1, 0xe1, 0x6e, 0xb2, 0x91, 0x4b, 0x1a, 0xbf, + 0x47, 0xc7, 0x5d, 0xec, 0xb7, 0x3e, 0x94, 0x16, 0xf9, 0xe3, 0x6f, 0x99, + 0x66, 0xdf, 0x98, 0x78, 0xba, 0xa5, 0xe6, 0x98, 0x5c, 0x0b, 0x54, 0x93, + 0xde, 0xf7, 0xe1, 0xd8, 0x2e, 0x53, 0x13, 0xab, 0x37, 0xb6, 0x41, 0x64, + 0x1e, 0x53, 0xa7, 0x0a, 0x13, 0xdd, 0xaa, 0x38, 0x3c, 0x8f, 0xa1, 0x34, + 0x88, 0xbe, 0x58, 0x31, 0xdb, 0x38, 0xff, 0x89, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x82, 0xd8, 0x6a, 0xbc, + 0x34, 0x29, 0x29, 0x2f, 0x8f, 0xab, 0x93, 0x9f, 0x6c, 0x33, 0x50, 0x04, + 0x1a, 0x10, 0xca, 0x58, 0x3d, 0xe3, 0xea, 0xa0, 0x22, 0xe7, 0x37, 0x08, + 0xe4, 0x04, 0xa0, 0x12, 0x48, 0xf8, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x30, 0x9c, + 0x5a, 0x82, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x86, 0x95, 0x9e, 0x70, 0x61, 0xda, + 0x81, 0x33, 0x84, 0x10, 0x52, 0x84, 0x2c, 0x6a, 0x53, 0x20, 0x1a, 0x10, + 0xb2, 0xbf, 0x01, 0x32, 0xab, 0x4b, 0x19, 0x0c, 0x68, 0x64, 0x90, 0x74, + 0x02, 0x68, 0x25, 0x99, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x30, 0x9c, 0x5a, 0x82, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x64, 0x2a, 0x1d, 0xda, 0xa7, 0x53, 0x90, 0x3c, + 0xab, 0x32, 0x75, 0xdf, 0xc9, 0xee, 0x26, 0xca, 0x1a, 0x10, 0x7a, 0xde, + 0xd9, 0x5e, 0xfa, 0x3b, 0xce, 0x97, 0x70, 0xaa, 0x13, 0x5a, 0x61, 0x30, + 0x55, 0xa7, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0x30, 0x9c, 0x5a, 0x82, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0xcd, 0x64, 0x0e, 0xee, 0x09, 0x94, 0xf8, 0xe2, 0xcb, 0x1b, + 0x96, 0x28, 0x40, 0xea, 0xb9, 0xcc, 0x1a, 0x10, 0x61, 0x7d, 0xbf, 0xb6, + 0x82, 0xfc, 0xfe, 0xb1, 0x9c, 0xc7, 0xe5, 0xc2, 0x43, 0x29, 0xd5, 0x01, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0x30, 0x9c, 0x5a, 0x82, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x92, 0x3a, 0xb1, 0x7b, 0x18, 0x74, 0xff, 0x88, 0x41, 0x20, 0x30, 0x50, + 0xf2, 0x6d, 0x4f, 0xa3, 0x1a, 0x10, 0x93, 0xfc, 0x85, 0x77, 0x13, 0x4f, + 0xee, 0x62, 0x22, 0xeb, 0x26, 0x59, 0xab, 0x32, 0xf7, 0x18, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0x30, 0x9c, 0x5a, 0x82, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x20, 0xff, 0xc2, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_LicenseWithRenewal_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x80, 0xbe, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x80, 0xbe, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x70, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xec, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x1a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x3e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x6c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x7e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xbe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x22, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x34, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x55, 0x0a, 0x20, 0x46, 0x31, 0x33, 0x37, 0x39, 0x37, 0x34, 0x31, + 0x37, 0x33, 0x32, 0x37, 0x43, 0x37, 0x34, 0x38, 0x33, 0x39, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x46, 0x31, 0x33, 0x37, 0x39, 0x37, 0x34, 0x31, 0x37, 0x33, + 0x32, 0x37, 0x43, 0x37, 0x34, 0x38, 0x33, 0x39, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0xb4, 0x01, 0x40, 0x00, 0x48, 0x97, 0xc3, + 0xb4, 0xb5, 0x06, 0x12, 0x13, 0x08, 0x01, 0x10, 0x00, 0x18, 0x01, 0x20, + 0xb4, 0x01, 0x28, 0x00, 0x38, 0x0a, 0x48, 0x0f, 0x70, 0x00, 0x78, 0x00, + 0x1a, 0x56, 0x12, 0x10, 0xc0, 0x43, 0xee, 0x21, 0x9d, 0xb0, 0x02, 0xe7, + 0x1b, 0xb3, 0x3a, 0xa1, 0x0b, 0x94, 0x8f, 0xeb, 0x1a, 0x40, 0x10, 0x6f, + 0xd3, 0x68, 0xe9, 0xc5, 0xf4, 0x77, 0xca, 0x66, 0xf4, 0x87, 0x47, 0x43, + 0x22, 0x66, 0x6b, 0x03, 0x88, 0x12, 0xe2, 0x4a, 0x26, 0x58, 0x99, 0xbf, + 0xf6, 0x76, 0x18, 0x87, 0xe9, 0x5d, 0xbd, 0x1f, 0xd2, 0xbe, 0xec, 0x98, + 0x81, 0xc5, 0x1c, 0x0c, 0xa9, 0x7d, 0xee, 0xa4, 0x86, 0x74, 0x7c, 0x9d, + 0xb2, 0x59, 0x44, 0xa1, 0x63, 0xa2, 0xc3, 0xcf, 0xf3, 0xdf, 0x03, 0xe0, + 0xb9, 0xed, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x10, 0x57, 0xc9, 0x3e, 0xc5, 0x48, 0x89, 0xfa, 0xe2, 0xfd, 0x96, + 0x83, 0xdd, 0xdf, 0xc5, 0xef, 0x36, 0x1a, 0x10, 0x73, 0x60, 0x45, 0x82, + 0x67, 0xb8, 0x92, 0xf9, 0x5d, 0x8e, 0x59, 0x33, 0xa6, 0xf9, 0x39, 0x67, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x19, 0x80, 0xbe, 0x39, 0xe1, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, + 0x11, 0x4b, 0xe8, 0x5f, 0x1b, 0x1d, 0x92, 0x60, 0xf6, 0xc6, 0xf4, 0xee, + 0xb3, 0x01, 0xd1, 0xee, 0x1a, 0x10, 0x80, 0x29, 0x82, 0xb9, 0xd1, 0x42, + 0xc2, 0x07, 0xfb, 0xf7, 0x86, 0x9c, 0x8a, 0xc9, 0x1d, 0xe5, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x19, 0x80, 0xbe, 0x39, 0xe1, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, 0x10, 0xc4, 0x63, + 0xca, 0x65, 0x10, 0x60, 0xf4, 0x50, 0x96, 0xf6, 0x4d, 0x2b, 0xb8, 0x8c, + 0x0b, 0x98, 0x1a, 0x10, 0x7e, 0x15, 0x6d, 0x5b, 0x0b, 0x97, 0x87, 0x26, + 0xa1, 0x29, 0x23, 0x01, 0x31, 0x97, 0x9f, 0x8c, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, + 0x80, 0xbe, 0x39, 0xe1, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0x42, 0xe6, 0x1d, 0x2b, + 0x1d, 0x73, 0x29, 0x86, 0x5c, 0x21, 0xcf, 0x04, 0x52, 0xfb, 0x41, 0x6c, + 0x1a, 0x10, 0xf0, 0x02, 0xfa, 0xb3, 0xb4, 0xf7, 0x43, 0x3d, 0xb8, 0x00, + 0x56, 0x04, 0xe1, 0xea, 0xfd, 0xa4, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0x80, 0xbe, + 0x39, 0xe1, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, + 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x16, 0x74, 0x55, 0x19, 0xf0, 0xde, + 0x59, 0xce, 0xee, 0x30, 0x2b, 0x83, 0x72, 0x1f, 0xa8, 0x42, 0x1a, 0x10, + 0x4b, 0x12, 0x29, 0x67, 0x53, 0x75, 0x83, 0xd0, 0xbd, 0xbd, 0xa4, 0xf4, + 0x9c, 0xf9, 0x70, 0x95, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0x80, 0xbe, 0x39, 0xe1, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x20, 0x97, 0xc3, 0xb4, 0xb5, 0x06, + 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_LicenseWithRenewal_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x82, 0xf6, 0x94, 0x9d, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x82, 0xf6, 0x94, 0x9d, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x7c, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x26, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x4a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x8a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x9c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xee, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x61, 0x0a, 0x20, 0x36, 0x31, 0x31, 0x42, 0x33, 0x41, 0x44, 0x38, + 0x34, 0x38, 0x32, 0x31, 0x34, 0x39, 0x39, 0x45, 0x33, 0x42, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x36, 0x31, 0x31, 0x42, 0x33, 0x41, 0x44, 0x38, 0x34, 0x38, + 0x32, 0x31, 0x34, 0x39, 0x39, 0x45, 0x33, 0x42, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0xe9, 0x80, 0xd5, 0x07, 0xcc, 0xa0, + 0x71, 0x63, 0x9a, 0x5e, 0x38, 0xb4, 0x01, 0x40, 0x00, 0x48, 0x8a, 0xc4, + 0xb4, 0xb5, 0x06, 0x12, 0x13, 0x08, 0x01, 0x10, 0x01, 0x18, 0x01, 0x20, + 0xb4, 0x01, 0x28, 0x00, 0x38, 0x0a, 0x48, 0x0f, 0x70, 0x00, 0x78, 0x00, + 0x1a, 0x56, 0x12, 0x10, 0xec, 0x49, 0x7e, 0x90, 0x3a, 0x42, 0xcb, 0xd1, + 0x7a, 0x73, 0x06, 0xc4, 0x72, 0x43, 0x56, 0x91, 0x1a, 0x40, 0x96, 0x32, + 0x82, 0xe3, 0x05, 0x42, 0xf9, 0xf4, 0x2f, 0xd5, 0x79, 0xb0, 0x52, 0x24, + 0x96, 0x06, 0x2c, 0x7c, 0x80, 0xb4, 0x12, 0xfb, 0x2b, 0x16, 0x3e, 0x6f, + 0xa5, 0x57, 0x95, 0x61, 0xf1, 0x99, 0xc3, 0xd8, 0x79, 0xb6, 0x6b, 0x9d, + 0xe4, 0x54, 0x9b, 0x8b, 0x94, 0xfc, 0xdc, 0x99, 0x02, 0x8e, 0xff, 0x52, + 0x9b, 0x16, 0x3d, 0x4f, 0x39, 0xa0, 0x4e, 0xfa, 0x09, 0xd4, 0xe5, 0x40, + 0xa3, 0x45, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x10, 0x0e, 0x35, 0x05, 0x2e, 0x76, 0x95, 0x32, 0x41, 0x9c, 0x5d, + 0x18, 0x1f, 0x7f, 0xae, 0x3b, 0x83, 0x1a, 0x10, 0x6e, 0x62, 0xb0, 0xf4, + 0x10, 0xbc, 0x18, 0x5b, 0x19, 0xf5, 0xd8, 0x37, 0x32, 0xfd, 0x70, 0x50, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x19, 0x82, 0xf6, 0x94, 0x9d, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, + 0x21, 0xeb, 0x75, 0x84, 0x5f, 0x33, 0xe9, 0x92, 0xc2, 0x29, 0x83, 0xc5, + 0x54, 0xda, 0x28, 0x1c, 0x1a, 0x10, 0xc9, 0x1d, 0xeb, 0xdc, 0x26, 0x77, + 0xc6, 0xd7, 0x44, 0xf9, 0x62, 0x8d, 0x4a, 0x4e, 0xa0, 0xc2, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x19, 0x82, 0xf6, 0x94, 0x9d, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, 0x10, 0xa8, 0x1e, + 0xd5, 0xa8, 0xec, 0xe6, 0xaa, 0x92, 0xec, 0x25, 0x56, 0x90, 0x2b, 0xbe, + 0xd0, 0x9f, 0x1a, 0x10, 0x04, 0x0a, 0x1f, 0x13, 0x11, 0x5b, 0xd7, 0xfe, + 0x5f, 0x39, 0xd3, 0x51, 0x97, 0x90, 0x81, 0xc6, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, + 0x82, 0xf6, 0x94, 0x9d, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0xe4, 0xc2, 0x8f, 0x85, + 0x55, 0xe7, 0xb8, 0x1d, 0xce, 0x89, 0x64, 0xc0, 0x2f, 0xa9, 0x5f, 0x80, + 0x1a, 0x10, 0x89, 0xd6, 0x99, 0x6c, 0x5e, 0x1b, 0xdd, 0xc2, 0x0c, 0x6d, + 0xdd, 0xb5, 0x7d, 0x94, 0x67, 0x45, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0x82, 0xf6, + 0x94, 0x9d, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, + 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x74, 0x3b, 0xf3, 0xcc, 0xfe, 0xec, + 0x56, 0xe1, 0xaa, 0x6c, 0x0c, 0xac, 0xf1, 0xdb, 0xf5, 0xb5, 0x1a, 0x10, + 0xae, 0xa6, 0x7b, 0x1c, 0xc9, 0xef, 0x7a, 0x1a, 0x62, 0x42, 0x8e, 0xc7, + 0xf4, 0xef, 0x3c, 0xd4, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0x82, 0xf6, 0x94, 0x9d, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x20, 0x8a, 0xc4, 0xb4, 0xb5, 0x06, + 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, + Both_CdmUseCase_LicenseWithRenewalPlayback_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xc4, 0xe2, 0xbc, 0x73, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xc4, 0xe2, 0xbc, 0x73, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x70, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xec, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x1a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x3e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x6c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x7e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xbe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x22, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x34, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x55, 0x0a, 0x20, 0x36, 0x44, 0x41, 0x43, 0x31, 0x36, 0x35, 0x45, + 0x41, 0x43, 0x45, 0x38, 0x43, 0x32, 0x35, 0x35, 0x33, 0x44, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x36, 0x44, 0x41, 0x43, 0x31, 0x36, 0x35, 0x45, 0x41, 0x43, + 0x45, 0x38, 0x43, 0x32, 0x35, 0x35, 0x33, 0x44, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x00, 0x40, 0xb4, 0x01, 0x48, 0xfd, 0xc4, + 0xb4, 0xb5, 0x06, 0x12, 0x13, 0x08, 0x01, 0x10, 0x00, 0x18, 0x01, 0x20, + 0x00, 0x28, 0xb4, 0x01, 0x38, 0x0a, 0x48, 0x0f, 0x70, 0x00, 0x78, 0x00, + 0x1a, 0x56, 0x12, 0x10, 0x0c, 0x52, 0xb7, 0x75, 0xe8, 0xd0, 0x65, 0x51, + 0x05, 0xb6, 0x63, 0x24, 0x92, 0x63, 0xfd, 0x42, 0x1a, 0x40, 0x8a, 0xdc, + 0x63, 0x37, 0x70, 0x46, 0x12, 0xf1, 0xae, 0xa4, 0xcc, 0xa4, 0xe3, 0x43, + 0x57, 0x03, 0x08, 0x53, 0x2c, 0xce, 0xc3, 0x7e, 0x54, 0xdd, 0x5f, 0xbd, + 0x97, 0xaf, 0x10, 0x2f, 0xe5, 0x3e, 0x8b, 0x15, 0xce, 0xd4, 0x1f, 0x41, + 0x60, 0xd9, 0x43, 0xab, 0x8e, 0x2a, 0xd0, 0xe0, 0xf0, 0x01, 0xf6, 0x21, + 0xd8, 0x2d, 0x52, 0xe6, 0x4a, 0xe5, 0x8b, 0x4f, 0xb4, 0x36, 0xdf, 0x9c, + 0x3f, 0xc2, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x10, 0x25, 0x2b, 0xe4, 0x29, 0xba, 0x1c, 0x00, 0x77, 0x7f, 0x1c, + 0xe9, 0x6e, 0x8a, 0xe5, 0x23, 0xbc, 0x1a, 0x10, 0xd7, 0x11, 0x41, 0x7d, + 0xf6, 0xae, 0x58, 0x85, 0x65, 0x3b, 0x5b, 0xc7, 0xb9, 0xf3, 0x2b, 0x13, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x19, 0xc4, 0xe2, 0xbc, 0x73, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, + 0x8c, 0x25, 0xe0, 0x1c, 0xe7, 0x6f, 0xcc, 0xd0, 0xdc, 0xe9, 0xa3, 0x8b, + 0x31, 0x28, 0x6b, 0x93, 0x1a, 0x10, 0xb0, 0x96, 0xa0, 0xb5, 0x68, 0xa0, + 0x78, 0xf6, 0xc5, 0x3d, 0xf4, 0xc6, 0x18, 0xd7, 0x47, 0x7a, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x19, 0xc4, 0xe2, 0xbc, 0x73, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, 0x10, 0x4e, 0x92, + 0xf4, 0xab, 0x16, 0x04, 0x9b, 0xc6, 0xaa, 0xcd, 0xe3, 0xcb, 0x4a, 0xab, + 0x3b, 0x15, 0x1a, 0x10, 0xb2, 0x56, 0xda, 0xdf, 0x49, 0x0c, 0x38, 0x62, + 0x57, 0xe3, 0x6c, 0x1f, 0x26, 0xd3, 0xdb, 0xdf, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, + 0xc4, 0xe2, 0xbc, 0x73, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0x76, 0xa9, 0x3a, 0x41, + 0x75, 0xf6, 0x9f, 0x31, 0xfe, 0x08, 0xea, 0x22, 0x2d, 0xa8, 0x79, 0xd8, + 0x1a, 0x10, 0xdf, 0x95, 0xc0, 0x68, 0xd6, 0x31, 0x96, 0xf1, 0x90, 0xf8, + 0x09, 0xcb, 0xef, 0x74, 0xac, 0xdd, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0xc4, 0xe2, + 0xbc, 0x73, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, + 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x6b, 0xe7, 0x26, 0xbe, 0xa6, 0x26, + 0x56, 0xae, 0x2d, 0x16, 0xa5, 0x42, 0x7f, 0xc1, 0xb1, 0x6d, 0x1a, 0x10, + 0x83, 0x11, 0xbe, 0x8e, 0x3c, 0xc1, 0xdc, 0xbf, 0x82, 0xd5, 0x93, 0x22, + 0xcb, 0xbe, 0x90, 0x78, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0xc4, 0xe2, 0xbc, 0x73, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x20, 0xfd, 0xc4, 0xb4, 0xb5, 0x06, + 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, + Both_CdmUseCase_LicenseWithRenewalPlayback_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x20, 0xe1, 0xd1, 0x5a, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x20, 0xe1, 0xd1, 0x5a, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x7c, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x26, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x4a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x8a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x9c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xee, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x61, 0x0a, 0x20, 0x43, 0x30, 0x37, 0x44, 0x32, 0x32, 0x31, 0x31, + 0x44, 0x33, 0x46, 0x36, 0x44, 0x45, 0x41, 0x34, 0x33, 0x46, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x43, 0x30, 0x37, 0x44, 0x32, 0x32, 0x31, 0x31, 0x44, 0x33, + 0x46, 0x36, 0x44, 0x45, 0x41, 0x34, 0x33, 0x46, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x1c, 0x0a, 0x82, 0x73, 0x51, 0x9b, + 0xaf, 0xbe, 0xf8, 0x2e, 0x38, 0x00, 0x40, 0xb4, 0x01, 0x48, 0xf0, 0xc5, + 0xb4, 0xb5, 0x06, 0x12, 0x13, 0x08, 0x01, 0x10, 0x01, 0x18, 0x01, 0x20, + 0x00, 0x28, 0xb4, 0x01, 0x38, 0x0a, 0x48, 0x0f, 0x70, 0x00, 0x78, 0x00, + 0x1a, 0x56, 0x12, 0x10, 0x94, 0x75, 0x90, 0x14, 0x5f, 0x70, 0xc3, 0x02, + 0x12, 0x84, 0x50, 0xaf, 0xfb, 0xab, 0xbd, 0x56, 0x1a, 0x40, 0x54, 0x42, + 0x79, 0x3f, 0xef, 0x70, 0x03, 0x29, 0x20, 0x91, 0x32, 0xc3, 0xb3, 0xb6, + 0x63, 0xc8, 0x58, 0x66, 0xe5, 0x34, 0x66, 0x1b, 0xe8, 0x1b, 0x09, 0x04, + 0xaa, 0x14, 0xd0, 0xdc, 0x0f, 0x50, 0xd1, 0xbc, 0x40, 0xcb, 0x84, 0xc5, + 0xff, 0x18, 0x97, 0x79, 0xa5, 0x20, 0xeb, 0x2c, 0xee, 0xd7, 0xc2, 0x59, + 0x7b, 0xf0, 0x91, 0x65, 0xf5, 0x19, 0x04, 0xe3, 0x2e, 0x96, 0x1c, 0xfe, + 0x5d, 0x51, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x10, 0x0d, 0x25, 0x91, 0x9d, 0x40, 0x22, 0x0c, 0x2c, 0xab, 0x86, + 0x69, 0x63, 0x6b, 0xb1, 0xd2, 0x48, 0x1a, 0x10, 0x89, 0xc6, 0xb0, 0x09, + 0x44, 0xc9, 0x0d, 0x49, 0x85, 0xd7, 0x78, 0x8a, 0x1e, 0xdd, 0x4f, 0x5c, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x19, 0x20, 0xe1, 0xd1, 0x5a, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, + 0xc9, 0x66, 0xa3, 0x8f, 0x29, 0x3b, 0x94, 0x9e, 0xc9, 0xcd, 0xd1, 0xf9, + 0x2c, 0x26, 0x7d, 0x81, 0x1a, 0x10, 0x0e, 0x74, 0x71, 0x12, 0x93, 0xf0, + 0x01, 0xd1, 0xa2, 0xe8, 0xb0, 0x50, 0xa9, 0xe1, 0xa5, 0x88, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x19, 0x20, 0xe1, 0xd1, 0x5a, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, 0x10, 0x10, 0xb0, + 0xfc, 0x76, 0x6b, 0x8f, 0xc8, 0x71, 0x0b, 0x31, 0x40, 0x8c, 0xb0, 0xb4, + 0x80, 0xd9, 0x1a, 0x10, 0x9d, 0xae, 0x96, 0xca, 0xdd, 0x36, 0x50, 0xf7, + 0x23, 0xf2, 0x60, 0x01, 0x03, 0x4d, 0xae, 0x5b, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, + 0x20, 0xe1, 0xd1, 0x5a, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0xf8, 0xcb, 0xd8, 0x67, + 0x27, 0x7c, 0xb9, 0x8e, 0x43, 0x67, 0xd5, 0x6f, 0x2d, 0xd2, 0x99, 0x88, + 0x1a, 0x10, 0xa5, 0xe1, 0x70, 0x1c, 0x19, 0xdf, 0xb7, 0x9a, 0xe9, 0xfe, + 0xcf, 0xb0, 0xa2, 0x25, 0x19, 0xcd, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0x20, 0xe1, + 0xd1, 0x5a, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, + 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x43, 0x95, 0xaf, 0x22, 0xd1, 0x9a, + 0x79, 0x6a, 0xd3, 0x18, 0x36, 0xca, 0xc1, 0x19, 0xed, 0x66, 0x1a, 0x10, + 0xc2, 0x1d, 0xe9, 0xdb, 0x76, 0x06, 0xdb, 0xf5, 0xd2, 0x68, 0xf2, 0xd0, + 0x68, 0xef, 0xbe, 0xed, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x19, 0x20, 0xe1, 0xd1, 0x5a, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x20, 0xf0, 0xc5, 0xb4, 0xb5, 0x06, + 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_LimitedDurationLicense_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x5b, 0xd8, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x5b, 0xd8, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x70, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xec, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x1a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x2c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x3e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x6c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x7e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x90, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xbe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x22, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x34, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x41, 0x34, 0x37, 0x32, 0x35, 0x30, 0x39, 0x30, + 0x36, 0x37, 0x37, 0x43, 0x45, 0x37, 0x37, 0x38, 0x34, 0x31, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x41, 0x34, 0x37, 0x32, 0x35, 0x30, 0x39, 0x30, 0x36, 0x37, + 0x37, 0x43, 0x45, 0x37, 0x37, 0x38, 0x34, 0x31, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x0f, 0x40, 0x3c, 0x48, 0xe3, 0xc6, 0xb4, + 0xb5, 0x06, 0x12, 0x14, 0x08, 0x01, 0x10, 0x00, 0x18, 0x01, 0x20, 0x0f, + 0x28, 0x3c, 0x38, 0x0f, 0x48, 0x05, 0x58, 0x01, 0x70, 0x00, 0x78, 0x01, + 0x1a, 0x56, 0x12, 0x10, 0x52, 0xe3, 0xf4, 0xe6, 0xc3, 0x44, 0x70, 0xcd, + 0x6b, 0x0f, 0x54, 0x67, 0xfe, 0x80, 0x76, 0xd7, 0x1a, 0x40, 0x79, 0x9d, + 0xb3, 0x1b, 0x7f, 0x58, 0x70, 0xa0, 0x7a, 0x05, 0x36, 0xf2, 0xd5, 0xe2, + 0x95, 0x2c, 0x8b, 0xac, 0x91, 0x95, 0x09, 0xb8, 0x26, 0xdc, 0xcb, 0xfe, + 0xbc, 0xef, 0x27, 0x71, 0x1a, 0x84, 0x4a, 0x30, 0x84, 0x7d, 0x8e, 0xdc, + 0xd9, 0x66, 0x12, 0x34, 0x32, 0x44, 0x25, 0xb3, 0x0c, 0xf2, 0x18, 0x27, + 0xea, 0x66, 0x00, 0x1b, 0xb3, 0x05, 0x95, 0x20, 0x34, 0x1d, 0x26, 0xe8, + 0xa0, 0xe1, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x10, 0x6e, 0xf6, 0xdf, 0xf8, 0x38, 0xbe, 0xb2, 0x96, 0x9c, 0xa3, + 0x65, 0xdf, 0xf1, 0xa2, 0x59, 0xce, 0x1a, 0x10, 0x14, 0x3a, 0x78, 0x2a, + 0x4c, 0x6a, 0x10, 0xb2, 0x51, 0x0b, 0x58, 0xe4, 0xb6, 0x8f, 0x1a, 0x58, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x14, 0x5b, 0xd8, 0x01, 0xfc, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, + 0x55, 0xe5, 0x52, 0xb1, 0x89, 0x2c, 0x3c, 0x7d, 0xef, 0x2e, 0x8e, 0x64, + 0x40, 0x6b, 0xd4, 0x42, 0x1a, 0x10, 0x78, 0x6f, 0xc3, 0x73, 0x1e, 0x12, + 0xdd, 0x30, 0x8d, 0x00, 0x2e, 0xf4, 0x19, 0xbe, 0x4b, 0x76, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x14, 0x5b, 0xd8, 0x01, 0xfc, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, 0x10, 0x85, 0x34, + 0xd8, 0xc1, 0x61, 0xe3, 0x0f, 0xd4, 0x2a, 0x5d, 0xc4, 0x74, 0x11, 0x08, + 0xf4, 0x45, 0x1a, 0x10, 0xc0, 0x4d, 0xbf, 0xd2, 0xac, 0xe2, 0x28, 0xd2, + 0x33, 0x37, 0x69, 0x7b, 0x6f, 0x49, 0x4d, 0x6c, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, + 0x5b, 0xd8, 0x01, 0xfc, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0x96, 0xe6, 0x6d, 0xd7, + 0xe7, 0xdb, 0x0b, 0xcf, 0x7b, 0x36, 0xdf, 0x0a, 0x30, 0xbe, 0x6c, 0xd6, + 0x1a, 0x10, 0x7d, 0xe6, 0x12, 0x91, 0x5b, 0x52, 0xcd, 0x78, 0x76, 0x37, + 0xde, 0xe2, 0xee, 0x78, 0x00, 0xc2, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0x5b, 0xd8, + 0x01, 0xfc, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, + 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x71, 0x01, 0xd1, 0xff, 0x79, 0xb9, + 0xc3, 0x2d, 0x12, 0x4a, 0x32, 0x93, 0x91, 0xa4, 0xe8, 0xd7, 0x1a, 0x10, + 0xea, 0xe0, 0xc8, 0x89, 0x42, 0x3e, 0x7d, 0x81, 0x24, 0x8e, 0x63, 0x81, + 0x28, 0x64, 0xf6, 0x7b, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0x5b, 0xd8, 0x01, 0xfc, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x20, 0xe3, 0xc6, 0xb4, 0xb5, 0x06, + 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_LimitedDurationLicense_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xda, 0xf8, 0x2b, 0x90, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xda, 0xf8, 0x2b, 0x90, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x7c, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x26, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x4a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x8a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x9c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xee, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x1c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x33, 0x39, 0x36, 0x34, 0x34, 0x45, 0x43, 0x41, + 0x36, 0x35, 0x45, 0x36, 0x37, 0x45, 0x44, 0x32, 0x34, 0x33, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x33, 0x39, 0x36, 0x34, 0x34, 0x45, 0x43, 0x41, 0x36, 0x35, + 0x45, 0x36, 0x37, 0x45, 0x44, 0x32, 0x34, 0x33, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0xdc, 0x17, 0x02, 0xd3, 0xa6, 0xd1, + 0xa4, 0x7f, 0xcb, 0x1d, 0x38, 0x0f, 0x40, 0x3c, 0x48, 0x84, 0xc7, 0xb4, + 0xb5, 0x06, 0x12, 0x14, 0x08, 0x01, 0x10, 0x01, 0x18, 0x01, 0x20, 0x0f, + 0x28, 0x3c, 0x38, 0x0f, 0x48, 0x05, 0x58, 0x01, 0x70, 0x00, 0x78, 0x01, + 0x1a, 0x56, 0x12, 0x10, 0x8d, 0x0b, 0xa4, 0x03, 0xc0, 0xde, 0xd4, 0x61, + 0xd6, 0x68, 0xb0, 0xae, 0xc2, 0x6a, 0x2a, 0x6b, 0x1a, 0x40, 0x8a, 0x9a, + 0xd7, 0x0f, 0xec, 0x45, 0x78, 0xb6, 0x5f, 0x65, 0x18, 0x64, 0x35, 0xb9, + 0x8f, 0xe2, 0xa7, 0x7e, 0x8f, 0xb3, 0x1c, 0xaf, 0xad, 0x48, 0x5e, 0xe9, + 0x7c, 0x15, 0x0e, 0x1c, 0xd1, 0xbe, 0x48, 0x47, 0xc7, 0x1e, 0xfa, 0xe7, + 0x5e, 0x45, 0xa9, 0x2b, 0xc9, 0x4f, 0x3b, 0x4a, 0x9e, 0xeb, 0x37, 0x8a, + 0x13, 0x76, 0x04, 0x49, 0x5f, 0xce, 0x08, 0x21, 0xa6, 0xbd, 0x34, 0x14, + 0x89, 0xc5, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x10, 0x08, 0x1f, 0x9e, 0x3f, 0xc8, 0x31, 0xd2, 0xcc, 0x02, 0x7a, + 0xb6, 0xf8, 0x06, 0x6b, 0xe5, 0xb3, 0x1a, 0x10, 0xc6, 0xc1, 0x21, 0x01, + 0x06, 0xa7, 0x10, 0x0b, 0x54, 0x71, 0x91, 0x84, 0xd2, 0xa8, 0x08, 0x44, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x14, 0xda, 0xf8, 0x2b, 0x90, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, + 0x37, 0xf2, 0xef, 0x04, 0xc8, 0x82, 0x22, 0x6e, 0xba, 0xec, 0x4d, 0x25, + 0xb4, 0x6e, 0x39, 0x2a, 0x1a, 0x10, 0x5f, 0x4c, 0x17, 0x73, 0x9d, 0x0b, + 0x6c, 0x4d, 0x67, 0x7a, 0xf9, 0x4b, 0xce, 0x50, 0x48, 0xed, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x14, 0xda, 0xf8, 0x2b, 0x90, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, 0x10, 0x28, 0x6e, + 0x4f, 0x94, 0x5f, 0x75, 0x26, 0x11, 0x20, 0x28, 0xe0, 0x42, 0xdc, 0xa9, + 0xa2, 0x68, 0x1a, 0x10, 0x5f, 0x6f, 0x05, 0xf5, 0x4e, 0x83, 0xcb, 0x60, + 0xe7, 0x9a, 0x3b, 0xad, 0x7e, 0x83, 0xb6, 0xeb, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, + 0xda, 0xf8, 0x2b, 0x90, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0xf6, 0x34, 0x39, 0x27, + 0x73, 0x3f, 0x72, 0xa5, 0x92, 0xf5, 0x49, 0x7e, 0x66, 0x35, 0xa2, 0xb7, + 0x1a, 0x10, 0x69, 0x0f, 0xc9, 0xea, 0x36, 0xec, 0xd7, 0x1b, 0x43, 0x83, + 0x3f, 0x23, 0x64, 0x66, 0x73, 0x5f, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0xda, 0xf8, + 0x2b, 0x90, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, + 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x47, 0x10, 0xc1, 0xb7, 0xda, 0x86, + 0xac, 0x15, 0x74, 0x9c, 0x9e, 0x31, 0x8b, 0x9a, 0xe6, 0x48, 0x1a, 0x10, + 0xf7, 0xa2, 0xa5, 0x65, 0x51, 0x57, 0x48, 0xb3, 0x8f, 0x35, 0x2e, 0x39, + 0xe3, 0x91, 0x2b, 0xe5, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0xda, 0xf8, 0x2b, 0x90, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x20, 0x84, 0xc7, 0xb4, 0xb5, 0x06, + 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_RenewOnLicenseLoad_Case1S_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x10, 0xea, 0x10, 0xdf, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x10, 0xea, 0x10, 0xdf, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x73, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xcb, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xef, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x1d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x2f, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x41, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x6f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x81, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x93, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc1, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd3, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe5, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x13, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x25, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x37, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x34, 0x38, 0x44, 0x32, 0x30, 0x36, 0x32, 0x46, + 0x43, 0x31, 0x37, 0x31, 0x39, 0x39, 0x31, 0x34, 0x34, 0x35, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x34, 0x38, 0x44, 0x32, 0x30, 0x36, 0x32, 0x46, 0x43, 0x31, + 0x37, 0x31, 0x39, 0x39, 0x31, 0x34, 0x34, 0x35, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x14, 0x40, 0x32, 0x48, 0xa5, 0xc7, 0xb4, + 0xb5, 0x06, 0x12, 0x17, 0x08, 0x01, 0x10, 0x00, 0x18, 0x01, 0x20, 0x14, + 0x28, 0x32, 0x38, 0x0f, 0x48, 0x05, 0x58, 0x01, 0x70, 0x00, 0x78, 0x01, + 0x90, 0x01, 0x02, 0x1a, 0x56, 0x12, 0x10, 0x4a, 0x0e, 0xde, 0x4f, 0x27, + 0x70, 0x76, 0xae, 0x64, 0x48, 0xd3, 0x93, 0x9e, 0x6f, 0x6c, 0x21, 0x1a, + 0x40, 0xe0, 0x17, 0xd7, 0x3e, 0xd5, 0x54, 0xe8, 0xdc, 0x92, 0xec, 0xbc, + 0x6f, 0x95, 0x77, 0xfb, 0x77, 0x29, 0x19, 0x8e, 0xb3, 0xe1, 0x37, 0xd3, + 0xb0, 0x05, 0x00, 0x7f, 0xb4, 0x2d, 0x01, 0x93, 0x9f, 0x89, 0x5a, 0xa6, + 0xde, 0xea, 0xce, 0x9a, 0xaa, 0x16, 0x08, 0xee, 0x79, 0x39, 0xad, 0x03, + 0x82, 0x2b, 0xb6, 0x79, 0xb5, 0xd8, 0x52, 0x5b, 0x33, 0x04, 0xd2, 0xcd, + 0x36, 0xb3, 0xff, 0x9a, 0x93, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x12, 0x10, 0xba, 0xcd, 0x6c, 0x66, 0x64, 0xd5, 0x6e, + 0xe3, 0x82, 0xcc, 0xf5, 0x4d, 0xa5, 0x04, 0xed, 0xac, 0x1a, 0x10, 0x41, + 0x3e, 0x00, 0x0c, 0xde, 0x73, 0x9f, 0x78, 0xe4, 0x2b, 0xc5, 0x6e, 0x8e, + 0xdf, 0x00, 0xaf, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, + 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0x10, 0xea, 0x10, 0xdf, 0x80, + 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x31, 0x12, 0x10, 0x0c, 0x9d, 0xca, 0x32, 0x37, 0x3d, 0xcc, 0xc1, 0x90, + 0x81, 0x0a, 0x93, 0x85, 0xb7, 0x62, 0x60, 0x1a, 0x10, 0x93, 0x9d, 0x64, + 0x4d, 0x5c, 0x31, 0xd3, 0xa6, 0x7c, 0x70, 0x1a, 0x55, 0xe8, 0xf0, 0x5e, + 0x8f, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, + 0x39, 0x00, 0x00, 0x00, 0x14, 0x10, 0xea, 0x10, 0xdf, 0x80, 0x00, 0x00, + 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, + 0x10, 0x65, 0x2b, 0xdf, 0x43, 0x47, 0x6e, 0xc8, 0x35, 0xee, 0xb8, 0xff, + 0xd8, 0xaa, 0x58, 0x3f, 0xd5, 0x1a, 0x10, 0xa8, 0x2f, 0xd3, 0xe8, 0xbf, + 0xa3, 0x1b, 0x64, 0xbf, 0x30, 0xb6, 0xd1, 0x1f, 0xb0, 0x37, 0xbe, 0x20, + 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, + 0x00, 0x00, 0x14, 0x10, 0xea, 0x10, 0xdf, 0x80, 0x00, 0x00, 0x08, 0x62, + 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0x63, + 0xdc, 0x18, 0x6b, 0x16, 0x3e, 0x34, 0x54, 0x38, 0x9a, 0x56, 0x84, 0x96, + 0x4c, 0xd7, 0xba, 0x1a, 0x10, 0xf9, 0x66, 0x8c, 0xbb, 0x61, 0xb1, 0x59, + 0x20, 0x0a, 0xe8, 0x80, 0xa8, 0xc8, 0xf3, 0x48, 0xa6, 0x20, 0x02, 0x28, + 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, + 0x14, 0x10, 0xea, 0x10, 0xdf, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, + 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x69, 0x91, 0x92, + 0x28, 0xce, 0xd3, 0x89, 0x7c, 0x1d, 0x27, 0x4f, 0x62, 0x5e, 0x05, 0x8f, + 0x68, 0x1a, 0x10, 0xe3, 0x15, 0x7f, 0xc3, 0x4c, 0x72, 0x5b, 0x39, 0x84, + 0x24, 0xd7, 0xa5, 0x0d, 0x3d, 0x3e, 0x8d, 0x20, 0x02, 0x28, 0x01, 0x42, + 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0x10, + 0xea, 0x10, 0xdf, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x20, 0xa5, 0xc7, + 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_RenewOnLicenseLoad_Case1S_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x59, 0x0d, 0xec, 0xb8, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x59, 0x0d, 0xec, 0xb8, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x7f, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe9, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xfb, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x13, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x29, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x3b, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x4d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x13, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x7b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x8d, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x9f, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x13, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xcd, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xdf, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xf1, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x13, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x1f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x31, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x43, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x13, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x39, 0x41, 0x30, 0x41, 0x43, 0x39, 0x32, 0x42, + 0x46, 0x43, 0x39, 0x42, 0x41, 0x45, 0x42, 0x31, 0x34, 0x37, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x39, 0x41, 0x30, 0x41, 0x43, 0x39, 0x32, 0x42, 0x46, 0x43, + 0x39, 0x42, 0x41, 0x45, 0x42, 0x31, 0x34, 0x37, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x2a, 0x7d, 0x15, 0x23, 0xfa, 0x6f, + 0xba, 0x6d, 0x86, 0x85, 0x38, 0x14, 0x40, 0x32, 0x48, 0xd0, 0xc7, 0xb4, + 0xb5, 0x06, 0x12, 0x17, 0x08, 0x01, 0x10, 0x01, 0x18, 0x01, 0x20, 0x14, + 0x28, 0x32, 0x38, 0x0f, 0x48, 0x05, 0x58, 0x01, 0x70, 0x00, 0x78, 0x01, + 0x90, 0x01, 0x02, 0x1a, 0x56, 0x12, 0x10, 0x19, 0x33, 0xec, 0xdd, 0xdc, + 0x97, 0xb9, 0xf2, 0x59, 0x30, 0x89, 0x8a, 0xff, 0x7f, 0xa0, 0x65, 0x1a, + 0x40, 0x1a, 0x1e, 0xc0, 0x59, 0x66, 0x08, 0x47, 0x01, 0x23, 0x88, 0xe0, + 0x0f, 0x54, 0xbb, 0x85, 0x93, 0xe5, 0x72, 0x9b, 0x73, 0x07, 0xf5, 0x97, + 0x65, 0x5d, 0x7c, 0x2f, 0x7f, 0x99, 0xd5, 0x23, 0x75, 0x9c, 0x40, 0x3e, + 0x54, 0xda, 0x77, 0x27, 0x1a, 0x31, 0x14, 0x29, 0x24, 0x10, 0xe0, 0xbc, + 0xa3, 0xf4, 0x08, 0x45, 0x8b, 0x66, 0x12, 0x13, 0xa5, 0x6b, 0x5b, 0xb1, + 0x43, 0x5d, 0xc8, 0x3c, 0x7e, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x12, 0x10, 0x68, 0x2c, 0x7e, 0xf3, 0x1c, 0x9f, 0xaf, + 0xde, 0xe9, 0xf1, 0xcf, 0xc4, 0xaa, 0xae, 0x8c, 0x2a, 0x1a, 0x10, 0x15, + 0xdb, 0x68, 0x48, 0x67, 0x00, 0x22, 0x14, 0xc8, 0xa8, 0xa2, 0x39, 0x03, + 0xb6, 0x8b, 0xbd, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, + 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0x59, 0x0d, 0xec, 0xb8, 0x80, + 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x31, 0x12, 0x10, 0x78, 0xb6, 0x5b, 0xe3, 0xf3, 0x08, 0xfb, 0x4a, 0x20, + 0x48, 0xc5, 0x9a, 0x7b, 0xd1, 0x57, 0x29, 0x1a, 0x10, 0x75, 0x1b, 0x8a, + 0x54, 0xfc, 0x92, 0xfd, 0xf1, 0x14, 0x37, 0x7b, 0xc6, 0xfc, 0x2d, 0x04, + 0x7c, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, + 0x39, 0x00, 0x00, 0x00, 0x14, 0x59, 0x0d, 0xec, 0xb8, 0x80, 0x00, 0x40, + 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x12, + 0x10, 0x4f, 0x9e, 0x2e, 0xce, 0x34, 0xb2, 0xd6, 0x03, 0x67, 0x0c, 0x69, + 0x98, 0xba, 0xd7, 0xde, 0x29, 0x1a, 0x10, 0x23, 0x20, 0x7c, 0xc5, 0x52, + 0xfc, 0x03, 0x07, 0x3c, 0x06, 0x08, 0xa3, 0x42, 0xa8, 0x29, 0x99, 0x20, + 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, + 0x00, 0x00, 0x14, 0x59, 0x0d, 0xec, 0xb8, 0x80, 0x00, 0x40, 0x00, 0x62, + 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, 0x8c, + 0x86, 0x44, 0x65, 0x76, 0xb3, 0x54, 0x7e, 0xd9, 0xb6, 0xf6, 0xc4, 0x3e, + 0x51, 0x5f, 0x0b, 0x1a, 0x10, 0x4f, 0x12, 0x5f, 0x62, 0x23, 0x79, 0x80, + 0xa8, 0x46, 0x50, 0xbe, 0x39, 0x14, 0x13, 0x9b, 0x5b, 0x20, 0x02, 0x28, + 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, + 0x14, 0x59, 0x0d, 0xec, 0xb8, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, + 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x9b, 0x62, 0x95, + 0x0f, 0x58, 0xd5, 0x45, 0x07, 0x16, 0xa2, 0x35, 0xcf, 0x86, 0xbc, 0x96, + 0x99, 0x1a, 0x10, 0x45, 0x7a, 0x20, 0xb0, 0xdd, 0x25, 0x31, 0x51, 0xd3, + 0x9c, 0x74, 0x18, 0x62, 0x1c, 0xa9, 0x76, 0x20, 0x02, 0x28, 0x01, 0x42, + 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x14, 0x59, + 0x0d, 0xec, 0xb8, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x20, 0xd0, 0xc7, + 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_Heartbeat_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x36, 0x8e, 0xf6, 0xeb, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x36, 0x8e, 0xf6, 0xeb, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x68, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x24, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x36, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x64, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x76, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb6, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xda, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x34, 0x42, 0x41, 0x34, 0x33, 0x42, 0x43, 0x38, + 0x35, 0x43, 0x44, 0x30, 0x39, 0x45, 0x37, 0x38, 0x35, 0x31, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x34, 0x42, 0x41, 0x34, 0x33, 0x42, 0x43, 0x38, 0x35, 0x43, + 0x44, 0x30, 0x39, 0x45, 0x37, 0x38, 0x35, 0x31, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0xa7, 0xc9, 0xb4, + 0xb5, 0x06, 0x12, 0x0c, 0x08, 0x01, 0x10, 0x00, 0x18, 0x01, 0x38, 0x1e, + 0x48, 0x0a, 0x50, 0x0a, 0x1a, 0x56, 0x12, 0x10, 0x9b, 0x97, 0x9b, 0x03, + 0x59, 0x32, 0x8d, 0x82, 0x69, 0x24, 0xbe, 0x1f, 0x7f, 0x71, 0x52, 0x6c, + 0x1a, 0x40, 0x6d, 0xfd, 0xdc, 0x0d, 0xd7, 0xd5, 0xdb, 0xeb, 0x02, 0x17, + 0xdc, 0xc1, 0xb3, 0x3f, 0xd7, 0x68, 0xe6, 0x4e, 0xb1, 0x97, 0x12, 0x0b, + 0x2f, 0xcd, 0x0c, 0xf8, 0x91, 0x01, 0xc2, 0xd5, 0x9b, 0xad, 0x56, 0x16, + 0x35, 0x23, 0x99, 0xca, 0xb2, 0x41, 0x2e, 0x15, 0xa3, 0x8f, 0x06, 0x5f, + 0xf3, 0xbb, 0xe7, 0x6f, 0xde, 0x9d, 0xb3, 0x6a, 0x8c, 0x52, 0xec, 0x7e, + 0x13, 0x52, 0x64, 0x3e, 0xf7, 0x44, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x73, 0xba, 0xef, 0xaa, 0x53, 0x8e, + 0x41, 0x94, 0x4e, 0x0a, 0x02, 0xff, 0xa9, 0xcd, 0xee, 0x0d, 0x1a, 0x10, + 0x0e, 0x60, 0x55, 0x73, 0x78, 0xf5, 0x1a, 0xb9, 0xf5, 0x5c, 0x4a, 0x9f, + 0xc9, 0xac, 0xcf, 0x52, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0x36, 0x8e, 0xf6, 0xeb, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x31, 0x12, 0x10, 0xbe, 0x2c, 0xb6, 0xb8, 0x69, 0xb5, 0x7f, 0x69, + 0x28, 0x98, 0x25, 0xdd, 0x63, 0x81, 0xa5, 0xec, 0x1a, 0x10, 0xe5, 0xd2, + 0x15, 0xaf, 0x8e, 0x54, 0xa7, 0x85, 0x34, 0x10, 0x1d, 0x1d, 0xca, 0xba, + 0xba, 0xa7, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0x36, 0x8e, 0xf6, 0xeb, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, + 0x12, 0x10, 0xa8, 0x10, 0xae, 0xc1, 0x39, 0xff, 0x86, 0x2a, 0x52, 0x1c, + 0x22, 0xd8, 0x89, 0x69, 0x6a, 0x90, 0x1a, 0x10, 0xe0, 0x0e, 0x29, 0x3d, + 0x1b, 0x89, 0xb5, 0x99, 0x8b, 0x12, 0x5a, 0x53, 0xbe, 0xda, 0xaa, 0xac, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x28, 0x36, 0x8e, 0xf6, 0xeb, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, + 0x0b, 0xa9, 0xe7, 0x7b, 0x84, 0x6a, 0xb3, 0xa7, 0x16, 0x36, 0x89, 0x26, + 0xd1, 0x4c, 0xbe, 0x23, 0x1a, 0x10, 0x94, 0x7e, 0xec, 0xe9, 0xee, 0x52, + 0xc3, 0x52, 0x71, 0x6a, 0x5b, 0x03, 0x3a, 0x9a, 0xc3, 0x1a, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x28, 0x36, 0x8e, 0xf6, 0xeb, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0xe3, 0x21, + 0xae, 0x0d, 0x39, 0x71, 0x20, 0x28, 0x56, 0x2e, 0xd6, 0xac, 0x5e, 0x54, + 0xbf, 0x6c, 0x1a, 0x10, 0xa0, 0x96, 0xf4, 0xc5, 0x6a, 0x72, 0x8f, 0x61, + 0x92, 0x25, 0xde, 0x0e, 0x39, 0xdf, 0xf6, 0xfe, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, + 0x36, 0x8e, 0xf6, 0xeb, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x20, 0xa7, + 0xc9, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_Heartbeat_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0x5a, 0xd4, 0x0a, 0x89, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0x5a, 0xd4, 0x0a, 0x89, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x74, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x1e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x30, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x42, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x70, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x82, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x94, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x34, 0x38, 0x42, 0x31, 0x33, 0x30, 0x39, 0x35, + 0x34, 0x38, 0x41, 0x41, 0x44, 0x34, 0x31, 0x33, 0x35, 0x33, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x34, 0x38, 0x42, 0x31, 0x33, 0x30, 0x39, 0x35, 0x34, 0x38, + 0x41, 0x41, 0x44, 0x34, 0x31, 0x33, 0x35, 0x33, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x65, 0xb2, 0xc5, 0xd5, 0x31, 0xb0, + 0x4b, 0x40, 0x53, 0x03, 0x38, 0x00, 0x40, 0x00, 0x48, 0x81, 0xca, 0xb4, + 0xb5, 0x06, 0x12, 0x0c, 0x08, 0x01, 0x10, 0x01, 0x18, 0x01, 0x38, 0x1e, + 0x48, 0x0a, 0x50, 0x0a, 0x1a, 0x56, 0x12, 0x10, 0xdc, 0xa7, 0x95, 0x72, + 0x7e, 0x4c, 0x6a, 0x6b, 0x02, 0x44, 0xc2, 0xab, 0xfe, 0xee, 0x56, 0x74, + 0x1a, 0x40, 0x38, 0x26, 0x6c, 0x26, 0x69, 0x31, 0x54, 0x65, 0xa4, 0xe2, + 0x5d, 0xe6, 0xb5, 0xfb, 0x69, 0x9b, 0x0f, 0x2e, 0x0a, 0xc2, 0xb7, 0xd0, + 0x21, 0x08, 0x28, 0x9e, 0xe4, 0x42, 0x7c, 0xb4, 0x4b, 0x24, 0xae, 0x84, + 0x2c, 0x62, 0xd0, 0xce, 0x28, 0xa4, 0x40, 0xf3, 0x62, 0xc3, 0x0d, 0xeb, + 0x35, 0xe4, 0xab, 0x0b, 0x97, 0xe3, 0x16, 0xa5, 0xda, 0x64, 0xbf, 0x21, + 0xce, 0xb3, 0xe8, 0xdd, 0x43, 0x90, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x0c, 0x98, 0x6a, 0x35, 0xe6, 0xb8, + 0xdb, 0x18, 0x14, 0xfb, 0x26, 0x0b, 0x1d, 0x47, 0xd2, 0x35, 0x1a, 0x10, + 0x4c, 0x84, 0x2f, 0x13, 0x00, 0x8b, 0x70, 0x5c, 0x2b, 0x7d, 0x68, 0xd4, + 0x71, 0x6c, 0xc3, 0x21, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0x5a, 0xd4, 0x0a, 0x89, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x31, 0x12, 0x10, 0x1d, 0x07, 0x1b, 0xb7, 0xba, 0xd4, 0x0e, 0xca, + 0xf2, 0xc7, 0xe6, 0xfb, 0x46, 0x55, 0x13, 0x9b, 0x1a, 0x10, 0x1a, 0x61, + 0xb0, 0x2e, 0x47, 0x6c, 0x3e, 0xa3, 0x80, 0x5e, 0x93, 0x39, 0xd0, 0x01, + 0x01, 0xa3, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0x5a, 0xd4, 0x0a, 0x89, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, + 0x12, 0x10, 0x0e, 0x34, 0x51, 0x46, 0x2d, 0x2a, 0xad, 0x20, 0xc2, 0x14, + 0x9b, 0xf8, 0x9a, 0xbb, 0x3e, 0x00, 0x1a, 0x10, 0xee, 0xac, 0x12, 0x83, + 0x2f, 0xbd, 0x11, 0x53, 0x34, 0x10, 0xfe, 0x1e, 0x22, 0x4b, 0x18, 0x76, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x28, 0x5a, 0xd4, 0x0a, 0x89, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, + 0x74, 0xdf, 0x6a, 0x22, 0x81, 0x54, 0x60, 0xd6, 0x42, 0x98, 0x04, 0x4f, + 0x18, 0x9e, 0xe1, 0xf6, 0x1a, 0x10, 0x5b, 0x97, 0xf5, 0xdd, 0x82, 0x7d, + 0x0e, 0x35, 0x78, 0x25, 0xc6, 0xdf, 0x81, 0xc8, 0xbe, 0x0c, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x28, 0x5a, 0xd4, 0x0a, 0x89, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x6e, 0x29, + 0x1a, 0x42, 0x88, 0x76, 0x3a, 0x70, 0x40, 0x3c, 0x6e, 0xf9, 0xee, 0x14, + 0x39, 0x3a, 0x1a, 0x10, 0x30, 0xb8, 0x4a, 0x77, 0x9f, 0xd0, 0x62, 0xe1, + 0x7c, 0xf9, 0xf2, 0x32, 0xbf, 0xa4, 0x9f, 0x21, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, + 0x5a, 0xd4, 0x0a, 0x89, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x20, 0x81, + 0xca, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_UnlimitedStreaming_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xbe, 0x2a, 0xe7, 0xb9, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xbe, 0x2a, 0xe7, 0xb9, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x6a, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x66, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x78, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x8a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xca, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xdc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1c, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x30, 0x42, 0x44, 0x39, 0x43, 0x37, 0x36, 0x45, + 0x31, 0x34, 0x36, 0x42, 0x38, 0x46, 0x35, 0x39, 0x35, 0x35, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x30, 0x42, 0x44, 0x39, 0x43, 0x37, 0x36, 0x45, 0x31, 0x34, + 0x36, 0x42, 0x38, 0x46, 0x35, 0x39, 0x35, 0x35, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0xdb, 0xca, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x00, + 0x28, 0x00, 0x70, 0x01, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0xde, 0x22, + 0xd9, 0x34, 0xc2, 0x42, 0x7c, 0xf6, 0x5a, 0xc9, 0xde, 0x6a, 0xc0, 0x40, + 0x19, 0xea, 0x1a, 0x40, 0xb7, 0x12, 0x6c, 0xd4, 0x15, 0x05, 0x1f, 0xa2, + 0x9c, 0xf1, 0x9e, 0xfe, 0x81, 0xb1, 0xbb, 0x0f, 0xba, 0x57, 0xd4, 0xdb, + 0x50, 0x66, 0xcd, 0x4b, 0xcb, 0xe1, 0xee, 0x18, 0x6f, 0x2e, 0x2c, 0x59, + 0xe5, 0x78, 0x4d, 0xe1, 0xec, 0x89, 0xc1, 0xab, 0xc5, 0x95, 0x19, 0x97, + 0x1b, 0xe9, 0x3a, 0xcc, 0xe0, 0x52, 0x9b, 0xb7, 0x09, 0x8a, 0x47, 0xb2, + 0x5f, 0xea, 0xf2, 0x06, 0xa8, 0xc4, 0xdd, 0x54, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xba, 0x1a, 0xbc, 0xfc, + 0xb9, 0x36, 0xcb, 0x44, 0x0a, 0x92, 0xb1, 0x52, 0x8d, 0x27, 0x51, 0x98, + 0x1a, 0x10, 0xcb, 0x86, 0x0e, 0x0f, 0x31, 0xe4, 0x5e, 0xab, 0xf0, 0xcd, + 0xa7, 0xbb, 0xae, 0x00, 0x8c, 0xb8, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x2a, + 0xe7, 0xb9, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0x80, 0x8b, 0x50, 0xab, 0xa4, 0x3a, + 0x58, 0x49, 0x5b, 0x69, 0x79, 0x85, 0x02, 0xad, 0x56, 0x59, 0x1a, 0x10, + 0x63, 0xfe, 0xe7, 0x13, 0xd8, 0x76, 0xa1, 0x15, 0x90, 0x4d, 0x34, 0x1a, + 0xc7, 0xea, 0x9d, 0x47, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x2a, 0xe7, 0xb9, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0xb7, 0x84, 0x92, 0xfc, 0x43, 0x74, 0x3f, 0x31, + 0x1f, 0x9e, 0x53, 0x72, 0x92, 0x15, 0xf1, 0x5f, 0x1a, 0x10, 0xfa, 0xac, + 0xe2, 0xc8, 0x5a, 0xee, 0xb9, 0x68, 0x3a, 0xf3, 0xa2, 0xe2, 0x47, 0xaa, + 0xe9, 0x46, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x2a, 0xe7, 0xb9, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0x0b, 0x63, 0x83, 0x87, 0xbb, 0xad, 0x30, 0xfc, 0x2b, 0x9b, + 0x75, 0x04, 0xfc, 0xb0, 0x2e, 0x78, 0x1a, 0x10, 0xb1, 0x44, 0xc6, 0x41, + 0xd8, 0x97, 0x11, 0x96, 0x76, 0xc5, 0x75, 0x8c, 0x57, 0xf5, 0x50, 0xa4, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0xbe, 0x2a, 0xe7, 0xb9, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0x3d, 0xf5, 0x9c, 0x44, 0xd9, 0x05, 0xb1, 0x07, 0xcf, 0x70, 0x6e, 0xad, + 0x81, 0xe8, 0xa6, 0x5c, 0x1a, 0x10, 0x8f, 0x67, 0x52, 0xfb, 0xaa, 0xca, + 0xf8, 0x21, 0x79, 0x7b, 0x79, 0xd0, 0x75, 0x44, 0x60, 0x0a, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0xbe, 0x2a, 0xe7, 0xb9, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x20, 0xdb, 0xca, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_UnlimitedStreaming_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xdf, 0x2f, 0xf2, 0x0f, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xdf, 0x2f, 0xf2, 0x0f, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x76, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x20, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x32, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x44, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x72, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x84, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x96, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc4, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x16, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x28, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x3a, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0a, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x41, 0x30, 0x34, 0x41, 0x35, 0x34, 0x35, 0x35, + 0x37, 0x46, 0x31, 0x44, 0x33, 0x45, 0x37, 0x36, 0x35, 0x37, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x41, 0x30, 0x34, 0x41, 0x35, 0x34, 0x35, 0x35, 0x37, 0x46, + 0x31, 0x44, 0x33, 0x45, 0x37, 0x36, 0x35, 0x37, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x22, 0x68, 0x2f, 0xc4, 0xb4, 0x15, + 0xfc, 0xb6, 0xc2, 0xcf, 0x38, 0x00, 0x40, 0x00, 0x48, 0xe9, 0xca, 0xb4, + 0xb5, 0x06, 0x12, 0x0e, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x00, + 0x28, 0x00, 0x70, 0x01, 0x78, 0x01, 0x1a, 0x56, 0x12, 0x10, 0x5d, 0x88, + 0x80, 0x98, 0xed, 0xee, 0xfd, 0x3e, 0xdb, 0x1d, 0xb5, 0xf8, 0x5c, 0x57, + 0x2a, 0x10, 0x1a, 0x40, 0xb8, 0x34, 0x58, 0xcb, 0xdf, 0xe1, 0xd3, 0xb3, + 0xba, 0x7c, 0x79, 0xd7, 0xb1, 0x97, 0xd7, 0x2e, 0x92, 0xe0, 0x59, 0x7b, + 0xdf, 0xeb, 0xd0, 0x77, 0xdc, 0xa4, 0x99, 0xc3, 0xb4, 0x08, 0x4b, 0xa7, + 0xcd, 0x07, 0x13, 0x57, 0xad, 0xc0, 0x62, 0xa6, 0x1a, 0xdb, 0x3c, 0x12, + 0xdd, 0xe4, 0x26, 0x3d, 0x97, 0x84, 0xb7, 0x9d, 0x86, 0x97, 0x5e, 0x70, + 0x5b, 0xcd, 0x0d, 0x82, 0xe0, 0x67, 0xa2, 0xe1, 0x20, 0x01, 0x1a, 0x50, + 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x99, 0x32, 0xbf, 0xea, + 0x06, 0x43, 0xaa, 0x24, 0xb1, 0xfa, 0x28, 0x77, 0x97, 0xe1, 0x8c, 0x3e, + 0x1a, 0x10, 0xfc, 0xa8, 0x97, 0xae, 0x0e, 0x76, 0xe3, 0x67, 0x41, 0x78, + 0x6b, 0xd2, 0xbd, 0x49, 0x00, 0x05, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, + 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xdf, 0x2f, + 0xf2, 0x0f, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x31, 0x12, 0x10, 0xdd, 0x51, 0x4d, 0x68, 0x64, 0x7f, + 0x4f, 0x5d, 0x74, 0x1a, 0x1a, 0xba, 0x5b, 0xac, 0xfe, 0xd1, 0x1a, 0x10, + 0x99, 0xa9, 0x87, 0x15, 0x06, 0x2b, 0x21, 0x47, 0x89, 0xff, 0xc2, 0xb0, + 0x8d, 0xea, 0xf8, 0xc0, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xdf, 0x2f, 0xf2, 0x0f, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x32, 0x12, 0x10, 0x23, 0x0d, 0x5c, 0xc1, 0x0a, 0x1b, 0xca, 0x5e, + 0xe4, 0x43, 0x21, 0x03, 0x59, 0x49, 0x4f, 0x26, 0x1a, 0x10, 0xfc, 0x1e, + 0x2f, 0x37, 0x49, 0x47, 0x61, 0xad, 0xf4, 0x07, 0x17, 0x63, 0x9c, 0x6a, + 0x32, 0x14, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x00, 0xdf, 0x2f, 0xf2, 0x0f, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, + 0x12, 0x10, 0x48, 0xf8, 0x47, 0x8a, 0x2c, 0x25, 0xb1, 0xae, 0xfe, 0x09, + 0xf2, 0x0e, 0x6b, 0xba, 0x49, 0xe0, 0x1a, 0x10, 0xf7, 0xab, 0xba, 0x72, + 0x6f, 0x6d, 0x57, 0x14, 0xea, 0xf0, 0xfb, 0x42, 0x34, 0x94, 0x37, 0xbf, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x00, 0xdf, 0x2f, 0xf2, 0x0f, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, + 0xca, 0x67, 0xf2, 0xdb, 0x83, 0xda, 0x77, 0x88, 0xf9, 0xf1, 0xda, 0x74, + 0xfc, 0x5b, 0xb7, 0xcc, 0x1a, 0x10, 0x67, 0x74, 0xf1, 0xfe, 0x3a, 0x10, + 0xe6, 0xfa, 0x78, 0xb7, 0x14, 0x0a, 0x79, 0x10, 0xba, 0x7e, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x00, 0xdf, 0x2f, 0xf2, 0x0f, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x20, 0xe9, 0xca, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_LicenseDuration_Case1_0) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xa4, 0xc5, 0xcc, 0x71, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xa4, 0xc5, 0xcc, 0x71, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x68, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xe4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x24, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x36, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x64, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x76, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x88, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xb6, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xc8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xda, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x1a, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x2c, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x42, 0x46, 0x44, 0x36, 0x34, 0x31, 0x30, 0x45, + 0x31, 0x33, 0x39, 0x39, 0x32, 0x45, 0x39, 0x36, 0x35, 0x39, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x42, 0x46, 0x44, 0x36, 0x34, 0x31, 0x30, 0x45, 0x31, 0x33, + 0x39, 0x39, 0x32, 0x45, 0x39, 0x36, 0x35, 0x39, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x00, 0x38, 0x00, 0x40, 0x00, 0x48, 0xf7, 0xca, 0xb4, + 0xb5, 0x06, 0x12, 0x0c, 0x08, 0x01, 0x10, 0x00, 0x18, 0x00, 0x20, 0x28, + 0x28, 0x28, 0x30, 0x28, 0x1a, 0x56, 0x12, 0x10, 0x53, 0xb4, 0x9c, 0x68, + 0x8e, 0x2e, 0xb8, 0xdf, 0x3c, 0xb4, 0xdd, 0x5a, 0x16, 0x9a, 0x4c, 0x16, + 0x1a, 0x40, 0x7b, 0xc7, 0xd9, 0x32, 0x40, 0x87, 0x3c, 0xa8, 0x81, 0x2d, + 0xe1, 0x22, 0x86, 0x47, 0xf0, 0xc9, 0x1d, 0x32, 0xdd, 0x3b, 0xa5, 0x50, + 0x93, 0xf5, 0x37, 0x89, 0xae, 0xe6, 0x2b, 0x1c, 0x34, 0xba, 0xb8, 0x6c, + 0xcf, 0xf8, 0x67, 0x10, 0xee, 0xf3, 0xe0, 0xad, 0xf5, 0x92, 0xd1, 0x09, + 0x34, 0x5d, 0xb0, 0xfb, 0x92, 0x46, 0xd2, 0x83, 0x29, 0xe8, 0xb1, 0x84, + 0x92, 0x41, 0xa9, 0x4b, 0x0d, 0xb4, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0x4e, 0x26, 0xf3, 0x93, 0x3a, 0x77, + 0x43, 0x65, 0xcf, 0xdf, 0xf4, 0x20, 0xec, 0xda, 0xff, 0x87, 0x1a, 0x10, + 0x86, 0x39, 0xc3, 0x26, 0xd6, 0xf7, 0x2c, 0x68, 0x4e, 0xc0, 0x75, 0x6a, + 0xcf, 0xf3, 0xf2, 0x7e, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0xa4, 0xc5, 0xcc, 0x71, + 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x31, 0x12, 0x10, 0x78, 0x79, 0x14, 0x68, 0x5c, 0xb0, 0xd1, 0x92, + 0xeb, 0x2c, 0xb4, 0x36, 0x3f, 0xf5, 0xb1, 0xc9, 0x1a, 0x10, 0xb6, 0x5d, + 0x0e, 0xcc, 0xc6, 0x1d, 0x92, 0xeb, 0x39, 0x1a, 0x21, 0xb4, 0x4b, 0x09, + 0x6b, 0xcd, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0xa4, 0xc5, 0xcc, 0x71, 0x80, 0x00, + 0x00, 0x08, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, + 0x12, 0x10, 0x00, 0x37, 0xab, 0x7a, 0xf8, 0xe3, 0xb1, 0x28, 0x7a, 0x0e, + 0x0e, 0x7e, 0x43, 0x0e, 0x0e, 0x25, 0x1a, 0x10, 0x50, 0x57, 0x27, 0x9b, + 0x86, 0xb6, 0xb5, 0x04, 0x4e, 0x44, 0x70, 0x74, 0xb0, 0xc7, 0xf5, 0xc3, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x28, 0xa4, 0xc5, 0xcc, 0x71, 0x80, 0x00, 0x00, 0x08, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, + 0xc4, 0x70, 0x38, 0xbf, 0x43, 0x20, 0xb2, 0x4f, 0x51, 0x3c, 0x57, 0xc2, + 0xa1, 0x03, 0x7c, 0x64, 0x1a, 0x10, 0x2d, 0xb1, 0x51, 0xb8, 0x27, 0xd5, + 0x63, 0xae, 0xb5, 0xbe, 0xa9, 0x9e, 0xa0, 0xf7, 0x90, 0x3b, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x28, 0xa4, 0xc5, 0xcc, 0x71, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x7c, 0x96, + 0xe4, 0xb2, 0x5c, 0x6b, 0x96, 0x5b, 0x80, 0xa4, 0x4f, 0x48, 0x27, 0x01, + 0x6f, 0x78, 0x1a, 0x10, 0xa8, 0x60, 0xe7, 0x0d, 0xb0, 0x84, 0x01, 0x18, + 0x0f, 0x83, 0x81, 0x20, 0xe2, 0x97, 0xd9, 0xbf, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, + 0xa4, 0xc5, 0xcc, 0x71, 0x80, 0x00, 0x00, 0x08, 0x62, 0x00, 0x20, 0xf7, + 0xca, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +TEST_F(ODKGoldenLicenseV19, Both_CdmUseCase_LicenseDuration_Case1_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x02, 0x00, 0x13, + 0xb7, 0x10, 0xd9, 0xef, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x39, 0x00, 0x02, 0x00, 0x13, + 0xb7, 0x10, 0xd9, 0xef, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x74, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xf0, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x1e, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x30, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x42, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0x70, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0x82, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x94, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x01, 0xd4, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, + 0xe6, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, + 0x14, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x26, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x02, 0x38, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, + 0x10, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t serialized_license_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x35, 0x32, 0x33, 0x35, 0x46, 0x39, 0x39, 0x41, + 0x41, 0x33, 0x36, 0x42, 0x35, 0x38, 0x36, 0x33, 0x35, 0x42, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x35, 0x32, 0x33, 0x35, 0x46, 0x39, 0x39, 0x41, 0x41, 0x33, + 0x36, 0x42, 0x35, 0x38, 0x36, 0x33, 0x35, 0x42, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x00, 0x32, 0x0a, 0x9b, 0x5d, 0xc8, 0x1d, 0xc3, 0x0a, + 0x07, 0xde, 0x22, 0x03, 0x38, 0x00, 0x40, 0x00, 0x48, 0x9d, 0xcb, 0xb4, + 0xb5, 0x06, 0x12, 0x0c, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x20, 0x28, + 0x28, 0x28, 0x30, 0x28, 0x1a, 0x56, 0x12, 0x10, 0x31, 0x8c, 0xe7, 0xac, + 0x98, 0x40, 0xd2, 0xf0, 0x67, 0xa9, 0xbe, 0x59, 0x32, 0x07, 0x97, 0xcd, + 0x1a, 0x40, 0x10, 0xba, 0xd8, 0x65, 0xb8, 0x95, 0x28, 0x0e, 0x6d, 0x9b, + 0x8a, 0x20, 0x11, 0xd3, 0x6c, 0x28, 0x36, 0xc4, 0xa1, 0xcb, 0x8f, 0x2e, + 0xbe, 0x83, 0xe3, 0x44, 0x7f, 0xf5, 0x5e, 0x5e, 0xd2, 0xf3, 0xac, 0x7d, + 0x4b, 0x75, 0x71, 0x79, 0xdc, 0x28, 0x1e, 0x73, 0x0f, 0x12, 0x98, 0xf9, + 0x9a, 0xf7, 0xeb, 0x09, 0xe9, 0xef, 0x31, 0x7c, 0x9b, 0x01, 0x35, 0x9b, + 0xa6, 0x5d, 0x18, 0x9b, 0x13, 0xd9, 0x20, 0x01, 0x1a, 0x50, 0x0a, 0x10, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x12, 0x10, 0xcc, 0xd7, 0x53, 0xef, 0x49, 0x29, + 0xfb, 0x4d, 0xbb, 0x3c, 0x83, 0x6b, 0x5b, 0x4f, 0x5a, 0x02, 0x1a, 0x10, + 0x51, 0xe1, 0x62, 0xca, 0xc9, 0x75, 0x20, 0x53, 0xc4, 0x8f, 0xf5, 0x13, + 0x6c, 0x20, 0x3f, 0x2a, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, + 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0xb7, 0x10, 0xd9, 0xef, + 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x31, 0x12, 0x10, 0x2e, 0x9a, 0xa5, 0x16, 0x41, 0xf7, 0xd5, 0xd2, + 0x36, 0x1a, 0xc2, 0x1d, 0x6f, 0x6c, 0xd7, 0x4f, 0x1a, 0x10, 0x37, 0x91, + 0x47, 0xd6, 0x05, 0xda, 0x36, 0xe6, 0x3e, 0xa1, 0xf2, 0x3c, 0x04, 0x1e, + 0x0c, 0xe6, 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, + 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, 0xb7, 0x10, 0xd9, 0xef, 0x80, 0x00, + 0x40, 0x00, 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, + 0x12, 0x10, 0x62, 0xef, 0x5e, 0x71, 0x5a, 0x87, 0x2a, 0xbf, 0xb0, 0xd0, + 0xed, 0x72, 0x80, 0xbe, 0x4c, 0x35, 0x1a, 0x10, 0xa8, 0xac, 0x08, 0x1b, + 0x97, 0x77, 0x91, 0x99, 0xd5, 0x6f, 0x69, 0xf0, 0x74, 0xed, 0xde, 0xd2, + 0x20, 0x02, 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, + 0x00, 0x00, 0x00, 0x28, 0xb7, 0x10, 0xd9, 0xef, 0x80, 0x00, 0x40, 0x00, + 0x62, 0x00, 0x1a, 0x50, 0x0a, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33, 0x12, 0x10, + 0xbf, 0x6c, 0x24, 0x85, 0xdc, 0xb6, 0x00, 0xf1, 0x93, 0x4e, 0x68, 0xcf, + 0x46, 0x82, 0x73, 0xb6, 0x1a, 0x10, 0x19, 0x62, 0xcb, 0x13, 0x1b, 0xae, + 0xb2, 0x99, 0xdf, 0x32, 0x12, 0x97, 0x2b, 0x12, 0xcc, 0x37, 0x20, 0x02, + 0x28, 0x01, 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, + 0x00, 0x28, 0xb7, 0x10, 0xd9, 0xef, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, + 0x1a, 0x50, 0x0a, 0x10, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x4b, 0x65, 0x79, 0x3d, 0x3d, 0x3d, 0x3d, 0x12, 0x10, 0x0b, 0xf9, + 0x8a, 0xd8, 0x20, 0x10, 0x1d, 0xcc, 0xc9, 0x68, 0x0f, 0xa3, 0xd7, 0xd5, + 0x4b, 0xe3, 0x1a, 0x10, 0xc3, 0xb3, 0x8f, 0x84, 0xcc, 0x8c, 0x6a, 0x18, + 0xb7, 0x61, 0x54, 0x65, 0xf8, 0x09, 0x85, 0x15, 0x20, 0x02, 0x28, 0x01, + 0x42, 0x12, 0x0a, 0x10, 0x6b, 0x63, 0x31, 0x39, 0x00, 0x00, 0x00, 0x28, + 0xb7, 0x10, 0xd9, 0xef, 0x80, 0x00, 0x40, 0x00, 0x62, 0x00, 0x20, 0x9d, + 0xcb, 0xb4, 0xb5, 0x06, 0x38, 0x00, + }; + serialized_license_ = + std::string(reinterpret_cast(serialized_license_raw), + sizeof(serialized_license_raw)); + const uint8_t core_request_sha256_raw[] = { + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + }; + core_request_sha256_ = + std::string(reinterpret_cast(core_request_sha256_raw), + sizeof(core_request_sha256_raw)); + nonce_required_ = true; + RunTest(); +} + +////////////////////////////////////////////////////////////////////// +// Renewal Tests. +// A few renewal examples from filter *PIG*:*CdmUseCase*. +// Note: running these cases generates many renewals. It should be +// ok to only test one or two. +////////////////////////////////////////////////////////////////////// + +TEST_F(ODKGoldenRenewalV19, Both_CdmUseCase_LicenseWithRenewal_Case1_0_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0x80, 0xbe, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x3d, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0x80, 0xbe, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x55, 0x0a, 0x20, 0x46, 0x31, 0x33, 0x37, 0x39, 0x37, 0x34, 0x31, + 0x37, 0x33, 0x32, 0x37, 0x43, 0x37, 0x34, 0x38, 0x33, 0x39, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x46, 0x31, 0x33, 0x37, 0x39, 0x37, 0x34, 0x31, 0x37, 0x33, + 0x32, 0x37, 0x43, 0x37, 0x34, 0x38, 0x33, 0x39, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x01, 0x38, 0xb4, 0x01, 0x40, 0x00, 0x48, 0x97, 0xc3, + 0xb4, 0xb5, 0x06, 0x12, 0x08, 0x08, 0x01, 0x18, 0x01, 0x38, 0x0a, 0x48, + 0x0f, 0x20, 0xae, 0xc3, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 25; + RunTest(); +} + +TEST_F(ODKGoldenRenewalV19, Both_CdmUseCase_LicenseWithRenewal_Case1_0_2) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0x80, 0xbe, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x3d, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0x80, 0xbe, 0x39, 0xe1, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x55, 0x0a, 0x20, 0x46, 0x31, 0x33, 0x37, 0x39, 0x37, 0x34, 0x31, + 0x37, 0x33, 0x32, 0x37, 0x43, 0x37, 0x34, 0x38, 0x33, 0x39, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x46, 0x31, 0x33, 0x37, 0x39, 0x37, 0x34, 0x31, 0x37, 0x33, + 0x32, 0x37, 0x43, 0x37, 0x34, 0x38, 0x33, 0x39, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x02, 0x38, 0xb4, 0x01, 0x40, 0x00, 0x48, 0x97, 0xc3, + 0xb4, 0xb5, 0x06, 0x12, 0x08, 0x08, 0x01, 0x18, 0x01, 0x38, 0x0a, 0x48, + 0x0f, 0x20, 0xc5, 0xc3, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 25; + RunTest(); +} + +TEST_F(ODKGoldenRenewalV19, + Both_CdmUseCase_LicenseWithRenewalPlayback_Case1_0_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0xc4, 0xe2, 0xbc, 0x73, 0x00, 0x00, 0x00, 0x41, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0xc4, 0xe2, 0xbc, 0x73, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x55, 0x0a, 0x20, 0x36, 0x44, 0x41, 0x43, 0x31, 0x36, 0x35, 0x45, + 0x41, 0x43, 0x45, 0x38, 0x43, 0x32, 0x35, 0x35, 0x33, 0x44, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x36, 0x44, 0x41, 0x43, 0x31, 0x36, 0x35, 0x45, 0x41, 0x43, + 0x45, 0x38, 0x43, 0x32, 0x35, 0x35, 0x33, 0x44, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x01, 0x38, 0x00, 0x40, 0xb4, 0x01, 0x48, 0xfd, 0xc4, + 0xb4, 0xb5, 0x06, 0x12, 0x08, 0x08, 0x01, 0x18, 0x01, 0x38, 0x0a, 0x48, + 0x0f, 0x20, 0x94, 0xc5, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 25; + RunTest(); +} + +TEST_F(ODKGoldenRenewalV19, + Both_CdmUseCase_LicenseWithRenewalPlayback_Case1_0_2) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0xc4, 0xe2, 0xbc, 0x73, 0x00, 0x00, 0x00, 0x41, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0xc4, 0xe2, 0xbc, 0x73, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x55, 0x0a, 0x20, 0x36, 0x44, 0x41, 0x43, 0x31, 0x36, 0x35, 0x45, + 0x41, 0x43, 0x45, 0x38, 0x43, 0x32, 0x35, 0x35, 0x33, 0x44, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x36, 0x44, 0x41, 0x43, 0x31, 0x36, 0x35, 0x45, 0x41, 0x43, + 0x45, 0x38, 0x43, 0x32, 0x35, 0x35, 0x33, 0x44, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x02, 0x38, 0x00, 0x40, 0xb4, 0x01, 0x48, 0xfd, 0xc4, + 0xb4, 0xb5, 0x06, 0x12, 0x08, 0x08, 0x01, 0x18, 0x01, 0x38, 0x0a, 0x48, + 0x0f, 0x20, 0xab, 0xc5, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 25; + RunTest(); +} + +TEST_F(ODKGoldenRenewalV19, Both_CdmUseCase_LimitedDurationLicense_Case1_0_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0x5b, 0xd8, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x45, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0x5b, 0xd8, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x33, 0x80, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x41, 0x34, 0x37, 0x32, 0x35, 0x30, 0x39, 0x30, + 0x36, 0x37, 0x37, 0x43, 0x45, 0x37, 0x37, 0x38, 0x34, 0x31, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x41, 0x34, 0x37, 0x32, 0x35, 0x30, 0x39, 0x30, 0x36, 0x37, + 0x37, 0x43, 0x45, 0x37, 0x37, 0x38, 0x34, 0x31, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x01, 0x38, 0x0f, 0x40, 0x3c, 0x48, 0xe3, 0xc6, 0xb4, + 0xb5, 0x06, 0x12, 0x0b, 0x08, 0x01, 0x18, 0x00, 0x38, 0x80, 0xe7, 0x84, + 0x0f, 0x48, 0x00, 0x20, 0xf4, 0xc6, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 31536000; + RunTest(); +} + +TEST_F(ODKGoldenRenewalV19, Both_CdmUseCase_RenewOnLicenseLoad_Case1L_0_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0x00, 0x35, 0xbe, 0x0c, 0x00, 0x00, 0x00, 0x51, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0x00, 0x35, 0xbe, 0x0c, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x33, 0x80, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x37, 0x34, 0x36, 0x30, 0x36, 0x32, 0x36, 0x35, + 0x39, 0x46, 0x32, 0x46, 0x45, 0x33, 0x33, 0x35, 0x34, 0x44, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x37, 0x34, 0x36, 0x30, 0x36, 0x32, 0x36, 0x35, 0x39, 0x46, + 0x32, 0x46, 0x45, 0x33, 0x33, 0x35, 0x34, 0x44, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x01, 0x38, 0x14, 0x40, 0x32, 0x48, 0xd1, 0xc8, 0xb4, + 0xb5, 0x06, 0x12, 0x0b, 0x08, 0x01, 0x18, 0x00, 0x38, 0x80, 0xe7, 0x84, + 0x0f, 0x48, 0x00, 0x20, 0xe0, 0xc8, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 31536000; + RunTest(); +} + +TEST_F(ODKGoldenRenewalV19, Both_CdmUseCase_RenewOnLicenseLoad_Case1L_1_2) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0xe6, 0x76, 0x4a, 0x7b, 0x00, 0x00, 0x00, 0x53, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0xe6, 0x76, 0x4a, 0x7b, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe1, 0x33, 0x80, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x60, 0x0a, 0x20, 0x32, 0x42, 0x33, 0x37, 0x33, 0x37, 0x31, 0x41, + 0x31, 0x38, 0x32, 0x42, 0x46, 0x32, 0x34, 0x34, 0x34, 0x46, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x32, 0x42, 0x33, 0x37, 0x33, 0x37, 0x31, 0x41, 0x31, 0x38, + 0x32, 0x42, 0x46, 0x32, 0x34, 0x34, 0x34, 0x46, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x02, 0x28, 0x01, 0x32, 0x0a, 0x90, 0x74, 0x9d, 0x38, 0xc0, 0xc2, + 0x36, 0x76, 0xd5, 0xb1, 0x38, 0x14, 0x40, 0x32, 0x48, 0xfc, 0xc8, 0xb4, + 0xb5, 0x06, 0x12, 0x0d, 0x08, 0x01, 0x10, 0x01, 0x18, 0x00, 0x38, 0x80, + 0xe7, 0x84, 0x0f, 0x48, 0x00, 0x20, 0x8b, 0xc9, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 31536000; + RunTest(); +} + +TEST_F(ODKGoldenRenewalV19, Both_CdmUseCase_Heartbeat_Case1_0_1) { + const uint8_t core_request_raw[] = { + 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x02, + 0x00, 0x13, 0x36, 0x8e, 0xf6, 0xeb, 0x00, 0x00, 0x00, 0x55, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, + }; + core_request_ = std::string(reinterpret_cast(core_request_raw), + sizeof(core_request_raw)); + const uint8_t core_response_raw[] = { + 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x24, 0x00, 0x02, 0x00, 0x13, + 0x36, 0x8e, 0xf6, 0xeb, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, + }; + core_response_ = + std::string(reinterpret_cast(core_response_raw), + sizeof(core_response_raw)); + const uint8_t renewal_raw[] = { + 0x0a, 0x54, 0x0a, 0x20, 0x34, 0x42, 0x41, 0x34, 0x33, 0x42, 0x43, 0x38, + 0x35, 0x43, 0x44, 0x30, 0x39, 0x45, 0x37, 0x38, 0x35, 0x31, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, + 0x12, 0x20, 0x34, 0x42, 0x41, 0x34, 0x33, 0x42, 0x43, 0x38, 0x35, 0x43, + 0x44, 0x30, 0x39, 0x45, 0x37, 0x38, 0x35, 0x31, 0x30, 0x30, 0x30, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x1a, 0x00, + 0x20, 0x01, 0x28, 0x01, 0x38, 0x00, 0x40, 0x00, 0x48, 0xa7, 0xc9, 0xb4, + 0xb5, 0x06, 0x12, 0x0a, 0x08, 0x01, 0x18, 0x01, 0x38, 0x1e, 0x48, 0x0a, + 0x50, 0x0a, 0x20, 0xb9, 0xc9, 0xb4, 0xb5, 0x06, + }; + renewal_ = std::string(reinterpret_cast(renewal_raw), + sizeof(renewal_raw)); + renewal_duration_seconds_ = 40; + RunTest(); +} + +////////////////////////////////////////////////////////////////////// +} // namespace + +} // namespace wvodk_test diff --git a/oemcrypto/odk/test/odk_test.cpp b/oemcrypto/odk/test/odk_test.cpp index 7a0d645..bd14883 100644 --- a/oemcrypto/odk/test/odk_test.cpp +++ b/oemcrypto/odk/test/odk_test.cpp @@ -1275,7 +1275,7 @@ std::vector TestCases() { {16, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 16, 5}, {17, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 17, 2}, {18, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 18, 4}, - {19, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 19, 4}, + {19, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 19, 5}, // Here are some known good versions. Make extra sure they work. {ODK_MAJOR_VERSION, 16, 3, 16, 3}, {ODK_MAJOR_VERSION, 16, 4, 16, 4}, @@ -1290,6 +1290,7 @@ std::vector TestCases() { {ODK_MAJOR_VERSION, 19, 2, 19, 2}, {ODK_MAJOR_VERSION, 19, 3, 19, 3}, {ODK_MAJOR_VERSION, 19, 4, 19, 4}, + {ODK_MAJOR_VERSION, 19, 5, 19, 5}, {0, 16, 3, 16, 3}, {0, 16, 4, 16, 4}, {0, 16, 5, 16, 5}, @@ -1302,6 +1303,7 @@ std::vector TestCases() { {0, 19, 2, 19, 2}, {0, 19, 3, 19, 3}, {0, 19, 4, 19, 4}, + {0, 19, 5, 19, 5}, }; return test_cases; } diff --git a/oemcrypto/odk/test/odk_test.gypi b/oemcrypto/odk/test/odk_test.gypi index 9cc33f6..abc9ed2 100644 --- a/oemcrypto/odk/test/odk_test.gypi +++ b/oemcrypto/odk/test/odk_test.gypi @@ -7,6 +7,7 @@ 'odk_golden_v16.cpp', 'odk_golden_v17.cpp', 'odk_golden_v18.cpp', + 'odk_golden_v19.cpp', 'odk_test.cpp', 'odk_test_helper.cpp', 'odk_test_helper.h', diff --git a/oemcrypto/opk/build/Makefile.rules b/oemcrypto/opk/build/Makefile.rules deleted file mode 100644 index e1a69a1..0000000 --- a/oemcrypto/opk/build/Makefile.rules +++ /dev/null @@ -1,364 +0,0 @@ -# We borrow heavily from the kernel build setup, though we are simpler since -# we don't have Kconfig tweaking settings on us. - -# The implicit make rules have it looking for RCS files, among other things. -# We instead explicitly write all the rules we care about. -# It's even quicker (saves ~200ms) to pass -r on the command line. -MAKEFLAGS=-r - -# The source directory tree. -srcdir := ../../.. -abs_srcdir := $(abspath $(srcdir)) - -# The name of the builddir. -builddir_name ?= out - -# The V=1 flag on command line makes us verbosely print command lines. -ifdef V - quiet= -else - quiet=quiet_ -endif - -# Specify BUILDTYPE=Release on the command line for a release build. -BUILDTYPE ?= debug - -# Directory all our build output goes into. -# Note that this must be two directories beneath src/ for unit tests to pass, -# as they reach into the src/ directory for data with relative paths. -builddir ?= $(builddir_name)/$(BUILDTYPE) -abs_builddir := $(abspath $(builddir)) -depsdir := $(builddir)/.deps - -# Object output directory. -obj := $(builddir)/obj -abs_obj := $(abspath $(obj)) - -# We build up a list of every single one of the targets so we can slurp in the -# generated dependency rule Makefiles in one pass. -all_deps := - - - -CC.target ?= $(CC_target) -CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS) -CXX.target ?= $(CXX_target) -CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS) -LINK.target ?= $(LINK) -LDFLAGS.target ?= $(LDFLAGS) -AR.target ?= $(AR) - -# C++ apps need to be linked with g++. -LINK ?= $(CXX.target) - -# TODO(evan): move all cross-compilation logic to gyp-time so we don't need -# to replicate this environment fallback in make as well. -CC.host ?= $(CC_host) -CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host) -CXX.host ?= $(CXX_host) -CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host) -LINK.host ?= $(CXX.host) -LDFLAGS.host ?= $(LDFLAGS_host) -AR.host ?= $(AR_host) - -# Define a dir function that can handle spaces. -# http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions -# "leading spaces cannot appear in the text of the first argument as written. -# These characters can be put into the argument value by variable substitution." -empty := -space := $(empty) $(empty) - -# http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces -replace_spaces = $(subst $(space),?,$1) -unreplace_spaces = $(subst ?,$(space),$1) -dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) - -# Flags to make gcc output dependency info. Note that you need to be -# careful here to use the flags that ccache and distcc can understand. -# We write to a dep file on the side first and then rename at the end -# so we can't end up with a broken dep file. -depfile = $(depsdir)/$(call replace_spaces,$@).d -DEPFLAGS = -MMD -MF $(depfile).raw - -# We have to fixup the deps output in a few ways. -# (1) the file output should mention the proper .o file. -# ccache or distcc lose the path to the target, so we convert a rule of -# the form: -# foobar.o: DEP1 DEP2 -# into -# path/to/foobar.o: DEP1 DEP2 -# (2) we want missing files not to cause us to fail to build. -# We want to rewrite -# foobar.o: DEP1 DEP2 \ -# DEP3 -# to -# DEP1: -# DEP2: -# DEP3: -# so if the files are missing, they're just considered phony rules. -# We have to do some pretty insane escaping to get those backslashes -# and dollar signs past make, the shell, and sed at the same time. -# Doesn't work with spaces, but that's fine: .d files have spaces in -# their names replaced with other characters. -define fixup_dep -# The depfile may not exist if the input file didn't have any #includes. -touch $(depfile).raw -# Fixup path as in (1). -sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) -# Add extra rules as in (2). -# We remove slashes and replace spaces with new lines; -# remove blank lines; -# delete the first line and append a colon to the remaining lines. -sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ - grep -v '^$$' |\ - sed -e 1d -e 's|$$|:|' \ - >> $(depfile) -rm $(depfile).raw -endef - -# Command definitions: -# - cmd_foo is the actual command to run; -# - quiet_cmd_foo is the brief-output summary of the command. - -quiet_cmd_cc = CC($(TOOLSET)) $@ -cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_cxx = CXX($(TOOLSET)) $@ -cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< - -quiet_cmd_touch = TOUCH $@ -cmd_touch = touch $@ - -quiet_cmd_copy = COPY $@ -# send stderr to /dev/null to ignore messages when linking directories. -cmd_copy = ln -f "$<" "$@" 2>/dev/null || (rm -rf "$@" && cp -af "$<" "$@") - -quiet_cmd_alink = AR($(TOOLSET)) $@ -cmd_alink = rm -f $@ && $(AR.$(TOOLSET)) crs $@ $(filter %.o,$^) - -quiet_cmd_alink_thin = AR($(TOOLSET)) $@ -cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^) - -# Due to circular dependencies between libraries :(, we wrap the -# special "figure out circular dependencies" flags around the entire -# input list during linking. -quiet_cmd_link = LINK($(TOOLSET)) $@ -cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS) - -# We support two kinds of shared objects (.so): -# 1) shared_library, which is just bundling together many dependent libraries -# into a link line. -# 2) loadable_module, which is generating a module intended for dlopen(). -# -# They differ only slightly: -# In the former case, we want to package all dependent code into the .so. -# In the latter case, we want to package just the API exposed by the -# outermost module. -# This means shared_library uses --whole-archive, while loadable_module doesn't. -# (Note that --whole-archive is incompatible with the --start-group used in -# normal linking.) - -# Other shared-object link notes: -# - Set SONAME to the library filename so our binaries don't reference -# the local, absolute paths used on the link command-line. -quiet_cmd_solink = SOLINK($(TOOLSET)) $@ -cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS) - -quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ -cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS) - - -# Define an escape_quotes function to escape single quotes. -# This allows us to handle quotes properly as long as we always use -# use single quotes and escape_quotes. -escape_quotes = $(subst ','\'',$(1)) -# This comment is here just to include a ' to unconfuse syntax highlighting. -# Define an escape_vars function to escape '$' variable syntax. -# This allows us to read/write command lines with shell variables (e.g. -# $LD_LIBRARY_PATH), without triggering make substitution. -escape_vars = $(subst $$,$$$$,$(1)) -# Helper that expands to a shell command to echo a string exactly as it is in -# make. This uses printf instead of echo because printf's behaviour with respect -# to escape sequences is more portable than echo's across different shells -# (e.g., dash, bash). -exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' - -# Helper to compare the command we're about to run against the command -# we logged the last time we ran the command. Produces an empty -# string (false) when the commands match. -# Tricky point: Make has no string-equality test function. -# The kernel uses the following, but it seems like it would have false -# positives, where one string reordered its arguments. -# arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ -# $(filter-out $(cmd_$@), $(cmd_$(1)))) -# We instead substitute each for the empty string into the other, and -# say they're equal if both substitutions produce the empty string. -# .d files contain ? instead of spaces, take that into account. -command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ - $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) - -# Helper that is non-empty when a prerequisite changes. -# Normally make does this implicitly, but we force rules to always run -# so we can check their command lines. -# $? -- new prerequisites -# $| -- order-only dependencies -prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) - -# Helper that executes all postbuilds until one fails. -define do_postbuilds - @E=0;\ - for p in $(POSTBUILDS); do\ - eval $$p;\ - E=$$?;\ - if [ $$E -ne 0 ]; then\ - break;\ - fi;\ - done;\ - if [ $$E -ne 0 ]; then\ - rm -rf "$@";\ - exit $$E;\ - fi -endef - -# do_cmd: run a command via the above cmd_foo names, if necessary. -# Should always run for a given target to handle command-line changes. -# Second argument, if non-zero, makes it do asm/C/C++ dependency munging. -# Third argument, if non-zero, makes it do POSTBUILDS processing. -# Note: We intentionally do NOT call dirx for depfile, since it contains ? for -# spaces already and dirx strips the ? characters. -define do_cmd -$(if $(or $(command_changed),$(prereq_changed)), - @$(call exact_echo, $($(quiet)cmd_$(1))) - @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" - $(if $(findstring flock,$(word 1,$(cmd_$1))), - @$(cmd_$(1)) - @echo " $(quiet_cmd_$(1)): Finished", - @$(cmd_$(1)) - ) - @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) - @$(if $(2),$(fixup_dep)) - $(if $(and $(3), $(POSTBUILDS)), - $(call do_postbuilds) - ) -) -endef - -# Declare the "all" target first so it is the default, -# even though we don't have the deps yet. -.PHONY: all -all: - -# make looks for ways to re-generate included makefiles, but in our case, we -# don't have a direct way. Explicitly telling make that it has nothing to do -# for them makes it go faster. -%.d: ; - -# Use FORCE_DO_CMD to force a target to run. Should be coupled with -# do_cmd. -.PHONY: FORCE_DO_CMD -FORCE_DO_CMD: - -TOOLSET := target -# Suffix rules, putting all outputs into $(obj). -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) - -# Try building from generated source, too. -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) - -$(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD - @$(call do_cmd,cxx,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD - @$(call do_cmd,cc,1) -$(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD - @$(call do_cmd,cc,1) - - -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/odk/src/odk.target.mk)))),) - include oemcrypto/odk/src/odk.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/opk/build/ta.target.mk)))),) - include oemcrypto/opk/build/ta.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/opk/oemcrypto_ta/oemcrypto_ta.target.mk)))),) - include oemcrypto/opk/oemcrypto_ta/oemcrypto_ta.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_clock.target.mk)))),) - include oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_clock.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_crypto.target.mk)))),) - include oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_crypto.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_renewal.target.mk)))),) - include oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_renewal.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_root_of_trust.target.mk)))),) - include oemcrypto/opk/oemcrypto_ta/wtpi_reference/oemcrypto_ta_reference_root_of_trust.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,oemcrypto/opk/serialization/tee/opk_tee.target.mk)))),) - include oemcrypto/opk/serialization/tee/opk_tee.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,third_party/boringssl/crypto.target.mk)))),) - include third_party/boringssl/crypto.target.mk -endif -ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ - $(findstring $(join ^,$(prefix)),\ - $(join ^,third_party/cbor.target.mk)))),) - include third_party/cbor.target.mk -endif - -# "all" is a concatenation of the "all" targets from all the included -# sub-makefiles. This is just here to clarify. -all: - -# Add in dependency-tracking rules. $(all_deps) is the list of every single -# target in our tree. Only consider the ones with .d (dependency) info: -d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) -ifneq ($(d_files),) - include $(d_files) -endif diff --git a/oemcrypto/opk/build/ree-sources.mk b/oemcrypto/opk/build/ree-sources.mk index 234c4c1..0d2194a 100644 --- a/oemcrypto/opk/build/ree-sources.mk +++ b/oemcrypto/opk/build/ree-sources.mk @@ -119,24 +119,8 @@ ifeq ($(USE_DEFAULT_BORINGSSL), y) boringssl_dir ?= $(OPK_REPO_TOP)/third_party/boringssl boringssl_sources_raw += \ - $(crypto_sources) - - ifeq ($(ARCH), 64) - ifneq ($(IS_ARM), 0) - boringssl_sources_raw += $(linux_aarch64_sources) - else - boringssl_sources_raw += $(linux_x86_64_sources) - endif - else ifeq ($(ARCH), 32) - ifneq ($(IS_ARM), 0) - boringssl_sources_raw += $(linux_arm_sources) - else - boringssl_sources_raw += $(linux_x86_sources) - endif - - else - $(error No known value for ARCH; assembly not included for BoringSSL) - endif + $(crypto_sources) \ + $(crypto_sources_asm) boringssl_sources += \ $(addprefix $(boringssl_dir)/kit/, $(boringssl_sources_raw)) \ diff --git a/oemcrypto/opk/oemcrypto_ta/oemcrypto.c b/oemcrypto/opk/oemcrypto_ta/oemcrypto.c index 0c308fa..26fbd14 100644 --- a/oemcrypto/opk/oemcrypto_ta/oemcrypto.c +++ b/oemcrypto/opk/oemcrypto_ta/oemcrypto.c @@ -4757,6 +4757,20 @@ OEMCryptoResult OEMCrypto_SetSessionUsage(OEMCrypto_SESSION session UNUSED, return OEMCrypto_ERROR_NOT_IMPLEMENTED; } +// CAS only, currently not implemented +OEMCryptoResult OEMCrypto_GetPVRKey(OEMCrypto_SESSION session UNUSED, + uint8_t* wrapped_pvr_key UNUSED, + size_t* wrapped_pvr_key_length UNUSED) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; +} + +// CAS only, currently not implemented +OEMCryptoResult OEMCrypto_LoadPVRKey(OEMCrypto_SESSION session UNUSED, + const uint8_t* wrapped_pvr_key UNUSED, + size_t wrapped_pvr_key_length UNUSED) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; +} + OEMCryptoResult OEMCrypto_GetEmbeddedDrmCertificate( uint8_t* public_cert UNUSED, size_t* public_cert_length UNUSED) { return OEMCrypto_ERROR_NOT_IMPLEMENTED; diff --git a/oemcrypto/opk/oemcrypto_ta/oemcrypto_api_macros.h b/oemcrypto/opk/oemcrypto_ta/oemcrypto_api_macros.h index 5d19f72..fec38f8 100644 --- a/oemcrypto/opk/oemcrypto_ta/oemcrypto_api_macros.h +++ b/oemcrypto/opk/oemcrypto_ta/oemcrypto_api_macros.h @@ -34,8 +34,8 @@ // version bumps to v17.1, the first released OPK implementation would be // v17.1.0 #define API_MAJOR_VERSION 19 -#define API_MINOR_VERSION 4 +#define API_MINOR_VERSION 5 #define OPK_PATCH_VERSION 0 -#define OPK_BUILD_ID "19.4.0" +#define OPK_BUILD_ID "19.5.0" #endif /* OEMCRYPTO_TA_OEMCRYPTO_API_MACROS_H_ */ diff --git a/oemcrypto/opk/oemcrypto_ta/oemcrypto_usage_table.c b/oemcrypto/opk/oemcrypto_ta/oemcrypto_usage_table.c index d996e38..997a5dd 100644 --- a/oemcrypto/opk/oemcrypto_ta/oemcrypto_usage_table.c +++ b/oemcrypto/opk/oemcrypto_ta/oemcrypto_usage_table.c @@ -556,6 +556,7 @@ NO_IGNORE_RESULT static OEMCryptoResult RollGenerationNumber( UsageEntry* entry) { ABORT_IF_NULL(entry); if (entry->data.index >= MAX_NUMBER_OF_USAGE_ENTRIES) { + LOGE("Too many entries"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } uint64_t new_generation_number = g_usage_table.master_generation_number + 1; @@ -682,6 +683,15 @@ OEMCryptoResult OPKI_CreateUsageTableHeader(uint8_t* header_buffer, g_usage_table_state = USAGE_TABLE_ERROR_STATE; return OEMCrypto_ERROR_SYSTEM_INVALIDATED; } + /* Save the generation number. + */ + if (WTPI_SaveGenerationNumber(g_usage_table.master_generation_number) != + OEMCrypto_SUCCESS) { + LOGE("Failed to save generation number: %" PRIu64, + g_usage_table.master_generation_number); + g_usage_table_state = USAGE_TABLE_ERROR_STATE; + return OEMCrypto_ERROR_SYSTEM_INVALIDATED; + } } else { /* Only other valid state is not initialized, which is not valid for * this function. */ @@ -723,6 +733,15 @@ OEMCryptoResult OPKI_LoadUsageTableHeader(const uint8_t* buffer, g_usage_table_state = USAGE_TABLE_ERROR_STATE; return OEMCrypto_ERROR_SYSTEM_INVALIDATED; } + /* Save the generation number. + */ + if (WTPI_SaveGenerationNumber(g_usage_table.master_generation_number) != + OEMCrypto_SUCCESS) { + LOGE("Failed to save generation number: %" PRIu64, + g_usage_table.master_generation_number); + g_usage_table_state = USAGE_TABLE_ERROR_STATE; + return OEMCrypto_ERROR_SYSTEM_INVALIDATED; + } } else { /* Only other valid state is not initialized, which is not valid for * this function. */ @@ -747,8 +766,16 @@ OEMCryptoResult OPKI_LoadUsageTableHeader(const uint8_t* buffer, /* Leave the state as active, so that the generation number is kept. It * is not a security risk to leave an empty usage header in memory. */ g_usage_table_state = USAGE_TABLE_ACTIVE_STATE; + LOGE("Usage header skew: saved_value=%lu, header=%lu, delta=%ld", + g_usage_table.master_generation_number, + header.master_generation_number, + // Even though this is unsigned subtraction and may overflow, the + // result will still be correct after the cast. + (int64_t)(g_usage_table.master_generation_number - + header.master_generation_number)); return OEMCrypto_ERROR_GENERATION_SKEW; } + g_usage_table.table_size = header.table_size; memset(g_usage_table.generation_numbers, 0, sizeof(g_usage_table.generation_numbers)); @@ -767,9 +794,12 @@ NO_IGNORE_RESULT static OEMCryptoResult GrabEntry(OEMCrypto_SESSION session_id, UsageEntry** entry_ptr) { ABORT_IF_NULL(entry_ptr); if (usage_entry_number >= MAX_NUMBER_OF_USAGE_ENTRIES) { + LOGE("Too many usage entries: %u/%u", usage_entry_number, + (unsigned int)MAX_NUMBER_OF_USAGE_ENTRIES); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } /* Check that the session doesn't have entry already. */ @@ -814,10 +844,11 @@ void OPKI_ReleaseEntry(OEMCrypto_SESSION session_id) { OEMCryptoResult OPKI_CreateNewUsageEntry(OEMCrypto_SESSION session_id, uint32_t* usage_entry_number) { if (!usage_entry_number) { + LOGE("Entry number null"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { - /* Usage table header must be loaded. */ + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (FindUsageEntry(session_id) != NULL) { @@ -848,7 +879,7 @@ OEMCryptoResult OPKI_CreateNewUsageEntry(OEMCrypto_SESSION session_id, OEMCryptoResult OPKI_ReuseUsageEntry(OEMCrypto_SESSION session_id, uint32_t usage_entry_number) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { - /* Usage table header must be loaded. */ + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (FindUsageEntry(session_id) != NULL) { @@ -857,6 +888,8 @@ OEMCryptoResult OPKI_ReuseUsageEntry(OEMCrypto_SESSION session_id, } /* Check that the |usage_entry_number| is valid. */ if (usage_entry_number >= MAX_NUMBER_OF_USAGE_ENTRIES) { + LOGE("Too many usage entries: %u/%u", usage_entry_number, + (unsigned int)MAX_NUMBER_OF_USAGE_ENTRIES); return OEMCrypto_ERROR_INSUFFICIENT_RESOURCES; } if (usage_entry_number >= g_usage_table.table_size) { @@ -882,7 +915,7 @@ OEMCryptoResult OPKI_LoadUsageEntry(OEMCrypto_SESSION session_id, const uint8_t* buffer, size_t buffer_length) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { - /* Usage table header must be loaded. */ + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (FindUsageEntry(session_id) != NULL) { @@ -892,7 +925,7 @@ OEMCryptoResult OPKI_LoadUsageEntry(OEMCrypto_SESSION session_id, if (usage_entry_number >= MAX_NUMBER_OF_USAGE_ENTRIES) { LOGE("Too many usage entries: %u/%u", usage_entry_number, (unsigned int)MAX_NUMBER_OF_USAGE_ENTRIES); - return OEMCrypto_ERROR_UNKNOWN_FAILURE; + return OEMCrypto_ERROR_INSUFFICIENT_RESOURCES; } if (usage_entry_number >= g_usage_table.table_size) { LOGE("Invalid usage entry number: %u", usage_entry_number); @@ -952,6 +985,7 @@ OEMCryptoResult OPKI_UpdateUsageEntry(OEMCrypto_SESSION session_id, uint8_t* entry_buffer, size_t* entry_buffer_length) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (!header_buffer_length || !entry_buffer_length) { @@ -970,7 +1004,12 @@ OEMCryptoResult OPKI_UpdateUsageEntry(OEMCrypto_SESSION session_id, *entry_buffer_length = entry_size; /* Check that the session has an entry, and it's state is valid. */ UsageEntry* entry = FindUsageEntry(session_id); - if (!header_buffer || !entry_buffer || !entry) { + if (!header_buffer || !entry_buffer) { + LOGE("Null argument"); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } /* New clock values in the usage entry. */ @@ -993,10 +1032,12 @@ OEMCryptoResult OPKI_UpdateUsageEntry(OEMCrypto_SESSION session_id, OEMCryptoResult OPKI_ForbidReportUsage(OEMCrypto_SESSION session_id) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } UsageEntry* entry = FindUsageEntry(session_id); if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } const OEMCryptoResult result = RollGenerationNumber(entry); @@ -1007,10 +1048,17 @@ OEMCryptoResult OPKI_ForbidReportUsage(OEMCrypto_SESSION session_id) { OEMCryptoResult OPKI_SetUsageEntryPST(OEMCrypto_SESSION session_id, const uint8_t* pst, size_t pst_length) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } UsageEntry* entry = FindUsageEntry(session_id); - if (!entry || GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_NEW) { + if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + if (GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_NEW) { + LOGE("Incorrect usage entry status: expected=%x, actual=%x", + USAGE_ENTRY_NEW, GetUsageEntryStatusFromEntry(entry)); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (!pst || pst_length == 0 || pst_length > MAX_PST_LENGTH) { @@ -1036,11 +1084,17 @@ OEMCryptoResult OPKI_VerfiyUsageEntryPST(OEMCrypto_SESSION session_id, const uint8_t* pst, size_t pst_length) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } UsageEntry* entry = FindUsageEntry(session_id); - if (!entry || GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_LOADED) { - LOGE("Invalid usage entry status"); + if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + if (GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_LOADED) { + LOGE("Incorrect usage entry status: expected=%x, actual=%x", + USAGE_ENTRY_LOADED, GetUsageEntryStatusFromEntry(entry)); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (!pst || pst_length == 0 || pst_length > MAX_PST_LENGTH) { @@ -1058,11 +1112,17 @@ OEMCryptoResult OPKI_SetUsageEntryMacKeys( OEMCrypto_SESSION session_id, WTPI_K1_SymmetricKey_Handle mac_key_server, WTPI_K1_SymmetricKey_Handle mac_key_client) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } UsageEntry* entry = FindUsageEntry(session_id); - if (!entry || GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_NEW) { - LOGE("Invalid usage entry status"); + if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + if (GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_NEW) { + LOGE("Incorrect usage entry status: expected=%x, actual=%x", + USAGE_ENTRY_NEW, GetUsageEntryStatusFromEntry(entry)); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } OEMCryptoResult result; @@ -1093,11 +1153,17 @@ OEMCryptoResult OPKI_VerifyUsageEntryMacKeys( OEMCrypto_SESSION session_id, WTPI_K1_SymmetricKey_Handle mac_key_server, WTPI_K1_SymmetricKey_Handle mac_key_client) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } UsageEntry* entry = FindUsageEntry(session_id); - if (!entry || GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_LOADED) { - LOGE("Invalid usage entry status"); + if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + if (GetUsageEntryStatusFromEntry(entry) != USAGE_ENTRY_LOADED) { + LOGE("Incorrect usage entry status: expected=%x, actual=%x", + USAGE_ENTRY_LOADED, GetUsageEntryStatusFromEntry(entry)); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } OEMCryptoResult result; @@ -1130,12 +1196,16 @@ OEMCryptoResult OPKI_VerifyUsageEntryMacKeys( OEMCryptoResult OPKI_SetUsageEntryRecentDecrypt(OEMCrypto_SESSION session_id) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } UsageEntry* entry = FindUsageEntry(session_id); - if (!entry || - GetUsageEntryStatusFromEntry(entry) == USAGE_ENTRY_DEACTIVATED) { - LOGE("Invalid usage entry status"); + if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + if (GetUsageEntryStatusFromEntry(entry) == USAGE_ENTRY_DEACTIVATED) { + LOGE("Usage entry deactivated"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } entry->recent_decrypt = true; @@ -1147,12 +1217,13 @@ OEMCryptoResult OPKI_DeactivateUsageEntry(OEMCrypto_SESSION session_id, const uint8_t* pst UNUSED, size_t pst_length UNUSED) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } /* Check that the session has an entry, and it's state is valid. */ UsageEntry* entry = FindUsageEntry(session_id); if (!entry) { - LOGE("Failed to deactivate usage entry. Invalid entry status."); + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } OEMCryptoResult result = OPKI_ForbidReportUsage(session_id); @@ -1166,11 +1237,13 @@ OEMCryptoResult OPKI_ReportUsage(OEMCrypto_SESSION session_id, const uint8_t* pst, size_t pst_length, uint8_t* buffer, size_t* buffer_length) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } RETURN_INVALID_CONTEXT_IF_NULL(buffer_length); UsageEntry* entry = FindUsageEntry(session_id); if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } size_t length_needed = sizeof(OEMCrypto_PST_Report) + pst_length; @@ -1259,10 +1332,12 @@ OEMCryptoResult OPKI_SignReleaseRequest(OEMCrypto_SESSION session_id, uint8_t* signature, size_t* signature_length UNUSED) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } UsageEntry* entry = FindUsageEntry(session_id); if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } WTPI_K1_SymmetricKey_Handle key = NULL; @@ -1294,6 +1369,7 @@ OEMCryptoResult OPKI_GetUsageEntryInfo(OEMCrypto_SESSION session_id, UsageEntry* entry = FindUsageEntry(session_id); if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } @@ -1313,6 +1389,7 @@ OEMCryptoResult OPKI_GetUsageEntryInfo(OEMCrypto_SESSION session_id, OEMCryptoResult OPKI_MoveEntry(OEMCrypto_SESSION session_id, uint32_t new_index) { if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (new_index >= MAX_NUMBER_OF_USAGE_ENTRIES) { @@ -1320,6 +1397,7 @@ OEMCryptoResult OPKI_MoveEntry(OEMCrypto_SESSION session_id, } UsageEntry* entry = FindUsageEntry(session_id); if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } uint32_t index = entry->data.index; @@ -1345,6 +1423,7 @@ OEMCryptoResult OPKI_ShrinkUsageTableHeader(uint32_t new_entry_count, size_t* header_buffer_length) { RETURN_INVALID_CONTEXT_IF_NULL(header_buffer_length); if (g_usage_table_state != USAGE_TABLE_ACTIVE_STATE) { + LOGE("Usage table not initialized"); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } if (new_entry_count >= g_usage_table.table_size) { @@ -1352,6 +1431,7 @@ OEMCryptoResult OPKI_ShrinkUsageTableHeader(uint32_t new_entry_count, } for (size_t i = new_entry_count; i < g_usage_table.table_size; i++) { if (g_usage_table.entries[i]) { + LOGE("Usage entry %zu is in use", i); return OEMCrypto_ERROR_ENTRY_IN_USE; } } @@ -1376,6 +1456,7 @@ NO_IGNORE_RESULT OEMCryptoResult OPKI_UpdateClockValues( RETURN_INVALID_CONTEXT_IF_NULL(clock_values); UsageEntry* entry = FindUsageEntry(session_id); if (!entry) { + LOGE("Unable to find usage entry for session: %d", session_id); return OEMCrypto_ERROR_UNKNOWN_FAILURE; } /* New clock values in the usage entry. */ diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_cas_interface.h b/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_cas_interface.h index a48a451..5ff0592 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_cas_interface.h +++ b/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_cas_interface.h @@ -112,7 +112,7 @@ OEMCryptoResult WTPI_InstallContentIV(void* key_slot_descriptor, uint8_t* iv, size_t iv_length, bool is_even); /** - * Get the key token from |key_slot_descriptor|, and places the result + * Gets the key token from |key_slot_descriptor|, and places the result * in |key_token| and sets |key_token_length| to the appropriate length. The key * token is implementation-specific and is used by the key consumer to locate * the key slot. It can be as simple as just an index into a shared key table, @@ -137,6 +137,82 @@ OEMCryptoResult WTPI_GetKeyToken(void* key_slot_descriptor, uint8_t* key_token, */ size_t WTPI_GetKeyTokenSize(void); +/** + * Sets the session's usage information and scrambling mode in + * |key_slot_descriptor|. + * + * Caller retains ownership of all pointers. + * + * @param[in] key_slot_descriptor: key slot info and properties holder + * @param[in] intent: session usage information + * @param[in] mode: scrambling mode + * + * @retval OEMCrypto_SUCCESS success + * @retval OEMCrypto_ERROR_INVALID_CONTEXT any of the pointers are NULL + * @retval OEMCrypto_ERROR_NOT_IMPLEMENTED + */ +OEMCryptoResult WTPI_SetCasUsage(void* key_slot_descriptor, uint32_t intent, + uint32_t mode); + +/** + * Returns the session's usage information and scrambling mode from + * |key_slot_descriptor|. + * + * Caller retains ownership of all pointers. + * + * @param[in] key_slot_descriptor: key slot info and properties holder + * @param[out] intent: session usage information + * @param[out] mode: scrambling mode + * + * @retval OEMCrypto_SUCCESS success + * @retval OEMCrypto_ERROR_INVALID_CONTEXT any of the pointers are NULL + * @retval OEMCrypto_ERROR_NOT_IMPLEMENTED + */ +OEMCryptoResult WTPI_GetCasUsage(void* key_slot_descriptor, uint32_t* intent, + uint32_t* mode); + +/** + * Installs entitled content key to a key slot specified in + * |key_slot_descriptor|. This method is currently used exclusively by CAS with + * PVR support. + * + * Caller retains ownership of all pointers. + * + * @param[in] key_slot_descriptor: info of the destination key slot where the + * key is to be installed + * @param[in] key_handle: key to install + * @param[in] scrambling_mode: scrambling mode + * @param[in] is_even: key parity flag + * + * @retval OEMCrypto_SUCCESS success + * @retval OEMCrypto_ERROR_INVALID_CONTEXT any of the pointers are NULL, or + * |key_handle| is invalid + * @retval OEMCrypto_ERROR_NOT_IMPLEMENTED + */ +OEMCryptoResult WTPI_InstallPVRContentKey( + void* key_slot_descriptor, WTPI_K1_SymmetricKey_Handle key_handle, + uint32_t scrambling_mode, bool is_even); + +/** + * Installs entitled content IV to a key slot specified in + * |key_slot_descriptor|. This method is currently used exclusively by CAS with + * PVR support. + * + * Caller retains ownership of all pointers. + * + * @param[in] key_slot_descriptor: info of the destination key slot where the IV + * is to be installed + * @param[in] iv: pointer to the initialization vector to be installed + * @param[in] iv_length: size of the initialization vector + * @param[in] is_even: key parity flag + * + * @retval OEMCrypto_SUCCESS success + * @retval OEMCrypto_ERROR_INVALID_CONTEXT any of the pointers are NULL + * @retval OEMCrypto_ERROR_NOT_IMPLEMENTED + */ +OEMCryptoResult WTPI_InstallPVRContentIV(void* key_slot_descriptor, uint8_t* iv, + size_t iv_length, bool is_even); + /// @} #ifdef __cplusplus diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crc32_interface.h b/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crc32_interface.h index 40cf538..b5aab78 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crc32_interface.h +++ b/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crc32_interface.h @@ -57,21 +57,21 @@ OEMCryptoResult WTPI_Crc32Cont(const uint8_t* in, size_t in_length, /** * Hashes the contents of an output buffer for the purposes of decrypt hash * verification. Calculates the new CRC-32 value given the previous CRC-32 - * value, |prev_crc|, and |in_length| bytes of the output buffer |in| starting + * value, |prev_crc|, and |in_count| bytes of the output buffer |in| starting * at offset |in_offset|. Places the result in |new_crc|. * * Caller retains ownership of all pointers. * - * @param[in] in: input OutputBuffer type + * @param[in] in: the OutputBuffer whose contents should be hashed * @param[in] in_offset: offset into the data buffer where the CRC operation * should begin processing bytes - * @param[in] in_length: number of bytes to process + * @param[in] in_count: number of bytes to process * @param[in] prev_crc: previous CRC hash * @param[out] new_crc: new CRC hash after bytes have been processed * * @retval OEMCrypto_ERROR_NOT_IMPLEMENTED if |in| is a secure buffer and this * device does not support secure buffers - * @retval OEMCrypto_ERROR_INVALID_CONTEXT if |in_length| is 0 or any of the + * @retval OEMCrypto_ERROR_INVALID_CONTEXT if |in_count| is 0 or any of the * pointers are NULL * @retval OEMCrypto_ERROR_INVALID_CONTEXT if the buffer is secure and the * handle is invalid @@ -79,7 +79,7 @@ OEMCryptoResult WTPI_Crc32Cont(const uint8_t* in, size_t in_length, * @retval OEMCrypto_SUCCESS otherwise */ OEMCryptoResult WTPI_Crc32Cont_OutputBuffer(const OPK_OutputBuffer* in, - size_t in_offset, size_t in_length, + size_t in_offset, size_t in_count, uint32_t prev_crc, uint32_t* new_crc); diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crypto_and_key_management_interface_layer2.h b/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crypto_and_key_management_interface_layer2.h index 5218188..4966c83 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crypto_and_key_management_interface_layer2.h +++ b/oemcrypto/opk/oemcrypto_ta/wtpi/wtpi_crypto_and_key_management_interface_layer2.h @@ -390,7 +390,7 @@ OEMCryptoResult WTPI_K2_AESDecryptAndCreateKeyHandle( * * @param[in] decrypt_key_handle: key handle for AES decryption * @param[in] enc_mac_keys: AES-encrypted keys to be decrypted and turned into - * handlese + * handles * @param[in] enc_mac_keys_length: length of AES-encrypted input, in bytes * @param[in] iv: initialization vector * @param[out] out_mac_key_server: output key handle for server @@ -416,9 +416,13 @@ OEMCryptoResult WTPI_K2_AESDecryptAndCreateKeyHandleForMacKeys( * @param[in] key_handle: key handle for AES CMAC operation * @param[in] counter: input value used for CMAC. If this function is being * called multiple times to derive different keys from the same context, this - * counter should be incremented +2 each time. + * counter should be incremented +2 each time + * @param[in] key_label: input label data for AES CMAC + * @param[in] key_label_length: length of label data in bytes * @param[in] context: input data for AES CMAC * @param[in] context_length: length of context data in bytes + * @param[in] context_suffix: input data for AES CMAC + * @param[in] context_suffix_length: length of context_suffix data in bytes * @param[in] out_key_type: desired type of output key * @param[in] out_key_size: desired size of output key * @param[out] out_key_handle: output key handle @@ -430,9 +434,10 @@ OEMCryptoResult WTPI_K2_AESDecryptAndCreateKeyHandleForMacKeys( */ OEMCryptoResult WTPI_K2_DeriveKeyFromKeyHandle( WTPI_K2_SymmetricKey_Handle key_handle, uint8_t counter, - const uint8_t* context, size_t context_length, - SymmetricKeyType out_key_type, KeySize out_key_size, - WTPI_K2_SymmetricKey_Handle* out_key_handle); + const uint8_t* key_label, size_t key_label_length, const uint8_t* context, + size_t context_length, const uint8_t* context_suffix, + size_t context_suffix_length, SymmetricKeyType out_key_type, + KeySize out_key_size, WTPI_K2_SymmetricKey_Handle* out_key_handle); /** * Wraps the |key_handle| into a buffer that can be saved to the file system. diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/cose_util.c b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/cose_util.c index 2260749..7de7870 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/cose_util.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/cose_util.c @@ -196,7 +196,9 @@ static DiceResult EncodeProtectedAttributes(size_t buffer_size, uint8_t* buffer, static DiceResult EncodeConfigurationDescriptor(size_t buffer_size, uint8_t* buffer, - size_t* encoded_size) { + size_t* encoded_size, + uint32_t entry_index, + bool is_leaf) { /* -4670548 : bstr .cbor { ; Configuration Descriptor ? -70002 : tstr, ; Component name @@ -217,7 +219,14 @@ static DiceResult EncodeConfigurationDescriptor(size_t buffer_size, // Add component name. CborWriteInt(kComponentNameLabel, &out); - CborWriteTstr("Widevine", &out); + if (is_leaf) { + // The leaf certificate's component name must contain "Widevine". + CborWriteTstr("Widevine", &out); + } else { + char buf[32] = {0}; + snprintf(buf, sizeof(buf), "Component %u", entry_index); + CborWriteTstr(buf, &out); + } // Add component version. CborWriteInt(kComponentVersionLabel, &out); @@ -366,7 +375,7 @@ OEMCryptoResult DiceCoseSignAndEncodeSign1(const uint8_t* payload, static OEMCryptoResult GenerateEncodedBccPayload( const uint8_t* encoded_public_key, size_t encoded_public_key_size, - uint32_t entry_index, uint8_t* out, size_t* out_length) { + uint32_t entry_index, bool is_leaf, uint8_t* out, size_t* out_length) { ABORT_IF_NULL(encoded_public_key); ABORT_IF_ZERO(encoded_public_key_size); ABORT_IF_NULL(out); @@ -449,7 +458,7 @@ static OEMCryptoResult GenerateEncodedBccPayload( size_t configuration_descriptor_size = 0; const DiceResult dice_result = EncodeConfigurationDescriptor( sizeof(configuration_descriptor), configuration_descriptor, - &configuration_descriptor_size); + &configuration_descriptor_size, entry_index, is_leaf); if (dice_result != kDiceResultOk) { return OEMCrypto_ERROR_UNKNOWN_FAILURE; } @@ -596,7 +605,7 @@ OEMCryptoResult BuildDegenerateBootCertificateChain( uint8_t bcc_payload[BCC_MAX_LENGTH]; size_t bcc_payload_size = sizeof(bcc_payload); OEMCryptoResult result = GenerateEncodedBccPayload( - encoded_public_key, encoded_public_key_size, /*entry_index=*/0, + encoded_public_key, encoded_public_key_size, /*entry_index=*/0, true, bcc_payload, &bcc_payload_size); if (result != OEMCrypto_SUCCESS) return result; @@ -680,9 +689,10 @@ OEMCryptoResult BuildBootCertificateChain( uint8_t bcc_payload[BCC_MAX_PAYLOAD_LENGTH]; size_t bcc_payload_size = sizeof(bcc_payload); + const bool is_leaf = (i == entry_count - 1); OEMCryptoResult result = GenerateEncodedBccPayload( encoded_entry_public_key, encoded_entry_public_key_size, - /*entry_index=*/(uint32_t)i, bcc_payload, &bcc_payload_size); + /*entry_index=*/(uint32_t)i, is_leaf, bcc_payload, &bcc_payload_size); if (result != OEMCrypto_SUCCESS) return result; size_t encoded_cose_sign1_size = 0; result = DiceCoseSignAndEncodeSign1( diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crc32.c b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crc32.c index a4a72a6..a821140 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crc32.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crc32.c @@ -83,14 +83,14 @@ OEMCryptoResult WTPI_Crc32Cont(const uint8_t* in, size_t in_length, } OEMCryptoResult WTPI_Crc32Cont_OutputBuffer(const OPK_OutputBuffer* in, - size_t in_offset, size_t in_length, + size_t in_offset, size_t in_count, uint32_t prev_crc, uint32_t* new_crc) { size_t total_size; - if (OPK_AddOverflowUX(in_offset, in_length, &total_size)) { + if (OPK_AddOverflowUX(in_offset, in_count, &total_size)) { return OEMCrypto_ERROR_INVALID_CONTEXT; } - if (in == NULL || in_length == 0 || new_crc == NULL || + if (in == NULL || in_count == 0 || new_crc == NULL || total_size > in->size) { return OEMCrypto_ERROR_INVALID_CONTEXT; } @@ -108,6 +108,6 @@ OEMCryptoResult WTPI_Crc32Cont_OutputBuffer(const OPK_OutputBuffer* in, } else { return OEMCrypto_ERROR_INVALID_CONTEXT; } - *new_crc = wvrunningcrc32(src, in_length, prev_crc); + *new_crc = wvrunningcrc32(src, in_count, prev_crc); return OEMCrypto_SUCCESS; } diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crypto_and_key_management_layer1_hw.c b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crypto_and_key_management_layer1_hw.c index 65232c9..9df6c72 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crypto_and_key_management_layer1_hw.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crypto_and_key_management_layer1_hw.c @@ -767,8 +767,8 @@ OEMCryptoResult WTPI_C1_RandomBytes(uint8_t* out, size_t size) { } OEMCryptoResult WTPI_K1_PrepareExternalKeyHandle( - WTPI_K1_SymmetricKey_Handle key_handle, uint8_t* out_buffer, - size_t* out_buffer_length) { + WTPI_K1_SymmetricKey_Handle key_handle UNUSED, uint8_t* out_buffer UNUSED, + size_t* out_buffer_length UNUSED) { // TODO(mattfedd): something hardware specific? return OEMCrypto_ERROR_NOT_IMPLEMENTED; } diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_reference.gyp b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_reference.gyp index b8e4df2..f2bc117 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_reference.gyp +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_reference.gyp @@ -4,7 +4,6 @@ { 'variables': { - # TODO(b/207176111): add test scripts to cover both reference crypto impl 'reference_crypto_impl%': 'software', 'prov4_bcc_signature_type%': 'none', 'use_provisioning_30%': 'none', diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_oemcrypto_tee_test_api.c b/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_oemcrypto_tee_test_api.c index 0e2f850..3192394 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_oemcrypto_tee_test_api.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_oemcrypto_tee_test_api.c @@ -1930,7 +1930,7 @@ cleanup_and_return: } OEMCryptoResult WTPI_Crc32Cont_OutputBuffer(const OPK_OutputBuffer* in, - size_t in_offset, size_t in_length, + size_t in_offset, size_t in_count, uint32_t prev_crc, uint32_t* new_crc) { pthread_mutex_lock(&api_lock); @@ -1939,7 +1939,7 @@ OEMCryptoResult WTPI_Crc32Cont_OutputBuffer(const OPK_OutputBuffer* in, ODK_Message response = ODK_Message_Create(NULL, 0); API_Initialize(); - request = OPK_Pack_Crc32Cont_OutputBuffer_Request(in, in_offset, in_length, + request = OPK_Pack_Crc32Cont_OutputBuffer_Request(in, in_offset, in_count, prev_crc, new_crc); if (ODK_Message_GetStatus(&request) != MESSAGE_STATUS_OK) { if (ODK_Message_GetStatus(&request) == MESSAGE_STATUS_BUFFER_TOO_LARGE) { diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.c b/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.c index 4b7c797..7fb1e8c 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.c @@ -1984,7 +1984,7 @@ void OPK_Unpack_Crc32Cont_Response(ODK_Message* msg, OEMCryptoResult* result, ODK_Message OPK_Pack_Crc32Cont_OutputBuffer_Request(const OPK_OutputBuffer* in, size_t in_offset, - size_t in_length, + size_t in_count, uint32_t prev_crc, const uint32_t* new_crc) { uint32_t api_value = 10053; /* from _tee10053 */ @@ -1992,21 +1992,9 @@ ODK_Message OPK_Pack_Crc32Cont_OutputBuffer_Request(const OPK_OutputBuffer* in, OPK_Pack_uint32_t(&msg, &api_value); uint64_t timestamp = time(0); OPK_Pack_uint64_t(&msg, ×tamp); - OPK_Pack_size_t(&msg, &in_length); - /* pack object array with packer function OPK_Pack_OPK_OutputBuffer */ - ODK_Message* const odk_message = &msg; - const void* const objs = (const void*)in; - const LengthType count = OPK_ToLengthType(in_length); - const size_t size = sizeof(OPK_OutputBuffer); - const bool is_null = objs == NULL || OPK_LengthIsNull(count); - if (!OPK_PackBoolValue(odk_message, is_null)) { - for (size_t i = 0; i < OPK_ToSizeT(count); i++) { - const uint8_t* new_address = (const uint8_t*)objs + i * size; - OPK_Pack_OPK_OutputBuffer( - odk_message, (const OPK_OutputBuffer*)(const void*)new_address); - } - } + OPK_PackNullable_OPK_OutputBuffer(&msg, in); OPK_Pack_size_t(&msg, &in_offset); + OPK_Pack_size_t(&msg, &in_count); OPK_Pack_uint32_t(&msg, &prev_crc); OPK_PackIsNull(&msg, new_crc); OPK_PackEOM(&msg); diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.h b/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.h index 29dbb77..a9bb7fc 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.h +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_ree_serializer.h @@ -309,7 +309,7 @@ void OPK_Unpack_Crc32Cont_Response(ODK_Message* msg, OEMCryptoResult* result, uint32_t** new_crc); ODK_Message OPK_Pack_Crc32Cont_OutputBuffer_Request(const OPK_OutputBuffer* in, size_t in_offset, - size_t in_length, + size_t in_count, uint32_t prev_crc, const uint32_t* new_crc); void OPK_Unpack_Crc32Cont_OutputBuffer_Response(ODK_Message* msg, diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_test/settings.gypi b/oemcrypto/opk/oemcrypto_ta/wtpi_test/settings.gypi index 85c7fd7..463185b 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/settings.gypi +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/settings.gypi @@ -21,6 +21,13 @@ '-g', '-Werror=all', ], + 'cflags_c' : [ + '-std=c11', + '-D_POSIX_C_SOURCE=200809L', + ], + 'cflags_cc' : [ + '-std=c++17', + ], 'include_dirs' : [ '.', '<(common_dir)', diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_dispatcher.c b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_dispatcher.c index 9d9b22b..25cca8d 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_dispatcher.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_dispatcher.c @@ -1178,23 +1178,25 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, } case 10053: /* WTPI_Crc32Cont_OutputBuffer */ { - size_t in_length; - OPK_Init_size_t((size_t*)&in_length); - OPK_OutputBuffer* in; - OPK_InitPointer((uint8_t**)&in); + OPK_OutputBuffer* in = + (OPK_OutputBuffer*)OPK_VarAlloc(sizeof(OPK_OutputBuffer)); + if (in == NULL) goto handle_out_of_memory; + OPK_Init_OPK_OutputBuffer((OPK_OutputBuffer*)in); size_t in_offset; OPK_Init_size_t((size_t*)&in_offset); + size_t in_count; + OPK_Init_size_t((size_t*)&in_count); uint32_t prev_crc; OPK_Init_uint32_t((uint32_t*)&prev_crc); uint32_t* new_crc; OPK_InitPointer((uint8_t**)&new_crc); - OPK_Unpack_Crc32Cont_OutputBuffer_Request( - request, &in, &in_offset, &in_length, &prev_crc, &new_crc); + OPK_Unpack_Crc32Cont_OutputBuffer_Request(request, &in, &in_offset, + &in_count, &prev_crc, &new_crc); if (!ODK_Message_IsValid(request)) goto handle_invalid_request; OEMCryptoResult result; OPK_Init_uint32_t((uint32_t*)&result); LOGD("Crc32Cont_OutputBuffer"); - result = WTPI_Crc32Cont_OutputBuffer(in, in_offset, in_length, prev_crc, + result = WTPI_Crc32Cont_OutputBuffer(in, in_offset, in_count, prev_crc, new_crc); *response = OPK_Pack_Crc32Cont_OutputBuffer_Response(result, new_crc); break; diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.c b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.c index c3045c2..1dfdd04 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.c @@ -1541,42 +1541,16 @@ ODK_Message OPK_Pack_Crc32Cont_Response(OEMCryptoResult result, void OPK_Unpack_Crc32Cont_OutputBuffer_Request( ODK_Message* msg, OPK_OutputBuffer** in, size_t* in_offset, - size_t* in_length, uint32_t* prev_crc, uint32_t** new_crc) { + size_t* in_count, uint32_t* prev_crc, uint32_t** new_crc) { uint32_t api_value = UINT32_MAX; OPK_Unpack_uint32_t(msg, &api_value); if (api_value != 10053) ODK_MESSAGE_SETSTATUS(msg, MESSAGE_STATUS_API_VALUE_ERROR); uint64_t timestamp; OPK_Unpack_uint64_t(msg, ×tamp); - OPK_Unpack_size_t(msg, in_length); - /* unpack object array with unpacker function OPK_Unpack_OPK_OutputBuffer */ - ODK_Message* odk_message = msg; - void** address = (void**)in; - LengthType count = OPK_FromSizeTPtr(in_length); - size_t size = sizeof(OPK_OutputBuffer); - if (address) { - *address = NULL; - } - if (!OPK_UnpackIsNull(odk_message)) { - if (address && !OPK_LengthIsNull(count)) { - size_t bytes_to_unpack = 0; - if (odk_mul_overflow_ux(OPK_ToSizeT(count), size, &bytes_to_unpack)) { - ODK_MESSAGE_SETSTATUS(odk_message, MESSAGE_STATUS_PARSE_ERROR); - } else { - *address = OPK_BumpAllocate(bytes_to_unpack); - if (!*address) { - ODK_MESSAGE_SETSTATUS(odk_message, MESSAGE_STATUS_OUT_OF_MEMORY); - } else { - for (size_t i = 0; i < OPK_ToSizeT(count); i++) { - uint8_t* new_address = (uint8_t*)(*address) + size * i; - OPK_Unpack_OPK_OutputBuffer( - odk_message, (OPK_OutputBuffer*)((void*)new_address)); - } - } - } - } - } + OPK_UnpackNullable_OPK_OutputBuffer(msg, in); OPK_Unpack_size_t(msg, in_offset); + OPK_Unpack_size_t(msg, in_count); OPK_Unpack_uint32_t(msg, prev_crc); *new_crc = (uint32_t*)OPK_UnpackAlloc(msg, sizeof(uint32_t)); OPK_UnpackEOM(msg); diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.h b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.h index 089e4b9..f24fe23 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.h +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_tee_serializer.h @@ -286,7 +286,7 @@ ODK_Message OPK_Pack_Crc32Cont_Response(OEMCryptoResult result, const uint32_t* new_crc); void OPK_Unpack_Crc32Cont_OutputBuffer_Request( ODK_Message* msg, OPK_OutputBuffer** in, size_t* in_offset, - size_t* in_length, uint32_t* prev_crc, uint32_t** new_crc); + size_t* in_count, uint32_t* prev_crc, uint32_t** new_crc); ODK_Message OPK_Pack_Crc32Cont_OutputBuffer_Response(OEMCryptoResult result, const uint32_t* new_crc); void OPK_Unpack_GetTrustedTime_Request(ODK_Message* msg, uint64_t** time_in_s); diff --git a/oemcrypto/opk/oemcrypto_ta/wtpi_useless/wtpi_cas.c b/oemcrypto/opk/oemcrypto_ta/wtpi_useless/wtpi_cas.c index 930ca25..81d4d90 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_useless/wtpi_cas.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_useless/wtpi_cas.c @@ -49,3 +49,28 @@ size_t WTPI_GetKeyTokenSize(void) { // TODO return 0; } + +OEMCryptoResult WTPI_SetCasUsage(void* key_slot_descriptor, uint32_t intent, + uint32_t mode) { + // TODO + return OEMCrypto_SUCCESS; +} + +OEMCryptoResult WTPI_GetCasUsage(void* key_slot_descriptor, uint32_t* intent, + uint32_t* mode) { + // TODO + return OEMCrypto_SUCCESS; +} + +OEMCryptoResult WTPI_InstallPVRContentKey( + void* key_slot_descriptor, WTPI_K1_SymmetricKey_Handle key_handle, + uint32_t scrambling_mode, bool is_even) { + // TODO + return OEMCrypto_SUCCESS; +} + +OEMCryptoResult WTPI_InstallPVRContentIV(void* key_slot_descriptor, uint8_t* iv, + size_t iv_length, bool is_even) { + // TODO + return OEMCrypto_SUCCESS; +} diff --git a/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/wtpi_cas.c b/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/wtpi_cas.c index 964d8b0..8cd79ef 100644 --- a/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/wtpi_cas.c +++ b/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/wtpi_cas.c @@ -90,3 +90,28 @@ OEMCryptoResult WTPI_GetKeyToken(void* key_slot_descriptor, uint8_t* key_token, } size_t WTPI_GetKeyTokenSize(void) { return sizeof(CasKeyDescriptor); } + +OEMCryptoResult WTPI_SetCasUsage(void* key_slot_descriptor UNUSED, + uint32_t intent UNUSED, uint32_t mode UNUSED) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; +} + +OEMCryptoResult WTPI_GetCasUsage(void* key_slot_descriptor UNUSED, + uint32_t* intent UNUSED, + uint32_t* mode UNUSED) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; +} + +OEMCryptoResult WTPI_InstallPVRContentKey( + void* key_slot_descriptor UNUSED, + WTPI_K1_SymmetricKey_Handle key_handle UNUSED, + uint32_t scrambling_mode UNUSED, bool is_even UNUSED) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; +} + +OEMCryptoResult WTPI_InstallPVRContentIV(void* key_slot_descriptor UNUSED, + uint8_t* iv UNUSED, + size_t iv_length UNUSED, + bool is_even UNUSED) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; +} diff --git a/oemcrypto/opk/ports/linux/common/test/shared_memory_test.gyp b/oemcrypto/opk/ports/linux/common/test/shared_memory_test.gyp index f5b4220..5ead2c8 100644 --- a/oemcrypto/opk/ports/linux/common/test/shared_memory_test.gyp +++ b/oemcrypto/opk/ports/linux/common/test/shared_memory_test.gyp @@ -1,6 +1,6 @@ { 'includes' : { - '../../../../serialization/settings.gypi', + '../../../../serialization/defaults.gypi', }, 'target_defaults': { 'include_dirs' : [ diff --git a/oemcrypto/opk/ports/linux/liboemcrypto.gyp b/oemcrypto/opk/ports/linux/liboemcrypto.gyp index f44feb0..16ba4c2 100644 --- a/oemcrypto/opk/ports/linux/liboemcrypto.gyp +++ b/oemcrypto/opk/ports/linux/liboemcrypto.gyp @@ -3,7 +3,7 @@ 'serialization_adapter_dir' : 'common', }, 'includes' : [ - '../../serialization/settings.gypi', + '../../serialization/defaults.gypi', ], 'targets' : [ { diff --git a/oemcrypto/opk/ports/linux/oemcrypto_tee_simulator.gyp b/oemcrypto/opk/ports/linux/oemcrypto_tee_simulator.gyp index 43b5f05..3108e1a 100644 --- a/oemcrypto/opk/ports/linux/oemcrypto_tee_simulator.gyp +++ b/oemcrypto/opk/ports/linux/oemcrypto_tee_simulator.gyp @@ -12,7 +12,7 @@ 'serialization_adapter_dir' : 'common', }, 'includes' : { - '../../serialization/settings.gypi', + '../../serialization/defaults.gypi', }, 'target_defaults': { 'include_dirs' : [ diff --git a/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/layer2_crypto_key_table.c b/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/layer2_crypto_key_table.c index b5d855d..1b49452 100644 --- a/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/layer2_crypto_key_table.c +++ b/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/layer2_crypto_key_table.c @@ -170,14 +170,15 @@ bool K2_IsKeyValid(uint32_t index) { case CONTENT_KEY: // We cheat a little here. We also call generic crypto keys "content // keys", even though some of them are 256 bit HMAC keys. - return key->size == KEY_SIZE_128 || key->size == KEY_SIZE_256; + return (key->size == KEY_SIZE_128 || key->size == KEY_SIZE_256); case ENTITLEMENT_KEY: case MAC_KEY_SERVER: case MAC_KEY_CLIENT: return key->size == KEY_SIZE_256; case ENCRYPTION_KEY: - case DERIVING_KEY: return key->size == KEY_SIZE_128; + case DERIVING_KEY: + return (key->size == KEY_SIZE_128 || key->size == KEY_SIZE_256); } return false; } diff --git a/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_crypto_and_key_management_layer2_hw.c b/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_crypto_and_key_management_layer2_hw.c index 536794b..918ed33 100644 --- a/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_crypto_and_key_management_layer2_hw.c +++ b/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_crypto_and_key_management_layer2_hw.c @@ -122,15 +122,19 @@ OEMCryptoResult WTPI_C2_AESCBCEncrypt(WTPI_K2_SymmetricKey_Handle key_handle, static OEMCryptoResult DeriveKeyWithCMACToKeyHandle( const uint8_t* key, KeySize key_size, uint8_t counter, - const uint8_t* context, size_t context_length, - SymmetricKeyType out_key_type, KeySize out_key_size, - WTPI_K2_SymmetricKey_Handle* out_key_handle) { + const uint8_t* key_label, size_t key_label_length, const uint8_t* context, + size_t context_length, const uint8_t* context_suffix, + size_t context_suffix_length, SymmetricKeyType out_key_type, + KeySize out_key_size, WTPI_K2_SymmetricKey_Handle* out_key_handle) { if ((out_key_size != KEY_SIZE_128 && out_key_size != KEY_SIZE_256) || - context == NULL || context_length <= 0 || out_key_handle == NULL) { + key == NULL || key_label == NULL || context == NULL || + context_length <= 0 || context_suffix == NULL || out_key_handle == NULL) { return OEMCrypto_ERROR_INVALID_CONTEXT; } uint8_t buffer[KEY_SIZE_256]; - if (!OPKI_DeriveKeyWithCMAC(key, key_size, counter, context, context_length, + if (!OPKI_DeriveKeyWithCMAC(key, key_size, counter, key_label, + key_label_length, context, context_length, + context_suffix, context_suffix_length, out_key_size, buffer)) { return OEMCrypto_ERROR_UNKNOWN_FAILURE; } @@ -244,6 +248,17 @@ OEMCryptoResult WTPI_C2_HMAC_SHA256_Verify( return OEMCrypto_SUCCESS; } +OEMCryptoResult WTPI_C2_SHA512(const uint8_t* message, size_t message_length, + uint8_t* out) { + if (message == NULL || message_length == 0 || out == NULL) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + if (!SHA512(message, message_length, out)) { + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + return OEMCrypto_SUCCESS; +} + OEMCryptoResult WTPI_C2_RandomBytes(uint8_t* out, size_t size) { if (out == NULL || size == 0) return OEMCrypto_ERROR_INVALID_CONTEXT; if (RAND_bytes(out, (int)size) != 1) return OEMCrypto_ERROR_UNKNOWN_FAILURE; @@ -298,6 +313,8 @@ OEMCryptoResult WTPI_K2_DeriveDeviceKeyIntoHandle( // Cast the type into 32 bits so it is the same size as the gap left for it in // full_context. This will be a no-op on most architectures. const uint32_t type_32 = (uint32_t)type_temp; + // Don't pass these values so the derivation is the same as before. + const uint8_t kNoBuffer[1]; // Build a full context that is unique to this starting context / key type // combination. We start with a context template with blanks at the beginning // and fill the blanks with the starting context and key type. @@ -308,8 +325,10 @@ OEMCryptoResult WTPI_K2_DeriveDeviceKeyIntoHandle( memcpy(full_context + 4, &type_32, 4); const uint8_t counter = 1; result = WTPI_K2_DeriveKeyFromKeyHandle( - temp_key_handle, counter, (const uint8_t*)full_context, context_length, - out_key_type, out_key_size, out_key_handle); + temp_key_handle, counter, kNoBuffer, + /* key_label_length= */ 0, (const uint8_t*)full_context, context_length, + kNoBuffer, /* context_suffix_length= */ 0, out_key_type, out_key_size, + out_key_handle); WTPI_K2_FreeKeyHandle(temp_key_handle); return result; } @@ -385,11 +404,12 @@ OEMCryptoResult WTPI_K2_AESDecryptAndCreateKeyHandleForMacKeys( OEMCryptoResult WTPI_K2_DeriveKeyFromKeyHandle( WTPI_K2_SymmetricKey_Handle key_handle, uint8_t counter, - const uint8_t* context, size_t context_length, - SymmetricKeyType out_key_type, KeySize out_key_size, - WTPI_K2_SymmetricKey_Handle* out_key_handle) { - if (key_handle == NULL || context == NULL || context_length == 0 || - out_key_handle == NULL) { + const uint8_t* key_label, size_t key_label_length, const uint8_t* context, + size_t context_length, const uint8_t* context_suffix, + size_t context_suffix_length, SymmetricKeyType out_key_type, + KeySize out_key_size, WTPI_K2_SymmetricKey_Handle* out_key_handle) { + if (key_handle == NULL || key_label == NULL || context == NULL || + context_length == 0 || context_suffix == NULL || out_key_handle == NULL) { return OEMCrypto_ERROR_INVALID_CONTEXT; } if (!WTPI_K2_IsKeyHandleValid(key_handle)) { @@ -400,12 +420,13 @@ OEMCryptoResult WTPI_K2_DeriveKeyFromKeyHandle( if (K2_GetKeyType(key_handle->index) != DERIVING_KEY) { return OEMCrypto_ERROR_INVALID_CONTEXT; } - return DeriveKeyWithCMACToKeyHandle(key, key_size, counter, context, - context_length, out_key_type, - out_key_size, out_key_handle); + return DeriveKeyWithCMACToKeyHandle( + key, key_size, counter, key_label, key_label_length, context, + context_length, context_suffix, context_suffix_length, out_key_type, + out_key_size, out_key_handle); } -OEMCryptoResult WTPI_K2_WrapKey(uint32_t context, +OEMCryptoResult WTPI_K2_WrapKey(uint32_t context UNUSED, WTPI_K2_SymmetricKey_Handle key_handle, SymmetricKeyType key_type, uint8_t* wrapped_key, size_t wrapped_key_length) { @@ -432,8 +453,9 @@ OEMCryptoResult WTPI_K2_WrapKey(uint32_t context, } OEMCryptoResult WTPI_K2_UnwrapIntoKeyHandle( - uint32_t context, const uint8_t* wrapped_key, size_t wrapped_key_length, - SymmetricKeyType key_type, WTPI_K2_SymmetricKey_Handle* out_key_handle) { + uint32_t context UNUSED, const uint8_t* wrapped_key, + size_t wrapped_key_length, SymmetricKeyType key_type, + WTPI_K2_SymmetricKey_Handle* out_key_handle) { if (wrapped_key == NULL || wrapped_key_length == 0 || out_key_handle == NULL) { return OEMCrypto_ERROR_INVALID_CONTEXT; diff --git a/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_test_impl.gyp b/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_test_impl.gyp index 417d082..ac0316c 100644 --- a/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_test_impl.gyp +++ b/oemcrypto/opk/ports/linux/ta/common/wtpi_impl/wtpi_test_impl.gyp @@ -6,7 +6,6 @@ 'variables': { 'oemcrypto_ta_dir' : '<(DEPTH)/oemcrypto/opk/oemcrypto_ta', 'odk_dir' : '<(DEPTH)/oemcrypto/odk', - # TODO(b/207176111): add test scripts to cover both reference crypto impl 'reference_crypto_impl%': 'software', 'test_renewal%': 0, # Path to wtpi implementations that pass tests but are unsuitable for diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/opk_config.h b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/opk_config.h index 5ea9181..ec279c9 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/opk_config.h +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/opk_config.h @@ -50,6 +50,22 @@ #define OPK_CONFIG_PROVISIONING_METHOD OEMCrypto_BootCertificateChain #endif +#if defined(WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE) +// WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE: +// OEMCrypto_BCCSigType_Unknown = 0, +// OEMCrypto_BCCSigType_CBOR = 1, +// OEMCrypto_BCCSigType_PKCS7 = 2, +#if WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE == 1 +#define OPK_CONFIG_BCC_SIGNATURE_TYPE OEMCrypto_BCCSigType_CBOR +#elif WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE == 2 +#define OPK_CONFIG_BCC_SIGNATURE_TYPE OEMCrypto_BCCSigType_PKCS7 +#endif +#endif + +#ifndef OPK_CONFIG_BCC_SIGNATURE_TYPE +#define OPK_CONFIG_BCC_SIGNATURE_TYPE OEMCrypto_BCCSigType_Unknown +#endif + // Use defaults from wtpi_reference for the rest #include "config/default.h" diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/transport_interface.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/transport_interface.c index 25f814e..2273e21 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/transport_interface.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/transport_interface.c @@ -24,18 +24,16 @@ static uint8_t message_buffer[OPK_TRANSPORT_MESSAGE_SIZE]; -bool TOS_Transport_Initialize(void) { - return true; -} +bool TOS_Transport_Initialize(void) { return true; } void TOS_Transport_Terminate(void) {} ODK_Message TOS_Transport_GetRequest(void) { - return ODK_Message_Create(message_buffer, sizeof(message_buffer)); + return ODK_Message_Create(message_buffer, sizeof(message_buffer)); } ODK_Message TOS_Transport_GetResponse(void) { - return TOS_Transport_GetRequest(); + return TOS_Transport_GetRequest(); } void TOS_Transport_ReleaseMessage(ODK_Message* message) {} diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_clock_layer2.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_clock_layer2.c index 7ea83fe..b93b301 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_clock_layer2.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_clock_layer2.c @@ -24,11 +24,11 @@ #include OEMCryptoResult WTPI_GetSecureTimer(uint64_t* time_in_s) { - int64_t now; - int rc = trusty_gettime(0, &now); - if (rc != NO_ERROR) { - return OEMCrypto_ERROR_UNKNOWN_FAILURE; - } - *time_in_s = now / 1000000000ll; - return OEMCrypto_SUCCESS; + int64_t now; + int rc = trusty_gettime(0, &now); + if (rc != NO_ERROR) { + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + *time_in_s = now / 1000000000ll; + return OEMCrypto_SUCCESS; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_config.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_config.c new file mode 100644 index 0000000..52b71d1 --- /dev/null +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_config.c @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "wtpi_config_interface.h" + +#include + +#include +#include "opk_config.h" + +OEMCrypto_Security_Level WTPI_GetSecurityLevel(void) { + return OPK_CONFIG_SECURITY_LEVEL; +} + +/* + * WIDEVINE_PROVISION_METHOD is a mandatory variable set by the platform's build + * file (*-inc.mk) + */ +OEMCrypto_ProvisioningMethod WTPI_GetProvisioningMethod(void) { +#if WIDEVINE_PROVISION_METHOD == 2 + return OEMCrypto_Keybox; +#elif WIDEVINE_PROVISION_METHOD == 4 + return OEMCrypto_BootCertificateChain; +#else +# error message "Unsupported provisioning method." +#endif +} + +OEMCryptoResult WTPI_GetBCCType(OEMCrypto_BCCType* bcc_type) { + if (bcc_type == NULL) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + if (WTPI_GetProvisioningMethod() != OEMCrypto_BootCertificateChain) { + return OEMCrypto_ERROR_NOT_IMPLEMENTED; + } + *bcc_type = OEMCrypto_CBOR; + return OEMCrypto_SUCCESS; +} + +uint32_t WTPI_GetResourceRatingTier(void) { + return OPK_CONFIG_RESOURCE_RATING_TIER; +} + +uint32_t TEE_GetRSAPaddingSchemes(void) { + return kSign_RSASSA_PSS ^ kSign_PKCS1_Block1; +} + +OEMCryptoResult WTPI_GetCurrentSRMVersion(uint32_t* srm_version) { + if (srm_version == NULL) return OEMCrypto_ERROR_INVALID_CONTEXT; + *srm_version = 0; + return OEMCrypto_SUCCESS; +} + +bool WTPI_IsAntiRollbackHWPresent(void) { + return OPK_CONFIG_HW_ANTIROLLBACK_SUPPORTED; +} + +OEMCryptoResult WTPI_ApplyCGMS(uint8_t cgms_field) { + /* No CGMS for test impl. */ + return OEMCrypto_ERROR_UNKNOWN_FAILURE; +} + +bool WTPI_IsCGMS_AActive(void) { return false; } + +bool WTPI_SupportsCGMS_A(void) { return OPK_CONFIG_SUPPORTS_CGMSA; } + +bool WTPI_HasAnalogDisplay(void) { return OPK_CONFIG_HAS_ANALOG_DISPLAY; } + +bool WTPI_IsAnalogDisplayActive(void) { return false; } + +bool WTPI_CanDisableAnalogDisplay(void) { return false; } + +bool WTPI_DisableAnalogDisplay(void) { + return OPK_CONFIG_CAN_DISABLE_ANALOG_DISPLAY; +} + +size_t WTPI_MaxOutputSizeForDecrypt(void) { + return OPK_CONFIG_MAX_OUTPUT_SIZE_FOR_DECRYPT; +} + +bool WTPI_IsClosedPlatform(void) { return OPK_CONFIG_IS_CLOSED_PLATFORM; } + +size_t WTPI_MaxBufferSizeForGenericCrypto(void) { + return OPK_CONFIG_MAX_BUFFER_SIZE_FOR_GENERIC_CRYPTO; +} + +size_t WTPI_MaxSampleSize(void) { return OPK_CONFIG_MAX_SAMPLE_SIZE; } + +uint32_t WTPI_SupportedCertificates(void) { + return OPK_CONFIG_SUPPORTED_CERTIFICATES; +} + +bool WTPI_IsProductionReady(void) { + return system_state_provisioning_allowed() == false; +} + +OEMCrypto_DTCP2_Capability WTPI_GetDTCP2Capability(void) { + return OEMCrypto_NO_DTCP2; +} + +OEMCrypto_WatermarkingSupport WTPI_GetWatermarkingSupport(void) { + return OPK_CONFIG_WATERMARKING_SUPPORT; +} + +OPK_FeatureStatus WTPI_IsTAAntiRollbackEnabled(void) { + if (!system_state_app_loading_skip_version_check()) { + return OPK_FEATURE_ENABLED; + } + return OPK_FEATURE_DISABLED; +} + +bool WTPI_ContentDecryptBypassesTA(void) { + return OPK_CONFIG_DECRYPT_BYPASSES_TA; +} diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_initialize_terminate.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_initialize_terminate.c index 64ad3ed..0783dc0 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_initialize_terminate.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_initialize_terminate.c @@ -26,62 +26,64 @@ #include "tee_context.h" static void close_storage_sessions(tee_context* ctx) { - if (ctx->old_provisioning_session != STORAGE_INVALID_SESSION) { - storage_close_session(ctx->old_provisioning_session); - ctx->old_provisioning_session = STORAGE_INVALID_SESSION; - } - if (ctx->new_provisioning_session != STORAGE_INVALID_SESSION) { - storage_close_session(ctx->new_provisioning_session); - ctx->new_provisioning_session = STORAGE_INVALID_SESSION; - } - if (ctx->user_data_session != STORAGE_INVALID_SESSION) { - storage_close_session(ctx->user_data_session); - ctx->user_data_session = STORAGE_INVALID_SESSION; - } + if (ctx->old_provisioning_session != STORAGE_INVALID_SESSION) { + storage_close_session(ctx->old_provisioning_session); + ctx->old_provisioning_session = STORAGE_INVALID_SESSION; + } + if (ctx->new_provisioning_session != STORAGE_INVALID_SESSION) { + storage_close_session(ctx->new_provisioning_session); + ctx->new_provisioning_session = STORAGE_INVALID_SESSION; + } + if (ctx->user_data_session != STORAGE_INVALID_SESSION) { + storage_close_session(ctx->user_data_session); + ctx->user_data_session = STORAGE_INVALID_SESSION; + } } OEMCryptoResult WTPI_Initialize(void) { - TLOGD("WTPI_Initialize\n"); + TLOGD("WTPI_Initialize\n"); - tee_context* ctx = get_tee_context(); + tee_context* ctx = get_tee_context(); - assert(ctx->old_provisioning_session == STORAGE_INVALID_SESSION); - assert(ctx->new_provisioning_session == STORAGE_INVALID_SESSION); - assert(ctx->user_data_session == STORAGE_INVALID_SESSION); + assert(ctx->old_provisioning_session == STORAGE_INVALID_SESSION); + assert(ctx->new_provisioning_session == STORAGE_INVALID_SESSION); + assert(ctx->user_data_session == STORAGE_INVALID_SESSION); - storage_session_t newsession; - int rc = storage_open_session(&newsession, STORAGE_CLIENT_TP_PORT); - if (rc < 0) { - TLOGE("WTPI_Initialize: couldn't open provisioning override storage session\n"); - close_storage_sessions(ctx); - return OEMCrypto_ERROR_UNKNOWN_FAILURE; - } - ctx->new_provisioning_session = newsession; + storage_session_t newsession; + int rc = storage_open_session(&newsession, STORAGE_CLIENT_TP_PORT); + if (rc < 0) { + TLOGE( + "WTPI_Initialize: couldn't open provisioning override storage " + "session\n"); + close_storage_sessions(ctx); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + ctx->new_provisioning_session = newsession; - rc = storage_open_session(&newsession, STORAGE_CLIENT_TD_PORT); - if (rc < 0) { - TLOGE("WTPI_Initialize: couldn't open user data storage session\n"); - close_storage_sessions(ctx); - return OEMCrypto_ERROR_UNKNOWN_FAILURE; - } - ctx->user_data_session = newsession; + rc = storage_open_session(&newsession, STORAGE_CLIENT_TD_PORT); + if (rc < 0) { + TLOGE("WTPI_Initialize: couldn't open user data storage session\n"); + close_storage_sessions(ctx); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + ctx->user_data_session = newsession; - rc = storage_open_session(&newsession, STORAGE_CLIENT_TDP_PORT); - if (rc < 0) { - TLOGE("WTPI_Initialize: couldn't open provisioning storage session\n"); - /* - * Don't return an error. We use the new_provisioning_session (TP) - * by default, so we might not need old_provisioning_session (TDP). - */ - } else { - ctx->old_provisioning_session = newsession; - } + rc = storage_open_session(&newsession, STORAGE_CLIENT_TDP_PORT); + if (rc < 0) { + TLOGE("WTPI_Initialize: couldn't open provisioning storage session\n"); + /* + * Don't return an error. We use the new_provisioning_session (TP) + * by default, so we might not need old_provisioning_session (TDP). + */ + } else { + ctx->old_provisioning_session = newsession; + } - return OEMCrypto_SUCCESS; + return OEMCrypto_SUCCESS; } OEMCryptoResult WTPI_Terminate(void) { - TLOGD("WTPI_Terminate\n"); - close_storage_sessions(get_tee_context()); - return OEMCrypto_SUCCESS; + TLOGD("WTPI_Terminate\n"); + close_storage_sessions(get_tee_context()); + return OEMCrypto_SUCCESS; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_persistent_storage_layer1.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_persistent_storage_layer1.c index e079a78..e02e93e 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_persistent_storage_layer1.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_persistent_storage_layer1.c @@ -28,78 +28,78 @@ static const char* kPersistPath = "widevine_persistent_data"; OEMCryptoResult WTPI_PrepareStoredPersistentData(void) { - TLOGD("WTPI_PrepareStoredPersistentData\n"); - tee_context* ctx = get_tee_context(); - assert(ctx->user_data_session != STORAGE_INVALID_SESSION); - return OEMCrypto_SUCCESS; + TLOGD("WTPI_PrepareStoredPersistentData\n"); + tee_context* ctx = get_tee_context(); + assert(ctx->user_data_session != STORAGE_INVALID_SESSION); + return OEMCrypto_SUCCESS; } OEMCryptoResult WTPI_LoadPersistentData(uint8_t* data, size_t* data_length) { - TLOGD("WTPI_LoadPersistentData\n"); + TLOGD("WTPI_LoadPersistentData\n"); - if (!data || !data_length) { - return OEMCrypto_ERROR_INVALID_CONTEXT; + if (!data || !data_length) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + + tee_context* ctx = get_tee_context(); + assert(ctx->user_data_session != STORAGE_INVALID_SESSION); + + file_handle_t handle; + int rc = + storage_open_file(ctx->user_data_session, &handle, kPersistPath, 0, 0); + if (rc < 0) { + if (rc == ERR_NOT_FOUND) { + return OPK_ERROR_NO_PERSISTENT_DATA; } + return OEMCrypto_ERROR_OPEN_FAILURE; + } - tee_context* ctx = get_tee_context(); - assert(ctx->user_data_session != STORAGE_INVALID_SESSION); - - file_handle_t handle; - int rc = storage_open_file(ctx->user_data_session, &handle, kPersistPath, 0, - 0); - if (rc < 0) { - if (rc == ERR_NOT_FOUND) { - return OPK_ERROR_NO_PERSISTENT_DATA; - } - return OEMCrypto_ERROR_OPEN_FAILURE; - } - - storage_off_t datasize; - rc = storage_get_file_size(handle, &datasize); - if (rc < 0) { - TLOGE("couldn't get file size: %d\n", rc); - storage_close_file(handle); - return OEMCrypto_ERROR_OPEN_FAILURE; - } - - if (datasize > *data_length) { - TLOGE("persisted data too big"); - storage_close_file(handle); - *data_length = datasize; - return OEMCrypto_ERROR_SHORT_BUFFER; - } - - rc = storage_read(handle, 0, data, datasize); + storage_off_t datasize; + rc = storage_get_file_size(handle, &datasize); + if (rc < 0) { + TLOGE("couldn't get file size: %d\n", rc); + storage_close_file(handle); + return OEMCrypto_ERROR_OPEN_FAILURE; + } + + if (datasize > *data_length) { + TLOGE("persisted data too big"); storage_close_file(handle); - if (rc < 0) { - TLOGE("error reading persisted data: %d\n", rc); - return OEMCrypto_ERROR_OPEN_FAILURE; - } *data_length = datasize; - return OEMCrypto_SUCCESS; + return OEMCrypto_ERROR_SHORT_BUFFER; + } + + rc = storage_read(handle, 0, data, datasize); + storage_close_file(handle); + if (rc < 0) { + TLOGE("error reading persisted data: %d\n", rc); + return OEMCrypto_ERROR_OPEN_FAILURE; + } + *data_length = datasize; + return OEMCrypto_SUCCESS; } OEMCryptoResult WTPI_StorePersistentData(const uint8_t* data, size_t data_length) { - TLOGD("WTPI_StorePersistentData\n"); + TLOGD("WTPI_StorePersistentData\n"); - tee_context* ctx = get_tee_context(); - assert(ctx->user_data_session != STORAGE_INVALID_SESSION); + tee_context* ctx = get_tee_context(); + assert(ctx->user_data_session != STORAGE_INVALID_SESSION); - file_handle_t handle; - int rc = storage_open_file( - ctx->user_data_session, &handle, kPersistPath, - STORAGE_FILE_OPEN_CREATE | STORAGE_FILE_OPEN_TRUNCATE, 0); - if (rc < 0) { - TLOGE("failed to create persist file: %d\n", rc); - return OEMCrypto_ERROR_OPEN_FAILURE; - } + file_handle_t handle; + int rc = storage_open_file( + ctx->user_data_session, &handle, kPersistPath, + STORAGE_FILE_OPEN_CREATE | STORAGE_FILE_OPEN_TRUNCATE, 0); + if (rc < 0) { + TLOGE("failed to create persist file: %d\n", rc); + return OEMCrypto_ERROR_OPEN_FAILURE; + } - rc = storage_write(handle, 0, data, data_length, STORAGE_OP_COMPLETE); - storage_close_file(handle); - if (rc < 0) { - TLOGE("failed to write persist data: %d\n", rc); - return OEMCrypto_ERROR_UNKNOWN_FAILURE; - } - return OEMCrypto_SUCCESS; + rc = storage_write(handle, 0, data, data_length, STORAGE_OP_COMPLETE); + storage_close_file(handle); + if (rc < 0) { + TLOGE("failed to write persist data: %d\n", rc); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + return OEMCrypto_SUCCESS; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_provisioning_4.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_provisioning_4.c index c98cec8..2632c5b 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_provisioning_4.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_provisioning_4.c @@ -33,13 +33,14 @@ #include "ecc_util.h" #include "oemcrypto_check_macros.h" #include "oemcrypto_key_types.h" +#include "opk_config.h" #include "wtpi_crypto_asymmetric_interface.h" #include "wtpi_device_key_interface.h" #include "wtpi_logging_interface.h" #include "wtpi_memory_interface.h" #define MAX_DEVICE_INFO_SIZE 768 -#define MAX_BCC_SIGNATURE_SIZE 4096 +#define MAX_BCC_SIGNATURE_SIZE 8192 OEMCryptoResult WTPI_GetBootCertificateChain(uint8_t* out, size_t* out_length) { if (out_length == NULL) { @@ -327,27 +328,7 @@ OEMCryptoResult WTPI_GetDeviceFusedStatus(bool* is_fused) { } OEMCrypto_BCCSignatureType WTPI_GetBCCSignatureType(void) { - return OEMCrypto_BCCSigType_Unknown; -} - -OEMCryptoResult WTPI_GenerateBCCSignature(uint8_t* out, size_t* out_length) { - (void)out; - (void)out_length; - return OEMCrypto_ERROR_NOT_IMPLEMENTED; -} - -OEMCryptoResult WTPI_StoreBCCSignature(const uint8_t* signature, - size_t signature_length) { - (void)signature; - (void)signature_length; - return OEMCrypto_ERROR_NOT_IMPLEMENTED; -} - -OEMCryptoResult WTPI_LoadBCCSignature(uint8_t* signature, - size_t* signature_length) { - (void)signature; - (void)signature_length; - return OEMCrypto_ERROR_NOT_IMPLEMENTED; + return OPK_CONFIG_BCC_SIGNATURE_TYPE; } OEMCryptoResult WTPI_GetMaxBCCSignatureSize(size_t* out_length) { @@ -357,3 +338,65 @@ OEMCryptoResult WTPI_GetMaxBCCSignatureSize(size_t* out_length) { *out_length = MAX_BCC_SIGNATURE_SIZE; return OEMCrypto_SUCCESS; } + +OEMCryptoResult WTPI_LoadBCCSignature(uint8_t* out, size_t* out_length) { + if (out == NULL || out_length == NULL) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + size_t required_bcc_signature_size = 0; + OEMCryptoResult result = + WTPI_GetMaxBCCSignatureSize(&required_bcc_signature_size); + if (result != OEMCrypto_SUCCESS) return result; + // Defensive check. Caller to ensure the out buffer is large enough. + if (*out_length < required_bcc_signature_size) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + + uint8_t* signature_buf = NULL; + uint32_t signature_buf_len = 0; + long rc = keymaster_open(); + if (rc < 0) { + TLOGE("Failed to connect to keymaster (err=%ld)\n", rc); + return OEMCrypto_ERROR_UNKNOWN_FAILURE; + } + + keymaster_session_t session = (keymaster_session_t)rc; + rc = keymaster_get_uds_certs(session, &signature_buf, &signature_buf_len); + if (rc < 0) { + TLOGE("Failed to get UdsCerts from keymaster (err=%ld)\n", rc); + result = OEMCrypto_ERROR_UNKNOWN_FAILURE; + goto cleanup; + } + if (signature_buf_len == 0) { + TLOGE("UdsCerts is empty\n"); + result = OEMCrypto_ERROR_UNKNOWN_FAILURE; + goto cleanup; + } + if (signature_buf_len > required_bcc_signature_size) { + TLOGE("UdsCerts size too large: %u\n", signature_buf_len); + result = OEMCrypto_ERROR_BUFFER_TOO_LARGE; + goto cleanup; + } + // A validity check on the signature CBOR map + struct CborIn cbor_in; + CborInInit(signature_buf, signature_buf_len, &cbor_in); + size_t num_pairs; + if (CborReadMap(&cbor_in, &num_pairs) != CBOR_READ_RESULT_OK) { + TLOGE("Signature byte stream is not valid CBOR or a map\n"); + result = OEMCrypto_ERROR_UNKNOWN_FAILURE; + goto cleanup; + } + *out_length = signature_buf_len; + memcpy(out, signature_buf, *out_length); + result = OEMCrypto_SUCCESS; +cleanup: + free(signature_buf); + keymaster_close(session); + return result; +} + +OEMCryptoResult WTPI_GenerateBCCSignature(uint8_t* out, size_t* out_length) { + (void)out; + (void)out_length; + return OEMCrypto_ERROR_NOT_IMPLEMENTED; +} diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_root_of_trust_layer2.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_root_of_trust_layer2.c index fa13341..bc35025 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_root_of_trust_layer2.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_root_of_trust_layer2.c @@ -34,135 +34,139 @@ static const char* kKeyboxPath = "widevine_keybox"; OEMCryptoResult WTPI_UnwrapRootOfTrust(const uint8_t* input, - size_t input_length, - uint8_t* output, + size_t input_length, uint8_t* output, size_t* output_length) { - TLOGD("WTPI_UnwrapRootOfTrust\n"); + TLOGD("WTPI_UnwrapRootOfTrust\n"); - if (input == NULL || output == NULL || output_length == NULL) { - TLOGE("WTPI_UnwrapRootOfTrust: invalid parameters\n"); - return OEMCrypto_ERROR_INVALID_CONTEXT; - } + if (input == NULL || output == NULL || output_length == NULL) { + TLOGE("WTPI_UnwrapRootOfTrust: invalid parameters\n"); + return OEMCrypto_ERROR_INVALID_CONTEXT; + } - /* Try to unwrap the keybox. */ - int rc = keybox_unwrap(input, input_length, output, *output_length, - output_length); - if (rc == KEYBOX_STATUS_SUCCESS) { - return OEMCrypto_SUCCESS; - } - - /* If unwrapping failed, assume the keybox is cleartext. */ - TLOGW("WTPI_UnwrapRootOfTrust: decryption failed (%d), assuming cleartext\n", - rc); - - /* The output buffer needs to be at least the size of the input buffer. */ - size_t min_output_length = input_length; - if (min_output_length > *output_length) { - *output_length = min_output_length; - TLOGE("WTPI_UnwrapRootOfTrust: output buffer too short, should be at least %zu bytes\n", - min_output_length); - return OEMCrypto_ERROR_SHORT_BUFFER; - } - - *output_length = min_output_length; - memcpy(output, input, *output_length); + /* Try to unwrap the keybox. */ + int rc = + keybox_unwrap(input, input_length, output, *output_length, output_length); + if (rc == KEYBOX_STATUS_SUCCESS) { return OEMCrypto_SUCCESS; + } + + /* If unwrapping failed, assume the keybox is cleartext. */ + TLOGW("WTPI_UnwrapRootOfTrust: decryption failed (%d), assuming cleartext\n", + rc); + + /* The output buffer needs to be at least the size of the input buffer. */ + size_t min_output_length = input_length; + if (min_output_length > *output_length) { + *output_length = min_output_length; + TLOGE( + "WTPI_UnwrapRootOfTrust: output buffer too short, should be at least " + "%zu bytes\n", + min_output_length); + return OEMCrypto_ERROR_SHORT_BUFFER; + } + + *output_length = min_output_length; + memcpy(output, input, *output_length); + return OEMCrypto_SUCCESS; } OEMCryptoResult WTPI_SaveRootOfTrust(const uint8_t* keybox, size_t length) { - TLOGD("WTPI_SaveRootOfTrust\n"); - tee_context* ctx = get_tee_context(); - assert(ctx->new_provisioning_session != STORAGE_INVALID_SESSION); + TLOGD("WTPI_SaveRootOfTrust\n"); + tee_context* ctx = get_tee_context(); + assert(ctx->new_provisioning_session != STORAGE_INVALID_SESSION); - if (!system_state_provisioning_allowed()) { - TLOGE("provisioning not allowed\n"); - return OEMCrypto_ERROR_INVALID_CONTEXT; - } + if (!system_state_provisioning_allowed()) { + TLOGE("provisioning not allowed\n"); + return OEMCrypto_ERROR_INVALID_CONTEXT; + } - if (keybox == NULL) { - TLOGE("WTPI_SaveRootOfTrust: no keybox provided\n"); - return OEMCrypto_ERROR_INVALID_CONTEXT; - } + if (keybox == NULL) { + TLOGE("WTPI_SaveRootOfTrust: no keybox provided\n"); + return OEMCrypto_ERROR_INVALID_CONTEXT; + } - file_handle_t handle; - int rc = storage_open_file( - ctx->new_provisioning_session, &handle, kKeyboxPath, - STORAGE_FILE_OPEN_CREATE | STORAGE_FILE_OPEN_TRUNCATE, 0); - if (rc < 0) { - TLOGE("WTPI_SaveRootOfTrust: failed to create keybox: %d\n", rc); - return OEMCrypto_ERROR_OPEN_FAILURE; - } - rc = storage_write(handle, 0, keybox, length, STORAGE_OP_COMPLETE); - storage_close_file(handle); - if (rc < 0) { - TLOGE("WTPI_SaveRootOfTrust: failed to write keybox: %d\n", rc); - return OEMCrypto_ERROR_CLOSE_FAILURE; - } + file_handle_t handle; + int rc = storage_open_file( + ctx->new_provisioning_session, &handle, kKeyboxPath, + STORAGE_FILE_OPEN_CREATE | STORAGE_FILE_OPEN_TRUNCATE, 0); + if (rc < 0) { + TLOGE("WTPI_SaveRootOfTrust: failed to create keybox: %d\n", rc); + return OEMCrypto_ERROR_OPEN_FAILURE; + } + rc = storage_write(handle, 0, keybox, length, STORAGE_OP_COMPLETE); + storage_close_file(handle); + if (rc < 0) { + TLOGE("WTPI_SaveRootOfTrust: failed to write keybox: %d\n", rc); + return OEMCrypto_ERROR_CLOSE_FAILURE; + } - return OEMCrypto_SUCCESS; + return OEMCrypto_SUCCESS; } OEMCryptoResult WTPI_LoadRootOfTrust(uint8_t* keybox, size_t* length) { - TLOGD("WTPI_LoadRootOfTrust\n"); - tee_context* ctx = get_tee_context(); - assert(ctx->new_provisioning_session != STORAGE_INVALID_SESSION); + TLOGD("WTPI_LoadRootOfTrust\n"); + tee_context* ctx = get_tee_context(); + assert(ctx->new_provisioning_session != STORAGE_INVALID_SESSION); - if (keybox == NULL || length == NULL) { - TLOGE("WTPI_LoadRootOfTrust: invalid parameters\n"); - return OEMCrypto_ERROR_INVALID_CONTEXT; - } + if (keybox == NULL || length == NULL) { + TLOGE("WTPI_LoadRootOfTrust: invalid parameters\n"); + return OEMCrypto_ERROR_INVALID_CONTEXT; + } - file_handle_t handle; - int rc = storage_open_file(ctx->new_provisioning_session, &handle, - kKeyboxPath, 0, 0); - bool loading_from_backup = false; + file_handle_t handle; + int rc = storage_open_file(ctx->new_provisioning_session, &handle, + kKeyboxPath, 0, 0); + bool loading_from_backup = false; + if (rc < 0) { + TLOGE( + "WTPI_LoadRootOfTrust: error opening keybox on TP. Attempting TDP.\n"); + assert(ctx->old_provisioning_session != STORAGE_INVALID_SESSION); + rc = storage_open_file(ctx->old_provisioning_session, &handle, kKeyboxPath, + 0, 0); if (rc < 0) { - TLOGE("WTPI_LoadRootOfTrust: error opening keybox on TP. Attempting TDP.\n"); - assert(ctx->old_provisioning_session != STORAGE_INVALID_SESSION); - rc = storage_open_file(ctx->old_provisioning_session, &handle, - kKeyboxPath, 0, 0); - if (rc < 0) { - TLOGE("WTPI_LoadRootOfTrust: error opening keybox: %d\n", rc); - return OEMCrypto_ERROR_OPEN_FAILURE; - } - - loading_from_backup = true; + TLOGE("WTPI_LoadRootOfTrust: error opening keybox: %d\n", rc); + return OEMCrypto_ERROR_OPEN_FAILURE; } - storage_off_t keysize; - rc = storage_get_file_size(handle, &keysize); - if (rc < 0) { - TLOGE("WTPI_LoadRootOfTrust: couldn't get file size: %d\n", rc); - storage_close_file(handle); - return OEMCrypto_ERROR_OPEN_FAILURE; - } + loading_from_backup = true; + } - if (*length < keysize) { - TLOGE("WTPI_LoadRootOfTrust: output buffer too small, should be at least %zu bytes\n", - (size_t)keysize); - storage_close_file(handle); - *length = keysize; - return OEMCrypto_ERROR_SHORT_BUFFER; - } - - rc = storage_read(handle, 0, keybox, keysize); + storage_off_t keysize; + rc = storage_get_file_size(handle, &keysize); + if (rc < 0) { + TLOGE("WTPI_LoadRootOfTrust: couldn't get file size: %d\n", rc); storage_close_file(handle); - if (rc < 0) { - TLOGE("WTPI_LoadRootOfTrust: error reading keybox: %d\n", rc); - return OEMCrypto_ERROR_KEYBOX_INVALID; - } - assert((size_t)rc == keysize); - - if (loading_from_backup) { - TLOGD("WTPI_LoadRootOfTrust: attempting to copy keybox from TDP to TP\n"); - rc = WTPI_SaveRootOfTrust(keybox, keysize); - if (rc != OEMCrypto_SUCCESS) { - TLOGE("WTPI_LoadRootOfTrust: failed to copy keybox from TDP to TP\n"); - } - } - - TLOGD("WTPI_LoadRootOfTrust: read %lu bytes for keybox\n", keysize); + return OEMCrypto_ERROR_OPEN_FAILURE; + } + if (*length < keysize) { + TLOGE( + "WTPI_LoadRootOfTrust: output buffer too small, should be at least %zu " + "bytes\n", + (size_t)keysize); + storage_close_file(handle); *length = keysize; - return OEMCrypto_SUCCESS; + return OEMCrypto_ERROR_SHORT_BUFFER; + } + + rc = storage_read(handle, 0, keybox, keysize); + storage_close_file(handle); + if (rc < 0) { + TLOGE("WTPI_LoadRootOfTrust: error reading keybox: %d\n", rc); + return OEMCrypto_ERROR_KEYBOX_INVALID; + } + assert((size_t)rc == keysize); + + if (loading_from_backup) { + TLOGD("WTPI_LoadRootOfTrust: attempting to copy keybox from TDP to TP\n"); + rc = WTPI_SaveRootOfTrust(keybox, keysize); + if (rc != OEMCrypto_SUCCESS) { + TLOGE("WTPI_LoadRootOfTrust: failed to copy keybox from TDP to TP\n"); + } + } + + TLOGD("WTPI_LoadRootOfTrust: read %lu bytes for keybox\n", keysize); + + *length = keysize; + return OEMCrypto_SUCCESS; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_secure_buffer_access.c b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_secure_buffer_access.c index 0dae23b..da1c632 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_secure_buffer_access.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/interface_impls/wtpi_secure_buffer_access.c @@ -16,12 +16,11 @@ #include "wtpi_secure_buffer_access_interface.h" -OEMCryptoResult WTPI_GetSecureBufferAddress(void* secure, - size_t offset, +OEMCryptoResult WTPI_GetSecureBufferAddress(void* secure, size_t offset, uint8_t** out_addr) { - if (secure == NULL || out_addr == NULL) { - return OEMCrypto_ERROR_INVALID_CONTEXT; - } - *out_addr = ((uint8_t*)secure) + offset; - return OEMCrypto_SUCCESS; + if (secure == NULL || out_addr == NULL) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + *out_addr = ((uint8_t*)secure) + offset; + return OEMCrypto_SUCCESS; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/libtrusty/trusty.c b/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/libtrusty/trusty.c index f675dfe..74f6589 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/libtrusty/trusty.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/libtrusty/trusty.c @@ -35,49 +35,44 @@ #include int tipc_connect(const char* dev_name, const char* srv_name) { - int fd; - int rc; + int fd; + int rc; - fd = TEMP_FAILURE_RETRY(open(dev_name, O_RDWR)); - if (fd < 0) { - rc = -errno; - TLOGE("%s: cannot open tipc device \"%s\": %s\n", __func__, dev_name, - strerror(errno)); - return rc < 0 ? rc : -1; - } + fd = TEMP_FAILURE_RETRY(open(dev_name, O_RDWR)); + if (fd < 0) { + rc = -errno; + TLOGE("%s: cannot open tipc device \"%s\": %s\n", __func__, dev_name, + strerror(errno)); + return rc < 0 ? rc : -1; + } - rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_CONNECT, srv_name)); - if (rc < 0) { - rc = -errno; - TLOGE("%s: can't connect to tipc service \"%s\" (err=%d)\n", __func__, - srv_name, errno); - close(fd); - return rc < 0 ? rc : -1; - } - - TLOGD("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd); - return fd; -} - -ssize_t tipc_send(int fd, - const struct iovec* iov, - int iovcnt, - struct trusty_shm* shms, - int shmcnt) { - struct tipc_send_msg_req req; - req.iov = (__u64)iov; - req.iov_cnt = (__u64)iovcnt; - req.shm = (__u64)shms; - req.shm_cnt = (__u64)shmcnt; - - int rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_SEND_MSG, &req)); - if (rc < 0) { - TLOGE("%s: failed to send message (err=%d)\n", __func__, rc); - } - - return rc; -} - -void tipc_close(int fd) { + rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_CONNECT, srv_name)); + if (rc < 0) { + rc = -errno; + TLOGE("%s: can't connect to tipc service \"%s\" (err=%d)\n", __func__, + srv_name, errno); close(fd); + return rc < 0 ? rc : -1; + } + + TLOGD("%s: connected to \"%s\" fd %d\n", __func__, srv_name, fd); + return fd; } + +ssize_t tipc_send(int fd, const struct iovec* iov, int iovcnt, + struct trusty_shm* shms, int shmcnt) { + struct tipc_send_msg_req req; + req.iov = (__u64)iov; + req.iov_cnt = (__u64)iovcnt; + req.shm = (__u64)shms; + req.shm_cnt = (__u64)shmcnt; + + int rc = TEMP_FAILURE_RETRY(ioctl(fd, TIPC_IOC_SEND_MSG, &req)); + if (rc < 0) { + TLOGE("%s: failed to send message (err=%d)\n", __func__, rc); + } + + return rc; +} + +void tipc_close(int fd) { close(fd); } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/secure_buffer.c b/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/secure_buffer.c index b3a4546..09868ad 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/secure_buffer.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/secure_buffer.c @@ -36,62 +36,63 @@ * TODO: can we do this in a more principled manner? */ typedef struct native_handle { - int version; /* sizeof(native_handle_t) */ - int numFds; /* number of file-descriptors at &data[0] */ - int numInts; /* number of ints at &data[numFds] */ - int data[]; /* numFds + numInts ints */ + int version; /* sizeof(native_handle_t) */ + int numFds; /* number of file-descriptors at &data[0] */ + int numInts; /* number of ints at &data[numFds] */ + int data[]; /* numFds + numInts ints */ } native_handle_t; void TOS_SecureBuffer_Pack(ODK_Message* message, const OEMCrypto_DestBufferDesc* obj) { - assert(obj != NULL); - assert(obj->type == OEMCrypto_BufferType_Secure); + assert(obj != NULL); + assert(obj->type == OEMCrypto_BufferType_Secure); - /* Avoid global side effects if serialization has already failed. */ - if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { - return; - } + /* Avoid global side effects if serialization has already failed. */ + if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { + return; + } - /* - * If the base is NULL, we calculating the message size rather than - * actually serializing the message. Skip registering the handle. - */ - int index = 0; - if (ODK_Message_GetBase(message) != NULL) { - /* Decode the handle. */ - native_handle_t* h = - (native_handle_t*)(obj->buffer.secure.secure_buffer); - int fd = h->data[0]; - size_t fd_len = h->data[h->numFds + 0]; - if (fd_len > WV_MAX_REASONABLE_BUFFER_SIZE) { - TLOGE("Secure output buffer is unexpectedly large.\n"); - ODK_Message_SetStatus(message, MESSAGE_STATUS_OVERFLOW_ERROR); - return; - } - if (fd_len < obj->buffer.secure.secure_buffer_length) { - TLOGE("API believes the secure output buffer is bigger than the system does.\n"); - ODK_Message_SetStatus(message, MESSAGE_STATUS_OVERFLOW_ERROR); - return; - } - index = register_handle(fd); + /* + * If the base is NULL, we calculating the message size rather than + * actually serializing the message. Skip registering the handle. + */ + int index = 0; + if (ODK_Message_GetBase(message) != NULL) { + /* Decode the handle. */ + native_handle_t* h = (native_handle_t*)(obj->buffer.secure.secure_buffer); + int fd = h->data[0]; + size_t fd_len = h->data[h->numFds + 0]; + if (fd_len > WV_MAX_REASONABLE_BUFFER_SIZE) { + TLOGE("Secure output buffer is unexpectedly large.\n"); + ODK_Message_SetStatus(message, MESSAGE_STATUS_OVERFLOW_ERROR); + return; } - OPK_Pack_int(message, &index); - OPK_Pack_size_t(message, &obj->buffer.secure.secure_buffer_length); - OPK_Pack_size_t(message, &obj->buffer.secure.offset); + if (fd_len < obj->buffer.secure.secure_buffer_length) { + TLOGE( + "API believes the secure output buffer is bigger than the system " + "does.\n"); + ODK_Message_SetStatus(message, MESSAGE_STATUS_OVERFLOW_ERROR); + return; + } + index = register_handle(fd); + } + OPK_Pack_int(message, &index); + OPK_Pack_size_t(message, &obj->buffer.secure.secure_buffer_length); + OPK_Pack_size_t(message, &obj->buffer.secure.offset); } /* Not called, but required by linker. */ void TOS_SecureBuffer_Unpack(ODK_Message* message, OEMCrypto_DestBufferDesc* obj) { - (void)(message); - (void)(obj); - assert(0); + (void)(message); + (void)(obj); + assert(0); } /* Not called, but required by linker. */ bool TOS_SecureBuffer_CheckSize(void* handle, size_t size) { - (void)handle; - (void)size; - assert(0); - return false; + (void)handle; + (void)size; + assert(0); + return false; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/transport.c b/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/transport.c index 18b4e47..49dfe25 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/transport.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/liboemcrypto/transport.c @@ -42,272 +42,263 @@ static uint8_t message_buffer[OPK_TRANSPORT_MESSAGE_SIZE]; -bool TOS_Transport_Initialize(void) { - return true; -} +bool TOS_Transport_Initialize(void) { return true; } void TOS_Transport_Terminate(void) {} ODK_Message TOS_Transport_GetRequest(void) { - return ODK_Message_Create(message_buffer, sizeof(message_buffer)); + return ODK_Message_Create(message_buffer, sizeof(message_buffer)); } void TOS_Transport_ReleaseMessage(ODK_Message* message) { - assert(message); - (void)message; + assert(message); + (void)message; } static struct wv_ipc_header create_header(uint16_t tag) { - return (struct wv_ipc_header){.tag = tag}; + return (struct wv_ipc_header){.tag = tag}; } -static int send_tagged(int chan, - struct wv_ipc_header header, - void* data, - size_t num_bytes, - struct trusty_shm* handles, +static int send_tagged(int chan, struct wv_ipc_header header, void* data, + size_t num_bytes, struct trusty_shm* handles, size_t num_handles) { - if (num_bytes > WV_MAX_PAYLOAD_SIZE) { - TLOGE("Message is too big (%zu)\n", num_bytes); - return -1; - } + if (num_bytes > WV_MAX_PAYLOAD_SIZE) { + TLOGE("Message is too big (%zu)\n", num_bytes); + return -1; + } - struct iovec msg[] = { - { - .iov_base = &header, - .iov_len = WV_HEADER_SIZE, - }, - { - .iov_base = data, - .iov_len = num_bytes, - }, - }; - ssize_t rc = tipc_send(chan, msg, countof(msg), handles, num_handles); - if (rc < 0) { - TLOGE("Client send error on %d: %s (%zd)\n", chan, strerror(errno), rc); - return rc; - } - if ((size_t)rc != WV_HEADER_SIZE + num_bytes) { - TLOGE("Did not send complete message (%zd)\n", rc); - return -1; - } - return 0; + struct iovec msg[] = { + { + .iov_base = &header, + .iov_len = WV_HEADER_SIZE, + }, + { + .iov_base = data, + .iov_len = num_bytes, + }, + }; + ssize_t rc = tipc_send(chan, msg, countof(msg), handles, num_handles); + if (rc < 0) { + TLOGE("Client send error on %d: %s (%zd)\n", chan, strerror(errno), rc); + return rc; + } + if ((size_t)rc != WV_HEADER_SIZE + num_bytes) { + TLOGE("Did not send complete message (%zd)\n", rc); + return -1; + } + return 0; } -static int receive_tagged(int chan, - struct wv_ipc_header* header, - uint8_t* data, +static int receive_tagged(int chan, struct wv_ipc_header* header, uint8_t* data, size_t* num_bytes) { - struct iovec msg[] = { - { - .iov_base = header, - .iov_len = WV_HEADER_SIZE, - }, - { - .iov_base = data, - .iov_len = *num_bytes, - }, - }; - ssize_t rc = readv(chan, msg, countof(msg)); - if (rc < 0) { - TLOGE("Client receive error on %d: %s (%zd)\n", chan, strerror(errno), - rc); - return rc; - } - if ((size_t)rc < WV_HEADER_SIZE) { - TLOGE("Message too small to contain header\n"); - return -1; - } - *num_bytes = (size_t)rc - WV_HEADER_SIZE; - return 0; + struct iovec msg[] = { + { + .iov_base = header, + .iov_len = WV_HEADER_SIZE, + }, + { + .iov_base = data, + .iov_len = *num_bytes, + }, + }; + ssize_t rc = readv(chan, msg, countof(msg)); + if (rc < 0) { + TLOGE("Client receive error on %d: %s (%zd)\n", chan, strerror(errno), rc); + return rc; + } + if ((size_t)rc < WV_HEADER_SIZE) { + TLOGE("Message too small to contain header\n"); + return -1; + } + *num_bytes = (size_t)rc - WV_HEADER_SIZE; + return 0; } struct shared_buffer { - int fd; - void* addr; - size_t size; + int fd; + void* addr; + size_t size; }; -static int allocate_shared_buffer(int dma_heap_fd, - size_t size, +static int allocate_shared_buffer(int dma_heap_fd, size_t size, struct shared_buffer* buf) { - /* Default for early out. */ - buf->fd = -1; - buf->addr = NULL; - buf->size = 0; + /* Default for early out. */ + buf->fd = -1; + buf->addr = NULL; + buf->size = 0; - size_t aligned = 0; - if (align_overflow(size, getauxval(AT_PAGESZ), &aligned)) { - TLOGE("Rounding up buffer size oveflowed\n"); - return -1; - } + size_t aligned = 0; + if (align_overflow(size, getauxval(AT_PAGESZ), &aligned)) { + TLOGE("Rounding up buffer size oveflowed\n"); + return -1; + } - if (aligned > WV_MAX_REASONABLE_BUFFER_SIZE) { - TLOGE("Requested an unreasonablly large buffer\n"); - return -1; - } + if (aligned > WV_MAX_REASONABLE_BUFFER_SIZE) { + TLOGE("Requested an unreasonablly large buffer\n"); + return -1; + } - struct dma_heap_allocation_data allocation_request = { - .len = aligned, - .fd_flags = O_RDWR | O_CLOEXEC, - }; + struct dma_heap_allocation_data allocation_request = { + .len = aligned, + .fd_flags = O_RDWR | O_CLOEXEC, + }; - /* Create the dma buffer. */ - int rc = ioctl(dma_heap_fd, DMA_HEAP_IOCTL_ALLOC, &allocation_request); - if (rc < 0) { - TLOGE("Buffer allocation request failed (%d)\n", rc); - return -1; - } + /* Create the dma buffer. */ + int rc = ioctl(dma_heap_fd, DMA_HEAP_IOCTL_ALLOC, &allocation_request); + if (rc < 0) { + TLOGE("Buffer allocation request failed (%d)\n", rc); + return -1; + } - int fd = allocation_request.fd; - if (fd < 0) { - TLOGE("Allocation request returned bad fd (%d)\n", fd); - return -1; - } + int fd = allocation_request.fd; + if (fd < 0) { + TLOGE("Allocation request returned bad fd (%d)\n", fd); + return -1; + } - void* addr = mmap(NULL, aligned, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (addr == MAP_FAILED) { - TLOGE("Failed to map buffer\n"); - close(fd); - return -1; - } + void* addr = mmap(NULL, aligned, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if (addr == MAP_FAILED) { + TLOGE("Failed to map buffer\n"); + close(fd); + return -1; + } - buf->fd = fd; - buf->addr = addr; - buf->size = aligned; + buf->fd = fd; + buf->addr = addr; + buf->size = aligned; - return 0; + return 0; } static void close_shared_buffer(struct shared_buffer* buf) { - if (buf->fd >= 0) { - close(buf->fd); - buf->fd = -1; - } - if (buf->addr != NULL) { - munmap(buf->addr, buf->size); - buf->addr = NULL; - buf->size = 0; - } + if (buf->fd >= 0) { + close(buf->fd); + buf->fd = -1; + } + if (buf->addr != NULL) { + munmap(buf->addr, buf->size); + buf->addr = NULL; + buf->size = 0; + } } struct transport_context { - bool ok; - int chan; - struct shared_buffer message; - struct shared_buffer shared; + bool ok; + int chan; + struct shared_buffer message; + struct shared_buffer shared; }; static int allocate_buffers(struct transport_context* ctx) { - const char* device_name = "/dev/dma_heap/system"; - int dma_heap_fd = open(device_name, O_RDONLY | O_CLOEXEC); - if (dma_heap_fd < 0) { - TLOGE("Cannot open %s\n", device_name); - return -1; - } - if (allocate_shared_buffer(dma_heap_fd, WV_MESSAGE_BUFFER_SIZE, - &ctx->message) != 0) { - goto on_message_alloc_error; - } - if (allocate_shared_buffer(dma_heap_fd, WV_SHARED_BUFFER_SIZE, - &ctx->shared) != 0) { - goto on_shared_alloc_error; - } - close(dma_heap_fd); - TEE_SharedMemory_Bind(ctx->shared.addr, ctx->shared.size); - return 0; + const char* device_name = "/dev/dma_heap/system"; + int dma_heap_fd = open(device_name, O_RDONLY | O_CLOEXEC); + if (dma_heap_fd < 0) { + TLOGE("Cannot open %s\n", device_name); + return -1; + } + if (allocate_shared_buffer(dma_heap_fd, WV_MESSAGE_BUFFER_SIZE, + &ctx->message) != 0) { + goto on_message_alloc_error; + } + if (allocate_shared_buffer(dma_heap_fd, WV_SHARED_BUFFER_SIZE, + &ctx->shared) != 0) { + goto on_shared_alloc_error; + } + close(dma_heap_fd); + TEE_SharedMemory_Bind(ctx->shared.addr, ctx->shared.size); + return 0; on_shared_alloc_error: - close_shared_buffer(&ctx->message); + close_shared_buffer(&ctx->message); on_message_alloc_error: - close(dma_heap_fd); - return -1; + close(dma_heap_fd); + return -1; } static void stop_trusty_transport(struct transport_context* ctx) { - if (ctx->ok) { - TOS_SharedMemory_Release(); - close_shared_buffer(&ctx->shared); - close_shared_buffer(&ctx->message); - if (ctx->chan >= 0) { - tipc_close(ctx->chan); - ctx->chan = -1; - } - ctx->ok = false; + if (ctx->ok) { + TOS_SharedMemory_Release(); + close_shared_buffer(&ctx->shared); + close_shared_buffer(&ctx->message); + if (ctx->chan >= 0) { + tipc_close(ctx->chan); + ctx->chan = -1; } + ctx->ok = false; + } } static int start_trusty_transport(struct transport_context* ctx) { - assert(!ctx->ok); - ctx->chan = -1; + assert(!ctx->ok); + ctx->chan = -1; - const char* device = "/dev/trusty-ipc-dev0"; - const char* port = WV_PORT_NAME; - int chan = tipc_connect(device, port); - if (chan < 0) { - TLOGE("Could not connect to %s through %s\n", port, device); - return -1; - } + const char* device = "/dev/trusty-ipc-dev0"; + const char* port = WV_PORT_NAME; + int chan = tipc_connect(device, port); + if (chan < 0) { + TLOGE("Could not connect to %s through %s\n", port, device); + return -1; + } - OPK_Initialize(); + OPK_Initialize(); - if (allocate_buffers(ctx) != 0) { - TOS_SharedMemory_Release(); - close(chan); - return -1; - } + if (allocate_buffers(ctx) != 0) { + TOS_SharedMemory_Release(); + close(chan); + return -1; + } - /* - * At this point the context is complete, but we still need to bind the - * buffers to the other side. - */ - ctx->chan = chan; - ctx->ok = true; + /* + * At this point the context is complete, but we still need to bind the + * buffers to the other side. + */ + ctx->chan = chan; + ctx->ok = true; - /* Bind the shared buffers. */ - struct trusty_shm handles[] = { - { - .fd = ctx->message.fd, - .transfer = TRUSTY_SHARE, - }, - { - .fd = ctx->shared.fd, - .transfer = TRUSTY_SHARE, - }, - }; - struct bind_message message = { - .protocol_version = WV_PROTOCOL_VERSION, - .message_buffer_size = ctx->message.size, - .shared_buffer_size = ctx->shared.size, - }; - int rc = send_tagged(chan, create_header(WV_TAG_BIND), &message, - sizeof(message), handles, countof(handles)); - if (rc != 0) { - goto on_bind_error; - } + /* Bind the shared buffers. */ + struct trusty_shm handles[] = { + { + .fd = ctx->message.fd, + .transfer = TRUSTY_SHARE, + }, + { + .fd = ctx->shared.fd, + .transfer = TRUSTY_SHARE, + }, + }; + struct bind_message message = { + .protocol_version = WV_PROTOCOL_VERSION, + .message_buffer_size = ctx->message.size, + .shared_buffer_size = ctx->shared.size, + }; + int rc = send_tagged(chan, create_header(WV_TAG_BIND), &message, + sizeof(message), handles, countof(handles)); + if (rc != 0) { + goto on_bind_error; + } - /* - * Get ACK. - * If we don't wait for an ACK and send too many messages, the TA's - * receive buffer will fill up and messages will be silently discarded. - * This is a quirk of how IPC messages are transfered from the HLOS to - * the TA. For now, we work around it. - */ - struct wv_ipc_header header; - size_t num_bytes = 0; - rc = receive_tagged(chan, &header, NULL, &num_bytes); - if (rc != 0) { - goto on_bind_error; - } - if (header.tag != WV_TAG_ACK) { - TLOGE("Client received non-ACK message %d\n", header.tag); - goto on_bind_error; - } - return 0; + /* + * Get ACK. + * If we don't wait for an ACK and send too many messages, the TA's + * receive buffer will fill up and messages will be silently discarded. + * This is a quirk of how IPC messages are transfered from the HLOS to + * the TA. For now, we work around it. + */ + struct wv_ipc_header header; + size_t num_bytes = 0; + rc = receive_tagged(chan, &header, NULL, &num_bytes); + if (rc != 0) { + goto on_bind_error; + } + if (header.tag != WV_TAG_ACK) { + TLOGE("Client received non-ACK message %d\n", header.tag); + goto on_bind_error; + } + return 0; on_bind_error: - stop_trusty_transport(ctx); - return -1; + stop_trusty_transport(ctx); + return -1; } /* Must be global due to the API we're working with. */ @@ -315,35 +306,35 @@ struct transport_context context; /* Create the connection if it doesn't already exist. */ static int get_connection() { - struct transport_context* ctx = &context; - if (!ctx->ok) { - start_trusty_transport(ctx); - } - return ctx->chan; + struct transport_context* ctx = &context; + if (!ctx->ok) { + start_trusty_transport(ctx); + } + return ctx->chan; } /* * Close the connection if the shared library is unloaded. */ __attribute__((destructor)) static void stop_hook() { - struct transport_context* ctx = &context; - stop_trusty_transport(ctx); + struct transport_context* ctx = &context; + stop_trusty_transport(ctx); } static struct trusty_shm handles[WV_MAX_NUM_HANDLES]; static size_t num_handles; int register_handle(int fd) { - if (num_handles >= countof(handles)) { - return -1; - } - int index = num_handles; - handles[index] = (struct trusty_shm){ - .fd = dup(fd), - .transfer = TRUSTY_SEND_SECURE, - }; - num_handles += 1; - return index; + if (num_handles >= countof(handles)) { + return -1; + } + int index = num_handles; + handles[index] = (struct trusty_shm){ + .fd = dup(fd), + .transfer = TRUSTY_SEND_SECURE, + }; + num_handles += 1; + return index; } /* @@ -353,77 +344,77 @@ int register_handle(int fd) { * TODO: sure we always clean up the global state. */ void post_send_hook() { - for (size_t i = 0; i < num_handles; i++) { - close(handles[i].fd); - handles[i].fd = -1; - } - num_handles = 0; + for (size_t i = 0; i < num_handles; i++) { + close(handles[i].fd); + handles[i].fd = -1; + } + num_handles = 0; } OPK_TransportStatus TOS_Transport_SendMessage(ODK_Message* message, ODK_Message* response) { - int chan = get_connection(); - if (chan < 0) { - goto on_error; - } + int chan = get_connection(); + if (chan < 0) { + goto on_error; + } - size_t sz = ODK_Message_GetSize(message); + size_t sz = ODK_Message_GetSize(message); - /* Validate the message size. */ - if (sz > context.message.size) { - TLOGE("Message too big. (%zu)\n", sz); - goto on_error; - } + /* Validate the message size. */ + if (sz > context.message.size) { + TLOGE("Message too big. (%zu)\n", sz); + goto on_error; + } - /* Copy the message into shared memory. */ - memcpy(context.message.addr, ODK_Message_GetBase(message), sz); + /* Copy the message into shared memory. */ + memcpy(context.message.addr, ODK_Message_GetBase(message), sz); - /* Send IPC message. */ - struct widevine_message m = { - .message_size = (uint32_t)sz, - }; - int rc = send_tagged(chan, create_header(WV_TAG_WIDEVINE), &m, sizeof(m), - handles, num_handles); - if (rc != 0) { - goto on_error; - } + /* Send IPC message. */ + struct widevine_message m = { + .message_size = (uint32_t)sz, + }; + int rc = send_tagged(chan, create_header(WV_TAG_WIDEVINE), &m, sizeof(m), + handles, num_handles); + if (rc != 0) { + goto on_error; + } - post_send_hook(); + post_send_hook(); - /* Receive the response data */ - struct wv_ipc_header header; - uint8_t ipc_buffer[WV_IPC_BUFFER_SIZE]; - size_t num_bytes = sizeof(ipc_buffer); - rc = receive_tagged(chan, &header, ipc_buffer, &num_bytes); - if (rc != 0) { - goto on_error; - } + /* Receive the response data */ + struct wv_ipc_header header; + uint8_t ipc_buffer[WV_IPC_BUFFER_SIZE]; + size_t num_bytes = sizeof(ipc_buffer); + rc = receive_tagged(chan, &header, ipc_buffer, &num_bytes); + if (rc != 0) { + goto on_error; + } - if (validate_message_metadata(header.tag, num_bytes, 0) != 0) { - goto on_error; - } + if (validate_message_metadata(header.tag, num_bytes, 0) != 0) { + goto on_error; + } - if (header.tag != WV_TAG_WIDEVINE) { - TLOGE("Client received non-WIDEVINE response %d\n", header.tag); - goto on_error; - } + if (header.tag != WV_TAG_WIDEVINE) { + TLOGE("Client received non-WIDEVINE response %d\n", header.tag); + goto on_error; + } - struct widevine_message* msg = (struct widevine_message*)ipc_buffer; + struct widevine_message* msg = (struct widevine_message*)ipc_buffer; - /* Validate the size. */ - sz = msg->message_size; - if (sz > context.message.size) { - TLOGE("Message too large (%u)\n", msg->message_size); - return OPK_TRANSPORT_STATUS_IO_ERROR; - } + /* Validate the size. */ + sz = msg->message_size; + if (sz > context.message.size) { + TLOGE("Message too large (%u)\n", msg->message_size); + return OPK_TRANSPORT_STATUS_IO_ERROR; + } - /* Fill in the response. */ - *response = TOS_Transport_GetRequest(); - ODK_Message_SetSize(response, sz); - memcpy(ODK_Message_GetBase(response), context.message.addr, sz); - return OPK_TRANSPORT_STATUS_OK; + /* Fill in the response. */ + *response = TOS_Transport_GetRequest(); + ODK_Message_SetSize(response, sz); + memcpy(ODK_Message_GetBase(response), context.message.addr, sz); + return OPK_TRANSPORT_STATUS_OK; on_error: - post_send_hook(); - return OPK_TRANSPORT_STATUS_IO_ERROR; + post_send_hook(); + return OPK_TRANSPORT_STATUS_IO_ERROR; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.c b/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.c index a22b231..a62d1c2 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.c @@ -43,202 +43,230 @@ * this transaction. */ struct secure_buffer_info { - int handle; - size_t size; - void* addr; + int handle; + size_t size; + void* addr; }; static struct secure_buffer_info secure_buffers[WV_MAX_NUM_HANDLES]; -static size_t num_secure_buffers; +static size_t num_secure_buffers = 0; /* * This buffer was received as part of a transaction and should be mapped and * cleaned up as needed. */ int register_secure_buffer(int handle) { - assert(handle != INVALID_IPC_HANDLE); - /* - * This should only triggered if the IPC system handle limit gets out of - * sync with the secure buffer array size. - */ - if (num_secure_buffers >= countof(secure_buffers)) { - TLOGE("Tried to register too many secure buffers.\n"); - return -1; - } - secure_buffers[num_secure_buffers] = (struct secure_buffer_info){ - .handle = handle, .size = 0, .addr = NULL}; - num_secure_buffers += 1; - return 0; + assert(handle != INVALID_IPC_HANDLE); + /* + * This should only triggered if the IPC system handle limit gets out of + * sync with the secure buffer array size. + */ + if (num_secure_buffers >= countof(secure_buffers)) { + TLOGE("Tried to register too many secure buffers.\n"); + return -1; + } + secure_buffers[num_secure_buffers] = + (struct secure_buffer_info){.handle = handle, .size = 0, .addr = NULL}; + num_secure_buffers += 1; + return 0; } int secure_buffer_address(size_t index, void** out_addr) { - if (index >= num_secure_buffers) { - TLOGE("Invalid secure buffer handle.\n"); - return -1; + if (index >= num_secure_buffers) { + TLOGE("Invalid secure buffer handle.\n"); + return -1; + } + void* addr = secure_buffers[index].addr; + size_t size = secure_buffers[index].size; + if (addr == NULL && size > 0) { + /* Lazy mmap */ + int handle = secure_buffers[index].handle; + assert(handle != INVALID_IPC_HANDLE); + /* Validate this handle is safe to use as a secure output buffer. */ + if (system_specific_validate_secure_output_buffer(handle) != 0) { + return -1; } - void* addr = secure_buffers[index].addr; - size_t size = secure_buffers[index].size; - if (addr == NULL && size > 0) { - /* Lazy mmap */ - int handle = secure_buffers[index].handle; - assert(handle != INVALID_IPC_HANDLE); - /* Validate this handle is safe to use as a secure output buffer. */ - if (system_specific_validate_secure_output_buffer(handle) != 0) { - return -1; - } - addr = mmap(0, size, PROT_READ | PROT_WRITE, 0, handle, 0); - if (addr == MAP_FAILED) { - TLOGE("Failed to map handle=%d size=%zu\n", handle, size); - return -1; - } - /* Cache */ - secure_buffers[index].addr = addr; + addr = mmap(0, size, PROT_READ | PROT_WRITE, 0, handle, 0); + if (addr == MAP_FAILED) { + TLOGE("Failed to map handle=%d size=%zu\n", handle, size); + return -1; + } + /* Cache */ + secure_buffers[index].addr = addr; - /* Handle no longer needed */ - close(handle); - secure_buffers[index].handle = INVALID_IPC_HANDLE; + /* Handle no longer needed */ + close(handle); + secure_buffers[index].handle = INVALID_IPC_HANDLE; + } + *out_addr = addr; + return 0; +} + +// TODO: We only need to call arch_clean_cache_range() on the mmap'ed address. +// Unfortunately the path to that function appears to be paved with DMA +// syscalls, without us needing any of the DMA functionality. +int secure_buffer_clean_cache(void) { + for (size_t i = 0; i < num_secure_buffers; i++) { + void* addr = secure_buffers[i].addr; + size_t size = secure_buffers[i].size; + if (addr != NULL && size > 0) { + // These are not exactly being used for their intended purpose. + // Typically prepare_dma is called when data is ready for hardware + // to read, then finish_dma is called when the hardware is done. + // We just need to clean the cache, to ensure the device can see + // the memory contents. When one function is called , you should + // call the other. + int ret = + prepare_dma(addr, size, DMA_FLAG_TO_DEVICE | DMA_FLAG_NO_PMEM, NULL); + if (ret < 0) { + TLOGE("prepare_dma returned error %d\n", ret); + return -1; + } + ret = finish_dma(addr, size, DMA_FLAG_TO_DEVICE); + if (ret < 0) { + TLOGE("finish_dma returned error %d\n", ret); + return -1; + } } - *out_addr = addr; - return 0; + } + return 0; } void cleanup_secure_buffers(void) { - for (size_t i = 0; i < num_secure_buffers; i++) { - /* Clean up mapping */ - void* addr = secure_buffers[i].addr; - size_t size = secure_buffers[i].size; - if (addr != NULL) { - /* Flush */ - finish_dma(addr, size, DMA_FLAG_FROM_DEVICE); - /* Unmap */ - if (munmap(addr, size)) { - TLOGE(" %zu munmap failed, size %zu\n", i, size); - } - } - - /* Clean up handle */ - int handle = secure_buffers[i].handle; - if (handle != INVALID_IPC_HANDLE) { - close(handle); - } - - /* Overly cautious clear */ - secure_buffers[i] = (struct secure_buffer_info){ - .handle = INVALID_IPC_HANDLE, .size = 0, .addr = NULL}; + for (size_t i = 0; i < num_secure_buffers; i++) { + /* Clean up mapping */ + void* addr = secure_buffers[i].addr; + size_t size = secure_buffers[i].size; + if (addr != NULL) { + /* Unmap */ + if (munmap(addr, size)) { + TLOGE(" %zu munmap failed, size %zu\n", i, size); + } } - num_secure_buffers = 0; + + /* Clean up handle */ + int handle = secure_buffers[i].handle; + if (handle != INVALID_IPC_HANDLE) { + close(handle); + } + + /* Overly cautious clear */ + secure_buffers[i] = (struct secure_buffer_info){ + .handle = INVALID_IPC_HANDLE, .size = 0, .addr = NULL}; + } + num_secure_buffers = 0; } void TOS_SecureBuffer_Unpack(ODK_Message* message, OEMCrypto_DestBufferDesc* obj) { - assert(obj->type == OEMCrypto_BufferType_Secure); + assert(obj->type == OEMCrypto_BufferType_Secure); - /* - * This function has side effects, so we should not continue trying to - * unpack in an error state. - */ - if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { - return; - } + /* + * This function has side effects, so we should not continue trying to + * unpack in an error state. + */ + if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { + return; + } - /* Deserialize the handle index. */ - int raw_index = 0; - OPK_Unpack_int(message, &raw_index); - if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { - return; - } + /* Deserialize the handle index. */ + int raw_index = 0; + OPK_Unpack_int(message, &raw_index); + if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { + return; + } - /* Bounds check the index. */ - if (raw_index < 0 || (size_t)raw_index >= num_secure_buffers) { - TLOGE("Index out of range (%d)\n", raw_index); - ODK_Message_SetStatus(message, MESSAGE_STATUS_INVALID_ENUM_VALUE); - return; - } + /* Bounds check the index. */ + if (raw_index < 0 || (size_t)raw_index >= num_secure_buffers) { + TLOGE("Index out of range (%d)\n", raw_index); + ODK_Message_SetStatus(message, MESSAGE_STATUS_INVALID_ENUM_VALUE); + return; + } - size_t index = (size_t)raw_index; + size_t index = (size_t)raw_index; - /* Deserialize the other fields. */ - size_t handle_length = 0; - OPK_Unpack_size_t(message, &handle_length); - size_t offset = 0; - OPK_Unpack_size_t(message, &offset); + /* Deserialize the other fields. */ + size_t handle_length = 0; + OPK_Unpack_size_t(message, &handle_length); + size_t offset = 0; + OPK_Unpack_size_t(message, &offset); - /* Again, avoid side effects. */ - if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { - return; - } + /* Again, avoid side effects. */ + if (ODK_Message_GetStatus(message) != MESSAGE_STATUS_OK) { + return; + } - /* Reject unreasonablely large buffers before we do any math on the size. */ - if (handle_length > WV_MAX_REASONABLE_BUFFER_SIZE) { - TLOGE("Secure output buffer is unexpectedly large.\n"); - ODK_Message_SetStatus(message, MESSAGE_STATUS_OVERFLOW_ERROR); - return; - } + /* Reject unreasonablely large buffers before we do any math on the size. */ + if (handle_length > WV_MAX_REASONABLE_BUFFER_SIZE) { + TLOGE("Secure output buffer is unexpectedly large.\n"); + ODK_Message_SetStatus(message, MESSAGE_STATUS_OVERFLOW_ERROR); + return; + } - /* Validate invariant */ - if (offset >= handle_length) { - TLOGE("offset is outside secure buffer\n"); - ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); - return; - } + /* Validate invariant */ + if (offset >= handle_length) { + TLOGE("offset is outside secure buffer\n"); + ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); + return; + } - /* - * Size is not known when the handle is initially received via IPC. - * Note that the Widevine API may give strange non-page-sized buffer sizes - * that are smaller than the actual buffer size. We work from these sizes - * so that we don't map and unmap too much memory, and don't need to - * enforce an invariant between the "real" and the "specified" sizes. - */ - size_t size = 0; - if (align_overflow(handle_length, 4096, &size)) { - TLOGE("Rounding up buffer size overflowed (%zu)\n", handle_length); - ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); - return; - } + /* + * Size is not known when the handle is initially received via IPC. + * Note that the Widevine API may give strange non-page-sized buffer sizes + * that are smaller than the actual buffer size. We work from these sizes + * so that we don't map and unmap too much memory, and don't need to + * enforce an invariant between the "real" and the "specified" sizes. + */ + size_t size = 0; + if (align_overflow(handle_length, 4096, &size)) { + TLOGE("Rounding up buffer size overflowed (%zu)\n", handle_length); + ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); + return; + } - /* Validate */ - if (secure_buffers[index].size != 0) { - TLOGE("Attempted to redefine secure buffer size\n"); - ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); - return; - } + /* Validate */ + if (secure_buffers[index].size != 0) { + TLOGE("Attempted to redefine secure buffer size\n"); + ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); + return; + } - /* Commit */ - secure_buffers[index].size = size; + /* Commit */ + secure_buffers[index].size = size; - /* - * Eagerly map the buffer and store the pointer as the handle. - * In the future we may have an opaque handle and lazy map. - */ - void* addr; - if (secure_buffer_address(index, &addr) != 0) { - ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); - return; - } - obj->buffer.secure.secure_buffer = addr; - obj->buffer.secure.secure_buffer_length = handle_length; - obj->buffer.secure.offset = offset; + /* + * Eagerly map the buffer and store the pointer as the handle. + * In the future we may have an opaque handle and lazy map. + */ + void* addr; + if (secure_buffer_address(index, &addr) != 0) { + ODK_Message_SetStatus(message, MESSAGE_STATUS_PARSE_ERROR); + return; + } + obj->buffer.secure.secure_buffer = addr; + obj->buffer.secure.secure_buffer_length = handle_length; + obj->buffer.secure.offset = offset; } /* Not called, but required by linker. */ void TOS_SecureBuffer_Pack(ODK_Message* message, const OEMCrypto_DestBufferDesc* obj) { - (void)(message); - (void)(obj); - assert(0); + (void)(message); + (void)(obj); + assert(0); } bool TOS_SecureBuffer_CheckSize(void* handle, size_t size) { - for (size_t i = 0; i < num_secure_buffers; i++) { - if (secure_buffers[i].addr == handle) { - if (secure_buffers[i].size >= size) { - return true; - } else { - TLOGE("buffer size too small\n"); - return false; - } - } + for (size_t i = 0; i < num_secure_buffers; i++) { + if (secure_buffers[i].addr == handle) { + if (secure_buffers[i].size >= size) { + return true; + } else { + TLOGE("buffer size too small\n"); + return false; + } } - TLOGE("unknown handle\n"); - return true; + } + TLOGE("unknown handle\n"); + return true; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.h b/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.h index 6e9181a..2dbbb21 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.h +++ b/oemcrypto/opk/ports/trusty/ta/reference/secure_buffer.h @@ -12,5 +12,6 @@ __BEGIN_CDECLS int register_secure_buffer(int handle) WARN_UNUSED_RESULT; void cleanup_secure_buffers(void); +int secure_buffer_clean_cache(void); __END_CDECLS diff --git a/oemcrypto/opk/ports/trusty/ta/reference/shared/shared_memory.c b/oemcrypto/opk/ports/trusty/ta/reference/shared/shared_memory.c index 1011d44..02050c0 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/shared/shared_memory.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/shared/shared_memory.c @@ -35,15 +35,15 @@ static uint8_t* pool; static size_t pool_size; void TEE_SharedMemory_Bind(uint8_t* buffer, size_t size) { - pool = buffer; - pool_size = size; + pool = buffer; + pool_size = size; } /* * Initialize shared memory pool */ bool TOS_SharedMemory_Initialize(void) { - return pool != NULL && pool_size != 0; + return pool != NULL && pool_size != 0; } /* @@ -58,7 +58,7 @@ bool TOS_SharedMemory_Initialize(void) { * A handle to the shared memory, or NULL if allocation fails */ bool TOS_SharedMemory_Allocate(size_t size) { - return pool != NULL && size <= pool_size; + return pool != NULL && size <= pool_size; } /* @@ -66,8 +66,8 @@ bool TOS_SharedMemory_Allocate(size_t size) { * by TOS_SharedMemory_Allocate. */ void TOS_SharedMemory_Release(void) { - pool = NULL; - pool_size = 0; + pool = NULL; + pool_size = 0; } /* @@ -76,9 +76,7 @@ void TOS_SharedMemory_Release(void) { * Returns: * The address of the shared memory region refered by |handle| */ -uint8_t* TOS_SharedMemory_GetAddress(void) { - return pool; -} +uint8_t* TOS_SharedMemory_GetAddress(void) { return pool; } /* * Return the size of a shared memory region @@ -86,9 +84,7 @@ uint8_t* TOS_SharedMemory_GetAddress(void) { * Returns: * the size of the shared memory region */ -size_t TOS_SharedMemory_GetSize(void) { - return pool_size; -} +size_t TOS_SharedMemory_GetSize(void) { return pool_size; } /* * Copy data into and/or out of the memory block @@ -120,18 +116,16 @@ void TOS_SharedMemory_Finalize(OPK_SharedMemory_CopyVector* in_vec, size_t in_count, OPK_SharedMemory_CopyVector* out_vec, size_t out_count) { - for (size_t i = 0; i < in_count; i++) { - if (in_vec[i].address) { - memcpy(pool + in_vec[i].offset, in_vec[i].address, - in_vec[i].length); - } + for (size_t i = 0; i < in_count; i++) { + if (in_vec[i].address) { + memcpy(pool + in_vec[i].offset, in_vec[i].address, in_vec[i].length); } - for (size_t i = 0; i < out_count; i++) { - if (out_vec[i].address) { - memcpy(out_vec[i].address, pool + out_vec[i].offset, - out_vec[i].length); - } + } + for (size_t i = 0; i < out_count; i++) { + if (out_vec[i].address) { + memcpy(out_vec[i].address, pool + out_vec[i].offset, out_vec[i].length); } + } } /* @@ -143,6 +137,4 @@ void TOS_SharedMemory_Finalize(OPK_SharedMemory_CopyVector* in_vec, * various parameters that are annotated as OEMCrypto_SharedMemory * in OEMCryptoCENC.h. */ -size_t TOS_SharedMemory_AvailableSize(void) { - return pool_size; -} +size_t TOS_SharedMemory_AvailableSize(void) { return pool_size; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/shared/widevine_ipc_protocol.c b/oemcrypto/opk/ports/trusty/ta/reference/shared/widevine_ipc_protocol.c index c5661f1..05b29cb 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/shared/widevine_ipc_protocol.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/shared/widevine_ipc_protocol.c @@ -21,75 +21,74 @@ #include const char* tag_name(uint16_t tag) { - switch (tag) { + switch (tag) { case WV_TAG_ACK: - return "ACK"; + return "ACK"; case WV_TAG_BIND: - return "BIND"; + return "BIND"; case WV_TAG_WIDEVINE: - return "WIDEVINE"; + return "WIDEVINE"; default: - return "UNKNOWN"; - } + return "UNKNOWN"; + } } struct message_info { - int unknown; - size_t exact_bytes; - size_t min_handles; - size_t max_handles; + int unknown; + size_t exact_bytes; + size_t min_handles; + size_t max_handles; }; static struct message_info get_message_info(uint16_t tag) { - switch (tag) { + switch (tag) { case WV_TAG_ACK: - return (struct message_info){ - .unknown = 0, - .exact_bytes = sizeof(struct ack_message), - .min_handles = 0, - .max_handles = 0, - }; + return (struct message_info){ + .unknown = 0, + .exact_bytes = sizeof(struct ack_message), + .min_handles = 0, + .max_handles = 0, + }; case WV_TAG_BIND: - return (struct message_info){ - .unknown = 0, - .exact_bytes = sizeof(struct bind_message), - .min_handles = 2, - .max_handles = 2, - }; + return (struct message_info){ + .unknown = 0, + .exact_bytes = sizeof(struct bind_message), + .min_handles = 2, + .max_handles = 2, + }; case WV_TAG_WIDEVINE: - return (struct message_info){ - .unknown = 0, - .exact_bytes = sizeof(struct widevine_message), - .min_handles = 0, - .max_handles = WV_MAX_NUM_HANDLES, - }; + return (struct message_info){ + .unknown = 0, + .exact_bytes = sizeof(struct widevine_message), + .min_handles = 0, + .max_handles = WV_MAX_NUM_HANDLES, + }; default: - return (struct message_info){ - .unknown = 1, - .exact_bytes = 0, - .min_handles = 0, - .max_handles = 0, - }; - } + return (struct message_info){ + .unknown = 1, + .exact_bytes = 0, + .min_handles = 0, + .max_handles = 0, + }; + } } -int validate_message_metadata(uint16_t tag, - size_t num_bytes, +int validate_message_metadata(uint16_t tag, size_t num_bytes, size_t num_handles) { - struct message_info info = get_message_info(tag); - if (info.unknown != 0) { - TLOGE("Unknown tag (%d)\n", tag); - return -1; - } - if (num_bytes != info.exact_bytes) { - TLOGE("Incorrect number of bytes (%zu) for %s message.\n", num_bytes, - tag_name(tag)); - return -1; - } - if (num_handles < info.min_handles || num_handles > info.max_handles) { - TLOGE("Incorrect number of handles (%zu) for %s message.\n", - num_handles, tag_name(tag)); - return -1; - } - return 0; + struct message_info info = get_message_info(tag); + if (info.unknown != 0) { + TLOGE("Unknown tag (%d)\n", tag); + return -1; + } + if (num_bytes != info.exact_bytes) { + TLOGE("Incorrect number of bytes (%zu) for %s message.\n", num_bytes, + tag_name(tag)); + return -1; + } + if (num_handles < info.min_handles || num_handles > info.max_handles) { + TLOGE("Incorrect number of handles (%zu) for %s message.\n", num_handles, + tag_name(tag)); + return -1; + } + return 0; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/tee_context.c b/oemcrypto/opk/ports/trusty/ta/reference/tee_context.c index acf00cb..7843e19 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/tee_context.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/tee_context.c @@ -19,6 +19,4 @@ static tee_context ctx = {STORAGE_INVALID_SESSION, STORAGE_INVALID_SESSION, STORAGE_INVALID_SESSION}; -tee_context* get_tee_context() { - return &ctx; -} +tee_context* get_tee_context(void) { return &ctx; } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/widevine_app.c b/oemcrypto/opk/ports/trusty/ta/reference/widevine_app.c index b44a9dc..cb79b6b 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/widevine_app.c +++ b/oemcrypto/opk/ports/trusty/ta/reference/widevine_app.c @@ -50,156 +50,151 @@ ODK_Message request; * It must be safe to call this function multiple times on the same array. */ static void close_handles(handle_t* handles, size_t num_handles) { - assert(handles != NULL || num_handles == 0); - for (size_t i = 0; i < num_handles; i++) { - if (handles[i] >= 0) { - close(handles[i]); - handles[i] = -1; - } + assert(handles != NULL || num_handles == 0); + for (size_t i = 0; i < num_handles; i++) { + if (handles[i] >= 0) { + close(handles[i]); + handles[i] = -1; } + } } static struct wv_ipc_header create_header(uint16_t tag) { - return (struct wv_ipc_header){.tag = tag}; + return (struct wv_ipc_header){.tag = tag}; } -static int send_tagged(handle_t chan, - struct wv_ipc_header header, - void* data, +static int send_tagged(handle_t chan, struct wv_ipc_header header, void* data, size_t num_bytes) { - TLOGD("Server send %d %d - %zu bytes\n", chan, header.tag, num_bytes); + TLOGD("Server send %d %d - %zu bytes\n", chan, header.tag, num_bytes); - if (num_bytes > WV_MAX_PAYLOAD_SIZE) { - TLOGE("Message is too big (%zu)\n", num_bytes); - return -1; - } + if (num_bytes > WV_MAX_PAYLOAD_SIZE) { + TLOGE("Message is too big (%zu)\n", num_bytes); + return -1; + } - struct iovec iov[2] = { - { - .iov_base = &header, - .iov_len = WV_HEADER_SIZE, - }, - { - .iov_base = data, - .iov_len = num_bytes, - }, - }; + struct iovec iov[2] = { + { + .iov_base = &header, + .iov_len = WV_HEADER_SIZE, + }, + { + .iov_base = data, + .iov_len = num_bytes, + }, + }; - ipc_msg_t msg = { - .num_iov = countof(iov), - .iov = iov, - .num_handles = 0, - .handles = NULL, - }; + ipc_msg_t msg = { + .num_iov = countof(iov), + .iov = iov, + .num_handles = 0, + .handles = NULL, + }; - ssize_t rc = send_msg(chan, &msg); - if (rc < 0) { - TLOGE("Error sending message (%zd)\n", rc); - return -1; - } - if ((size_t)rc != WV_HEADER_SIZE + num_bytes) { - TLOGE("Did not send complete message (%zd)\n", rc); - return -1; - } - return 0; + ssize_t rc = send_msg(chan, &msg); + if (rc < 0) { + TLOGE("Error sending message (%zd)\n", rc); + return -1; + } + if ((size_t)rc != WV_HEADER_SIZE + num_bytes) { + TLOGE("Did not send complete message (%zd)\n", rc); + return -1; + } + return 0; } -static int receive_tagged(handle_t chan, - struct wv_ipc_header* header, - uint8_t* data, - size_t* num_bytes, - handle_t* handles, +static int receive_tagged(handle_t chan, struct wv_ipc_header* header, + uint8_t* data, size_t* num_bytes, handle_t* handles, size_t* num_handles) { - struct iovec iov[2] = { - { - .iov_base = header, - .iov_len = WV_HEADER_SIZE, - }, - { - .iov_base = data, - .iov_len = *num_bytes, - }, - }; - ipc_msg_t msg = { - .num_iov = countof(iov), - .iov = iov, - .num_handles = *num_handles, - .handles = handles, - }; + struct iovec iov[2] = { + { + .iov_base = header, + .iov_len = WV_HEADER_SIZE, + }, + { + .iov_base = data, + .iov_len = *num_bytes, + }, + }; + ipc_msg_t msg = { + .num_iov = countof(iov), + .iov = iov, + .num_handles = *num_handles, + .handles = handles, + }; - /* Check the message info. */ - ipc_msg_info_t info; - ssize_t rc = get_msg(chan, &info); - if (rc < 0) { - TLOGE("get_msg failed %d\n", chan); - goto on_early_error; - } + /* Check the message info. */ + ipc_msg_info_t info; + ssize_t rc = get_msg(chan, &info); + if (rc < 0) { + TLOGE("get_msg failed %d\n", chan); + goto on_early_error; + } - /* Check we have enough space to read the message. */ - if (info.len > WV_HEADER_SIZE + *num_bytes) { - TLOGE("Buffer too small %d %zu\n", chan, info.len); - goto on_post_get_error; - } - if (info.num_handles > *num_handles) { - TLOGE("Too many handles %d %u\n", chan, info.num_handles); - goto on_post_get_error; - } + /* Check we have enough space to read the message. */ + if (info.len > WV_HEADER_SIZE + *num_bytes) { + TLOGE("Buffer too small %d %zu\n", chan, info.len); + goto on_post_get_error; + } + if (info.num_handles > *num_handles) { + TLOGE("Too many handles %d %u\n", chan, info.num_handles); + goto on_post_get_error; + } - /* Copy the message data. */ - rc = read_msg(chan, info.id, 0, &msg); - if (rc < 0) { - TLOGE("read_msg failed %d\n", chan); - goto on_post_get_error; - } - if ((size_t)rc < WV_HEADER_SIZE) { - TLOGE("Message too small to contain header\n"); - goto on_post_read_error; - } + /* Copy the message data. */ + rc = read_msg(chan, info.id, 0, &msg); + if (rc < 0) { + TLOGE("read_msg failed %d\n", chan); + goto on_post_get_error; + } + if ((size_t)rc < WV_HEADER_SIZE) { + TLOGE("Message too small to contain header\n"); + goto on_post_read_error; + } - *num_bytes = (size_t)rc - WV_HEADER_SIZE; - *num_handles = info.num_handles; - put_msg(chan, info.id); - TLOGD("Server receive %d %d - %zd bytes\n", chan, header->tag, rc); - return 0; + *num_bytes = (size_t)rc - WV_HEADER_SIZE; + *num_handles = info.num_handles; + put_msg(chan, info.id); + TLOGD("Server receive %d %d - %zd bytes\n", chan, header->tag, rc); + return 0; on_post_read_error: - close_handles(handles, info.num_handles); + close_handles(handles, info.num_handles); on_post_get_error: - put_msg(chan, info.id); + put_msg(chan, info.id); on_early_error: - return -1; + return -1; } struct widevine_ctx { - void* shared_message_addr; - size_t shared_message_size; + void* shared_message_addr; + size_t shared_message_size; - void* shared_buffer_addr; - size_t shared_buffer_size; + void* shared_buffer_addr; + size_t shared_buffer_size; }; static bool is_bound(struct widevine_ctx* ctx) { - return ctx->shared_message_addr != NULL && ctx->shared_buffer_addr != NULL; + return ctx->shared_message_addr != NULL && ctx->shared_buffer_addr != NULL; } static void close_shared_memory(struct widevine_ctx* ctx) { - TEE_SharedMemory_Bind(NULL, 0); - if (ctx->shared_buffer_addr != NULL) { - int rc = munmap(ctx->shared_buffer_addr, ctx->shared_buffer_size); - if (rc != NO_ERROR) { - TLOGW("munmap() failed: %d\n", rc); - } - ctx->shared_buffer_addr = NULL; - ctx->shared_buffer_size = 0; + TEE_SharedMemory_Bind(NULL, 0); + if (ctx->shared_buffer_addr != NULL) { + int rc = munmap(ctx->shared_buffer_addr, ctx->shared_buffer_size); + if (rc != NO_ERROR) { + TLOGW("munmap() failed: %d\n", rc); } - if (ctx->shared_message_addr != NULL) { - int rc = munmap(ctx->shared_message_addr, ctx->shared_message_size); - if (rc != NO_ERROR) { - TLOGW("munmap() failed: %d\n", rc); - } - ctx->shared_message_addr = NULL; - ctx->shared_message_size = 0; + ctx->shared_buffer_addr = NULL; + ctx->shared_buffer_size = 0; + } + if (ctx->shared_message_addr != NULL) { + int rc = munmap(ctx->shared_message_addr, ctx->shared_message_size); + if (rc != NO_ERROR) { + TLOGW("munmap() failed: %d\n", rc); } + ctx->shared_message_addr = NULL; + ctx->shared_message_size = 0; + } } static void bind_shared_memory(struct widevine_ctx* ctx, @@ -207,297 +202,289 @@ static void bind_shared_memory(struct widevine_ctx* ctx, size_t shared_message_size, void* shared_buffer_addr, size_t shared_buffer_size) { - close_shared_memory(ctx); + close_shared_memory(ctx); - ctx->shared_message_addr = shared_message_addr; - ctx->shared_message_size = shared_message_size; + ctx->shared_message_addr = shared_message_addr; + ctx->shared_message_size = shared_message_size; - ctx->shared_buffer_addr = shared_buffer_addr; - ctx->shared_buffer_size = shared_buffer_size; + ctx->shared_buffer_addr = shared_buffer_addr; + ctx->shared_buffer_size = shared_buffer_size; - TEE_SharedMemory_Bind(shared_buffer_addr, shared_buffer_size); + TEE_SharedMemory_Bind(shared_buffer_addr, shared_buffer_size); } -static int on_widevine_connect(const struct tipc_port* port, - handle_t chan, - const struct uuid* peer, - void** ctx_p) { - struct widevine_ctx* ctx = calloc(1, sizeof(*ctx)); - if (ctx == NULL) { - TLOGE("Failed to allocate connection context.\n"); - return ERR_NO_MEMORY; - } +static int on_widevine_connect(const struct tipc_port* port, handle_t chan, + const struct uuid* peer, void** ctx_p) { + struct widevine_ctx* ctx = calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + TLOGE("Failed to allocate connection context.\n"); + return ERR_NO_MEMORY; + } - *ctx_p = ctx; - return NO_ERROR; + *ctx_p = ctx; + return NO_ERROR; } static void on_widevine_channel_cleanup(void* _ctx) { - struct widevine_ctx* ctx = (struct widevine_ctx*)_ctx; - close_shared_memory(ctx); - free(ctx); + struct widevine_ctx* ctx = (struct widevine_ctx*)_ctx; + close_shared_memory(ctx); + free(ctx); } static int validate_buffer_sizes(struct bind_message* msg) { - size_t page_size = getauxval(AT_PAGESZ); + size_t page_size = getauxval(AT_PAGESZ); - size_t shared_message_size = msg->message_buffer_size; - if (shared_message_size % page_size != 0) { - TLOGE("Message buffer is not page aligned. (%zu)\n", - shared_message_size); - return -1; - } - /* - * The message is copied into a preallocated buffer. Check that the shared - * memory region is the same size as the preallocated buffer. If the memory - * region is larger than the preallocated buffer, the client may see dynamic - * failures if it tries to pass large messages. Similarly, if the memory - * region is smaller the server may fail to copy out the message. Make sure - * the buffers have exactly the same size. - */ - if (shared_message_size != ODK_Message_GetCapacity(&request)) { - TLOGE("Message buffer is wrong size. (%zu/%zu)\n", shared_message_size, - ODK_Message_GetCapacity(&request)); - return -1; - } + size_t shared_message_size = msg->message_buffer_size; + if (shared_message_size % page_size != 0) { + TLOGE("Message buffer is not page aligned. (%zu)\n", shared_message_size); + return -1; + } + /* + * The message is copied into a preallocated buffer. Check that the shared + * memory region is the same size as the preallocated buffer. If the memory + * region is larger than the preallocated buffer, the client may see dynamic + * failures if it tries to pass large messages. Similarly, if the memory + * region is smaller the server may fail to copy out the message. Make sure + * the buffers have exactly the same size. + */ + if (shared_message_size != ODK_Message_GetCapacity(&request)) { + TLOGE("Message buffer is wrong size. (%zu/%zu)\n", shared_message_size, + ODK_Message_GetCapacity(&request)); + return -1; + } - size_t shared_buffer_size = msg->shared_buffer_size; - if (shared_buffer_size % page_size != 0) { - TLOGE("Shared buffer is not page aligned. (%zu)\n", shared_buffer_size); - return -1; - } - if (shared_buffer_size > WV_MAX_REASONABLE_BUFFER_SIZE) { - TLOGE("Shared buffer is unexpectedly large. (%zu)\n", - shared_buffer_size); - return -1; - } + size_t shared_buffer_size = msg->shared_buffer_size; + if (shared_buffer_size % page_size != 0) { + TLOGE("Shared buffer is not page aligned. (%zu)\n", shared_buffer_size); + return -1; + } + if (shared_buffer_size > WV_MAX_REASONABLE_BUFFER_SIZE) { + TLOGE("Shared buffer is unexpectedly large. (%zu)\n", shared_buffer_size); + return -1; + } - return 0; + return 0; } -static int dispatch_bind_message(handle_t chan, - struct widevine_ctx* ctx, - void* bytes, - size_t num_bytes, - handle_t* handles, - size_t num_handles) { - struct bind_message* msg = (struct bind_message*)bytes; +static int dispatch_bind_message(handle_t chan, struct widevine_ctx* ctx, + void* bytes, size_t num_bytes, + handle_t* handles, size_t num_handles) { + struct bind_message* msg = (struct bind_message*)bytes; - if (msg->protocol_version != WV_PROTOCOL_VERSION) { - TLOGE("Received protocol version %u, expected %u.\n", - msg->protocol_version, WV_PROTOCOL_VERSION); - return -1; + if (msg->protocol_version != WV_PROTOCOL_VERSION) { + TLOGE("Received protocol version %u, expected %u.\n", msg->protocol_version, + WV_PROTOCOL_VERSION); + return -1; + } + + if (validate_buffer_sizes(msg) != 0) { + return -1; + } + + /* Validate that the buffers are safe to use for IPC. */ + if (system_specific_validate_ipc_buffer(handles[0]) != 0) { + return -1; + } + if (system_specific_validate_ipc_buffer(handles[1]) != 0) { + return -1; + } + + /* Bind the shared message buffer. */ + size_t shared_message_size = msg->message_buffer_size; + void* shared_message_addr = + mmap(0, shared_message_size, PROT_READ | PROT_WRITE, 0, handles[0], 0); + if (shared_message_addr == MAP_FAILED) { + TLOGE("Could not map message buffer.\n"); + return -1; + } + + /* Bind the bulk shared memory buffer. */ + size_t shared_buffer_size = msg->shared_buffer_size; + void* shared_buffer_addr = + mmap(0, shared_buffer_size, PROT_READ | PROT_WRITE, 0, handles[1], 0); + if (shared_buffer_addr == MAP_FAILED) { + TLOGE("Could not map shared buffer.\n"); + int rc = munmap(shared_message_addr, shared_message_size); + if (rc != NO_ERROR) { + TLOGW("munmap() failed: %d\n", rc); } + return -1; + } - if (validate_buffer_sizes(msg) != 0) { - return -1; - } + bind_shared_memory(ctx, shared_message_addr, shared_message_size, + shared_buffer_addr, shared_buffer_size); - /* Validate that the buffers are safe to use for IPC. */ - if (system_specific_validate_ipc_buffer(handles[0]) != 0) { - return -1; - } - if (system_specific_validate_ipc_buffer(handles[1]) != 0) { - return -1; - } + /* OPK_Initialize needs to be called after the shared memory is bound, not + * before */ + OPK_Initialize(); - /* Bind the shared message buffer. */ - size_t shared_message_size = msg->message_buffer_size; - void* shared_message_addr = mmap(0, shared_message_size, - PROT_READ | PROT_WRITE, 0, handles[0], 0); - if (shared_message_addr == MAP_FAILED) { - TLOGE("Could not map message buffer.\n"); - return -1; - } - - /* Bind the bulk shared memory buffer. */ - size_t shared_buffer_size = msg->shared_buffer_size; - void* shared_buffer_addr = mmap(0, shared_buffer_size, - PROT_READ | PROT_WRITE, 0, handles[1], 0); - if (shared_buffer_addr == MAP_FAILED) { - TLOGE("Could not map shared buffer.\n"); - int rc = munmap(shared_message_addr, shared_message_size); - if (rc != NO_ERROR) { - TLOGW("munmap() failed: %d\n", rc); - } - return -1; - } - - bind_shared_memory(ctx, shared_message_addr, shared_message_size, - shared_buffer_addr, shared_buffer_size); - - /* OPK_Initialize needs to be called after the shared memory is bound, not before */ - OPK_Initialize(); - - /* ACK */ - return send_tagged(chan, create_header(WV_TAG_ACK), NULL, 0); + /* ACK */ + return send_tagged(chan, create_header(WV_TAG_ACK), NULL, 0); } -static int dispatch_widevine_message(handle_t chan, - struct widevine_ctx* ctx, - void* bytes, - size_t num_bytes, - handle_t* handles, - size_t num_handles) { - struct widevine_message* msg = (struct widevine_message*)bytes; +static int dispatch_widevine_message(handle_t chan, struct widevine_ctx* ctx, + void* bytes, size_t num_bytes, + handle_t* handles, size_t num_handles) { + struct widevine_message* msg = (struct widevine_message*)bytes; - /* - * Copy in the message. - * The message must be copied in to prevent the client from attacking the - * sever by mutating memory as it is read. That can result in subtle time of - * check / time of use bugs. - */ - size_t sz = msg->message_size; - if (sz > ctx->shared_message_size || sz > WV_MESSAGE_BUFFER_SIZE) { - TLOGE("Message size exceeds shared memory size. %zu > %zu\n", sz, - ctx->shared_message_size); - return -1; - } - if (sz > ODK_Message_GetCapacity(&request)) { - TLOGE("Message size exceeds internal buffer size. %zu > %zu\n", sz, - ODK_Message_GetCapacity(&request)); - return -1; - } - ODK_Message_Reset(&request); - ODK_Message_SetSize(&request, sz); - memcpy(ODK_Message_GetBase(&request), ctx->shared_message_addr, sz); + /* + * Copy in the message. + * The message must be copied in to prevent the client from attacking the + * sever by mutating memory as it is read. That can result in subtle time of + * check / time of use bugs. + */ + size_t sz = msg->message_size; + if (sz > ctx->shared_message_size || sz > WV_MESSAGE_BUFFER_SIZE) { + TLOGE("Message size exceeds shared memory size. %zu > %zu\n", sz, + ctx->shared_message_size); + return -1; + } + if (sz > ODK_Message_GetCapacity(&request)) { + TLOGE("Message size exceeds internal buffer size. %zu > %zu\n", sz, + ODK_Message_GetCapacity(&request)); + return -1; + } + ODK_Message_Reset(&request); + ODK_Message_SetSize(&request, sz); + memcpy(ODK_Message_GetBase(&request), ctx->shared_message_addr, sz); - /* Transfer ownership of the handles to the Widevine code. */ - for (size_t i = 0; i < num_handles; i++) { - if (register_secure_buffer(handles[i]) < 0) { - cleanup_secure_buffers(); - return -1; - } - handles[i] = -1; + /* Transfer ownership of the handles to the Widevine code. */ + for (size_t i = 0; i < num_handles; i++) { + if (register_secure_buffer(handles[i]) < 0) { + cleanup_secure_buffers(); + return -1; } + handles[i] = -1; + } - /* Execute the request. */ - ODK_Message response; - ODK_MessageStatus message_status = OPK_DispatchMessage(&request, &response); - cleanup_secure_buffers(); - if (message_status != MESSAGE_STATUS_OK) { - TLOGE("Error dispatching request message, status=%d\n", message_status); - /* TODO what should we be doing here? */ - } + /* Execute the request. */ + ODK_Message response; + ODK_MessageStatus message_status = OPK_DispatchMessage(&request, &response); + if (message_status != MESSAGE_STATUS_OK) { + TLOGE("Error dispatching request message, status=%d\n", message_status); + /* TODO what should we be doing here? */ + } - /* Copy out the response. */ - /* TODO synthesize an OOM message if needed. */ - size_t response_size = 0; - response_size = ODK_Message_GetSize(&response); - if (response_size > ctx->shared_message_size) { - TLOGE("Response too large.\n"); - response_size = 0; - } - memcpy(ctx->shared_message_addr, ODK_Message_GetBase(&response), - response_size); - TOS_Transport_ReleaseMessage(&response); + int secure_buffer_res = secure_buffer_clean_cache(); + if (secure_buffer_res != 0) { + TLOGE("Error cleaning cache\n"); + } - /* Notify the client of the response. */ - struct widevine_message response_msg = { - .message_size = (uint32_t)response_size, - }; - return send_tagged(chan, create_header(WV_TAG_WIDEVINE), &response_msg, - sizeof(response_msg)); + cleanup_secure_buffers(); + + /* Copy out the response. */ + /* TODO synthesize an OOM message if needed. */ + size_t response_size = 0; + response_size = ODK_Message_GetSize(&response); + if (response_size > ctx->shared_message_size) { + TLOGE("Response too large.\n"); + response_size = 0; + } + memcpy(ctx->shared_message_addr, ODK_Message_GetBase(&response), + response_size); + TOS_Transport_ReleaseMessage(&response); + + /* Notify the client of the response. */ + struct widevine_message response_msg = { + .message_size = (uint32_t)response_size, + }; + return send_tagged(chan, create_header(WV_TAG_WIDEVINE), &response_msg, + sizeof(response_msg)); } -static int dispatch_message(handle_t chan, - struct widevine_ctx* ctx, - uint16_t tag, - void* bytes, - size_t num_bytes, - handle_t* handles, - size_t num_handles) { - switch (tag) { +static int dispatch_message(handle_t chan, struct widevine_ctx* ctx, + uint16_t tag, void* bytes, size_t num_bytes, + handle_t* handles, size_t num_handles) { + switch (tag) { case WV_TAG_WIDEVINE: - if (is_bound(ctx)) { - return dispatch_widevine_message(chan, ctx, bytes, num_bytes, - handles, num_handles); - } else { - TLOGE("Unexpected %s message while unbound\n", tag_name(tag)); - return -1; - } - case WV_TAG_BIND: - if (is_bound(ctx)) { - TLOGE("Unexpected %s message while bound\n", tag_name(tag)); - return -1; - } else { - return dispatch_bind_message(chan, ctx, bytes, num_bytes, handles, + if (is_bound(ctx)) { + return dispatch_widevine_message(chan, ctx, bytes, num_bytes, handles, num_handles); - } - default: - TLOGE("Unexpected %s message\n", tag_name(tag)); + } else { + TLOGE("Unexpected %s message while unbound\n", tag_name(tag)); return -1; - } + } + case WV_TAG_BIND: + if (is_bound(ctx)) { + TLOGE("Unexpected %s message while bound\n", tag_name(tag)); + return -1; + } else { + return dispatch_bind_message(chan, ctx, bytes, num_bytes, handles, + num_handles); + } + default: + TLOGE("Unexpected %s message\n", tag_name(tag)); + return -1; + } } -static int on_widevine_message(const struct tipc_port* port, - handle_t chan, +static int on_widevine_message(const struct tipc_port* port, handle_t chan, void* _ctx) { - struct widevine_ctx* ctx = (struct widevine_ctx*)_ctx; + struct widevine_ctx* ctx = (struct widevine_ctx*)_ctx; - /* Receive the IPC data. */ - struct wv_ipc_header header; - uint8_t ipc_buffer[WV_IPC_BUFFER_SIZE]; - handle_t handles[WV_MAX_NUM_HANDLES]; - size_t num_bytes = sizeof(ipc_buffer); - size_t num_handles = countof(handles); - int rc = receive_tagged(chan, &header, ipc_buffer, &num_bytes, handles, - &num_handles); - if (rc != 0) { - return -1; - } + /* Receive the IPC data. */ + struct wv_ipc_header header; + uint8_t ipc_buffer[WV_IPC_BUFFER_SIZE]; + handle_t handles[WV_MAX_NUM_HANDLES]; + size_t num_bytes = sizeof(ipc_buffer); + size_t num_handles = countof(handles); + int rc = receive_tagged(chan, &header, ipc_buffer, &num_bytes, handles, + &num_handles); + if (rc != 0) { + return -1; + } - if (validate_message_metadata(header.tag, num_bytes, num_handles) != 0) { - close_handles(handles, num_handles); - return -1; - } - - rc = dispatch_message(chan, ctx, header.tag, ipc_buffer, num_bytes, handles, - num_handles); - /* - * Make sure the handles never leak. If you need to take ownership, - * replace the handle in the array with -1. - */ + if (validate_message_metadata(header.tag, num_bytes, num_handles) != 0) { close_handles(handles, num_handles); - return rc; + return -1; + } + + rc = dispatch_message(chan, ctx, header.tag, ipc_buffer, num_bytes, handles, + num_handles); + /* + * Make sure the handles never leak. If you need to take ownership, + * replace the handle in the array with -1. + */ + close_handles(handles, num_handles); + return rc; } int main(void) { - int rc; - struct tipc_hset* hset; + int rc; + struct tipc_hset* hset; - /* Service configuration */ - static struct tipc_port_acl acl = { - .flags = IPC_PORT_ALLOW_NS_CONNECT, - }; - static struct tipc_port port = { - .name = WV_PORT_NAME, - .msg_max_size = WV_IPC_BUFFER_SIZE, - .msg_queue_len = 1, - .acl = &acl, - }; - static struct tipc_srv_ops ops = { - .on_connect = on_widevine_connect, - .on_message = on_widevine_message, - .on_channel_cleanup = on_widevine_channel_cleanup, - }; + /* Service configuration */ + static struct tipc_port_acl acl = { + .flags = IPC_PORT_ALLOW_NS_CONNECT, + }; + static struct tipc_port port = { + .name = WV_PORT_NAME, + .msg_max_size = WV_IPC_BUFFER_SIZE, + .msg_queue_len = 1, + .acl = &acl, + }; + static struct tipc_srv_ops ops = { + .on_connect = on_widevine_connect, + .on_message = on_widevine_message, + .on_channel_cleanup = on_widevine_channel_cleanup, + }; - request = ODK_Message_Create(message_buffer, sizeof(message_buffer)); + request = ODK_Message_Create(message_buffer, sizeof(message_buffer)); - /* Create event loop */ - hset = tipc_hset_create(); - if (IS_ERR(hset)) { - TLOGE("failed (%d) to create handle set\n", PTR_ERR(hset)); - return PTR_ERR(hset); - } + /* Create event loop */ + hset = tipc_hset_create(); + if (IS_ERR(hset)) { + TLOGE("failed (%d) to create handle set\n", PTR_ERR(hset)); + return PTR_ERR(hset); + } - /* Initialize event loop */ - rc = tipc_add_service(hset, &port, 1, 1, &ops); - if (rc != NO_ERROR) { - TLOGE("failed (%d) to initialize widevine service\n", rc); - return rc; - } + /* Initialize event loop */ + rc = tipc_add_service(hset, &port, 1, 1, &ops); + if (rc != NO_ERROR) { + TLOGE("failed (%d) to initialize widevine service\n", rc); + return rc; + } - /* Run event loop */ - return tipc_run_event_loop(hset); + /* Run event loop */ + return tipc_run_event_loop(hset); } diff --git a/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/device_key/rules.mk b/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/device_key/rules.mk index f1457c5..5d3a86c 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/device_key/rules.mk +++ b/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/device_key/rules.mk @@ -34,6 +34,11 @@ endif MODULE_DEFINES += \ WIDEVINE_PROVISION_METHOD=$(WIDEVINE_PROVISION_METHOD) \ +# Default value if WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE is not set by *-inc.mk. +WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE ?= 0 +MODULE_DEFINES += \ + WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE=$(WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE) + MODULE_DEFINES += \ OPK_CONFIG_SOC_VENDOR_NAME=Google \ OPK_CONFIG_SOC_MODEL_NAME=$(PLATFORM) \ diff --git a/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/other/rules.mk b/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/other/rules.mk index 67fa54d..9735d53 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/other/rules.mk +++ b/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/impl/other/rules.mk @@ -34,6 +34,11 @@ endif MODULE_DEFINES += \ WIDEVINE_PROVISION_METHOD=$(WIDEVINE_PROVISION_METHOD) \ +# Default value if WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE is not set by *-inc.mk. +WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE ?= 0 +MODULE_DEFINES += \ + WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE=$(WIDEVINE_PROVISION_BCC_SIGNATURE_TYPE) + MODULE_DEFINES += \ OPK_CONFIG_SOC_VENDOR_NAME=Google \ OPK_CONFIG_SOC_MODEL_NAME=$(PLATFORM) \ diff --git a/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/test/wtpi_test.cpp b/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/test/wtpi_test.cpp index 596f28b..6b582a2 100644 --- a/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/test/wtpi_test.cpp +++ b/oemcrypto/opk/ports/trusty/ta/reference/wtpi_lib/test/wtpi_test.cpp @@ -35,679 +35,657 @@ test_abort:; */ TEST(wtpi_tests, simple_decrypt_ctr_1) { - std::vector key = { - 0x1B, 0x0C, 0x04, 0x47, 0x78, 0x46, 0xB4, 0xC4, - 0xDC, 0xA3, 0x80, 0x87, 0x55, 0x94, 0x8C, 0x2B, - }; - std::vector iv = {0x42, 0xcd, 0x8d, 0x2b, 0x5e, 0x8b, 0x95, 0xe1, - 0x39, 0xf0, 0x66, 0x3c, 0xf8, 0x9b, 0xbe, 0xc8}; - std::vector clear = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f}; - std::vector encrypted = {0x4f, 0xf1, 0x9a, 0x72, 0x01, 0x19, - 0xda, 0x61, 0xe4, 0xfe, 0xfc, 0x11, - 0x69, 0xef, 0x2f, 0xf7}; + std::vector key = { + 0x1B, 0x0C, 0x04, 0x47, 0x78, 0x46, 0xB4, 0xC4, + 0xDC, 0xA3, 0x80, 0x87, 0x55, 0x94, 0x8C, 0x2B, + }; + std::vector iv = {0x42, 0xcd, 0x8d, 0x2b, 0x5e, 0x8b, 0x95, 0xe1, + 0x39, 0xf0, 0x66, 0x3c, 0xf8, 0x9b, 0xbe, 0xc8}; + std::vector clear = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; + std::vector encrypted = {0x4f, 0xf1, 0x9a, 0x72, 0x01, 0x19, + 0xda, 0x61, 0xe4, 0xfe, 0xfc, 0x11, + 0x69, 0xef, 0x2f, 0xf7}; - uint8_t output[32] = {0}; + uint8_t output[32] = {0}; - // set up sample description - OEMCrypto_SampleDescription sample = {}; - OEMCrypto_SubSampleDescription subsample = {}; - subsample.num_bytes_clear = 0; - subsample.num_bytes_encrypted = 16; - subsample.subsample_flags = 3; - subsample.block_offset = 0; - sample.subsamples_length = 1; - sample.subsamples = &subsample; - OEMCrypto_InputOutputPair* iop = &sample.buffers; - iop->input_data = encrypted.data(); - iop->input_data_length = encrypted.size(); - iop->output_descriptor.type = OEMCrypto_BufferType_Clear; - iop->output_descriptor.buffer.clear.clear_buffer = output; - iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); + // set up sample description + OEMCrypto_SampleDescription sample = {}; + OEMCrypto_SubSampleDescription subsample = {}; + subsample.num_bytes_clear = 0; + subsample.num_bytes_encrypted = 16; + subsample.subsample_flags = 3; + subsample.block_offset = 0; + sample.subsamples_length = 1; + sample.subsamples = &subsample; + OEMCrypto_InputOutputPair* iop = &sample.buffers; + iop->input_data = encrypted.data(); + iop->input_data_length = encrypted.size(); + iop->output_descriptor.type = OEMCrypto_BufferType_Clear; + iop->output_descriptor.buffer.clear.clear_buffer = output; + iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); - memcpy(sample.iv, iv.data(), iv.size()); + memcpy(sample.iv, iv.data(), iv.size()); - OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; - OPK_OutputBuffer output_buffer = {}; - output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; - output_buffer.buffer.clear_insecure = output; - output_buffer.size = clear.size(); - size_t output_offset = 0; - OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; - WTPI_K1_SymmetricKey_Handle key_handle = NULL; - OEMCryptoResult result = OEMCrypto_SUCCESS; + OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; + OPK_OutputBuffer output_buffer = {}; + output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; + output_buffer.buffer.clear_insecure = output; + output_buffer.size = clear.size(); + size_t output_offset = 0; + OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; + WTPI_K1_SymmetricKey_Handle key_handle = NULL; + OEMCryptoResult result = OEMCrypto_SUCCESS; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); - result = WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, - &key_handle); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); + result = + WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, &key_handle); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, - output_offset, cipher_mode); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, + output_offset, cipher_mode); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - for (size_t i = 0; i < clear.size(); i++) { - ASSERT_EQ(clear[i], output[i]); - } + for (size_t i = 0; i < clear.size(); i++) { + ASSERT_EQ(clear[i], output[i]); + } test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); } TEST(wtpi_tests, simple_decrypt_ctr_2) { - std::vector key = {0xac, 0x72, 0x37, 0x3e, 0x03, 0x21, 0x3c, 0x25, - 0xf2, 0x61, 0x2e, 0x85, 0x7b, 0xaf, 0xdb, 0x5e}; - std::vector iv = {0x0c, 0x0b, 0x1a, 0x92, 0x9f, 0x55, 0xbc, 0x48, - 0x1f, 0x02, 0xda, 0x78, 0x02, 0x3d, 0x13, 0x11}; - std::vector clear = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, - 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, - 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, - 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, - 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, - 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, - 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf}; - std::vector encrypted = { - 0x5d, 0xd9, 0xfb, 0x2b, 0xa8, 0xf2, 0xa9, 0xec, 0x34, 0xb9, 0x83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 0xaa}; - uint8_t output[176] = {0}; + std::vector key = {0xac, 0x72, 0x37, 0x3e, 0x03, 0x21, 0x3c, 0x25, + 0xf2, 0x61, 0x2e, 0x85, 0x7b, 0xaf, 0xdb, 0x5e}; + std::vector iv = {0x0c, 0x0b, 0x1a, 0x92, 0x9f, 0x55, 0xbc, 0x48, + 0x1f, 0x02, 0xda, 0x78, 0x02, 0x3d, 0x13, 0x11}; + std::vector clear = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, + 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, + 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, + 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, + 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, + 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf}; + std::vector encrypted = { + 0x5d, 0xd9, 0xfb, 0x2b, 0xa8, 0xf2, 0xa9, 0xec, 0x34, 0xb9, 0x83, 0x74, + 0x24, 0x6b, 0x9f, 0x75, 0xae, 0xbd, 0xe5, 0x7c, 0x81, 0x48, 0xac, 0x05, + 0x94, 0xec, 0xed, 0x85, 0x05, 0x60, 0xa6, 0x56, 0x71, 0x22, 0x79, 0xf0, + 0xf0, 0xab, 0x3f, 0x98, 0x5a, 0x8e, 0xe9, 0x5a, 0xbd, 0xb1, 0xf0, 0x39, + 0x7a, 0xf0, 0x97, 0x4e, 0x55, 0xd0, 0xaa, 0xa0, 0x53, 0x70, 0xe1, 0x34, + 0x67, 0x3f, 0x22, 0x54, 0x90, 0xe1, 0xde, 0xf4, 0x2b, 0x31, 0xb4, 0x99, + 0xc7, 0x20, 0x18, 0x30, 0x19, 0xf8, 0xb9, 0xa0, 0x25, 0xd6, 0x4b, 0xea, + 0xf5, 0x26, 0x30, 0x1e, 0xcd, 0xa7, 0xf6, 0xb3, 0x0c, 0x55, 0xa8, 0x0b, + 0xfe, 0x1a, 0xf9, 0x85, 0x94, 0xfc, 0x4f, 0xfa, 0x68, 0xf9, 0x28, 0xe8, + 0xf8, 0x0e, 0x1f, 0x5a, 0xa5, 0x0a, 0xb4, 0xe3, 0x91, 0x5c, 0xb0, 0xf7, + 0xb5, 0x5d, 0x1b, 0x95, 0xa5, 0x00, 0xa5, 0x60, 0x2c, 0x93, 0xf9, 0xa5, + 0xde, 0x32, 0x94, 0x72, 0xa3, 0xf9, 0xda, 0x87, 0x29, 0x7b, 0x91, 0xf0, + 0x17, 0x0a, 0xae, 0x82, 0xbc, 0xc3, 0x34, 0xc8, 0x4c, 0x82, 0x9d, 0x7b, + 0xe3, 0xce, 0x7f, 0x94, 0x41, 0x5f, 0x50, 0x57, 0xaa, 0x5e, 0x17, 0xd1, + 0x0b, 0xee, 0x98, 0x69, 0xd3, 0x1c, 0x84, 0x2f, 0xaa, 0xaa, 0xaa, 0xaa, + 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}; + uint8_t output[176] = {0}; - // set up sample description - OEMCrypto_SampleDescription sample = {}; - OEMCrypto_SubSampleDescription subsample = {}; - subsample.num_bytes_clear = 0; - subsample.num_bytes_encrypted = 176; - subsample.subsample_flags = 3; - subsample.block_offset = 0; - sample.subsamples_length = 1; - sample.subsamples = &subsample; - OEMCrypto_InputOutputPair* iop = &sample.buffers; - iop->input_data = encrypted.data(); - iop->input_data_length = encrypted.size(); - iop->output_descriptor.type = OEMCrypto_BufferType_Clear; - iop->output_descriptor.buffer.clear.clear_buffer = output; - iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); + // set up sample description + OEMCrypto_SampleDescription sample = {}; + OEMCrypto_SubSampleDescription subsample = {}; + subsample.num_bytes_clear = 0; + subsample.num_bytes_encrypted = 176; + subsample.subsample_flags = 3; + subsample.block_offset = 0; + sample.subsamples_length = 1; + sample.subsamples = &subsample; + OEMCrypto_InputOutputPair* iop = &sample.buffers; + iop->input_data = encrypted.data(); + iop->input_data_length = encrypted.size(); + iop->output_descriptor.type = OEMCrypto_BufferType_Clear; + iop->output_descriptor.buffer.clear.clear_buffer = output; + iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); - memcpy(sample.iv, iv.data(), iv.size()); + memcpy(sample.iv, iv.data(), iv.size()); - OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; - OPK_OutputBuffer output_buffer = {}; - output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; - output_buffer.buffer.clear_insecure = output; - output_buffer.size = clear.size(); - size_t output_offset = 0; - OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; - WTPI_K1_SymmetricKey_Handle key_handle = NULL; - OEMCryptoResult result = OEMCrypto_SUCCESS; + OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; + OPK_OutputBuffer output_buffer = {}; + output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; + output_buffer.buffer.clear_insecure = output; + output_buffer.size = clear.size(); + size_t output_offset = 0; + OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; + WTPI_K1_SymmetricKey_Handle key_handle = NULL; + OEMCryptoResult result = OEMCrypto_SUCCESS; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); - result = WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, - &key_handle); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); + result = + WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, &key_handle); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, - output_offset, cipher_mode); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, + output_offset, cipher_mode); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - for (size_t i = 0; i < clear.size(); i++) { - ASSERT_EQ(clear[i], output[i]); - } + for (size_t i = 0; i < clear.size(); i++) { + ASSERT_EQ(clear[i], output[i]); + } test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); } TEST(wtpi_tests, simple_decrypt_ctr_3) { - std::vector key = {0x02, 0xaa, 0xd5, 0xa4, 0x34, 0x11, 0x3b, 0xab, - 0xb0, 0xdf, 0xbe, 0x46, 0xc3, 0x33, 0x76, 0x6f}; - std::vector iv = {0x89, 0xa9, 0xf0, 0x0c, 0xdc, 0xa1, 0x50, 0x9d, - 0x58, 0x8f, 0x7f, 0x46, 0x8f, 0x8c, 0xd4, 0x42}; - std::vector clear = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, - 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, - 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, - 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, - 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, - 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa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x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, - 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, - 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, - 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, - 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, - 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, - 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, - 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, - 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, - 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, - 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, - 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, - 0x9f, 0xa0, 0xa1, 0xa2, 0xa3}; - std::vector encrypted = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0xa2, 0x10, 0xff, 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 0x84, 0x73, - 0xf1, 0x13, 0xe4, 0xdf, 0x05, 0x74, 0x35, 0xa0, 0x9d, 0xfd, 0x4d, - 0x77, 0xb9, 0x5b, 0xf7, 0x2a, 0xe3, 0x7d, 0xd4, 0x13, 0xb5, 0xdc, - 0xa4, 0x24, 0xad, 0xae, 0x4f, 0x8f, 0x97, 0xb6, 0x1d, 0x8f, 0xe3, - 0x39, 0xc7, 0x92, 0xe6, 0xa9, 0xa1, 0xe4, 0xee, 0x6a, 0xb4, 0x3f, - 0x90, 0xfd, 0xfc, 0x24, 0xfc, 0xfd, 0x5d, 0xe9, 0x32, 0xfb, 0xe2, - 0x8c, 0x41, 0xd4, 0x96, 0x4f, 0x59, 0x96, 0xbd, 0x4f, 0x76, 0x58, - 0xbc, 0x65, 0xbe, 0x2a, 0x63, 0xe4, 0xcf, 0x24, 0x8d, 0xa5, 0x63, - 0x75, 0x59, 0x1f, 0x19, 0xd4, 0x70, 0x52, 0xe8, 0xd4, 0x4d, 0x36, - 0x1c, 0xec, 0x23, 0x6b, 0xbe, 0x77, 0xcd, 0x41, 0xc9, 0xa4, 0x52, - 0xaf, 0x23, 0x55, 0xa2, 0xa1}; - uint8_t output[676] = {0}; + std::vector key = {0x02, 0xaa, 0xd5, 0xa4, 0x34, 0x11, 0x3b, 0xab, + 0xb0, 0xdf, 0xbe, 0x46, 0xc3, 0x33, 0x76, 0x6f}; + std::vector iv = {0x89, 0xa9, 0xf0, 0x0c, 0xdc, 0xa1, 0x50, 0x9d, + 0x58, 0x8f, 0x7f, 0x46, 0x8f, 0x8c, 0xd4, 0x42}; + std::vector clear = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,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, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, + 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, + 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, + 0xfc, 0xfd, 0xfe, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, + 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, + 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, + 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, + 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, + 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, + 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92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x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, + 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, 0x63, + 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, + 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, + 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3}; + std::vector encrypted = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0xa2, 0x10, 0xff, 0xf5, 0xc3, 0x78, 0xce, 0x45, 0x6a, 0xe9, 0xd6, + 0xb7, 0xb5, 0x66, 0x85, 0xde, 0xf0, 0x5f, 0x5f, 0x29, 0x36, 0x65, 0x6a, + 0xb3, 0x2d, 0x29, 0xef, 0x00, 0x3e, 0xfb, 0x7a, 0x10, 0xe0, 0x2a, 0xac, + 0xae, 0xcb, 0xc7, 0x25, 0xc9, 0xcc, 0xc2, 0x13, 0xbf, 0x8f, 0x3f, 0x5a, + 0xa6, 0xf4, 0xb2, 0x10, 0x85, 0xcb, 0x9b, 0xe5, 0x39, 0x7d, 0xa1, 0x2b, + 0xd9, 0x6a, 0x89, 0x58, 0x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0xab, 0x14, 0x84, 0x92, 0x27, 0xa1, 0x28, 0x73, 0x0b, + 0x73, 0x86, 0x0e, 0xb3, 0xe7, 0x85, 0xdb, 0xc0, 0xcf, 0x28, 0xde, 0x05, + 0x81, 0x38, 0x35, 0x90, 0xc2, 0xfd, 0x57, 0x16, 0x39, 0x04, 0x9e, 0x92, + 0xb7, 0x27, 0x23, 0x8c, 0xf3, 0x82, 0x0a, 0x7b, 0xf3, 0xcb, 0xbc, 0xf4, + 0xba, 0x3d, 0xc6, 0x50, 0xec, 0x1a, 0x13, 0x9d, 0x5a, 0x00, 0x6d, 0x8f, + 0x61, 0xdb, 0xce, 0x8e, 0xee, 0x32, 0x2b, 0x39, 0xf4, 0xa8, 0xe7, 0xe7, + 0xc9, 0xe8, 0x13, 0xeb, 0xed, 0xb1, 0x6c, 0x24, 0xa8, 0xd1, 0xcb, 0xb9, + 0x76, 0xed, 0x50, 0xf7, 0x28, 0xe9, 0x65, 0x32, 0x10, 0x0a, 0x1c, 0x2c, + 0x0b, 0xf9, 0x18, 0x11, 0xde, 0x87, 0xb3, 0x71, 0x7f, 0xa9, 0x30, 0x3c, + 0xd3, 0x45, 0x29, 0x64, 0x39, 0x56, 0x02, 0xa1, 0x25, 0xa1, 0xeb, 0x21, + 0xfe, 0x61, 0x41, 0xe3, 0x82, 0x96, 0x50, 0x9b, 0x8f, 0xaf, 0xce, 0xe5, + 0x76, 0xee, 0x92, 0x22, 0x17, 0x2c, 0x91, 0xce, 0x59, 0x32, 0xc3, 0x97, + 0x46, 0xa7, 0x63, 0x8f, 0x06, 0x97, 0xc9, 0x5c, 0xef, 0xf6, 0x6a, 0x1d, + 0xd3, 0xec, 0xb1, 0xa7, 0x9b, 0x82, 0xbf, 0x5f, 0xf9, 0x1c, 0xee, 0x25, + 0x17, 0xa9, 0x90, 0x50, 0x93, 0xc6, 0xc2, 0x10, 0x70, 0xd4, 0x97, 0x58, + 0xa6, 0x6c, 0x08, 0xc7, 0xcf, 0x52, 0x3d,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96, 0x4f, 0x59, 0x96, 0xbd, 0x4f, + 0x76, 0x58, 0xbc, 0x65, 0xbe, 0x2a, 0x63, 0xe4, 0xcf, 0x24, 0x8d, 0xa5, + 0x63, 0x75, 0x59, 0x1f, 0x19, 0xd4, 0x70, 0x52, 0xe8, 0xd4, 0x4d, 0x36, + 0x1c, 0xec, 0x23, 0x6b, 0xbe, 0x77, 0xcd, 0x41, 0xc9, 0xa4, 0x52, 0xaf, + 0x23, 0x55, 0xa2, 0xa1}; + uint8_t output[676] = {0}; - // set up sample description - OEMCrypto_SampleDescription sample = {}; - OEMCrypto_SubSampleDescription subsamples[3]; - subsamples[0].num_bytes_clear = 25; - subsamples[0].num_bytes_encrypted = 160; - subsamples[0].subsample_flags = 1; - subsamples[0].block_offset = 0; - subsamples[1].num_bytes_clear = 50; - subsamples[1].num_bytes_encrypted = 256; - subsamples[1].subsample_flags = 0; - subsamples[1].block_offset = 0; - subsamples[2].num_bytes_clear = 25; - subsamples[2].num_bytes_encrypted = 160; - subsamples[2].subsample_flags = 2; - subsamples[2].block_offset = 0; - sample.subsamples_length = 3; - sample.subsamples = &subsamples[0]; - OEMCrypto_InputOutputPair* iop = &sample.buffers; - iop->input_data = encrypted.data(); - iop->input_data_length = encrypted.size(); - iop->output_descriptor.type = OEMCrypto_BufferType_Clear; - iop->output_descriptor.buffer.clear.clear_buffer = output; - iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); + // set up sample description + OEMCrypto_SampleDescription sample = {}; + OEMCrypto_SubSampleDescription subsamples[3]; + subsamples[0].num_bytes_clear = 25; + subsamples[0].num_bytes_encrypted = 160; + subsamples[0].subsample_flags = 1; + subsamples[0].block_offset = 0; + subsamples[1].num_bytes_clear = 50; + subsamples[1].num_bytes_encrypted = 256; + subsamples[1].subsample_flags = 0; + subsamples[1].block_offset = 0; + subsamples[2].num_bytes_clear = 25; + subsamples[2].num_bytes_encrypted = 160; + subsamples[2].subsample_flags = 2; + subsamples[2].block_offset = 0; + sample.subsamples_length = 3; + sample.subsamples = &subsamples[0]; + OEMCrypto_InputOutputPair* iop = &sample.buffers; + iop->input_data = encrypted.data(); + iop->input_data_length = encrypted.size(); + iop->output_descriptor.type = OEMCrypto_BufferType_Clear; + iop->output_descriptor.buffer.clear.clear_buffer = output; + iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); - memcpy(sample.iv, iv.data(), iv.size()); + memcpy(sample.iv, iv.data(), iv.size()); - OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; - OPK_OutputBuffer output_buffer = {}; - output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; - output_buffer.buffer.clear_insecure = output; - output_buffer.size = clear.size(); - size_t output_offset = 0; - OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; - WTPI_K1_SymmetricKey_Handle key_handle = NULL; - OEMCryptoResult result = OEMCrypto_SUCCESS; + OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; + OPK_OutputBuffer output_buffer = {}; + output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; + output_buffer.buffer.clear_insecure = output; + output_buffer.size = clear.size(); + size_t output_offset = 0; + OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; + WTPI_K1_SymmetricKey_Handle key_handle = NULL; + OEMCryptoResult result = OEMCrypto_SUCCESS; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); - result = WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, - &key_handle); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); + result = + WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, &key_handle); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, - output_offset, cipher_mode); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, + output_offset, cipher_mode); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - for (size_t i = 0; i < clear.size(); i++) { - ASSERT_EQ(clear[i], output[i]); - } + for (size_t i = 0; i < clear.size(); i++) { + ASSERT_EQ(clear[i], output[i]); + } test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); } TEST(wtpi_tests, simple_decrypt_ctr_4) { - std::vector key = {0x7d, 0x54, 0x07, 0x87, 0x02, 0x4e, 0x0f, 0x87, - 0x9f, 0xe4, 0x29, 0xc2, 0xb4, 0xc9, 0x83, 0x1a}; - std::vector iv = {0x1c, 0x26, 0x2b, 0xbd, 0xb6, 0xdc, 0xb1, 0x14, - 0xb8, 0x20, 0x93, 0x23, 0x87, 0xfa, 0xe3, 0xa9}; - std::vector clear = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, - 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, - 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, - 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, - 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, - 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, - 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, - 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, - 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5}; - std::vector encrypted = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x58, - 0xd8, 0xae, 0xaf, 0x34, 0x08, 0x0a, 0xc5, 0x2e, 0xa2, 0x96, 0xd1, - 0x23, 0x38, 0x29, 0x49, 0x6e, 0x13, 0x3a, 0xe0, 0x94, 0x7e, 0xc1, - 0x1f, 0xb4, 0x48, 0xac, 0x59, 0x86, 0x4e, 0x9d, 0xc7, 0x2a, 0x92, - 0x4a, 0x19,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0b, 0xe3, 0xfb}; - uint8_t output[230] = {0}; + std::vector key = {0x7d, 0x54, 0x07, 0x87, 0x02, 0x4e, 0x0f, 0x87, + 0x9f, 0xe4, 0x29, 0xc2, 0xb4, 0xc9, 0x83, 0x1a}; + std::vector iv = {0x1c, 0x26, 0x2b, 0xbd, 0xb6, 0xdc, 0xb1, 0x14, + 0xb8, 0x20, 0x93, 0x23, 0x87, 0xfa, 0xe3, 0xa9}; + std::vector clear = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, + 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, + 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, + 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, + 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,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 0x46, 0xe1, 0x36, 0xbb, 0x1a, + 0x1c, 0x0b, 0x8b, 0xa7, 0x25, 0x87, 0xa1, 0x9a, 0x2d, 0xf0, 0xa7, 0x40, + 0xb3, 0x0d, 0x05, 0xfc, 0xe4, 0x33, 0x68, 0xb1, 0xb4, 0x18, 0x3c, 0x29, + 0x2b, 0xb1, 0xd2, 0x3e, 0x2e, 0x4d, 0x1e, 0x74, 0xff, 0x31, 0x34, 0x4c, + 0xd1, 0xee, 0x9d, 0x1e, 0xd7, 0x07, 0x4a, 0x05, 0x4e, 0x4d, 0xb8, 0x97, + 0xe2, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x16, + 0xe8, 0xee, 0x35, 0x1a, 0x45, 0x34, 0xd9, 0xd5, 0x33, 0xb6, 0xb9, 0x33, + 0x67, 0x1c, 0x71, 0xe3, 0x37, 0x94, 0xde, 0x8c, 0x48, 0x40, 0xe3, 0xf3, + 0x05, 0xc3, 0xcc, 0x42, 0x8e, 0x04, 0x23, 0xa9, 0xd7, 0x03, 0x43, 0x8e, + 0x92, 0x3b, 0x1f, 0x40, 0xf5, 0xb3, 0xc3, 0x3a, 0x1a, 0x12, 0x30, 0x0e, + 0x78, 0x83, 0xa6, 0xc6, 0x9c, 0x79, 0xf6, 0x31, 0xba, 0x24, 0x38, 0x27, + 0x08, 0x7a, 0x0c, 0xe9, 0xc2, 0x4e, 0xa7, 0xf6, 0xb5, 0x7a, 0x45, 0x0b, + 0xe3, 0xfb}; + uint8_t output[230] = {0}; - // set up sample description - OEMCrypto_SampleDescription sample = {}; - OEMCrypto_SubSampleDescription subsamples[3]; - subsamples[0].num_bytes_clear = 10; - subsamples[0].num_bytes_encrypted = 50; - subsamples[0].subsample_flags = 1; - subsamples[0].block_offset = 0; - subsamples[1].num_bytes_clear = 10; - subsamples[1].num_bytes_encrypted = 75; - subsamples[1].subsample_flags = 0; - subsamples[1].block_offset = 2; - subsamples[2].num_bytes_clear = 10; - subsamples[2].num_bytes_encrypted = 75; - subsamples[2].subsample_flags = 2; - subsamples[2].block_offset = 13; - sample.subsamples_length = 3; - sample.subsamples = &subsamples[0]; - OEMCrypto_InputOutputPair* iop = &sample.buffers; - iop->input_data = encrypted.data(); - iop->input_data_length = encrypted.size(); - iop->output_descriptor.type = OEMCrypto_BufferType_Clear; - iop->output_descriptor.buffer.clear.clear_buffer = output; - iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); + // set up sample description + OEMCrypto_SampleDescription sample = {}; + OEMCrypto_SubSampleDescription subsamples[3]; + subsamples[0].num_bytes_clear = 10; + subsamples[0].num_bytes_encrypted = 50; + subsamples[0].subsample_flags = 1; + subsamples[0].block_offset = 0; + subsamples[1].num_bytes_clear = 10; + subsamples[1].num_bytes_encrypted = 75; + subsamples[1].subsample_flags = 0; + subsamples[1].block_offset = 2; + subsamples[2].num_bytes_clear = 10; + subsamples[2].num_bytes_encrypted = 75; + subsamples[2].subsample_flags = 2; + subsamples[2].block_offset = 13; + sample.subsamples_length = 3; + sample.subsamples = &subsamples[0]; + OEMCrypto_InputOutputPair* iop = &sample.buffers; + iop->input_data = encrypted.data(); + iop->input_data_length = encrypted.size(); + iop->output_descriptor.type = OEMCrypto_BufferType_Clear; + iop->output_descriptor.buffer.clear.clear_buffer = output; + iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); - memcpy(sample.iv, iv.data(), iv.size()); + memcpy(sample.iv, iv.data(), iv.size()); - OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; - OPK_OutputBuffer output_buffer = {}; - output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; - output_buffer.buffer.clear_insecure = output; - output_buffer.size = clear.size(); - size_t output_offset = 0; - OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; - WTPI_K1_SymmetricKey_Handle key_handle = NULL; - OEMCryptoResult result = OEMCrypto_SUCCESS; + OEMCrypto_CENCEncryptPatternDesc pattern = {0, 0}; + OPK_OutputBuffer output_buffer = {}; + output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; + output_buffer.buffer.clear_insecure = output; + output_buffer.size = clear.size(); + size_t output_offset = 0; + OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CENC; + WTPI_K1_SymmetricKey_Handle key_handle = NULL; + OEMCryptoResult result = OEMCrypto_SUCCESS; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); - result = WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, - &key_handle); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); + result = + WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, &key_handle); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, - output_offset, cipher_mode); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, + output_offset, cipher_mode); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - for (size_t i = 0; i < clear.size(); i++) { - ASSERT_EQ(clear[i], output[i]); - } + for (size_t i = 0; i < clear.size(); i++) { + ASSERT_EQ(clear[i], output[i]); + } test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); } TEST(wtpi_tests, simple_decrypt_cbc_1) { - std::vector key = {0x7a, 0x3b, 0xc9, 0xb7, 0xce, 0xb6, 0x96, 0xf5, - 0xb1, 0x50, 0x29, 0xdc, 0x2a, 0x26, 0xd4, 0xbe}; - std::vector iv = {0x1b, 0x2e, 0x62, 0x62, 0x7b, 0x19, 0xc5, 0xba, - 0x68, 0x00, 0x58, 0x9f, 0xca, 0x70, 0xc8, 0x8b}; - std::vector clear = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, - 0x0c, 0x0d, 0x0e, 0x0f}; - std::vector encrypted = {0x1d, 0x4a, 0x20, 0xf4, 0x49, 0x02, - 0x13, 0xad, 0x1e, 0x47, 0xee, 0x44, - 0x36, 0x29, 0x4c, 0xae}; - uint8_t output[32] = {0}; + std::vector key = {0x7a, 0x3b, 0xc9, 0xb7, 0xce, 0xb6, 0x96, 0xf5, + 0xb1, 0x50, 0x29, 0xdc, 0x2a, 0x26, 0xd4, 0xbe}; + std::vector iv = {0x1b, 0x2e, 0x62, 0x62, 0x7b, 0x19, 0xc5, 0xba, + 0x68, 0x00, 0x58, 0x9f, 0xca, 0x70, 0xc8, 0x8b}; + std::vector clear = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f}; + std::vector encrypted = {0x1d, 0x4a, 0x20, 0xf4, 0x49, 0x02, + 0x13, 0xad, 0x1e, 0x47, 0xee, 0x44, + 0x36, 0x29, 0x4c, 0xae}; + uint8_t output[32] = {0}; - // set up sample description - OEMCrypto_SampleDescription sample = {}; - OEMCrypto_SubSampleDescription subsample = {}; - subsample.num_bytes_clear = 0; - subsample.num_bytes_encrypted = 16; - subsample.subsample_flags = 3; - subsample.block_offset = 0; - sample.subsamples_length = 1; - sample.subsamples = &subsample; - OEMCrypto_InputOutputPair* iop = &sample.buffers; - iop->input_data = encrypted.data(); - iop->input_data_length = encrypted.size(); - iop->output_descriptor.type = OEMCrypto_BufferType_Clear; - iop->output_descriptor.buffer.clear.clear_buffer = output; - iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); + // set up sample description + OEMCrypto_SampleDescription sample = {}; + OEMCrypto_SubSampleDescription subsample = {}; + subsample.num_bytes_clear = 0; + subsample.num_bytes_encrypted = 16; + subsample.subsample_flags = 3; + subsample.block_offset = 0; + sample.subsamples_length = 1; + sample.subsamples = &subsample; + OEMCrypto_InputOutputPair* iop = &sample.buffers; + iop->input_data = encrypted.data(); + iop->input_data_length = encrypted.size(); + iop->output_descriptor.type = OEMCrypto_BufferType_Clear; + iop->output_descriptor.buffer.clear.clear_buffer = output; + iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); - memcpy(sample.iv, iv.data(), iv.size()); + memcpy(sample.iv, iv.data(), iv.size()); - OEMCrypto_CENCEncryptPatternDesc pattern = {3, 7}; - OPK_OutputBuffer output_buffer = {}; - output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; - output_buffer.buffer.clear_insecure = output; - output_buffer.size = clear.size(); - size_t output_offset = 0; - OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CBCS; - WTPI_K1_SymmetricKey_Handle key_handle = NULL; - OEMCryptoResult result = OEMCrypto_SUCCESS; + OEMCrypto_CENCEncryptPatternDesc pattern = {3, 7}; + OPK_OutputBuffer output_buffer = {}; + output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; + output_buffer.buffer.clear_insecure = output; + output_buffer.size = clear.size(); + size_t output_offset = 0; + OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CBCS; + WTPI_K1_SymmetricKey_Handle key_handle = NULL; + OEMCryptoResult result = OEMCrypto_SUCCESS; - // SetPattern not yet supported - GTEST_SKIP(); - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); - result = WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, - &key_handle); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + // SetPattern not yet supported + GTEST_SKIP(); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); + result = + WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, &key_handle); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, - output_offset, cipher_mode); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, + output_offset, cipher_mode); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - for (size_t i = 0; i < clear.size(); i++) { - ASSERT_EQ(clear[i], output[i]); - } + for (size_t i = 0; i < clear.size(); i++) { + ASSERT_EQ(clear[i], output[i]); + } test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); } TEST(wtpi_tests, simple_decrypt_cbc_2) { - std::vector key = {0x0e, 0xe1, 0x08, 0x9c, 0x61, 0x05, 0xf5, 0xb1, - 0x86, 0x9d, 0x46, 0x3e, 0xde, 0x4b, 0xf2, 0xe3}; - std::vector iv = {0x1a, 0x08, 0x96, 0x4c, 0x09, 0x03, 0x3d, 0xad, - 0x6a, 0xf8, 0x72, 0x4d, 0x99, 0x77, 0xcb, 0x93}; - std::vector clear = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, - 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, - 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, - 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, - 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, - 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, - 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, - 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x60, 0x61, 0x62, - 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, - 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, - 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, - 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, - 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, - 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, - 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, - 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5}; - std::vector encrypted = { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x55, - 0x85, 0xde, 0x61, 0xea, 0x4a, 0x03, 0x88, 0xce, 0x04, 0x93, 0xf8, - 0x92, 0x94, 0x77, 0x22, 0x57, 0x38, 0x12, 0x61, 0xb2, 0x04, 0x76, - 0x9e, 0x55, 0x82, 0x81, 0xc5, 0x8d, 0x14, 0xb6, 0x94, 0x01, 0x72, - 0x41, 0xcd, 0xd7, 0xf3, 0x82, 0x47, 0x7d, 0x1c, 0x28, 0x69, 0x14, - 0xb8, 0x17, 0x49, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, - 0x42, 0x43, 0x44, 0x45, 0xed, 0xa2, 0xbf, 0x5b, 0xfc, 0xf3, 0x27, - 0x79, 0x3b, 0xf4, 0x59, 0x76, 0x28, 0x20, 0x2a, 0xf8, 0xdd, 0x82, - 0x9a, 0xa0, 0x55, 0x57, 0x11, 0x9a, 0x1a, 0x41, 0x18, 0x0d, 0xd0, - 0x9f, 0x54, 0x9e, 0xf5, 0x20, 0x52, 0xa1, 0xc6, 0x1b, 0xd6, 0xee, - 0x06, 0xcc, 0x1e, 0x33, 0xa9, 0x2e, 0x1f, 0xc2, 0x76, 0x77, 0x78, - 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, - 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, - 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, - 0x9a, 0xf5, 0xa5, 0xca, 0xf9, 0x0e, 0x46, 0x31, 0x2f, 0xd1, 0x48, - 0xac, 0x9b, 0xae, 0xc5, 0x8b, 0x16, 0x6e, 0x95, 0xdb, 0x66, 0x72, - 0x0c, 0xaa, 0x56, 0x37, 0x55, 0x87, 0x56, 0x51, 0xe2, 0x11, 0x87, - 0xb2, 0x69, 0xa2, 0x3b, 0x44, 0xf9, 0x85, 0x9c, 0x70, 0xfd, 0xb2, - 0xef, 0x7e, 0x56, 0xd9, 0x6c, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, - 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, - 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5}; - uint8_t output[230] = {0}; + std::vector key = {0x0e, 0xe1, 0x08, 0x9c, 0x61, 0x05, 0xf5, 0xb1, + 0x86, 0x9d, 0x46, 0x3e, 0xde, 0x4b, 0xf2, 0xe3}; + std::vector iv = {0x1a, 0x08, 0x96, 0x4c, 0x09, 0x03, 0x3d, 0xad, + 0x6a, 0xf8, 0x72, 0x4d, 0x99, 0x77, 0xcb, 0x93}; + std::vector clear = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, + 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, + 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, + 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, + 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, + 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, + 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, + 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, + 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, + 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, + 0xe4, 0xe5}; + std::vector encrypted = { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x55, 0x85, + 0xde, 0x61, 0xea, 0x4a, 0x03, 0x88, 0xce, 0x04, 0x93, 0xf8, 0x92, 0x94, + 0x77, 0x22, 0x57, 0x38, 0x12, 0x61, 0xb2, 0x04, 0x76, 0x9e, 0x55, 0x82, + 0x81, 0xc5, 0x8d, 0x14, 0xb6, 0x94, 0x01, 0x72, 0x41, 0xcd, 0xd7, 0xf3, + 0x82, 0x47, 0x7d, 0x1c, 0x28, 0x69, 0x14, 0xb8, 0x17, 0x49, 0x3a, 0x3b, + 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0xed, 0xa2, + 0xbf, 0x5b, 0xfc, 0xf3, 0x27, 0x79, 0x3b, 0xf4, 0x59, 0x76, 0x28, 0x20, + 0x2a, 0xf8, 0xdd, 0x82, 0x9a, 0xa0, 0x55, 0x57, 0x11, 0x9a, 0x1a, 0x41, + 0x18, 0x0d, 0xd0, 0x9f, 0x54, 0x9e, 0xf5, 0x20, 0x52, 0xa1, 0xc6, 0x1b, + 0xd6, 0xee, 0x06, 0xcc, 0x1e, 0x33, 0xa9, 0x2e, 0x1f, 0xc2, 0x76, 0x77, + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83, + 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xf5, + 0xa5, 0xca, 0xf9, 0x0e, 0x46, 0x31, 0x2f, 0xd1, 0x48, 0xac, 0x9b, 0xae, + 0xc5, 0x8b, 0x16, 0x6e, 0x95, 0xdb, 0x66, 0x72, 0x0c, 0xaa, 0x56, 0x37, + 0x55, 0x87, 0x56, 0x51, 0xe2, 0x11, 0x87, 0xb2, 0x69, 0xa2, 0x3b, 0x44, + 0xf9, 0x85, 0x9c, 0x70, 0xfd, 0xb2, 0xef, 0x7e, 0x56, 0xd9, 0x6c, 0xcb, + 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, + 0xe4, 0xe5}; + uint8_t output[230] = {0}; - // set up sample description - OEMCrypto_SampleDescription sample = {}; - OEMCrypto_SubSampleDescription subsamples[3]; - subsamples[0].num_bytes_clear = 10; - subsamples[0].num_bytes_encrypted = 50; - subsamples[0].subsample_flags = 1; - subsamples[0].block_offset = 0; - subsamples[1].num_bytes_clear = 10; - subsamples[1].num_bytes_encrypted = 75; - subsamples[1].subsample_flags = 0; - subsamples[1].block_offset = 0; - subsamples[2].num_bytes_clear = 10; - subsamples[2].num_bytes_encrypted = 75; - subsamples[2].subsample_flags = 2; - subsamples[2].block_offset = 0; - sample.subsamples_length = 3; - sample.subsamples = &subsamples[0]; - OEMCrypto_InputOutputPair* iop = &sample.buffers; - iop->input_data = encrypted.data(); - iop->input_data_length = encrypted.size(); - iop->output_descriptor.type = OEMCrypto_BufferType_Clear; - iop->output_descriptor.buffer.clear.clear_buffer = output; - iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); + // set up sample description + OEMCrypto_SampleDescription sample = {}; + OEMCrypto_SubSampleDescription subsamples[3]; + subsamples[0].num_bytes_clear = 10; + subsamples[0].num_bytes_encrypted = 50; + subsamples[0].subsample_flags = 1; + subsamples[0].block_offset = 0; + subsamples[1].num_bytes_clear = 10; + subsamples[1].num_bytes_encrypted = 75; + subsamples[1].subsample_flags = 0; + subsamples[1].block_offset = 0; + subsamples[2].num_bytes_clear = 10; + subsamples[2].num_bytes_encrypted = 75; + subsamples[2].subsample_flags = 2; + subsamples[2].block_offset = 0; + sample.subsamples_length = 3; + sample.subsamples = &subsamples[0]; + OEMCrypto_InputOutputPair* iop = &sample.buffers; + iop->input_data = encrypted.data(); + iop->input_data_length = encrypted.size(); + iop->output_descriptor.type = OEMCrypto_BufferType_Clear; + iop->output_descriptor.buffer.clear.clear_buffer = output; + iop->output_descriptor.buffer.clear.clear_buffer_length = clear.size(); - memcpy(sample.iv, iv.data(), iv.size()); + memcpy(sample.iv, iv.data(), iv.size()); - OEMCrypto_CENCEncryptPatternDesc pattern = {3, 7}; - OPK_OutputBuffer output_buffer = {}; - output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; - output_buffer.buffer.clear_insecure = output; - output_buffer.size = clear.size(); - size_t output_offset = 0; - OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CBCS; - WTPI_K1_SymmetricKey_Handle key_handle = NULL; - OEMCryptoResult result = OEMCrypto_SUCCESS; + OEMCrypto_CENCEncryptPatternDesc pattern = {3, 7}; + OPK_OutputBuffer output_buffer = {}; + output_buffer.type = OPK_CLEAR_INSECURE_OUTPUT_BUFFER; + output_buffer.buffer.clear_insecure = output; + output_buffer.size = clear.size(); + size_t output_offset = 0; + OEMCryptoCipherMode cipher_mode = OEMCrypto_CipherMode_CBCS; + WTPI_K1_SymmetricKey_Handle key_handle = NULL; + OEMCryptoResult result = OEMCrypto_SUCCESS; - // SetPattern not yet supported - GTEST_SKIP(); - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); - result = WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, - &key_handle); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + // SetPattern not yet supported + GTEST_SKIP(); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); + result = + WTPI_K1_CreateKeyHandle(key.data(), key.size(), CONTENT_KEY, &key_handle); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, - output_offset, cipher_mode); - ASSERT_EQ(OEMCrypto_SUCCESS, result); + result = WTPI_DecryptSample(key_handle, &sample, &pattern, &output_buffer, + output_offset, cipher_mode); + ASSERT_EQ(OEMCrypto_SUCCESS, result); - for (size_t i = 0; i < clear.size(); i++) { - ASSERT_EQ(clear[i], output[i]); - } + for (size_t i = 0; i < clear.size(); i++) { + ASSERT_EQ(clear[i], output[i]); + } test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); } - TEST(wtpi, storage_save_and_load) { - std::vector d1 = {'w', 't', 'p', 'i', 0xF}; - uint8_t* data_in = d1.data(); - size_t in_size = 3; - std::vector data_out(0); - size_t out_size = data_out.size(); + std::vector d1 = {'w', 't', 'p', 'i', 0xF}; + uint8_t* data_in = d1.data(); + size_t in_size = 3; + std::vector data_out(0); + size_t out_size = data_out.size(); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_Initialize()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_PrepareStoredPersistentData()); - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_Initialize()); - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_PrepareStoredPersistentData()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_StorePersistentData(data_in, in_size)); - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_StorePersistentData(data_in, in_size)); + ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, + WTPI_LoadPersistentData(data_out.data(), &out_size)); + data_out.resize(out_size); + ASSERT_EQ(in_size, out_size); + ASSERT_EQ(OEMCrypto_SUCCESS, + WTPI_LoadPersistentData(data_out.data(), &out_size)); + ASSERT_EQ(memcmp(data_out.data(), data_in, data_out.size()), 0); - ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, - WTPI_LoadPersistentData(data_out.data(), &out_size)); - data_out.resize(out_size); - ASSERT_EQ(in_size, out_size); - ASSERT_EQ(OEMCrypto_SUCCESS, - WTPI_LoadPersistentData(data_out.data(), &out_size)); - ASSERT_EQ(memcmp(data_out.data(), data_in, data_out.size()), 0); + // Do it again + data_out.clear(); + out_size = data_out.size(); + in_size = 5; + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_PrepareStoredPersistentData()); - // Do it again - data_out.clear(); - out_size = data_out.size(); - in_size = 5; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_PrepareStoredPersistentData()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_StorePersistentData(data_in, in_size)); - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_StorePersistentData(data_in, in_size)); - - ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, - WTPI_LoadPersistentData(data_out.data(), &out_size)); - data_out.resize(out_size); - ASSERT_EQ(in_size, out_size); - ASSERT_EQ(OEMCrypto_SUCCESS, - WTPI_LoadPersistentData(data_out.data(), &out_size)); - ASSERT_EQ(memcmp(data_out.data(), data_in, data_out.size()), 0); + ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, + WTPI_LoadPersistentData(data_out.data(), &out_size)); + data_out.resize(out_size); + ASSERT_EQ(in_size, out_size); + ASSERT_EQ(OEMCrypto_SUCCESS, + WTPI_LoadPersistentData(data_out.data(), &out_size)); + ASSERT_EQ(memcmp(data_out.data(), data_in, data_out.size()), 0); test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_Terminate()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_Terminate()); } TEST(wtpi, encrypt_and_sign) { - uint32_t context = 0x1234; - std::vector input(32, 0); - for (int i = 0; i < 32; i++) { - input[i] = i; - } - std::vector intermediate(1024, 0); - size_t intermediate_size = intermediate.size(); - std::vector output(32, 0); - size_t output_size = output.size(); + uint32_t context = 0x1234; + std::vector input(32, 0); + for (int i = 0; i < 32; i++) { + input[i] = i; + } + std::vector intermediate(1024, 0); + size_t intermediate_size = intermediate.size(); + std::vector output(32, 0); + size_t output_size = output.size(); - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); - ASSERT_EQ(OEMCrypto_SUCCESS, - WTPI_EncryptAndSign(context, input.data(), input.size(), - intermediate.data(), &intermediate_size)); - ASSERT_EQ(OEMCrypto_SUCCESS, - WTPI_VerifyAndDecrypt(context, intermediate.data(), - intermediate_size, output.data(), - &output_size)); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_InitializeKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, + WTPI_EncryptAndSign(context, input.data(), input.size(), + intermediate.data(), &intermediate_size)); + ASSERT_EQ( + OEMCrypto_SUCCESS, + WTPI_VerifyAndDecrypt(context, intermediate.data(), intermediate_size, + output.data(), &output_size)); - for (size_t i = 0; i < input.size(); i++) { - ASSERT_EQ(input[i], output[i]); - } + for (size_t i = 0; i < input.size(); i++) { + ASSERT_EQ(input[i], output[i]); + } test_abort:; - ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); + ASSERT_EQ(OEMCrypto_SUCCESS, WTPI_K1_TerminateKeyManagement()); } - PORT_TEST(wtpi_tests, "com.android.trusty.widevine.test") diff --git a/oemcrypto/opk/ports/trusty/ta/zuma/rules.mk b/oemcrypto/opk/ports/trusty/ta/zuma/rules.mk deleted file mode 100644 index f47b20a..0000000 --- a/oemcrypto/opk/ports/trusty/ta/zuma/rules.mk +++ /dev/null @@ -1,22 +0,0 @@ - -# Copyright (C) 2020 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# Same as GS201 build -# TODO: refactor build files to add hdcp -WIDEVINE_SOC_MODEL_NAME ?= ZUMA - -THIS_DIR := $(GET_LOCAL_DIR) -include $(THIS_DIR)/../gs201/rules.mk diff --git a/oemcrypto/opk/ports/trusty/ta/zuma/wtpi_hdcp.c b/oemcrypto/opk/ports/trusty/ta/zuma/wtpi_hdcp.c deleted file mode 100644 index 990d779..0000000 --- a/oemcrypto/opk/ports/trusty/ta/zuma/wtpi_hdcp.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "wtpi_hdcp_interface.h" - -#define TLOG_TAG "widevine" - -hwhdcp_session_t hwhdcp_session = INVALID_IPC_HANDLE; - -int system_specific_get_max_hdcp_level(OEMCrypto_HDCP_Capability* max_level) { - if (hwhdcp_session == INVALID_IPC_HANDLE) { - int rc = hwhdcp_open(&hwhdcp_session); - if (rc) { - TLOGE("Open hwhdcp session failed. (%d)\n", rc); - return rc; - } - } - - *max_level = hwhdcp_get_max_cap(hwhdcp_session); - return 0; -} - -int system_specific_get_current_hdcp_level( - OEMCrypto_HDCP_Capability* cur_level) { - if (hwhdcp_session == INVALID_IPC_HANDLE) { - int rc = hwhdcp_open(&hwhdcp_session); - if (rc) { - TLOGE("Open hwhdcp session failed. (%d)\n", rc); - return rc; - } - } - - *cur_level = hwhdcp_get_current_cap(hwhdcp_session); - return 0; -} - -int system_specific_set_hdcp_level(OEMCrypto_HDCP_Capability request_level) { - if (hwhdcp_session == INVALID_IPC_HANDLE) { - int rc = hwhdcp_open(&hwhdcp_session); - if (rc) { - TLOGE("Open hwhdcp session failed. (%d)\n", rc); - return rc; - } - } - - return hwhdcp_set_cp_level(hwhdcp_session, request_level); -} - -OEMCryptoResult WTPI_SetHDCPLevel(OEMCrypto_HDCP_Capability level) { - if (0 != system_specific_set_hdcp_level(level)) { - return OEMCrypto_ERROR_UNKNOWN_FAILURE; - } - - return OEMCrypto_SUCCESS; -} - -OEMCrypto_HDCP_Capability WTPI_CurrentHDCPCapability(void) { - OEMCrypto_HDCP_Capability current_level; - return system_specific_get_current_hdcp_level(¤t_level) - ? HDCP_NO_DIGITAL_OUTPUT - : current_level; -} - -OEMCrypto_HDCP_Capability WTPI_MaxHDCPCapability(void) { - OEMCrypto_HDCP_Capability max_level; - return system_specific_get_max_hdcp_level(&max_level) - ? HDCP_NO_DIGITAL_OUTPUT - : max_level; -} diff --git a/oemcrypto/opk/serialization/defaults.gypi b/oemcrypto/opk/serialization/defaults.gypi new file mode 100644 index 0000000..f3667ee --- /dev/null +++ b/oemcrypto/opk/serialization/defaults.gypi @@ -0,0 +1,44 @@ +# Common settings for OPK serialization +{ + 'variables': { + 'oemcrypto_dir' : '<(DEPTH)/oemcrypto', + 'odk_dir' : '<(oemcrypto_dir)/odk', + 'oemcrypto_ta_dir' : '<(oemcrypto_dir)/opk/oemcrypto_ta', + 'serialization_dir' : '<(oemcrypto_dir)/opk/serialization', + 'common_dir' : '<(serialization_dir)/common', + 'generator_dir' : '<(serialization_dir)/generator', + 'os_interfaces_dir' : '<(serialization_dir)/os_interfaces', + 'ree_dir' : '<(serialization_dir)/ree', + 'tee_dir' : '<(serialization_dir)/tee', + 'third_party_dir' : '<(DEPTH)/third_party', + 'json_dir' : '<(third_party_dir)/nlohmann-json', + 'jsmn_dir' : '<(third_party_dir)/jsmn', + 'enable_message_debug' : '(ODK_MAJOR_VERSION)); RecordWvProperty("test_major_version", std::to_string(ODK_MAJOR_VERSION)); RecordWvProperty("test_minor_version", std::to_string(ODK_MINOR_VERSION)); diff --git a/oemcrypto/test/oemcrypto_provisioning_test.cpp b/oemcrypto/test/oemcrypto_provisioning_test.cpp index a34a534..646acdc 100644 --- a/oemcrypto/test/oemcrypto_provisioning_test.cpp +++ b/oemcrypto/test/oemcrypto_provisioning_test.cpp @@ -252,7 +252,13 @@ TEST_F(OEMCryptoProv40Test, GetBootCertificateChainSuccess) { OEMCrypto_SUCCESS); util::BccValidator validator; EXPECT_EQ(util::CborMessageStatus::kCborParseOk, validator.Parse(bcc)); - EXPECT_EQ(util::CborMessageStatus::kCborValidateOk, validator.Validate()); + util::CborMessageStatus status = validator.Validate(); + EXPECT_LT(status, util::CborMessageStatus::kCborValidateError); + if (status >= util::CborMessageStatus::kCborValidateError) { + const std::string parsed_bcc = validator.GetFormattedMessage(); + LOGE("%s", parsed_bcc.c_str()); + LOGE("Validation results\n%s", validator.PrintValidateMessage().c_str()); + } } // Verifies BCC signature and its type if they are available. diff --git a/oemcrypto/util/include/cbor_validator.h b/oemcrypto/util/include/cbor_validator.h index ddc9dce..cb9bfb5 100644 --- a/oemcrypto/util/include/cbor_validator.h +++ b/oemcrypto/util/include/cbor_validator.h @@ -52,6 +52,7 @@ class CborValidator { GetValidateMessages() const { return validate_messages_; } + std::string PrintValidateMessage() const; // Prints |parse_result_| in readable format. Requires that Parse() is called // first and |parse_result_| contains a valid CBOR message. virtual std::string GetFormattedMessage() const; diff --git a/oemcrypto/util/include/prov4_validation_helper.h b/oemcrypto/util/include/prov4_validation_helper.h index 0667f90..2a1787e 100644 --- a/oemcrypto/util/include/prov4_validation_helper.h +++ b/oemcrypto/util/include/prov4_validation_helper.h @@ -24,16 +24,20 @@ std::string StatusToString(FieldStatus status); void ApplyStatus(CborMessageStatus& status, CborMessageStatus new_status); // Validates that the given field name is present, and prints error messages -// if not. +// if not. It is acceptable that some field, although specified as required by +// DICE specification, is not present in practice. This function will return +// kCborValidateWarning instead of the default kCborValidateError in those +// cases. template CborMessageStatus ValidateRequiredField( const std::string& name, const std::string& component, const std::pair& p, - std::vector>& msgs) { + std::vector>& msgs, + CborMessageStatus error = kCborValidateError) { if (p.first != kPresent) { - msgs.push_back(std::make_pair( - kCborValidateError, component + ": missing required field " + name)); - return kCborValidateError; + msgs.push_back( + std::make_pair(error, component + ": missing required field " + name)); + return error; } return kCborValidateOk; } diff --git a/oemcrypto/util/src/bcc_validator.cpp b/oemcrypto/util/src/bcc_validator.cpp index 74a538a..3b6b5f1 100644 --- a/oemcrypto/util/src/bcc_validator.cpp +++ b/oemcrypto/util/src/bcc_validator.cpp @@ -245,8 +245,8 @@ CborMessageStatus ConfigurationDescriptor::Validate( bool* is_widevine_entry) const { CborMessageStatus status = kCborParseOk; const std::string component = "ConfigurationDescriptor"; - CborMessageStatus cur_status = - ValidateRequiredField("component_name", component, component_name, msgs); + CborMessageStatus cur_status = ValidateRequiredField( + "component_name", component, component_name, msgs, kCborValidateWarning); ApplyStatus(status, cur_status); if (cur_status == kCborValidateOk) { std::string name = component_name.second; @@ -299,14 +299,14 @@ CborMessageStatus BccEntryPayload::Validate( if (!is_degenerated) { cur_status = ValidateRequiredField("code_hash", component, code_hash, msgs); ApplyStatus(status, cur_status); - cur_status = - ValidateRequiredField("config_hash", component, config_hash, msgs); + cur_status = ValidateRequiredField("config_hash", component, config_hash, + msgs, kCborValidateWarning); ApplyStatus(status, cur_status); if (config_descriptor.first == kAbsent) { msgs.push_back(std::make_pair( - kCborValidateError, + kCborValidateWarning, component + ": missing required field config_descriptor")); - ApplyStatus(status, kCborValidateError); + ApplyStatus(status, kCborValidateWarning); } else { cur_status = config_descriptor.second.Validate(msgs, is_widevine_entry); ApplyStatus(status, cur_status); @@ -393,9 +393,11 @@ CborMessageStatus Bcc::Validate( if (is_widevine_entry) found_widevine_entry = true; } if (!is_degenerated && !found_widevine_entry) { - msgs.push_back(std::make_pair(kCborValidateError, - component + ": Widevine cert not found.")); - ApplyStatus(status, kCborValidateError); + msgs.push_back( + std::make_pair(kCborValidateWarning, + component + ": Widevine cert not found. Expect a BCC " + "entry with component_name: widevine")); + ApplyStatus(status, kCborValidateWarning); } return status; } @@ -538,39 +540,45 @@ CborMessageStatus BccValidator::Validate() { for (size_t i = 1; i < bcc_array->size(); ++i) { const cppbor::Array* bcc_entry = (*bcc_array)[i]->asArray(); if (bcc_entry == nullptr) { - AddValidationMessage(kCborValidateError, - "BCC entry is empty at index " + std::to_string(i)); + AddValidationMessage(kCborValidateWarning, + "BCC entry is empty at index " + std::to_string(i) + + ". Skip current item."); continue; } if (bcc_entry->size() != 4) { - AddValidationMessage(kCborValidateError, + AddValidationMessage(kCborValidateWarning, "BCC entry index " + std::to_string(i) + " should contain 4 items. Actual: " + - std::to_string(bcc_entry->size())); + std::to_string(bcc_entry->size()) + + ". Skip current item."); continue; } if ((*bcc_entry)[0]->type() != cppbor::BSTR) { - AddValidationMessage(kCborValidateError, - "BCC entry index " + std::to_string(i) + - " protected field is not a CBOR bstr."); + AddValidationMessage( + kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " protected field is not a CBOR bstr. Skip current item."); continue; } if ((*bcc_entry)[1]->type() != cppbor::MAP) { - AddValidationMessage(kCborValidateError, - "BCC entry index " + std::to_string(i) + - " unprotected field is not a CBOR map."); + AddValidationMessage( + kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " unprotected field is not a CBOR map. Skip current item."); continue; } if ((*bcc_entry)[2]->type() != cppbor::BSTR) { - AddValidationMessage(kCborValidateError, - "BCC entry index " + std::to_string(i) + - " payload field is not a CBOR bstr."); + AddValidationMessage( + kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " payload field is not a CBOR bstr. Skip current item."); continue; } if ((*bcc_entry)[3]->type() != cppbor::BSTR) { - AddValidationMessage(kCborValidateError, - "BCC entry index " + std::to_string(i) + - " signature field is not a CBOR bstr."); + AddValidationMessage( + kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " signature field is not a CBOR bstr. Skip current item."); continue; } @@ -578,9 +586,9 @@ CborMessageStatus BccValidator::Validate() { const std::vector& encoded_protected_data = (*bcc_entry)[0]->asBstr()->value(); if (encoded_protected_data.empty()) { - AddValidationMessage( - kCborValidateError, - "BCC entry index " + std::to_string(i) + " empty protected data."); + AddValidationMessage(kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " empty protected data. Skip current item."); continue; } auto parse_result = cppbor::parse(encoded_protected_data); @@ -588,23 +596,25 @@ CborMessageStatus BccValidator::Validate() { std::move(std::get<0>(parse_result)); std::string error_message = std::move(std::get<2>(parse_result)); if (sub_item == nullptr || !error_message.empty()) { - AddValidationMessage(kCborValidateError, + AddValidationMessage(kCborValidateWarning, "BCC entry index " + std::to_string(i) + - " unable to parse protected: " + error_message); + " unable to parse protected: " + error_message + + " Skip current item."); continue; } if (sub_item->type() != cppbor::MAP) { - AddValidationMessage(kCborValidateError, + AddValidationMessage(kCborValidateWarning, "BCC entry index " + std::to_string(i) + " unexpected protected type: " + - CppborMajorTypeToString(sub_item->type())); + CppborMajorTypeToString(sub_item->type()) + + ". Skip current item."); continue; } const cppbor::Map* protected_map = sub_item->asMap(); if (protected_map == nullptr) { - AddValidationMessage( - kCborValidateError, - "BCC entry index " + std::to_string(i) + " protected map is null."); + AddValidationMessage(kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " protected map is null. Skip current item."); continue; } BccEntry entry; @@ -614,9 +624,7 @@ CborMessageStatus BccValidator::Validate() { status = ProcessBccEntryProtected(protected_map, &entry.protected_data.second); if (status == kCborValidateFatal) return status; - if (status != kCborValidateError) { - entry.protected_data.first = kPresent; - } + entry.protected_data.first = kPresent; } // Unprotected data in BCC entry is always empty, which is ignored. entry.unprotected.first = kEmpty; @@ -645,9 +653,9 @@ CborMessageStatus BccValidator::Validate() { // Parse and verify the payload if (encoded_payload.empty()) { - AddValidationMessage( - kCborValidateError, - "BCC entry index " + std::to_string(i) + " empty payload."); + AddValidationMessage(kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " empty payload. Skip current item."); continue; } parse_result = cppbor::parse(encoded_payload); @@ -655,24 +663,26 @@ CborMessageStatus BccValidator::Validate() { std::move(std::get<0>(parse_result)); error_message = std::move(std::get<2>(parse_result)); if (sub_item_payload == nullptr || !error_message.empty()) { - AddValidationMessage(kCborValidateError, + AddValidationMessage(kCborValidateWarning, "BCC entry index " + std::to_string(i) + - " unable to parse payload: " + error_message); + " unable to parse payload: " + error_message + + " Skip current item."); continue; } if (sub_item_payload->type() != cppbor::MAP) { AddValidationMessage( - kCborValidateError, + kCborValidateWarning, "BCC entry index " + std::to_string(i) + " unexpected payload type: " + - CppborMajorTypeToString(sub_item_payload->type())); + CppborMajorTypeToString(sub_item_payload->type()) + + ". Skip current item."); continue; } const cppbor::Map* payload_map = sub_item_payload->asMap(); if (payload_map == nullptr) { - AddValidationMessage( - kCborValidateError, - "BCC entry index " + std::to_string(i) + " payload is empty."); + AddValidationMessage(kCborValidateWarning, + "BCC entry index " + std::to_string(i) + + " payload is empty. Skip current item."); continue; } if (payload_map->size() == 0) { @@ -680,10 +690,8 @@ CborMessageStatus BccValidator::Validate() { } else { status = ProcessDiceChainEntryPayload(payload_map, &entry.payload.second); if (status == kCborValidateFatal) return status; - if (status != kCborValidateError) { - entry.payload.first = kPresent; - leaf_pub_key = entry.payload.second.subject_public_key.second; - } + entry.payload.first = kPresent; + leaf_pub_key = entry.payload.second.subject_public_key.second; } bcc.entries.push_back(std::move(entry)); } @@ -704,6 +712,7 @@ CborMessageStatus BccValidator::Validate() { CborMessageStatus BccValidator::ProcessConfigurationDescriptor( const cppbor::Map* config_descriptor_map, ConfigurationDescriptor* cd) { + CborMessageStatus status = kCborValidateOk; for (size_t index = 0; index < config_descriptor_map->size(); ++index) { std::pair&, const std::unique_ptr&> @@ -711,9 +720,11 @@ CborMessageStatus BccValidator::ProcessConfigurationDescriptor( if (entry.first->type() != cppbor::NINT && entry.first->type() != cppbor::UINT) { AddValidationMessage( - kCborValidateError, + kCborValidateWarning, "Invalid key type in configuration descriptor map: " + - CppborMajorTypeToString(entry.first->type())); + CppborMajorTypeToString(entry.first->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } const int64_t map_key = entry.first->asInt()->value(); @@ -721,10 +732,12 @@ CborMessageStatus BccValidator::ProcessConfigurationDescriptor( case kComponentNameLabel: { if (entry.second->type() != cppbor::TSTR) { AddValidationMessage( - kCborValidateError, + kCborValidateWarning, "Invalid value type in configuration descriptor map for " "key component name: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } cd->component_name.second = entry.second->asTstr()->value(); @@ -742,10 +755,12 @@ CborMessageStatus BccValidator::ProcessConfigurationDescriptor( cd->component_version.first = kPresent; } else { AddValidationMessage( - kCborValidateError, + kCborValidateWarning, "Invalid value type in configuration descriptor map for " "component version: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } } break; @@ -759,7 +774,9 @@ CborMessageStatus BccValidator::ProcessConfigurationDescriptor( kCborValidateError, "Invalid value type in configuration descriptor map for " "security version: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } else { cd->security_version.second = entry.second->asUint()->value(); @@ -772,11 +789,12 @@ CborMessageStatus BccValidator::ProcessConfigurationDescriptor( } } } - return message_status_; + return status; } CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( const cppbor::Map* public_key_map, BccPublicKeyInfo* public_key) { + CborMessageStatus status = kCborValidateOk; std::vector device_key_bytes_0; std::vector device_key_bytes_1; for (size_t index = 0; index < public_key_map->size(); ++index) { @@ -787,7 +805,9 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( entry.first->type() != cppbor::UINT) { AddValidationMessage(kCborValidateError, "Invalid key type in public key info map: " + - CppborMajorTypeToString(entry.first->type())); + CppborMajorTypeToString(entry.first->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); continue; } const int64_t map_key = entry.first->asInt()->value(); @@ -798,7 +818,9 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( kCborValidateError, "Invalid value type in public key info map for " "key MAP_KEY_DEVICE_KEY_TYPE: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); continue; } public_key->key_type.first = kPresent; @@ -812,7 +834,10 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( AddValidationMessage(kCborValidateError, "Invalid value in public key info map for key " "MAP_KEY_DEVICE_KEY_TYPE: " + - std::to_string(value)); + std::to_string(value) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); + continue; } } break; case MAP_KEY_DEVICE_KEY_ALGORITHM: { @@ -821,7 +846,9 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( kCborValidateError, "Invalid value type in public key info map for " "key MAP_KEY_DEVICE_KEY_ALGORITHM: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); continue; } public_key->signature_algorithm.first = kPresent; @@ -837,7 +864,10 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( AddValidationMessage(kCborValidateError, "Invalid value in public key info map for key " "MAP_KEY_DEVICE_KEY_ALGORITHM: " + - std::to_string(value)); + std::to_string(value) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); + continue; } } break; case MAP_KEY_DEVICE_KEY_OPS: @@ -849,7 +879,9 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( kCborValidateError, "Invalid value type in public key info map for " "key MAP_KEY_DEVICE_KEY_CURVE: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); continue; } public_key->curve.first = kPresent; @@ -865,7 +897,10 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( AddValidationMessage(kCborValidateError, "Invalid value in public key info map for key " "MAP_KEY_DEVICE_KEY_CURVE: " + - std::to_string(value)); + std::to_string(value) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); + continue; } } break; case MAP_KEY_DEVICE_KEY_BYTES_0: @@ -877,7 +912,9 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( kCborValidateError, "Invalid value type in public key info map for " "key MAP_KEY_DEVICE_KEY_BYTES_0/1: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); continue; } const std::vector& key_bytes = entry.second->asBstr()->value(); @@ -887,7 +924,9 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( key_bytes.size() != kP384KeyComponentSize) { AddValidationMessage(kCborValidateError, "Malformed public key data size of: " + - std::to_string(key_bytes.size())); + std::to_string(key_bytes.size()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateError); continue; } public_key->key_bytes.first = kPresent; @@ -904,7 +943,8 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( AddValidationMessage( kCborValidateError, "Malformed public key definition. Missing device public key bytes."); - return message_status_; + ApplyStatus(status, kCborValidateError); + return status; } std::vector device_key_bytes; if (public_key->key_type.second == DEVICE_KEY_OCTET_PAIR) { @@ -921,7 +961,8 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( AddValidationMessage(kCborValidateError, "Invalid ECDSA public key size: " + std::to_string(device_key_bytes.size())); - return message_status_; + ApplyStatus(status, kCborValidateError); + return status; } } else { device_key_bytes = std::move(device_key_bytes_0); @@ -930,11 +971,12 @@ CborMessageStatus BccValidator::ProcessSubjectPublicKeyInfo( if (public_key->key_bytes.second.empty()) { public_key->key_bytes.first = kEmpty; } - return message_status_; + return status; } CborMessageStatus BccValidator::ProcessBccEntryProtected( const cppbor::Map* protected_map, BccEntryProtected* protected_data) { + CborMessageStatus status = kCborValidateOk; for (size_t index = 0; index < protected_map->size(); ++index) { std::pair&, const std::unique_ptr&> @@ -942,9 +984,11 @@ CborMessageStatus BccValidator::ProcessBccEntryProtected( if (entry.first->type() != cppbor::NINT && entry.first->type() != cppbor::UINT) { AddValidationMessage( - kCborValidateError, + kCborValidateWarning, "Invalid key type in protected data map in bcc entry: " + - CppborMajorTypeToString(entry.first->type())); + CppborMajorTypeToString(entry.first->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } const int64_t map_key = entry.first->asInt()->value(); @@ -953,10 +997,12 @@ CborMessageStatus BccValidator::ProcessBccEntryProtected( if (entry.second->type() != cppbor::NINT && entry.second->type() != cppbor::UINT) { AddValidationMessage( - kCborValidateError, + kCborValidateWarning, "Invalid value type in protected data map for " "key 1: " + - CppborMajorTypeToString(entry.second->type())); + CppborMajorTypeToString(entry.second->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } protected_data->algorithm.first = kPresent; @@ -964,11 +1010,12 @@ CborMessageStatus BccValidator::ProcessBccEntryProtected( } break; } } - return message_status_; + return status; } CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( const cppbor::Map* payload_map, BccEntryPayload* payload) { + CborMessageStatus status = kCborValidateOk; for (size_t i = 0; i < payload_map->size(); ++i) { const auto& entry = (*payload_map)[i]; if (entry.first == nullptr || entry.first->asInt() == nullptr || @@ -991,7 +1038,9 @@ CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( } else if (key == kSubjectPublicKeyLabel) { const auto& value = entry.second->asBstr()->value(); if (value.empty()) { - AddValidationMessage(kCborValidateError, "Empty public key."); + AddValidationMessage(kCborValidateWarning, + "Empty public key. Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } auto parse_result = cppbor::parse(value); @@ -999,14 +1048,18 @@ CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( std::move(std::get<0>(parse_result)); std::string error_message = std::move(std::get<2>(parse_result)); if (sub_item == nullptr || !error_message.empty()) { - AddValidationMessage(kCborValidateError, - "Unable to parse public key: " + error_message); + AddValidationMessage(kCborValidateWarning, + "Unable to parse public key: " + error_message + + " Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } if (sub_item->type() != cppbor::MAP || sub_item->asMap() == nullptr) { - AddValidationMessage(kCborValidateError, + AddValidationMessage(kCborValidateWarning, "Unexpected public key type: " + - CppborMajorTypeToString(sub_item->type())); + CppborMajorTypeToString(sub_item->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } const cppbor::Map* public_key_map = sub_item->asMap(); @@ -1014,9 +1067,10 @@ CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( payload->subject_public_key.first = kEmpty; } else { payload->subject_public_key.first = kPresent; - CborMessageStatus status = ProcessSubjectPublicKeyInfo( + CborMessageStatus cur_status = ProcessSubjectPublicKeyInfo( public_key_map, &(payload->subject_public_key.second)); - if (status == kCborValidateFatal) return status; + if (cur_status == kCborValidateFatal) return cur_status; + ApplyStatus(status, cur_status); } } else if (key == kKeyUsageLabel) { payload->key_usage.second = entry.second->asBstr()->value(); @@ -1037,8 +1091,10 @@ CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( } else if (key == kConfigurationDescriptorLabel) { const auto& encoded_cd = entry.second->asBstr()->value(); if (encoded_cd.empty()) { - AddValidationMessage(kCborValidateError, - "Empty configuration descriptor."); + AddValidationMessage( + kCborValidateWarning, + "Empty configuration descriptor. Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } auto parse_result = cppbor::parse(encoded_cd); @@ -1046,15 +1102,18 @@ CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( std::move(std::get<0>(parse_result)); std::string error_message = std::move(std::get<2>(parse_result)); if (sub_item == nullptr || !error_message.empty()) { - AddValidationMessage( - kCborValidateError, - "Unable to parse configuration descriptor: " + error_message); + AddValidationMessage(kCborValidateWarning, + "Unable to parse configuration descriptor: " + + error_message + " Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } if (sub_item->type() != cppbor::MAP) { - AddValidationMessage(kCborValidateError, + AddValidationMessage(kCborValidateWarning, "Unexpected configuration descriptor type: " + - CppborMajorTypeToString(sub_item->type())); + CppborMajorTypeToString(sub_item->type()) + + ". Skip current item."); + ApplyStatus(status, kCborValidateWarning); continue; } const cppbor::Map* config_descriptor_map = sub_item->asMap(); @@ -1063,12 +1122,11 @@ CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( // OK, configuration descriptor is optional. payload->config_descriptor.first = kEmpty; } else { - CborMessageStatus status = ProcessConfigurationDescriptor( + CborMessageStatus cur_status = ProcessConfigurationDescriptor( config_descriptor_map, &(payload->config_descriptor.second)); - if (status == kCborValidateFatal) return status; - if (status != kCborValidateError) { - payload->config_descriptor.first = kPresent; - } + if (cur_status == kCborValidateFatal) return cur_status; + ApplyStatus(status, cur_status); + payload->config_descriptor.first = kPresent; } } else if (key == kAuthorityHashLabel) { payload->authority_hash.second = entry.second->asBstr()->value(); @@ -1083,7 +1141,7 @@ CborMessageStatus BccValidator::ProcessDiceChainEntryPayload( payload->mode.first = payload->mode.second.empty() ? kEmpty : kPresent; } } - return message_status_; + return status; } std::string BccValidator::GetFormattedMessage() const { diff --git a/oemcrypto/util/src/cbor_validator.cpp b/oemcrypto/util/src/cbor_validator.cpp index aff3939..9c14815 100644 --- a/oemcrypto/util/src/cbor_validator.cpp +++ b/oemcrypto/util/src/cbor_validator.cpp @@ -98,6 +98,14 @@ std::string CborValidator::GetFormattedMessage() const { return GetRawMessage(); } +std::string CborValidator::PrintValidateMessage() const { + std::stringstream ss; + for (auto& msg : validate_messages_) { + ss << CborMessageStatusToString(msg.first) << ": " << msg.second << "\n"; + } + return ss.str(); +} + void CborValidator::AddValidationMessage(CborMessageStatus status, const std::string& msg) { validate_messages_.push_back({status, msg}); diff --git a/oemcrypto/util/test/bcc_validator_unittest.cpp b/oemcrypto/util/test/bcc_validator_unittest.cpp index d05e1d6..84769a6 100644 --- a/oemcrypto/util/test/bcc_validator_unittest.cpp +++ b/oemcrypto/util/test/bcc_validator_unittest.cpp @@ -234,9 +234,7 @@ const std::vector kBccMissingIssuer = { static void DumpValidatorOutput(const BccValidator& validator) { const std::string out = validator.GetFormattedMessage(); LOGI("%s", out.c_str()); - for (auto& msg : validator.GetValidateMessages()) { - LOGE("Error code %d: %s", msg.first, msg.second.c_str()); - } + LOGE("Validation results\n%s", validator.PrintValidateMessage().c_str()); } TEST(OEMCryptoBccValidatorTest, BccParseError) { diff --git a/oemcrypto/util/test/device_info_validator_unittest.cpp b/oemcrypto/util/test/device_info_validator_unittest.cpp index 9454d97..759a71a 100644 --- a/oemcrypto/util/test/device_info_validator_unittest.cpp +++ b/oemcrypto/util/test/device_info_validator_unittest.cpp @@ -65,9 +65,7 @@ std::vector BuildDeviceInfo(int version) { static void DumpValidatorOutput(const DeviceInfoValidator& validator) { const std::string out = validator.GetFormattedMessage(); LOGI("%s", out.c_str()); - for (auto& msg : validator.GetValidateMessages()) { - LOGE("Error code %d: %s", msg.first, msg.second.c_str()); - } + LOGE("Validation results\n%s", validator.PrintValidateMessage().c_str()); } TEST(OEMCryptoDeviceInfoValidatorTest, DeviceInfoParseError) { diff --git a/oemcrypto/util/test/signed_csr_payload_validator_unittest.cpp b/oemcrypto/util/test/signed_csr_payload_validator_unittest.cpp index 2eccb70..6730b33 100644 --- a/oemcrypto/util/test/signed_csr_payload_validator_unittest.cpp +++ b/oemcrypto/util/test/signed_csr_payload_validator_unittest.cpp @@ -91,9 +91,7 @@ std::vector GetDefaultSignedCsrPayload() { static void DumpValidatorOutput(const SignedCsrPayloadValidator& validator) { const std::string out = validator.GetFormattedMessage(); LOGI("%s", out.c_str()); - for (auto& msg : validator.GetValidateMessages()) { - LOGE("Error code %d: %s", msg.first, msg.second.c_str()); - } + LOGE("Validation results\n%s", validator.PrintValidateMessage().c_str()); } } // namespace diff --git a/util/test/file_store_unittest.cpp b/util/test/file_store_unittest.cpp index ad30ac2..aaa8612 100644 --- a/util/test/file_store_unittest.cpp +++ b/util/test/file_store_unittest.cpp @@ -265,10 +265,17 @@ TEST_F(FileTest, ListFiles) { } TEST_F(FileTest, ListFiles_NotAPath) { - const std::string not_path("zzz/xxx"); + const std::string kTestFilename = "zzz.txt"; + const std::string dir_path = wvcdm::test_vectors::kTestDir; + const std::string file_path = PathJoin(dir_path, kTestFilename); + std::unique_ptr file = + file_system_.Open(file_path, FileSystem::kCreate); + ASSERT_TRUE(file) << "Failed to create file: " << kTestFilename; + file.reset(); // Close file + std::vector names; // Ask for non-existent path. - EXPECT_FALSE(file_system_.List(not_path, &names)); + EXPECT_FALSE(file_system_.List(file_path, &names)); } TEST_F(FileTest, ListFiles_NullParameter) {