From 92146d246809935cc0195ba2b7987e6f61e0444f Mon Sep 17 00:00:00 2001 From: Cong Lin Date: Wed, 2 Apr 2025 09:52:51 -0700 Subject: [PATCH] OEMCrypto and OPK 18.9 --- CHANGELOG.md | 22 ++++++ oemcrypto/include/OEMCryptoCENC.h | 70 ++++++++++++++++- oemcrypto/include/level3.h | 10 +++ oemcrypto/odk/include/core_message_features.h | 4 +- oemcrypto/odk/include/odk_structs.h | 4 +- oemcrypto/odk/src/core_message_features.cpp | 2 +- oemcrypto/odk/src/odk_timer.c | 2 +- oemcrypto/odk/test/odk_test.cpp | 4 +- oemcrypto/opk/oemcrypto_ta/oemcrypto.c | 14 ++++ .../opk/oemcrypto_ta/oemcrypto_api_macros.h | 2 +- .../oemcrypto_ta/wtpi/wtpi_cas_interface.h | 78 ++++++++++++++++++- .../oemcrypto_ta/wtpi/wtpi_crc32_interface.h | 10 +-- .../oemcrypto_ta/wtpi_reference/wtpi_crc32.c | 8 +- .../ree/GEN_oemcrypto_tee_test_api.c | 4 +- .../wtpi_test/ree/GEN_ree_serializer.c | 18 +---- .../wtpi_test/ree/GEN_ree_serializer.h | 2 +- .../wtpi_test/tee/GEN_dispatcher.c | 38 +++++++-- .../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 ++++++ .../linux/cas/tee/tee_simulator_cas/Makefile | 11 ++- .../cas/tee/tee_simulator_cas/data_share.h | 2 +- .../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 +- oemcrypto/opk/serialization/defaults.gypi | 44 +++++++++++ .../opk/serialization/ree/GEN_oemcrypto_api.c | 69 ++++++++++++++++ .../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/test/GEN_api_lock_file.c | 9 +++ oemcrypto/test/common.mk | 1 + oemcrypto/test/oemcrypto_basic_test.cpp | 4 +- oemcrypto/test/oemcrypto_decrypt_test.cpp | 2 +- util/test/file_store_unittest.cpp | 11 ++- 41 files changed, 656 insertions(+), 124 deletions(-) create mode 100644 oemcrypto/opk/serialization/defaults.gypi diff --git a/CHANGELOG.md b/CHANGELOG.md index b52101a..8aff930 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,33 @@ [TOC] +## [Version 18.9][v18.9] + +This release adds new OEMCrypto APIs to support CAS PVR. It also includes test +fixes and OPK build updates. + +### API + +- Added new OEMCrypto API for CAS PVR: `OEMCrypto_GetPVRKey()` and + `OEMCrypto_LoadPVRKey()` + +### OPK + +- Fixed memory overflow in WTPI test serialization of + `WTPI_Crc32Cont_OutputBufferBasic()` +- Added new WTPI for CAS PVR: `WTPI_SetCasUsage()`, `WTPI_GetCasUsage()`, + `WTPI_InstallPVRContentKey()` and `WTPI_InstallPVRContentIV()` +- Renamed OPK serialization `settings.gypi` to `defaults.gypi` +- Fixed macro definitions in the CAS TEE linux simulator Makefile + ## [Version 18.8][v18.8] This is a minor release with minor test improvements. ### Tests +- Updated `DecryptZeroSizeSubSample` test to pass on non-crash returns. This + fix is backported from 19.2 release - Update some CAST tests to enforce format of the message signed by OEMCrypto_GenerateRSASignature() - Skip usage table tests on devices that don't support usage tables @@ -599,3 +620,4 @@ Public release for OEMCrypto API and ODK library version 16.4. [v18.6]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v18.6 [v18.7]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v18.7 [v18.8]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v18.8 +[v18.9]: https://widevine-partner.googlesource.com/oemcrypto/+/refs/tags/v18.9 diff --git a/oemcrypto/include/OEMCryptoCENC.h b/oemcrypto/include/OEMCryptoCENC.h index 7c27ae0..033e931 100644 --- a/oemcrypto/include/OEMCryptoCENC.h +++ b/oemcrypto/include/OEMCryptoCENC.h @@ -3,7 +3,7 @@ // License Agreement. /** - * @mainpage OEMCrypto API v18.8 + * @mainpage OEMCrypto API v18.9 * * 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 @@ -722,6 +722,8 @@ typedef enum OEMCrypto_SignatureHashAlgorithm { #define OEMCrypto_MarkOfflineSession _oecc153 #define OEMCrypto_WrapClearPrivateKey _oecc154 #define OEMCrypto_SetSessionUsage _oecc155 +#define OEMCrypto_GetPVRKey _oecc157 +#define OEMCrypto_LoadPVRKey _oecc158 // clang-format on /// @addtogroup initcontrol @@ -1969,6 +1971,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 diff --git a/oemcrypto/include/level3.h b/oemcrypto/include/level3.h index 3085523..22b1343 100644 --- a/oemcrypto/include/level3.h +++ b/oemcrypto/include/level3.h @@ -122,6 +122,8 @@ #define Level3_MarkOfflineSession _lcc144 // Added in OEMCrypto v19.3, but back ported to v18 #define Level3_SetSessionUsage _lcc155 +#define Level3_GetPVRKey _lcc157 +#define Level3_LoadPVRKey _lcc158 #else #define Level3_Initialize _oecc01 #define Level3_Terminate _oecc02 @@ -228,6 +230,8 @@ #define Level3_MarkOfflineSession _oecc145 // Added in OEMCrypto v19.3, but back ported to v18 #define Level3_SetSessionUsage _oecc155 +#define Level3_GetPVRKey _oecc157 +#define Level3_LoadPVRKey _oecc158 #endif #define Level3_GetInitializationState _oecl3o01 @@ -454,6 +458,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/include/core_message_features.h b/oemcrypto/odk/include/core_message_features.h index 4626507..0d91b15 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 18.8. + // number. The default is 18.9. uint32_t maximum_major_version = 18; - uint32_t maximum_minor_version = 8; + uint32_t maximum_minor_version = 9; 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 54d1886..35aa7ff 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 18 -#define ODK_MINOR_VERSION 8 +#define ODK_MINOR_VERSION 9 /* ODK Version string. Date changed automatically on each release. */ -#define ODK_RELEASE_DATE "ODK v18.8 2024-11-04" +#define ODK_RELEASE_DATE "ODK v18.9 2025-03-11" /* The lowest version number for an ODK message. */ #define ODK_FIRST_VERSION 16 diff --git a/oemcrypto/odk/src/core_message_features.cpp b/oemcrypto/odk/src/core_message_features.cpp index 7b726bd..6351a4a 100644 --- a/oemcrypto/odk/src/core_message_features.cpp +++ b/oemcrypto/odk/src/core_message_features.cpp @@ -30,7 +30,7 @@ CoreMessageFeatures CoreMessageFeatures::DefaultFeatures( features.maximum_minor_version = 2; // 17.2 break; case 18: - features.maximum_minor_version = 8; // 18.8 + features.maximum_minor_version = 9; // 18.9 break; default: features.maximum_minor_version = 0; diff --git a/oemcrypto/odk/src/odk_timer.c b/oemcrypto/odk/src/odk_timer.c index c3a9456..2a7241f 100644 --- a/oemcrypto/odk/src/odk_timer.c +++ b/oemcrypto/odk/src/odk_timer.c @@ -274,7 +274,7 @@ OEMCryptoResult ODK_InitializeSessionValues(ODK_TimerLimits* timer_limits, nonce_values->api_minor_version = 2; break; case 18: - nonce_values->api_minor_version = 8; + nonce_values->api_minor_version = 9; break; default: nonce_values->api_minor_version = 0; diff --git a/oemcrypto/odk/test/odk_test.cpp b/oemcrypto/odk/test/odk_test.cpp index def762d..733d902 100644 --- a/oemcrypto/odk/test/odk_test.cpp +++ b/oemcrypto/odk/test/odk_test.cpp @@ -1216,7 +1216,7 @@ std::vector TestCases() { // number. {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, 8}, + {18, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 18, 9}, // 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}, @@ -1231,6 +1231,7 @@ std::vector TestCases() { {ODK_MAJOR_VERSION, 18, 6, 18, 6}, {ODK_MAJOR_VERSION, 18, 7, 18, 7}, {ODK_MAJOR_VERSION, 18, 8, 18, 8}, + {ODK_MAJOR_VERSION, 18, 9, 18, 9}, {0, 16, 3, 16, 3}, {0, 16, 4, 16, 4}, {0, 16, 5, 16, 5}, @@ -1241,6 +1242,7 @@ std::vector TestCases() { {0, 18, 6, 18, 6}, {0, 18, 7, 18, 7}, {0, 18, 8, 18, 8}, + {0, 18, 9, 18, 9}, }; return test_cases; } diff --git a/oemcrypto/opk/oemcrypto_ta/oemcrypto.c b/oemcrypto/opk/oemcrypto_ta/oemcrypto.c index 3c00289..117877e 100644 --- a/oemcrypto/opk/oemcrypto_ta/oemcrypto.c +++ b/oemcrypto/opk/oemcrypto_ta/oemcrypto.c @@ -4327,6 +4327,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 1ee8255..c100648 100644 --- a/oemcrypto/opk/oemcrypto_ta/oemcrypto_api_macros.h +++ b/oemcrypto/opk/oemcrypto_ta/oemcrypto_api_macros.h @@ -34,7 +34,7 @@ // version bumps to v17.1, the first released OPK implementation would be // v17.1.0 #define API_MAJOR_VERSION 18 -#define API_MINOR_VERSION 8 +#define API_MINOR_VERSION 9 #define OPK_PATCH_VERSION 0 #endif /* OEMCRYPTO_TA_OEMCRYPTO_API_MACROS_H_ */ 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_reference/wtpi_crc32.c b/oemcrypto/opk/oemcrypto_ta/wtpi_reference/wtpi_crc32.c index 1f3d1d8..9c1ac24 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; } @@ -105,6 +105,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_test/ree/GEN_oemcrypto_tee_test_api.c b/oemcrypto/opk/oemcrypto_ta/wtpi_test/ree/GEN_oemcrypto_tee_test_api.c index 367d025..ee2ab38 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 @@ -1602,7 +1602,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); @@ -1611,7 +1611,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 39b0e41..d936c65 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 @@ -1693,7 +1693,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 = 10045; /* from _tee10045 */ @@ -1701,21 +1701,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 194670c..7271b92 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 @@ -267,7 +267,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/tee/GEN_dispatcher.c b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_dispatcher.c index 42618bb..588ec17 100644 --- a/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_dispatcher.c +++ b/oemcrypto/opk/oemcrypto_ta/wtpi_test/tee/GEN_dispatcher.c @@ -274,6 +274,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, uint8_t* input; OPK_InitPointer((uint8_t**)&input); uint8_t* signature = (uint8_t*)OPK_VarAlloc(sizeof(uint8_t)); + if (signature == NULL) goto handle_out_of_memory; OPK_Init_uint8_t((uint8_t*)signature); OPK_Unpack_C1_HMAC_SHA256_Verify_Request(request, &key_handle, &input, &input_length, &signature); @@ -294,6 +295,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, OPK_InitPointer((uint8_t**)&input); OPK_OutputBuffer* out = (OPK_OutputBuffer*)OPK_VarAlloc(sizeof(OPK_OutputBuffer)); + if (out == NULL) goto handle_out_of_memory; OPK_Init_OPK_OutputBuffer((OPK_OutputBuffer*)out); size_t output_offset; OPK_Init_size_t((size_t*)&output_offset); @@ -544,6 +546,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, case 10022: /* WTPI_K1_PrepareExternalKeyHandle */ { size_t* out_buffer_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (out_buffer_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(out_buffer_length); WTPI_K1_SymmetricKey_Handle key_handle; OPK_Init_WTPI_K1_SymmetricKey_Handle( @@ -677,6 +680,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t message_length; OPK_Init_size_t((size_t*)&message_length); size_t* signature_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (signature_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(signature_length); WTPI_AsymmetricKey_Handle key; OPK_Init_WTPI_AsymmetricKey_Handle((WTPI_AsymmetricKey_Handle*)&key); @@ -704,6 +708,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t input_length; OPK_Init_size_t((size_t*)&input_length); size_t* out_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (out_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(out_length); WTPI_AsymmetricKey_Handle key; OPK_Init_WTPI_AsymmetricKey_Handle((WTPI_AsymmetricKey_Handle*)&key); @@ -726,6 +731,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t message_length; OPK_Init_size_t((size_t*)&message_length); size_t* signature_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (signature_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(signature_length); WTPI_AsymmetricKey_Handle key; OPK_Init_WTPI_AsymmetricKey_Handle((WTPI_AsymmetricKey_Handle*)&key); @@ -750,6 +756,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t key_source_length; OPK_Init_size_t((size_t*)&key_source_length); size_t* session_key_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (session_key_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(session_key_length); WTPI_AsymmetricKey_Handle key; OPK_Init_WTPI_AsymmetricKey_Handle((WTPI_AsymmetricKey_Handle*)&key); @@ -807,6 +814,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, case 10034: /* WTPI_GetBootCertificateChain */ { size_t* out_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (out_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(out_length); uint8_t* out; OPK_InitPointer((uint8_t**)&out); @@ -838,8 +846,10 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, { size_t* wrapped_private_key_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (wrapped_private_key_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(wrapped_private_key_length); size_t* public_key_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (public_key_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(public_key_length); CertSignatureType cert_type; OPK_Init_CertSignatureType((CertSignatureType*)&cert_type); @@ -871,6 +881,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t encoded_device_info_length; OPK_Init_size_t((size_t*)&encoded_device_info_length); size_t* signed_csr_payload_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (signed_csr_payload_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(signed_csr_payload_length); uint8_t* challenge; OPK_InitPointer((uint8_t**)&challenge); @@ -908,6 +919,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, case 10039: /* WTPI_GetDeviceInformation */ { size_t* out_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (out_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(out_length); uint8_t* out; OPK_InitPointer((uint8_t**)&out); @@ -926,6 +938,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t message_length; OPK_Init_size_t((size_t*)&message_length); size_t* signature_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (signature_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(signature_length); uint8_t* message; OPK_InitPointer((uint8_t**)&message); @@ -1005,23 +1018,25 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, } case 10045: /* 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; @@ -1343,6 +1358,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t data_length; OPK_Init_size_t((size_t*)&data_length); size_t* out_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (out_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(out_length); uint32_t context; OPK_Init_uint32_t((uint32_t*)&context); @@ -1365,6 +1381,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, size_t wrapped_length; OPK_Init_size_t((size_t*)&wrapped_length); size_t* out_length = (size_t*)OPK_VarAlloc(sizeof(size_t)); + if (out_length == NULL) goto handle_out_of_memory; OPK_Init_size_t(out_length); uint32_t context; OPK_Init_uint32_t((uint32_t*)&context); @@ -1390,6 +1407,7 @@ ODK_MessageStatus OPK_DispatchMessage(ODK_Message* request, uint8_t* wrapped; OPK_InitPointer((uint8_t**)&wrapped); uint8_t* signature = (uint8_t*)OPK_VarAlloc(sizeof(uint8_t)); + if (signature == NULL) goto handle_out_of_memory; OPK_Init_uint8_t((uint8_t*)signature); uint8_t* iv; OPK_InitPointer((uint8_t**)&iv); @@ -1416,4 +1434,10 @@ handle_invalid_request: LOGE("invalid request"); *response = CreateEmptyMessage(); return MESSAGE_STATUS_OK; + +handle_out_of_memory: + LOGE("out of memory"); + ODK_Message_SetStatus(request, MESSAGE_STATUS_OUT_OF_MEMORY); + *response = CreateEmptyMessage(); + return MESSAGE_STATUS_OK; } 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 2444eec..46bd36a 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 @@ -1312,42 +1312,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 != 10045) 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 a1e7e93..12830e3 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 @@ -247,7 +247,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/Makefile b/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/Makefile index 1931349..af2bb09 100644 --- a/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/Makefile +++ b/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/Makefile @@ -55,7 +55,16 @@ cflags += \ -DWTPI_BUILD_INFO=\"$(WTPI_BUILD_INFO)\" \ -DSUPPORT_CAS \ -DWV_POSIX_RESOURCE_ID=\"$(project)\" \ - -D_DEFAULT_SOURCE + -DOPK_CONFIG_SOC_VENDOR_NAME=$(SOC_VENDOR) \ + -DOPK_CONFIG_SOC_MODEL_NAME=$(SOC_MODEL) \ + -DOPK_CONFIG_TEE_OS_NAME=$(TEE_OS) \ + -DOPK_CONFIG_TEE_OS_VERSION=$(TEE_VERSION) \ + -DOPK_CONFIG_DEVICE_FORM_FACTOR=$(DEVICE_FORM_FACTOR) \ + -DOPK_CONFIG_IMPLEMENTER_NAME=$(IMPLEMENTER) \ + -DOPK_CONFIG_PROVISIONING_METHOD=$(PROVISIONING_METHOD) \ + -D_DEFAULT_SOURCE \ + -fstack-protector-strong \ + -D_DEBUG ldflags = \ -lrt -lpthread \ diff --git a/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/data_share.h b/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/data_share.h index 8b623e0..095930a 100644 --- a/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/data_share.h +++ b/oemcrypto/opk/ports/linux/cas/tee/tee_simulator_cas/data_share.h @@ -9,7 +9,7 @@ #include #include #include "OEMCryptoCENC.h" -#include "wtpi_config_macros.h" +#include "opk_config.h" #include "wtpi_crypto_and_key_management_interface_layer1.h" #ifdef __cplusplus 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/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_decrypt_test.cpp b/oemcrypto/test/oemcrypto_decrypt_test.cpp index 78d26bb..e95b009 100644 --- a/oemcrypto/test/oemcrypto_decrypt_test.cpp +++ b/oemcrypto/test/oemcrypto_decrypt_test.cpp @@ -518,7 +518,7 @@ TEST_P(OEMCryptoSessionTestsDecryptTests, DecryptZeroSizeSubSample) { ASSERT_NO_FATAL_FAILURE(LoadLicense()); ASSERT_NO_FATAL_FAILURE(MakeBuffers()); ASSERT_NO_FATAL_FAILURE(EncryptData()); - ASSERT_NO_FATAL_FAILURE(TestDecryptCENC()); + ASSERT_NO_FATAL_FAILURE(DecryptCENC()); } // There are probably no frames this small, but we should handle them anyway. 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) {