diff --git a/oemcrypto/odk/Android.bp b/oemcrypto/odk/Android.bp index 544c838..90c4a6d 100644 --- a/oemcrypto/odk/Android.bp +++ b/oemcrypto/odk/Android.bp @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -25,6 +25,11 @@ cc_library_static { "vendor/widevine/libwvdrmengine/oemcrypto/odk/include", "vendor/widevine/libwvdrmengine/oemcrypto/odk/src", ], + header_libs: [ + "jni_headers", + "libbase_headers", + "liblog_headers", + ], srcs: [ "src/odk.c", @@ -38,7 +43,7 @@ cc_library_static { proprietary: true, owner: "widevine", - min_sdk_version: "UpsideDownCake", + min_sdk_version: "34", } // ---------------------------------------------------------------- @@ -51,6 +56,11 @@ cc_library_static { "vendor/widevine/libwvdrmengine/oemcrypto/odk/include", "vendor/widevine/libwvdrmengine/oemcrypto/odk/src", ], + header_libs: [ + "jni_headers", + "libbase_headers", + "liblog_headers", + ], srcs: [ "src/core_message_deserialize.cpp", @@ -100,6 +110,9 @@ cc_test { ], srcs: [ + "test/odk_golden_v16.cpp", + "test/odk_golden_v17.cpp", + "test/odk_golden_v18.cpp", "test/odk_test.cpp", "test/odk_test_helper.cpp", "test/odk_timer_test.cpp", diff --git a/oemcrypto/odk/include/OEMCryptoCENCCommon.h b/oemcrypto/odk/include/OEMCryptoCENCCommon.h index a4e5438..ffc70ab 100644 --- a/oemcrypto/odk/include/OEMCryptoCENCCommon.h +++ b/oemcrypto/odk/include/OEMCryptoCENCCommon.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -93,6 +93,7 @@ typedef enum OEMCryptoResult { OEMCrypto_ERROR_DVR_FORBIDDEN = 63, OEMCrypto_ERROR_INSUFFICIENT_PRIVILEGE = 64, OEMCrypto_ERROR_INVALID_KEY = 65, + OEMCrypto_ERROR_INVALID_OEM_CERTIFICATE = 66, /* ODK return values */ ODK_ERROR_BASE = 1000, ODK_ERROR_CORE_MESSAGE = ODK_ERROR_BASE, @@ -122,6 +123,7 @@ typedef enum OEMCrypto_Usage_Entry_Status { kInactiveUnused = 4, } OEMCrypto_Usage_Entry_Status; +/* Not used publicly. Not documented with Doxygen. */ typedef enum OEMCrypto_ProvisioningRenewalType { OEMCrypto_NoRenewal = 0, OEMCrypto_RenewalACert = 1, @@ -137,7 +139,9 @@ typedef enum OEMCrypto_LicenseType { OEMCrypto_LicenseType_MaxValue = OEMCrypto_EntitlementLicense, } OEMCrypto_LicenseType; -/* Private key type used in the provisioning response. */ +/** + * Private key type used in the provisioning response. + */ typedef enum OEMCrypto_PrivateKeyType { OEMCrypto_RSA_Private_Key = 0, OEMCrypto_ECC_Private_Key = 1, diff --git a/oemcrypto/odk/include/core_message_deserialize.h b/oemcrypto/odk/include/core_message_deserialize.h index a52c5fd..fb80dc5 100644 --- a/oemcrypto/odk/include/core_message_deserialize.h +++ b/oemcrypto/odk/include/core_message_deserialize.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -34,6 +34,16 @@ namespace deserialize { bool CoreLicenseRequestFromMessage(const std::string& oemcrypto_core_message, ODK_LicenseRequest* core_license_request); +/** + * Counterpart (deserializer) of ODK_PrepareCoreReleaseRequest (serializer) + * + * Parameters: + * [in] oemcrypto_core_message + * [out] core_license_request + */ +bool CoreReleaseRequestFromMessage(const std::string& oemcrypto_core_message, + ODK_ReleaseRequest* core_release_request); + /** * Counterpart (deserializer) of ODK_PrepareCoreRenewalRequest (serializer) * diff --git a/oemcrypto/odk/include/core_message_features.h b/oemcrypto/odk/include/core_message_features.h index 1365dd8..36d9d83 100644 --- a/oemcrypto/odk/include/core_message_features.h +++ b/oemcrypto/odk/include/core_message_features.h @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC. All rights reserved. This file and proprietary +// Copyright 2021 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -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.3. - uint32_t maximum_major_version = 18; - uint32_t maximum_minor_version = 3; + // number. The default is 19.2. + uint32_t maximum_major_version = 19; + uint32_t maximum_minor_version = 2; bool operator==(const CoreMessageFeatures &other) const; bool operator!=(const CoreMessageFeatures &other) const { diff --git a/oemcrypto/odk/include/core_message_serialize.h b/oemcrypto/odk/include/core_message_serialize.h index a76b79f..64e9427 100644 --- a/oemcrypto/odk/include/core_message_serialize.h +++ b/oemcrypto/odk/include/core_message_serialize.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -25,7 +25,7 @@ namespace oemcrypto_core_message { namespace serialize { -using oemcrypto_core_message::features::CoreMessageFeatures; +using ::oemcrypto_core_message::features::CoreMessageFeatures; /** * Counterpart (serializer) of ODK_ParseLicense (deserializer) @@ -44,6 +44,23 @@ bool CreateCoreLicenseResponse(const CoreMessageFeatures& features, const std::string& core_request_sha256, std::string* oemcrypto_core_message); +/** + * Counterpart (serializer) of ODK_ParseLicense (deserializer) + * struct-input variant + * + * Parameters: + * [in] features feature support for response message. + * [in] core_request + * [in] seconds_since_license_requested + * [in] seconds_since_first_decrypt + * [out] oemcrypto_core_message + */ +bool CreateCoreReleaseResponse(const CoreMessageFeatures& features, + const ODK_ReleaseRequest& core_request, + int64_t seconds_since_license_requested, + int64_t seconds_since_first_decrypt, + std::string* oemcrypto_core_message); + /** * Counterpart (serializer) of ODK_ParseRenewal (deserializer) * diff --git a/oemcrypto/odk/include/core_message_serialize_proto.h b/oemcrypto/odk/include/core_message_serialize_proto.h index 73d7b73..5d69e1d 100644 --- a/oemcrypto/odk/include/core_message_serialize_proto.h +++ b/oemcrypto/odk/include/core_message_serialize_proto.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/include/core_message_types.h b/oemcrypto/odk/include/core_message_types.h index d268aef..05f66c1 100644 --- a/oemcrypto/odk/include/core_message_types.h +++ b/oemcrypto/odk/include/core_message_types.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -101,6 +101,17 @@ struct ODK_LicenseRequest { ODK_MessageCounter counter_info; }; +/** + * Output structure for CoreReleaseRequestFromMessage + * Input structure for CreateCoreReleaseResponse + */ +struct ODK_ReleaseRequest { + uint16_t api_minor_version; + uint16_t api_major_version; + uint32_t nonce; + uint32_t session_id; +}; + /** * Output structure for CoreRenewalRequestFromMessage * Input structure for CreateCoreRenewalResponse diff --git a/oemcrypto/odk/include/odk.h b/oemcrypto/odk/include/odk.h index 16af94a..679d4e0 100644 --- a/oemcrypto/odk/include/odk.h +++ b/oemcrypto/odk/include/odk.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -55,6 +55,9 @@ * * @defgroup common_types Common Types * Enumerations and structures that are used by several OEMCrypto and ODK + * + * @defgroup odk_derivation Key Derivation Utils + * Utilities and constants relating to key derivation. * functions. *********************************************************************/ @@ -274,6 +277,49 @@ OEMCryptoResult ODK_PrepareCoreLicenseRequest( const ODK_NonceValues* nonce_values, const ODK_MessageCounterInfo* counter_info); +/** + * Modifies the message to include a core license release at the beginning of + * the message buffer. The values in nonce_values are used to populate the + * message. + * + * This shall be called by OEMCrypto from OEMCrypto_PrepAndSignLicenseRelease. + * + * NOTE: if the message pointer is null and/or input core_message_size is + * zero, this function returns OEMCrypto_ERROR_SHORT_BUFFER and sets output + * core_message_size to the size needed. + * + * @param[in,out] message: Pointer to memory for the entire message. Modified by + * the ODK library. + * @param[in] message_length: length of the entire message buffer. + * @param[in,out] core_message_size: length of the core message at the beginning + * of the message. (in) size of buffer reserved for the core message, in + * bytes. (out) actual length of the core message, in bytes. + * @param[in] nonce_values: pointer to the session's nonce data. + * @param[in] status: the enumeration of OEMCrypto_Usage_Entry_Status + * @param[in] clock_security_level: the enumeration of + * OEMCryto_Clock_Security_Level + * @param[in] seconds_since_license_requested: the time between the license + * being requested and the release being generated in seconds + * @param[in] seconds_since_first_decrypt: The time since playback has started + * in seconds + * @param[in,out] clock_values: the session's clock values. + * @param[in] system_time_seconds: the current time on OEMCrypto's clock, in + * seconds. + * + * @retval OEMCrypto_SUCCESS + * @retval OEMCrypto_ERROR_SHORT_BUFFER: core_message_size is too small + * @retval OEMCrypto_ERROR_INVALID_CONTEXT + * + * @version + * This method is new in version 19 of the API. + */ +OEMCryptoResult ODK_PrepareCoreReleaseRequest( + uint8_t* message, size_t message_length, size_t* core_message_size, + ODK_NonceValues* nonce_values, uint32_t status, + uint32_t clock_security_level, int64_t seconds_since_license_requested, + int64_t seconds_since_first_decrypt, ODK_ClockValues* clock_values, + uint64_t system_time_seconds); + /** * Modifies the message to include a core renewal request at the beginning of * the message buffer. The values in nonce_values, clock_values and @@ -340,7 +386,7 @@ OEMCryptoResult ODK_PrepareCoreRenewalRequest(uint8_t* message, * of the message. (in) size of buffer reserved for the core message, in * bytes. (out) actual length of the core message, in bytes. * @param[in] nonce_values: pointer to the session's nonce data. - * @param[in] message_count_info: information used for server-side anomaly + * @param[in] counter_info: information used for server-side anomaly * detection * * @retval OEMCrypto_SUCCESS @@ -559,14 +605,17 @@ OEMCryptoResult ODK_RefreshV15Values(const ODK_TimerLimits* timer_limits, * @param[in,out] nonce_values: The session's nonce values. These will be * updated. * @param[out] parsed_license: the destination for the data. - * @param[out] timer_value: set if playback timer should be started. + * @param[out] timer_value: set to the new timer value. Only used if the return + * value is ODK_SET_TIMER. This must be non-null if OEMCrypto uses a + * hardware timer. * * @retval OEMCrypto_SUCCESS * @retval ODK_ERROR_CORE_MESSAGE: if the message did not parse correctly, or * there were other incorrect values. An error should be returned to the * CDM layer. * @retval ODK_UNSUPPORTED_API - * @retval ODK_SET_TIMER: if the playback timer has been started successfully + * @retval ODK_SET_TIMER: Success. The timer should be reset to the specified + * timer value. * @retval ODK_DISABLE_TIMER: if the playtime timer has been started * successfully then is disabled. * @retval ODK_TIMER_EXPIRED: if the license is attempted to be loaded after the @@ -574,7 +623,7 @@ OEMCryptoResult ODK_RefreshV15Values(const ODK_TimerLimits* timer_limits, * @retval OEMCrypto_ERROR_INVALĂ„ID_NONCE * * @version - * This method is new in version 16 of the API. + * This method changed in version 18 of the API. */ OEMCryptoResult ODK_ParseLicense( const uint8_t* message, size_t message_length, size_t core_message_length, @@ -618,6 +667,7 @@ OEMCryptoResult ODK_ParseLicense( * value is ODK_SET_TIMER. This must be non-null if OEMCrypto uses a * hardware timer. * + * @retval OEMCrypto_SUCCESS * @retval ODK_ERROR_CORE_MESSAGE: the message did not parse correctly, or there * were other incorrect values. An error should be returned to the CDM * layer. @@ -632,7 +682,7 @@ OEMCryptoResult ODK_ParseLicense( * @retval OEMCrypto_ERROR_INVALID_NONCE * * @version - * This method is new in version 16 of the API. + * This method changed in version 18 of the API. */ OEMCryptoResult ODK_ParseRenewal(const uint8_t* message, size_t message_length, size_t core_message_length, @@ -642,6 +692,33 @@ OEMCryptoResult ODK_ParseRenewal(const uint8_t* message, size_t message_length, ODK_ClockValues* clock_values, uint64_t* timer_value); +/** + * The function ODK_ParseRelease will parse the message and verify its + * header contents. If the message does not parse correctly, an error of + * ODK_ERROR_CORE_MESSAGE is returned. This function is mostly a placeholder + * function since there is no information needed in the release response. + * + * @param[in] message: pointer to the message buffer. + * @param[in] message_length: length of the entire message buffer. + * @param[in] core_message_size: length of the core message, at the beginning of + * the message buffer. + * @param[in,out] nonce_values: pointer to the session's nonce data. These might + * be updated if the server returns a lower API version. + * + * @retval OEMCrypto_SUCCESS + * @retval ODK_ERROR_CORE_MESSAGE: the message did not parse correctly, or there + * were other incorrect values. An error should be returned to the CDM + * layer. + * @retval ODK_UNSUPPORTED_API + * @retval OEMCrypto_ERROR_INVALID_NONCE + * + * @version + * This method is new in version 19 of the API. + */ +OEMCryptoResult ODK_ParseRelease(const uint8_t* message, size_t message_length, + size_t core_message_length, + ODK_NonceValues* nonce_values); + /** * The function ODK_ParseProvisioning will parse the message and verify the * nonce values match those in the license. @@ -670,7 +747,6 @@ OEMCryptoResult ODK_ParseRenewal(const uint8_t* message, size_t message_length, * @param[in] device_id: a pointer to a buffer containing the device ID of the * device. The ODK function will verify it matches that in the message. * @param[in] device_id_length: the length of the device ID. - * @param[out] counter_info: destination for counter portion of parse data. * @param[out] parsed_response: destination for response portion of parse data. * * @retval OEMCrypto_SUCCESS @@ -681,7 +757,7 @@ OEMCryptoResult ODK_ParseRenewal(const uint8_t* message, size_t message_length, * @retval OEMCrypto_ERROR_INVALID_NONCE * * @version - * This method is new in version 16 of the API. + * This method changed in version 18 of the API. */ OEMCryptoResult ODK_ParseProvisioning( const uint8_t* message, size_t message_length, size_t core_message_length, @@ -740,6 +816,83 @@ bool CheckApiVersionAtMost(const ODK_NonceValues* nonce_values, /// @} +/// @addtogroup odk_derivation +/// @{ + +/** + * Contains the key label for the Mac key derivation. This contains + * |ODK_MacKeyLabelWithZeroLength| number of bytes. + */ +extern const uint8_t ODK_MacKeyLabelWithZero[]; + +/** Contains the number of bytes in |ODK_MacKeyLabelWithZero|. */ +extern const size_t ODK_MacKeyLabelWithZeroLength; + +/** + * Contains the key label for the Encryption key derivation. This contains + * |ODK_EncKeyLabelWithZeroLength| number of bytes. + */ +extern const uint8_t ODK_EncKeyLabelWithZero[]; + +/** Contains the number of bytes in |ODK_EncKeyLabelWithZero|. */ +extern const size_t ODK_EncKeyLabelWithZeroLength; + +/** + * Contains the suffix bytes (NIST 800-108 key length) for Mac key derivation. + * This value is appended after the context string. This contains + * ODK_MacKeySuffixLength number of bytes. + */ +extern const uint8_t ODK_MacKeySuffix[]; + +/** Contains the number of bytes in |ODK_MacKeySuffix|. */ +extern const size_t ODK_MacKeySuffixLength; + +/** + * Contains the suffix bytes (NIST 800-108 key length) for Encryption key + * derivation. This value is appended after the context string. This contains + * ODK_EncKeySuffixLength number of bytes. + */ +extern const uint8_t ODK_EncKeySuffix[]; + +/** Contains the number of bytes in |ODK_EncKeySuffix|. */ +extern const size_t ODK_EncKeySuffixLength; + +/** + * Generates the key-derivation contexts for the license exchange based on the + * given context value. + * + * NOTE: if the mac_key_context/enc_key_context pointer are null and/or input + * mac_key_context_length/enc_key_context_length is zero, this function returns + * OEMCrypto_ERROR_SHORT_BUFFER and sets output + * mac_key_context_length/enc_key_context_length to the size needed. + * + * @param[in] context: pointer to the context buffer. + * @param[in] context_length: the length of the context buffer. + * @param[out] mac_key_context: an output buffer to contain the MAC key context. + * @param[in,out] mac_key_context_length: on input, contains the number of bytes + * in |mac_key_context|; on return, will contain the context length. + * @param[out] enc_key_context: an output buffer to contain the encryption key + * context. + * @param[in,out] enc_key_context_length: on input, contains the number of bytes + * in |enc_key_context|; on return, will contain the context length. + * + * @retval OEMCrypto_SUCCESS + * @retval OEMCrypto_ERROR_SHORT_BUFFER: mac_key_context_length or + * enc_key_context_length is too small + * @retval OEMCrypto_ERROR_INVALID_CONTEXT + * + * @version + * This method is new in version 19 of the API. + */ +OEMCryptoResult ODK_GenerateKeyContexts(const uint8_t* context, + size_t context_length, + uint8_t* mac_key_context, + size_t* mac_key_context_length, + uint8_t* enc_key_context, + size_t* enc_key_context_length); + +/// @} + #ifdef __cplusplus } #endif diff --git a/oemcrypto/odk/include/odk_attributes.h b/oemcrypto/odk/include/odk_attributes.h index 72321b1..3fe09bf 100644 --- a/oemcrypto/odk/include/odk_attributes.h +++ b/oemcrypto/odk/include/odk_attributes.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/include/odk_message.h b/oemcrypto/odk/include/odk_message.h index cdbf26b..aedd31a 100644 --- a/oemcrypto/odk/include/odk_message.h +++ b/oemcrypto/odk/include/odk_message.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/include/odk_structs.h b/oemcrypto/odk/include/odk_structs.h index 1debc12..55713f4 100644 --- a/oemcrypto/odk/include/odk_structs.h +++ b/oemcrypto/odk/include/odk_structs.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -15,11 +15,11 @@ extern "C" { #include "odk_target.h" /* The version of this library. */ -#define ODK_MAJOR_VERSION 18 -#define ODK_MINOR_VERSION 3 +#define ODK_MAJOR_VERSION 19 +#define ODK_MINOR_VERSION 2 /* ODK Version string. Date changed automatically on each release. */ -#define ODK_RELEASE_DATE "ODK v18.3 2023-07-07" +#define ODK_RELEASE_DATE "ODK v19.2 2024-06-11" /* The lowest version number for an ODK message. */ #define ODK_FIRST_VERSION 16 @@ -223,9 +223,10 @@ typedef struct { * entitlement keys. * @param nonce_required: indicates if the license requires a nonce. * @param timer_limits: time limits of the for the license. - * @param watermarking: specifies if device supports watermarking. - * @param dtcp2_required: specifies if device supports DTCP. - * @param renewal_delay_base: what time the timer starting is based off of. + * @param watermarking: indicates watermarking requirements of the license. + * @param dtcp2_required: indicates dtcp2 requirements of the license. + * @param renewal_delay_base: indicates which time is used for the renewal timer + * and playback timer starting point. * @param key_array_length: number of keys present. * @param key_array: set of keys to be installed. * @@ -262,9 +263,10 @@ typedef struct { * entitlement keys. * @param nonce_required: indicates if the license requires a nonce. * @param timer_limits: time limits of the for the license. - * @param watermarking: specifies if device supports watermarking. - * @param dtcp2_required: specifies if device supports DTCP. - * @param renewal_delay_base: what time the timer starting is based off of. + * @param watermarking: indicates watermarking requirements of the license. + * @param dtcp2_required: indicates dtcp2 requirements of the license. + * @param renewal_delay_base: indicates which time is used for the renewal timer + * and playback timer starting point. * @param key_array_length: number of keys present. * @param key_array: set of keys to be installed. This is a pointer to an array * to allow packing a number of keys greater than |ODK_MAX_NUM_KEYS|. diff --git a/oemcrypto/odk/include/odk_target.h b/oemcrypto/odk/include/odk_target.h index d1c0652..825a263 100644 --- a/oemcrypto/odk/include/odk_target.h +++ b/oemcrypto/odk/include/odk_target.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file is distributed +// Copyright 2019 Google LLC. This file is distributed // under the Widevine License Agreement. // Partners are expected to edit this file to support target specific code diff --git a/oemcrypto/odk/src/core_message_deserialize.cpp b/oemcrypto/odk/src/core_message_deserialize.cpp index 30e68c4..c990101 100644 --- a/oemcrypto/odk/src/core_message_deserialize.cpp +++ b/oemcrypto/odk/src/core_message_deserialize.cpp @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -11,6 +11,7 @@ #include #include "OEMCryptoCENCCommon.h" +#include "core_message_types.h" #include "odk_message.h" #include "odk_serialize.h" #include "odk_structs.h" @@ -147,6 +148,14 @@ bool CoreLicenseRequestFromMessage(const std::string& oemcrypto_core_message, return true; } +bool CoreReleaseRequestFromMessage(const std::string& oemcrypto_core_message, + ODK_ReleaseRequest* core_release_request) { + ODK_PreparedReleaseRequest prepared_release = {}; + return ParseRequest(ODK_Release_Request_Type, oemcrypto_core_message, + core_release_request, &prepared_release, + Unpack_ODK_PreparedReleaseRequest); +} + bool CoreRenewalRequestFromMessage(const std::string& oemcrypto_core_message, ODK_RenewalRequest* core_renewal_request) { const auto unpacker = Unpack_ODK_PreparedRenewalRequest; @@ -167,11 +176,12 @@ bool CoreProvisioningRequestFromMessage( ODK_NonceValues nonce; if (!GetNonceFromMessage(oemcrypto_core_message, &nonce)) return false; - if (nonce.api_major_version == 18) { + if (nonce.api_major_version >= 18) { // Use special case unpacker for v18.0 - const auto unpacker = nonce.api_minor_version == 0 - ? Unpack_ODK_PreparedProvisioningRequestV180 - : Unpack_ODK_PreparedProvisioningRequest; + const auto unpacker = + nonce.api_minor_version == 0 && nonce.api_major_version == 18 + ? Unpack_ODK_PreparedProvisioningRequestV180 + : Unpack_ODK_PreparedProvisioningRequest; ODK_PreparedProvisioningRequest prepared_provision = {}; if (!ParseRequest(ODK_Provisioning_Request_Type, oemcrypto_core_message, diff --git a/oemcrypto/odk/src/core_message_features.cpp b/oemcrypto/odk/src/core_message_features.cpp index b8cae56..249bfdf 100644 --- a/oemcrypto/odk/src/core_message_features.cpp +++ b/oemcrypto/odk/src/core_message_features.cpp @@ -1,4 +1,4 @@ -// Copyright 2021 Google LLC. All rights reserved. This file and proprietary +// Copyright 2021 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -19,7 +19,9 @@ CoreMessageFeatures CoreMessageFeatures::DefaultFeatures( uint32_t maximum_major_version) { CoreMessageFeatures features; features.maximum_major_version = maximum_major_version; - // The default minor version is the highest for each major version. + // The default minor version is the highest for each major version. This also + // needs to be updated with new version releases in + // ODK_InitializeSessionValues() when the minor version is being set. switch (maximum_major_version) { case 16: features.maximum_minor_version = 5; // 16.5 @@ -28,7 +30,10 @@ CoreMessageFeatures CoreMessageFeatures::DefaultFeatures( features.maximum_minor_version = 2; // 17.2 break; case 18: - features.maximum_minor_version = 3; // 18.3 + features.maximum_minor_version = 4; // 18.4 + break; + case 19: + features.maximum_minor_version = 2; // 19.2 break; default: features.maximum_minor_version = 0; diff --git a/oemcrypto/odk/src/core_message_serialize.cpp b/oemcrypto/odk/src/core_message_serialize.cpp index 5edd352..888b957 100644 --- a/oemcrypto/odk/src/core_message_serialize.cpp +++ b/oemcrypto/odk/src/core_message_serialize.cpp @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -10,6 +10,7 @@ #include #include +#include "core_message_types.h" #include "odk_serialize.h" #include "odk_structs.h" #include "odk_structs_priv.h" @@ -137,6 +138,23 @@ bool CreateCoreLicenseResponse(const CoreMessageFeatures& features, Pack_ODK_LicenseResponse); } +bool CreateCoreReleaseResponse(const CoreMessageFeatures& features, + const ODK_ReleaseRequest& core_request, + int64_t seconds_since_license_requested, + int64_t seconds_since_first_decrypt, + std::string* oemcrypto_core_message) { + (void)seconds_since_license_requested; + (void)seconds_since_first_decrypt; + ODK_ReleaseResponse release_response{}; + if (!CreateResponseHeader(features, ODK_Release_Response_Type, + &release_response.core_message, core_request)) { + return false; + } + return CreateResponse(ODK_Release_Response_Type, oemcrypto_core_message, + &release_response.core_message, release_response, + Pack_ODK_ReleaseResponse); +} + bool CreateCoreRenewalResponse(const CoreMessageFeatures& features, const ODK_RenewalRequest& core_request, uint64_t renewal_duration_seconds, diff --git a/oemcrypto/odk/src/core_message_serialize_proto.cpp b/oemcrypto/odk/src/core_message_serialize_proto.cpp index 61c5031..edb9453 100644 --- a/oemcrypto/odk/src/core_message_serialize_proto.cpp +++ b/oemcrypto/odk/src/core_message_serialize_proto.cpp @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -9,8 +9,10 @@ #include #include #include +#include #include +#include "OEMCryptoCENCCommon.h" #include "core_message_serialize.h" #include "license_protocol.pb.h" #include "odk_serialize.h" @@ -32,8 +34,8 @@ using oemcrypto_core_message::features::CoreMessageFeatures; * message: serialized license protobuf * field: substring value */ -OEMCrypto_Substring GetOecSubstring(const std::string& message, - const std::string& field) { +OEMCrypto_Substring GetOecSubstring(std::string_view message, + std::string_view field) { OEMCrypto_Substring substring = {}; size_t pos = message.find(field); if (pos != std::string::npos) { @@ -43,7 +45,7 @@ OEMCrypto_Substring GetOecSubstring(const std::string& message, } OEMCrypto_KeyObject KeyContainerToOecKey( - const std::string& proto, const video_widevine::License::KeyContainer& k, + std::string_view proto, const video_widevine::License::KeyContainer& k, const bool uses_padding) { OEMCrypto_KeyObject obj = {}; obj.key_id = GetOecSubstring(proto, k.id()); @@ -167,9 +169,14 @@ bool CreateCoreLicenseResponseFromProto(const CoreMessageFeatures& features, timer_limits.rental_duration_seconds = policy.rental_duration_seconds(); timer_limits.total_playback_duration_seconds = policy.playback_duration_seconds(); + // On devices these seconds are tracking time so should not be negative. + if (policy.renewal_delay_seconds() < 0 || + policy.renewal_recovery_duration_seconds() < 0) { + return false; + } timer_limits.initial_renewal_duration_seconds = - policy.renewal_delay_seconds() + - policy.renewal_recovery_duration_seconds(); + static_cast(policy.renewal_delay_seconds()) + + static_cast(policy.renewal_recovery_duration_seconds()); parsed_lic.key_array = key_array.data(); parsed_lic.key_array_length = static_cast(key_array.size()); diff --git a/oemcrypto/odk/src/kdo.gypi b/oemcrypto/odk/src/kdo.gypi index 6e77b45..cd8717a 100644 --- a/oemcrypto/odk/src/kdo.gypi +++ b/oemcrypto/odk/src/kdo.gypi @@ -1,4 +1,4 @@ -# Copyright 2019 Google LLC. All rights reserved. This file and proprietary +# Copyright 2019 Google LLC. This file and proprietary # source code may only be used and distributed under the Widevine License # Agreement. diff --git a/oemcrypto/odk/src/odk.c b/oemcrypto/odk/src/odk.c index 3ade4a7..3f4090f 100644 --- a/oemcrypto/odk/src/odk.c +++ b/oemcrypto/odk/src/odk.c @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -9,6 +9,7 @@ #include #include +#include "OEMCryptoCENCCommon.h" #include "odk_message.h" #include "odk_overflow.h" #include "odk_serialize.h" @@ -65,6 +66,15 @@ static OEMCryptoResult ODK_PrepareRequest( } break; } + case ODK_Release_Request_Type: { + core_message->message_length = ODK_RELEASE_REQUEST_SIZE; + if (sizeof(ODK_PreparedReleaseRequest) > prepared_request_buffer_length) { + return ODK_ERROR_CORE_MESSAGE; + } + Pack_ODK_PreparedReleaseRequest( + &msg, (ODK_PreparedReleaseRequest*)prepared_request_buffer); + break; + } case ODK_Renewal_Request_Type: { core_message->message_length = ODK_RENEWAL_REQUEST_SIZE; if (sizeof(ODK_PreparedRenewalRequest) > prepared_request_buffer_length) { @@ -223,6 +233,34 @@ OEMCryptoResult ODK_PrepareCoreLicenseRequest( } } +OEMCryptoResult ODK_PrepareCoreReleaseRequest( + uint8_t* message, size_t message_length, size_t* core_message_size, + ODK_NonceValues* nonce_values, uint32_t status, + uint32_t clock_security_level, int64_t seconds_since_license_requested, + int64_t seconds_since_first_decrypt, ODK_ClockValues* clock_values, + uint64_t system_time_seconds) { + (void)status; + (void)clock_security_level; + (void)seconds_since_license_requested; + (void)seconds_since_first_decrypt; + if (core_message_size == NULL || nonce_values == NULL || + clock_values == NULL) { + return ODK_ERROR_CORE_MESSAGE; + } + if (nonce_values->api_major_version >= 19) { + ODK_PreparedReleaseRequest release_request = {0}; + return ODK_PrepareRequest( + message, message_length, core_message_size, ODK_Release_Request_Type, + nonce_values, &release_request, sizeof(ODK_PreparedReleaseRequest)); + } else { + // If the version is pre 19 when license release isn't supported, create a + // license request. + return ODK_PrepareCoreRenewalRequest(message, message_length, + core_message_size, nonce_values, + clock_values, system_time_seconds); + } +} + OEMCryptoResult ODK_PrepareCoreRenewalRequest(uint8_t* message, size_t message_length, size_t* core_message_size, @@ -423,7 +461,7 @@ OEMCryptoResult ODK_ParseLicense( *timer_limits = parsed_license->timer_limits; /* And update the clock values state. */ clock_values->timer_status = ODK_CLOCK_TIMER_STATUS_LICENSE_LOADED; - if (nonce_values->api_major_version == 18 && license_load) { + if (nonce_values->api_major_version >= 18 && license_load) { err = ODK_AttemptFirstPlayback(system_time_seconds, timer_limits, clock_values, timer_value); return err; @@ -488,6 +526,33 @@ OEMCryptoResult ODK_ParseRenewal(const uint8_t* message, size_t message_length, timer_value); } +OEMCryptoResult ODK_ParseRelease(const uint8_t* message, size_t message_length, + size_t core_message_length, + ODK_NonceValues* nonce_values) { + if (message == NULL || nonce_values == NULL) { + return ODK_ERROR_CORE_MESSAGE; + } + + const OEMCryptoResult err = + ODK_ParseCoreHeader(message, message_length, core_message_length, + ODK_Release_Response_Type, nonce_values); + if (err != OEMCrypto_SUCCESS) { + return err; + } + + ODK_ReleaseResponse release_response = {0}; + ODK_Message msg = ODK_Message_Create((uint8_t*)message, message_length); + ODK_Message_SetSize(&msg, core_message_length); + Unpack_ODK_ReleaseResponse(&msg, &release_response); + + if (ODK_Message_GetStatus(&msg) != MESSAGE_STATUS_OK || + ODK_Message_GetOffset(&msg) != core_message_length) { + return ODK_ERROR_CORE_MESSAGE; + } + + return OEMCrypto_SUCCESS; +} + OEMCryptoResult ODK_ParseProvisioning( const uint8_t* message, size_t message_length, size_t core_message_length, ODK_NonceValues* nonce_values, const uint8_t* device_id, @@ -589,3 +654,69 @@ bool CheckApiVersionAtMost(const ODK_NonceValues* nonce_values, (nonce_values->api_major_version == major_version && nonce_values->api_minor_version <= minor_version); } + +const uint8_t ODK_MacKeyLabelWithZero[] = "AUTHENTICATION"; +const size_t ODK_MacKeyLabelWithZeroLength = sizeof(ODK_MacKeyLabelWithZero); +// This is the key size (512) in network byte order. +const uint8_t ODK_MacKeySuffix[] = {0x00, 0x00, 0x02, 0x00}; +const size_t ODK_MacKeySuffixLength = sizeof(ODK_MacKeySuffix); + +const uint8_t ODK_EncKeyLabelWithZero[] = "ENCRYPTION"; +const size_t ODK_EncKeyLabelWithZeroLength = sizeof(ODK_EncKeyLabelWithZero); +// This is the key size (128) in network byte order. +const uint8_t ODK_EncKeySuffix[] = {0x00, 0x00, 0x00, 0x80}; +const size_t ODK_EncKeySuffixLength = sizeof(ODK_EncKeySuffix); + +OEMCryptoResult ODK_GenerateKeyContexts(const uint8_t* context, + size_t context_length, + uint8_t* mac_key_context, + size_t* mac_key_context_length, + uint8_t* enc_key_context, + size_t* enc_key_context_length) { + size_t real_mac_length; + size_t real_enc_length; + if (odk_add_overflow_ux( + context_length, + ODK_MacKeyLabelWithZeroLength + ODK_MacKeySuffixLength, + &real_mac_length) || + real_mac_length > 0xffffffff || + odk_add_overflow_ux( + context_length, + ODK_EncKeyLabelWithZeroLength + ODK_EncKeySuffixLength, + &real_enc_length) || + real_enc_length > 0xffffffff) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + bool short_buffer = false; + if (mac_key_context_length) { + short_buffer = real_mac_length > *mac_key_context_length; + *mac_key_context_length = real_mac_length; + } + if (enc_key_context_length) { + short_buffer = short_buffer || real_enc_length > *enc_key_context_length; + *enc_key_context_length = real_enc_length; + } + if (short_buffer || !mac_key_context || !enc_key_context) { + return OEMCrypto_ERROR_SHORT_BUFFER; + } + + if (!context || !mac_key_context_length || !enc_key_context_length) { + return OEMCrypto_ERROR_INVALID_CONTEXT; + } + + memcpy(mac_key_context, ODK_MacKeyLabelWithZero, + ODK_MacKeyLabelWithZeroLength); + memcpy(mac_key_context + ODK_MacKeyLabelWithZeroLength, context, + context_length); + memcpy(mac_key_context + ODK_MacKeyLabelWithZeroLength + context_length, + ODK_MacKeySuffix, ODK_MacKeySuffixLength); + + memcpy(enc_key_context, ODK_EncKeyLabelWithZero, + ODK_EncKeyLabelWithZeroLength); + memcpy(enc_key_context + ODK_EncKeyLabelWithZeroLength, context, + context_length); + memcpy(enc_key_context + ODK_EncKeyLabelWithZeroLength + context_length, + ODK_EncKeySuffix, ODK_EncKeySuffixLength); + + return OEMCrypto_SUCCESS; +} diff --git a/oemcrypto/odk/src/odk.gyp b/oemcrypto/odk/src/odk.gyp index 4aa79a4..d026db1 100644 --- a/oemcrypto/odk/src/odk.gyp +++ b/oemcrypto/odk/src/odk.gyp @@ -1,4 +1,4 @@ -# Copyright 2019 Google LLC. All rights reserved. This file and proprietary +# Copyright 2019 Google LLC. This file and proprietary # source code may only be used and distributed under the Widevine License # Agreement. diff --git a/oemcrypto/odk/src/odk.gypi b/oemcrypto/odk/src/odk.gypi index 1867605..d37f134 100644 --- a/oemcrypto/odk/src/odk.gypi +++ b/oemcrypto/odk/src/odk.gypi @@ -1,4 +1,4 @@ -# Copyright 2019 Google LLC. All rights reserved. This file and proprietary +# Copyright 2019 Google LLC. This file and proprietary # source code may only be used and distributed under the Widevine License # Agreement. diff --git a/oemcrypto/odk/src/odk_assert.h b/oemcrypto/odk/src/odk_assert.h index 0517818..6322a5b 100644 --- a/oemcrypto/odk/src/odk_assert.h +++ b/oemcrypto/odk/src/odk_assert.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -9,7 +9,7 @@ extern "C" { #endif -#if (__STDC_VERSION__ >= 201112L) +#if defined(_MSC_VER) || (__STDC_VERSION__ >= 201112L) #include #define odk_static_assert static_assert #else diff --git a/oemcrypto/odk/src/odk_endian.h b/oemcrypto/odk/src/odk_endian.h index 58a2fd7..bdd79d1 100644 --- a/oemcrypto/odk/src/odk_endian.h +++ b/oemcrypto/odk/src/odk_endian.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/odk_message.c b/oemcrypto/odk/src/odk_message.c index 7cc05c0..a2487ff 100644 --- a/oemcrypto/odk/src/odk_message.c +++ b/oemcrypto/odk/src/odk_message.c @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/odk_message_priv.h b/oemcrypto/odk/src/odk_message_priv.h index 8ad5f03..f8e9bcc 100644 --- a/oemcrypto/odk/src/odk_message_priv.h +++ b/oemcrypto/odk/src/odk_message_priv.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/odk_overflow.c b/oemcrypto/odk/src/odk_overflow.c index 37c3bb9..ba19962 100644 --- a/oemcrypto/odk/src/odk_overflow.c +++ b/oemcrypto/odk/src/odk_overflow.c @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/odk_overflow.h b/oemcrypto/odk/src/odk_overflow.h index e725705..7b50552 100644 --- a/oemcrypto/odk/src/odk_overflow.h +++ b/oemcrypto/odk/src/odk_overflow.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/odk_serialize.c b/oemcrypto/odk/src/odk_serialize.c index eec0266..1f2e48e 100644 --- a/oemcrypto/odk/src/odk_serialize.c +++ b/oemcrypto/odk/src/odk_serialize.c @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -8,6 +8,8 @@ #include "odk_serialize.h" +#include "odk_message.h" +#include "odk_overflow.h" #include "odk_structs_priv.h" #include "serialization_base.h" @@ -50,10 +52,6 @@ static void Pack_ODK_ParsedLicense(ODK_Message* msg, ODK_Packing_ParsedLicense const* obj, const ODK_NonceValues* nonce_values) { /* hand-coded */ - if (obj->key_array_length > ODK_MAX_NUM_KEYS) { - ODK_Message_SetStatus(msg, MESSAGE_STATUS_OVERFLOW_ERROR); - return; - } Pack_OEMCrypto_Substring(msg, &obj->enc_mac_keys_iv); Pack_OEMCrypto_Substring(msg, &obj->enc_mac_keys); Pack_OEMCrypto_Substring(msg, &obj->pst); @@ -128,6 +126,11 @@ void Pack_ODK_PreparedLicenseRequestV17( Pack_ODK_CoreMessage(msg, &obj->core_message); } +void Pack_ODK_PreparedReleaseRequest(ODK_Message* msg, + const ODK_PreparedReleaseRequest* obj) { + Pack_ODK_CoreMessage(msg, &obj->core_message); +} + void Pack_ODK_PreparedRenewalRequest(ODK_Message* msg, ODK_PreparedRenewalRequest const* obj) { Pack_ODK_CoreMessage(msg, &obj->core_message); @@ -182,6 +185,11 @@ void Pack_ODK_LicenseResponse(ODK_Message* msg, } } +void Pack_ODK_ReleaseResponse(ODK_Message* msg, + ODK_ReleaseResponse const* obj) { + Pack_ODK_CoreMessage(msg, &obj->core_message); +} + void Pack_ODK_RenewalResponse(ODK_Message* msg, ODK_RenewalResponse const* obj) { Pack_ODK_PreparedRenewalRequest(msg, &obj->request); @@ -231,6 +239,36 @@ static void Unpack_OEMCrypto_KeyObject(ODK_Message* msg, Unpack_OEMCrypto_Substring(msg, &obj->key_data); Unpack_OEMCrypto_Substring(msg, &obj->key_control_iv); Unpack_OEMCrypto_Substring(msg, &obj->key_control); + + /* + Edge case for servers that incorrectly process protocol VERSION_2_2 padding. + Key data in proto is present, but each key's position in the core + message is missing. + + Use the key_data_iv offset to determine if the key_data is present. + This assumes that the serialized protobuf is deterministically ordered, and + that the content key is always 16 bytes. These assumptions should hold true + for v16 and older servers. + */ + if (ODK_Message_GetStatus(msg) == MESSAGE_STATUS_OK && + obj->key_data.offset == 0 && obj->key_data.length == 0) { + const size_t kKeyDataProtoHeaderSize = 2; + obj->key_data.offset = obj->key_data_iv.offset + obj->key_data_iv.length + + kKeyDataProtoHeaderSize; + obj->key_data.length = 16u; // assume 16-byte key + + // Check for overflow. The offset is relative to the end of the core + // message, so add that length to the calculation. + size_t substring_end = 0; // offset + length + size_t end = 0; // offset + length + message_length + if (odk_add_overflow_ux(obj->key_data.offset, obj->key_data.length, + &substring_end) || + odk_add_overflow_ux(substring_end, ODK_Message_GetSize(msg), &end) || + end > ODK_Message_GetCapacity(msg)) { + ODK_Message_SetStatus(msg, MESSAGE_STATUS_OVERFLOW_ERROR); + return; + } + } } static void Unpack_ODK_TimerLimits(ODK_Message* msg, ODK_TimerLimits* obj) { @@ -322,6 +360,11 @@ void Unpack_ODK_PreparedLicenseRequestV17(ODK_Message* msg, Unpack_ODK_CoreMessage(msg, &obj->core_message); } +void Unpack_ODK_PreparedReleaseRequest(ODK_Message* msg, + ODK_PreparedReleaseRequest* obj) { + Unpack_ODK_CoreMessage(msg, &obj->core_message); +} + void Unpack_ODK_PreparedRenewalRequest(ODK_Message* msg, ODK_PreparedRenewalRequest* obj) { Unpack_ODK_CoreMessage(msg, &obj->core_message); @@ -384,6 +427,10 @@ void Unpack_ODK_LicenseResponse(ODK_Message* msg, ODK_LicenseResponse* obj) { } } +void Unpack_ODK_ReleaseResponse(ODK_Message* msg, ODK_ReleaseResponse* obj) { + Unpack_ODK_CoreMessage(msg, &obj->core_message); +} + void Unpack_ODK_RenewalResponse(ODK_Message* msg, ODK_RenewalResponse* obj) { Unpack_ODK_PreparedRenewalRequest(msg, &obj->request); Unpack_uint64_t(msg, &obj->renewal_duration_seconds); diff --git a/oemcrypto/odk/src/odk_serialize.h b/oemcrypto/odk/src/odk_serialize.h index 1ec74b6..a7aa220 100644 --- a/oemcrypto/odk/src/odk_serialize.h +++ b/oemcrypto/odk/src/odk_serialize.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -20,6 +20,8 @@ void Pack_ODK_PreparedLicenseRequest(ODK_Message* msg, const ODK_PreparedLicenseRequest* obj); void Pack_ODK_PreparedLicenseRequestV17( ODK_Message* msg, const ODK_PreparedLicenseRequestV17* obj); +void Pack_ODK_PreparedReleaseRequest(ODK_Message* msg, + const ODK_PreparedReleaseRequest* obj); void Pack_ODK_PreparedRenewalRequest(ODK_Message* msg, const ODK_PreparedRenewalRequest* obj); void Pack_ODK_PreparedProvisioningRequest( @@ -34,6 +36,7 @@ void Pack_ODK_PreparedRenewedProvisioningRequest( /* odk unpack */ void Unpack_ODK_CoreMessage(ODK_Message* msg, ODK_CoreMessage* obj); void Unpack_ODK_LicenseResponse(ODK_Message* msg, ODK_LicenseResponse* obj); +void Unpack_ODK_ReleaseResponse(ODK_Message* msg, ODK_ReleaseResponse* obj); void Unpack_ODK_RenewalResponse(ODK_Message* msg, ODK_RenewalResponse* obj); void Unpack_ODK_ProvisioningResponse(ODK_Message* msg, ODK_ProvisioningResponse* obj); @@ -45,6 +48,7 @@ void Unpack_ODK_Provisioning40Response(ODK_Message* msg, /* kdo pack */ void Pack_ODK_LicenseResponse(ODK_Message* msg, const ODK_Packing_LicenseResponse* obj); +void Pack_ODK_ReleaseResponse(ODK_Message* msg, const ODK_ReleaseResponse* obj); void Pack_ODK_RenewalResponse(ODK_Message* msg, const ODK_RenewalResponse* obj); void Pack_ODK_ProvisioningResponse(ODK_Message* msg, const ODK_ProvisioningResponse* obj); @@ -58,6 +62,8 @@ void Unpack_ODK_PreparedLicenseRequest(ODK_Message* msg, ODK_PreparedLicenseRequest* obj); void Unpack_ODK_PreparedLicenseRequestV17(ODK_Message* msg, ODK_PreparedLicenseRequestV17* obj); +void Unpack_ODK_PreparedReleaseRequest(ODK_Message* msg, + ODK_PreparedReleaseRequest* obj); void Unpack_ODK_PreparedRenewalRequest(ODK_Message* msg, ODK_PreparedRenewalRequest* obj); void Unpack_ODK_PreparedProvisioningRequest( diff --git a/oemcrypto/odk/src/odk_structs_priv.h b/oemcrypto/odk/src/odk_structs_priv.h index 5306a4b..208ce2c 100644 --- a/oemcrypto/odk/src/odk_structs_priv.h +++ b/oemcrypto/odk/src/odk_structs_priv.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -24,13 +24,13 @@ typedef uint32_t ODK_MessageType; #define ODK_Renewal_Response_Type ((ODK_MessageType)4u) #define ODK_Provisioning_Request_Type ((ODK_MessageType)5u) #define ODK_Provisioning_Response_Type ((ODK_MessageType)6u) +#define ODK_Release_Request_Type ((ODK_MessageType)7u) +#define ODK_Release_Response_Type ((ODK_MessageType)8u) #define ODK_Renewed_Provisioning_Request_Type ((ODK_MessageType)11u) #define ODK_Provisioning40_Request_Type ((ODK_MessageType)12u) // TODO(b/244580447): Reserve future message types to support // forward compatibility. -#define ODK_Release_Request_Type ((ODK_MessageType)7u) -#define ODK_Release_Response_Type ((ODK_MessageType)8u) #define ODK_Common_Request_Type ((ODK_MessageType)9u) #define ODK_Common_Response_Type ((ODK_MessageType)10u) @@ -49,6 +49,10 @@ typedef struct { ODK_CoreMessage core_message; } ODK_PreparedLicenseRequestV17; +typedef struct { + ODK_CoreMessage core_message; +} ODK_PreparedReleaseRequest; + typedef struct { ODK_CoreMessage core_message; uint64_t playback_time; @@ -97,6 +101,10 @@ typedef struct { uint8_t request_hash[ODK_SHA256_HASH_SIZE]; } ODK_Packing_LicenseResponse; +typedef struct { + ODK_CoreMessage core_message; +} ODK_ReleaseResponse; + typedef struct { ODK_PreparedRenewalRequest request; uint64_t renewal_duration_seconds; @@ -124,6 +132,7 @@ typedef struct { #define ODK_CORE_MESSAGE_SIZE 20u #define ODK_LICENSE_REQUEST_SIZE 90u #define ODK_LICENSE_REQUEST_SIZE_V17 20u +#define ODK_RELEASE_REQUEST_SIZE 20u #define ODK_RENEWAL_REQUEST_SIZE 28u #define ODK_PROVISIONING_REQUEST_SIZE 94u #define ODK_PROVISIONING_REQUEST_SIZE_V17 88u diff --git a/oemcrypto/odk/src/odk_timer.c b/oemcrypto/odk/src/odk_timer.c index 6994532..d5523ec 100644 --- a/oemcrypto/odk/src/odk_timer.c +++ b/oemcrypto/odk/src/odk_timer.c @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -264,7 +264,25 @@ OEMCryptoResult ODK_InitializeSessionValues(ODK_TimerLimits* timer_limits, ODK_InitializeClockValues(clock_values, 0); nonce_values->api_major_version = api_major_version; - nonce_values->api_minor_version = ODK_MINOR_VERSION; + // This needs to be updated with new version releases in the default features + // of core message features. + switch (nonce_values->api_major_version) { + case 16: + nonce_values->api_minor_version = 5; + break; + case 17: + nonce_values->api_minor_version = 2; + break; + case 18: + nonce_values->api_minor_version = 4; + break; + case 19: + nonce_values->api_minor_version = 2; + break; + default: + nonce_values->api_minor_version = 0; + break; + } nonce_values->nonce = 0; nonce_values->session_id = session_id; @@ -337,7 +355,7 @@ OEMCryptoResult ODK_AttemptFirstPlayback(uint64_t system_time_seconds, return OEMCrypto_ERROR_INVALID_CONTEXT; } if (rental_time < timer_limits->earliest_playback_start_seconds) { - clock_values->timer_status = ODK_TIMER_EXPIRED; + clock_values->timer_status = ODK_CLOCK_TIMER_STATUS_EXPIRED; return ODK_TIMER_EXPIRED; } /* If the license is inactive or not loaded, then playback is not allowed. */ diff --git a/oemcrypto/odk/src/odk_util.c b/oemcrypto/odk/src/odk_util.c index a6669a4..12c93e4 100644 --- a/oemcrypto/odk/src/odk_util.c +++ b/oemcrypto/odk/src/odk_util.c @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/odk_util.h b/oemcrypto/odk/src/odk_util.h index ab932dd..723fb59 100644 --- a/oemcrypto/odk/src/odk_util.h +++ b/oemcrypto/odk/src/odk_util.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/serialization_base.c b/oemcrypto/odk/src/serialization_base.c index b84385b..4527b2a 100644 --- a/oemcrypto/odk/src/serialization_base.c +++ b/oemcrypto/odk/src/serialization_base.c @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/src/serialization_base.h b/oemcrypto/odk/src/serialization_base.h index 299e047..e4b0ef0 100644 --- a/oemcrypto/odk/src/serialization_base.h +++ b/oemcrypto/odk/src/serialization_base.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/test/fuzzing/Android.bp b/oemcrypto/odk/test/fuzzing/Android.bp index f351217..6ce3f45 100644 --- a/oemcrypto/odk/test/fuzzing/Android.bp +++ b/oemcrypto/odk/test/fuzzing/Android.bp @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp b/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp index 0a0c0ae..614d6e7 100644 --- a/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp +++ b/oemcrypto/odk/test/fuzzing/corpus_generator/Android.bp @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator.c b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator.c index 655bd06..3ebaaa9 100644 --- a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator.c +++ b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator.c @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. diff --git a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.c b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.c index 534b245..8a65bb2 100644 --- a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.c +++ b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.c @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. #include "fuzzing/corpus_generator/odk_corpus_generator_helper.h" diff --git a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.h b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.h index d6c1e99..9f495b7 100644 --- a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.h +++ b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_corpus_generator_helper.h @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. #ifndef WIDEVINE_ODK_TEST_FUZZING_CORPUS_GENERATOR_ODK_CORPUS_GENERATOR_HELPER_H_ diff --git a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_fuzz_corpus_generator.gyp b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_fuzz_corpus_generator.gyp index 8329984..9f46e3a 100644 --- a/oemcrypto/odk/test/fuzzing/corpus_generator/odk_fuzz_corpus_generator.gyp +++ b/oemcrypto/odk/test/fuzzing/corpus_generator/odk_fuzz_corpus_generator.gyp @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC. All rights reserved. This file and proprietary +# Copyright 2020 Google LLC. This file and proprietary # source code may only be used and distributed under the Widevine License # Agreement. diff --git a/oemcrypto/odk/test/fuzzing/odk_fuzz.gyp b/oemcrypto/odk/test/fuzzing/odk_fuzz.gyp index 694e3ac..11ec27b 100644 --- a/oemcrypto/odk/test/fuzzing/odk_fuzz.gyp +++ b/oemcrypto/odk/test/fuzzing/odk_fuzz.gyp @@ -1,4 +1,4 @@ -# Copyright 2019 Google LLC. All rights reserved. This file and proprietary +# Copyright 2019 Google LLC. This file and proprietary # source code may only be used and distributed under the Widevine License # Agreement. diff --git a/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.cpp b/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.cpp index 04905f1..b7797fd 100644 --- a/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.cpp @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. #include "fuzzing/odk_fuzz_helper.h" @@ -10,6 +10,7 @@ #include "odk.h" #include "odk_attributes.h" #include "odk_structs.h" +#include "odk_target.h" namespace oemcrypto_core_message { using features::CoreMessageFeatures; @@ -148,7 +149,7 @@ bool kdo_serialize_LicenseResponse(const ODK_ParseLicense_Args* args, parsed_license.key_array_length = parsed_lic.key_array_length; std::vector key_array; size_t i; - for (i = 0; i < parsed_lic.key_array_length; i++) { + for (i = 0; i < parsed_lic.key_array_length && i < ODK_MAX_NUM_KEYS; i++) { key_array.push_back(parsed_lic.key_array[i]); } parsed_license.key_array = key_array.data(); diff --git a/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.h b/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.h index 0f45467..309c2be 100644 --- a/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.h +++ b/oemcrypto/odk/test/fuzzing/odk_fuzz_helper.h @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. #ifndef WIDEVINE_ODK_TEST_FUZZING_ODK_FUZZ_HELPER_H_ diff --git a/oemcrypto/odk/test/fuzzing/odk_fuzz_structs.h b/oemcrypto/odk/test/fuzzing/odk_fuzz_structs.h index b35c56a..1d45557 100644 --- a/oemcrypto/odk/test/fuzzing/odk_fuzz_structs.h +++ b/oemcrypto/odk/test/fuzzing/odk_fuzz_structs.h @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. #ifndef WIDEVINE_ODK_TEST_FUZZING_ODK_FUZZ_STRUCTS_H_ diff --git a/oemcrypto/odk/test/fuzzing/odk_license_request_fuzz.cpp b/oemcrypto/odk/test/fuzzing/odk_license_request_fuzz.cpp index d089c4a..043f965 100644 --- a/oemcrypto/odk/test/fuzzing/odk_license_request_fuzz.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_license_request_fuzz.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz.cpp b/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz.cpp index f365524..c674cdb 100644 --- a/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz_with_mutator.cpp b/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz_with_mutator.cpp index 880e1d8..735ce7a 100644 --- a/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz_with_mutator.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_license_response_fuzz_with_mutator.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_provisioning_request_fuzz.cpp b/oemcrypto/odk/test/fuzzing/odk_provisioning_request_fuzz.cpp index deac024..b17f5e0 100644 --- a/oemcrypto/odk/test/fuzzing/odk_provisioning_request_fuzz.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_provisioning_request_fuzz.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz.cpp b/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz.cpp index 3a0457d..ecb96e8 100644 --- a/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz_with_mutator.cpp b/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz_with_mutator.cpp index 4ad8ca4..7e6c94e 100644 --- a/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz_with_mutator.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_provisioning_response_fuzz_with_mutator.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_renewal_request_fuzz.cpp b/oemcrypto/odk/test/fuzzing/odk_renewal_request_fuzz.cpp index d715eeb..befa8a4 100644 --- a/oemcrypto/odk/test/fuzzing/odk_renewal_request_fuzz.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_renewal_request_fuzz.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz.cpp b/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz.cpp index c090375..416c7b0 100644 --- a/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz_with_mutator.cpp b/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz_with_mutator.cpp index 2502ab8..7763f13 100644 --- a/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz_with_mutator.cpp +++ b/oemcrypto/odk/test/fuzzing/odk_renewal_response_fuzz_with_mutator.cpp @@ -1,4 +1,4 @@ -/* Copyright 2020 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2020 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */ diff --git a/oemcrypto/odk/test/odk_core_message_test.cpp b/oemcrypto/odk/test/odk_core_message_test.cpp index db476ad..bea7891 100644 --- a/oemcrypto/odk/test/odk_core_message_test.cpp +++ b/oemcrypto/odk/test/odk_core_message_test.cpp @@ -1,4 +1,4 @@ -// Copyright 2020 Google LLC. All rights reserved. This file and proprietary +// Copyright 2020 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -13,7 +13,10 @@ #include "core_message_serialize_proto.h" #include "core_message_types.h" #include "gtest/gtest.h" +#include "license_protocol.pb.h" #include "odk.h" +#include "odk_structs.h" +#include "third_party/absl/log/log.h" #include "third_party/absl/strings/escaping.h" namespace wvodk_test { diff --git a/oemcrypto/odk/test/odk_golden_v16.cpp b/oemcrypto/odk/test/odk_golden_v16.cpp index 2e80b0a..3dcf1f7 100644 --- a/oemcrypto/odk/test/odk_golden_v16.cpp +++ b/oemcrypto/odk/test/odk_golden_v16.cpp @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC. All rights reserved. This file and proprietary +// Copyright 2023 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -6,7 +6,9 @@ #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" diff --git a/oemcrypto/odk/test/odk_golden_v17.cpp b/oemcrypto/odk/test/odk_golden_v17.cpp index 786c678..e1e832c 100644 --- a/oemcrypto/odk/test/odk_golden_v17.cpp +++ b/oemcrypto/odk/test/odk_golden_v17.cpp @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC. All rights reserved. This file and proprietary +// Copyright 2023 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -6,7 +6,9 @@ #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" diff --git a/oemcrypto/odk/test/odk_golden_v18.cpp b/oemcrypto/odk/test/odk_golden_v18.cpp index c1adfb1..acbd8dc 100644 --- a/oemcrypto/odk/test/odk_golden_v18.cpp +++ b/oemcrypto/odk/test/odk_golden_v18.cpp @@ -1,4 +1,4 @@ -// Copyright 2023 Google LLC. All rights reserved. This file and proprietary +// Copyright 2023 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -6,7 +6,9 @@ #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" diff --git a/oemcrypto/odk/test/odk_test.cpp b/oemcrypto/odk/test/odk_test.cpp index 71073fc..1cc2f6c 100644 --- a/oemcrypto/odk/test/odk_test.cpp +++ b/oemcrypto/odk/test/odk_test.cpp @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -18,9 +18,11 @@ #include "core_message_serialize_proto.h" #include "core_message_types.h" #include "gtest/gtest.h" +#include "license_protocol.pb.h" #include "odk_overflow.h" #include "odk_structs.h" #include "odk_structs_priv.h" +#include "odk_target.h" #include "odk_test_helper.h" namespace wvodk_test { @@ -32,12 +34,14 @@ using oemcrypto_core_message::ODK_LicenseRequest; using oemcrypto_core_message::ODK_MessageCounter; using oemcrypto_core_message::ODK_Provisioning40Request; using oemcrypto_core_message::ODK_ProvisioningRequest; +using oemcrypto_core_message::ODK_ReleaseRequest; using oemcrypto_core_message::ODK_RenewalRequest; using oemcrypto_core_message::deserialize::CoreCommonRequestFromMessage; using oemcrypto_core_message::deserialize::CoreLicenseRequestFromMessage; using oemcrypto_core_message::deserialize::CoreProvisioning40RequestFromMessage; using oemcrypto_core_message::deserialize::CoreProvisioningRequestFromMessage; +using oemcrypto_core_message::deserialize::CoreReleaseRequestFromMessage; using oemcrypto_core_message::deserialize::CoreRenewalRequestFromMessage; using oemcrypto_core_message::deserialize:: CoreRenewedProvisioningRequestFromMessage; @@ -49,6 +53,7 @@ using oemcrypto_core_message::serialize::CreateCoreProvisioning40Response; using oemcrypto_core_message::serialize::CreateCoreProvisioningResponse; using oemcrypto_core_message::serialize:: CreateCoreProvisioningResponseFromProto; +using oemcrypto_core_message::serialize::CreateCoreReleaseResponse; using oemcrypto_core_message::serialize::CreateCoreRenewalResponse; constexpr uint32_t kExtraPayloadSize = 128u; @@ -255,7 +260,7 @@ TEST(OdkTest, SerializeFieldsStress) { size_t total_size = 0; for (int i = 0; i < n; i++) { fields[i].type = static_cast( - std::rand() % static_cast(ODK_LAST_STRESSABLE_TYPE)); + std::rand() % (static_cast(ODK_LAST_STRESSABLE_TYPE) + 1)); fields[i].value = malloc(ODK_AllocSize(fields[i].type)); fields[i].name = "stress"; total_size += ODK_FieldLength(fields[i].type); @@ -686,6 +691,35 @@ TEST(OdkTest, RenewalRequestRoundtrip) { odk_prepare_func, kdo_parse_func); } +TEST(OdkTest, ReleaseRequestRoundTrip) { + const uint32_t clock_security_level = 1; + const uint32_t status = 1; + constexpr uint64_t system_time_seconds = 0xBADDCAFE000FF1CE; + uint64_t playback_time = 0xCAFE00000000; + const int64_t seconds_since_license_requested = 1; + const int64_t seconds_since_first_decrypt = + static_cast(system_time_seconds - playback_time); + ODK_ClockValues clock_values; + memset(&clock_values, 0, sizeof(clock_values)); + clock_values.time_of_first_decrypt = seconds_since_first_decrypt; + std::vector extra_fields = {}; + auto odk_prepare_func = [&](uint8_t* const buf, size_t* size, + ODK_NonceValues* nonce_values) { + return ODK_PrepareCoreReleaseRequest( + buf, SIZE_MAX, size, nonce_values, status, clock_security_level, + seconds_since_license_requested, seconds_since_first_decrypt, + &clock_values, system_time_seconds); + }; + auto kdo_parse_func = [&](const std::string& oemcrypto_core_message, + ODK_ReleaseRequest* core_release_request) { + bool ok = CoreReleaseRequestFromMessage(oemcrypto_core_message, + core_release_request); + return ok; + }; + ValidateRequest(ODK_Release_Request_Type, extra_fields, + odk_prepare_func, kdo_parse_func); +} + TEST(OdkTest, ProvisionRequestRoundtrip) { ODK_MessageCounterInfo counter_info; counter_info.master_generation_number = 0x12345678abcdffff; @@ -1095,7 +1129,7 @@ TEST_P(OdkVersionTest, LicenseResponseRoundtripMoreThanMaxKeys) { bool result = CreateCoreLicenseResponse(features_, parsed_license, core_request, request_hash_string, &oemcrypto_core_message); - EXPECT_FALSE(result); + EXPECT_TRUE(result); delete[] buf; delete[] zero; @@ -1131,6 +1165,30 @@ TEST_P(OdkVersionTest, RenewalResponseRoundtrip) { kdo_prepare_func); } +TEST_P(OdkVersionTest, ReleaseResponseRoundtrip) { + ODK_ReleaseResponseParams params; + ODK_SetDefaultReleaseResponseParams(¶ms); + SetRequestVersion(¶ms); + const int64_t seconds_since_license_requested = + params.seconds_since_license_requested; + const int64_t seconds_since_first_decrypt = + params.seconds_since_first_decrypt; + auto odk_parse_func = [&](const uint8_t* buf, size_t size) { + OEMCryptoResult err = + ODK_ParseRelease(buf, size, size, &(params.core_message.nonce_values)); + return err; + }; + auto kdo_prepare_func = [&](ODK_ReleaseRequest& core_request, + std::string* oemcrypto_core_message) { + return CreateCoreReleaseResponse( + features_, core_request, seconds_since_license_requested, + seconds_since_first_decrypt, oemcrypto_core_message); + }; + ValidateResponse(GetParam(), &(params.core_message), + params.extra_fields, odk_parse_func, + kdo_prepare_func); +} + TEST_P(OdkVersionTest, ProvisionResponseRoundtrip) { ODK_ProvisioningResponseParams params; ODK_SetDefaultProvisioningResponseParams(¶ms, @@ -1216,7 +1274,8 @@ 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, 3}, + {18, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 18, 4}, + {19, ODK_MAJOR_VERSION, ODK_MINOR_VERSION, 19, 2}, // 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}, @@ -1226,12 +1285,19 @@ std::vector TestCases() { {ODK_MAJOR_VERSION, 18, 1, 18, 1}, {ODK_MAJOR_VERSION, 18, 2, 18, 2}, {ODK_MAJOR_VERSION, 18, 3, 18, 3}, + {ODK_MAJOR_VERSION, 19, 0, 19, 0}, + {ODK_MAJOR_VERSION, 19, 1, 19, 1}, + {ODK_MAJOR_VERSION, 19, 2, 19, 2}, {0, 16, 3, 16, 3}, {0, 16, 4, 16, 4}, {0, 16, 5, 16, 5}, {0, 17, 1, 17, 1}, {0, 17, 2, 17, 2}, - {0, 18, 3, 18, 3}, // Change to 19 when the default version is updated. + {0, 18, 3, 18, 3}, + {0, 18, 4, 18, 4}, + {0, 19, 0, 19, 0}, + {0, 19, 1, 19, 1}, + {0, 19, 2, 19, 2}, }; return test_cases; } @@ -1373,6 +1439,130 @@ TEST(OdkOverflowTest, MultiplyUX) { EXPECT_TRUE(odk_mul_overflow_ux(4, SIZE_MAX >> 1, &result)); } +TEST(OdkTest, GenerateKeyContexts_Success) { + const uint8_t kContext[] = { + 0x0a, 0x4c, 0x08, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, + 0x10, 0x19, 0x07, 0xd9, 0xff, 0xde, 0x13, 0xaa, 0x95, 0xc1, 0x22, 0x67, + 0x80, 0x53, 0x36, 0x21, 0x36, 0xbd, 0xf8, 0x40, 0x8f, 0x82, 0x76, 0xe4, + 0xc2, 0xd8, 0x7e, 0xc5, 0x2b, 0x61, 0xaa, 0x1b, 0x9f, 0x64, 0x6e, 0x58, + 0x73, 0x49, 0x30, 0xac, 0xeb, 0xe8, 0x99, 0xb3, 0xe4, 0x64, 0x18, 0x9a, + 0x14, 0xa8, 0x72, 0x02, 0xfb, 0x02, 0x57, 0x4e, 0x70, 0x64, 0x0b, 0xd2, + 0x2e, 0xf4, 0x4b, 0x2d, 0x7e, 0x39, 0x12, 0x25, 0x0a, 0x23, 0x0a, 0x14, + 0x08, 0x01, 0x12, 0x10, 0x09, 0x15, 0x00, 0x7c, 0xaa, 0x9b, 0x59, 0x31, + 0xb7, 0x6a, 0x3a, 0x85, 0xf0, 0x46, 0x52, 0x3e, 0x10, 0x01, 0x1a, 0x09, + 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x18, 0x01, 0x20, + 0x00, 0x2a, 0x0c, 0x31, 0x38, 0x38, 0x36, 0x37, 0x38, 0x37, 0x34, 0x30, + 0x35, 0x00, 0x00, + }; + const uint8_t kMacKey[] = { + 0x41, 0x55, 0x54, 0x48, 0x45, 0x4e, 0x54, 0x49, 0x43, 0x41, 0x54, 0x49, + 0x4f, 0x4e, 0x00, 0x0a, 0x4c, 0x08, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x10, 0x19, 0x07, 0xd9, 0xff, 0xde, 0x13, 0xaa, 0x95, + 0xc1, 0x22, 0x67, 0x80, 0x53, 0x36, 0x21, 0x36, 0xbd, 0xf8, 0x40, 0x8f, + 0x82, 0x76, 0xe4, 0xc2, 0xd8, 0x7e, 0xc5, 0x2b, 0x61, 0xaa, 0x1b, 0x9f, + 0x64, 0x6e, 0x58, 0x73, 0x49, 0x30, 0xac, 0xeb, 0xe8, 0x99, 0xb3, 0xe4, + 0x64, 0x18, 0x9a, 0x14, 0xa8, 0x72, 0x02, 0xfb, 0x02, 0x57, 0x4e, 0x70, + 0x64, 0x0b, 0xd2, 0x2e, 0xf4, 0x4b, 0x2d, 0x7e, 0x39, 0x12, 0x25, 0x0a, + 0x23, 0x0a, 0x14, 0x08, 0x01, 0x12, 0x10, 0x09, 0x15, 0x00, 0x7c, 0xaa, + 0x9b, 0x59, 0x31, 0xb7, 0x6a, 0x3a, 0x85, 0xf0, 0x46, 0x52, 0x3e, 0x10, + 0x01, 0x1a, 0x09, 0x39, 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, + 0x18, 0x01, 0x20, 0x00, 0x2a, 0x0c, 0x31, 0x38, 0x38, 0x36, 0x37, 0x38, + 0x37, 0x34, 0x30, 0x35, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, + }; + const uint8_t kEncKey[] = { + 0x45, 0x4e, 0x43, 0x52, 0x59, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x0a, + 0x4c, 0x08, 0x00, 0x12, 0x48, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, + 0x19, 0x07, 0xd9, 0xff, 0xde, 0x13, 0xaa, 0x95, 0xc1, 0x22, 0x67, 0x80, + 0x53, 0x36, 0x21, 0x36, 0xbd, 0xf8, 0x40, 0x8f, 0x82, 0x76, 0xe4, 0xc2, + 0xd8, 0x7e, 0xc5, 0x2b, 0x61, 0xaa, 0x1b, 0x9f, 0x64, 0x6e, 0x58, 0x73, + 0x49, 0x30, 0xac, 0xeb, 0xe8, 0x99, 0xb3, 0xe4, 0x64, 0x18, 0x9a, 0x14, + 0xa8, 0x72, 0x02, 0xfb, 0x02, 0x57, 0x4e, 0x70, 0x64, 0x0b, 0xd2, 0x2e, + 0xf4, 0x4b, 0x2d, 0x7e, 0x39, 0x12, 0x25, 0x0a, 0x23, 0x0a, 0x14, 0x08, + 0x01, 0x12, 0x10, 0x09, 0x15, 0x00, 0x7c, 0xaa, 0x9b, 0x59, 0x31, 0xb7, + 0x6a, 0x3a, 0x85, 0xf0, 0x46, 0x52, 0x3e, 0x10, 0x01, 0x1a, 0x09, 0x39, + 0x38, 0x37, 0x36, 0x35, 0x34, 0x33, 0x32, 0x31, 0x18, 0x01, 0x20, 0x00, + 0x2a, 0x0c, 0x31, 0x38, 0x38, 0x36, 0x37, 0x38, 0x37, 0x34, 0x30, 0x35, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, + }; + + std::vector mac_key(sizeof(kMacKey) + 24); + std::vector enc_key(sizeof(kEncKey) + 24); + size_t mac_key_size = mac_key.size(); + size_t enc_key_size = enc_key.size(); + ASSERT_EQ(OEMCrypto_SUCCESS, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), &mac_key[0], + &mac_key_size, &enc_key[0], &enc_key_size)); + ASSERT_EQ(mac_key_size, sizeof(kMacKey)); + ASSERT_EQ(enc_key_size, sizeof(kEncKey)); + mac_key.resize(mac_key_size); + enc_key.resize(enc_key_size); + + EXPECT_EQ(std::vector(kMacKey, kMacKey + sizeof(kMacKey)), mac_key); + EXPECT_EQ(std::vector(kEncKey, kEncKey + sizeof(kEncKey)), enc_key); +} + +TEST(OdkTest, GenerateKeyContexts_ShortBuffer) { + const uint8_t kContext[] = {1, 2, 3}; + size_t mac_key_size = 0; + size_t enc_key_size = 0; + ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), nullptr, + &mac_key_size, nullptr, &enc_key_size)); + EXPECT_EQ(mac_key_size, sizeof(kContext) + 19); + EXPECT_EQ(enc_key_size, sizeof(kContext) + 15); +} + +TEST(OdkTest, GenerateKeyContexts_ShortBufferMacOnly) { + const uint8_t kContext[] = {1, 2, 3}; + uint8_t buffer[128]; + size_t mac_key_size = 0; + size_t enc_key_size = sizeof(buffer); + ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), nullptr, + &mac_key_size, buffer, &enc_key_size)); + EXPECT_EQ(mac_key_size, sizeof(kContext) + 19); + EXPECT_EQ(enc_key_size, sizeof(kContext) + 15); +} + +TEST(OdkTest, GenerateKeyContexts_ShortBufferEncOnly) { + const uint8_t kContext[] = {1, 2, 3}; + uint8_t buffer[128]; + size_t mac_key_size = sizeof(buffer); + size_t enc_key_size = 0; + ASSERT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), buffer, + &mac_key_size, buffer, &enc_key_size)); + EXPECT_EQ(mac_key_size, sizeof(kContext) + 19); + EXPECT_EQ(enc_key_size, sizeof(kContext) + 15); +} + +TEST(OdkTest, GenerateKeyContexts_NullArgs) { + const uint8_t kContext[] = {1, 2, 3}; + uint8_t buffer[24]; + size_t buffer_size = sizeof(buffer); + size_t buffer_size2 = sizeof(buffer); + + EXPECT_EQ(OEMCrypto_ERROR_INVALID_CONTEXT, + ODK_GenerateKeyContexts(nullptr, sizeof(kContext), buffer, + &buffer_size, buffer, &buffer_size2)); + buffer_size = buffer_size2 = sizeof(buffer); // Update to avoid short buffer. + EXPECT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), nullptr, + &buffer_size, buffer, &buffer_size2)); + buffer_size = buffer_size2 = sizeof(buffer); // Update to avoid short buffer. + EXPECT_EQ(OEMCrypto_ERROR_INVALID_CONTEXT, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), buffer, nullptr, + buffer, &buffer_size2)); + buffer_size = buffer_size2 = sizeof(buffer); // Update to avoid short buffer. + EXPECT_EQ(OEMCrypto_ERROR_SHORT_BUFFER, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), buffer, + &buffer_size, nullptr, &buffer_size2)); + buffer_size = buffer_size2 = sizeof(buffer); // Update to avoid short buffer. + EXPECT_EQ(OEMCrypto_ERROR_INVALID_CONTEXT, + ODK_GenerateKeyContexts(kContext, sizeof(kContext), buffer, + &buffer_size, buffer, nullptr)); +} + } // namespace } // namespace wvodk_test diff --git a/oemcrypto/odk/test/odk_test.gypi b/oemcrypto/odk/test/odk_test.gypi index 1b5c5e7..9cc33f6 100644 --- a/oemcrypto/odk/test/odk_test.gypi +++ b/oemcrypto/odk/test/odk_test.gypi @@ -1,4 +1,4 @@ -# Copyright 2019 Google LLC. All rights reserved. This file and proprietary +# Copyright 2019 Google LLC. This file and proprietary # source code may only be used and distributed under the Widevine License # Agreement. diff --git a/oemcrypto/odk/test/odk_test_helper.cpp b/oemcrypto/odk/test/odk_test_helper.cpp index db9b2f2..184515d 100644 --- a/oemcrypto/odk/test/odk_test_helper.cpp +++ b/oemcrypto/odk/test/odk_test_helper.cpp @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -266,6 +266,14 @@ void ODK_SetDefaultLicenseResponseParams(ODK_LicenseResponseParams* params, } } +void ODK_SetDefaultReleaseResponseParams(ODK_ReleaseResponseParams* params) { + ODK_SetDefaultCoreFields(&(params->core_message), ODK_Release_Response_Type); + params->status = kActive; + params->clock_security_level = 0; + params->seconds_since_license_requested = 0; + params->seconds_since_first_decrypt = 0; +} + void ODK_SetDefaultRenewalResponseParams(ODK_RenewalResponseParams* params) { ODK_SetDefaultCoreFields(&(params->core_message), ODK_Renewal_Response_Type); params->system_time = 0xfaceb00c; @@ -350,22 +358,22 @@ size_t ODK_FieldLength(ODK_FieldType type) { return sizeof(uint32_t); case ODK_UINT64: return sizeof(uint64_t); - case ODK_BOOL: // Booleans are stored in the message as 32 bit ints. - return sizeof(uint32_t); + case ODK_INT64: + return sizeof(uint64_t); case ODK_SUBSTRING: return sizeof(uint32_t) + sizeof(uint32_t); case ODK_DEVICEID: return ODK_DEVICE_ID_LEN_MAX; - case ODK_MESSAGECOUNTER: - return ODK_MESSAGECOUNTERINFO_SIZE; case ODK_DEVICEINFO: return ODK_DEVICE_INFO_LEN_MAX; + case ODK_MESSAGECOUNTER: + return ODK_MESSAGECOUNTERINFO_SIZE; case ODK_RENEWALDATA: return ODK_KEYBOX_RENEWAL_DATA_SIZE; case ODK_HASH: return ODK_SHA256_HASH_SIZE; - default: - return SIZE_MAX; + case ODK_BOOL: // Booleans are stored in the message as 32 bit ints. + return sizeof(uint32_t); } } @@ -406,6 +414,12 @@ OEMCryptoResult ODK_WriteSingleField(uint8_t* buf, const ODK_Field* field) { memcpy(buf, &u64, sizeof(u64)); break; } + case ODK_INT64: { + const int64_t i64 = + oemcrypto_htobe64(*static_cast(field->value)); + memcpy(buf, &i64, sizeof(i64)); + break; + } case ODK_BOOL: { const bool value = *static_cast(field->value); const uint32_t u32 = oemcrypto_htobe32(value ? 1 : 0); @@ -485,6 +499,12 @@ OEMCryptoResult ODK_ReadSingleField(const uint8_t* buf, *u64p = oemcrypto_be64toh(*u64p); break; } + case ODK_INT64: { + memcpy(field->value, buf, sizeof(int64_t)); + int64_t* i64p = static_cast(field->value); + *i64p = oemcrypto_be64toh(*i64p); + break; + } case ODK_BOOL: { uint32_t value; memcpy(&value, buf, sizeof(uint32_t)); @@ -604,6 +624,14 @@ OEMCryptoResult ODK_DumpSingleField(const uint8_t* buf, << "\n"; break; } + case ODK_INT64: { + int64_t val; + memcpy(&val, buf, sizeof(int64_t)); + val = oemcrypto_be64toh(val); + std::cerr << field->name << ": " << val << " = 0x" << std::hex << val + << "\n"; + break; + } case ODK_SUBSTRING: { uint32_t off = 0; uint32_t len = 0; @@ -708,15 +736,15 @@ void ODK_ExpectEqualBuf(const void* s1, const void* s2, size_t n, if (temp_fd >= 0) { close(temp_fd); } else { - std::cerr << "Failed to open temp file." << std::endl; + std::cerr << "Failed to open temp file." << '\n'; break; } std::string tmp(_tmp); std::fstream out(tmp, std::ios::out | std::ios::binary); out.write(static_cast(buffers[i]), n); out.close(); - std::cerr << std::endl - << "Message buffer " << i << " dumped to " << tmp << std::endl; + std::cerr << '\n' + << "Message buffer " << i << " dumped to " << tmp << '\n'; size_t bytes_written; uint8_t* buf = const_cast(reinterpret_cast(buffers[i])); diff --git a/oemcrypto/odk/test/odk_test_helper.h b/oemcrypto/odk/test/odk_test_helper.h index b004233..5005b94 100644 --- a/oemcrypto/odk/test/odk_test_helper.h +++ b/oemcrypto/odk/test/odk_test_helper.h @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. All rights reserved. This file and proprietary +// Copyright 2019 Google LLC. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. @@ -9,6 +9,7 @@ #include #include +#include "OEMCryptoCENCCommon.h" #include "odk_structs.h" #include "odk_structs_priv.h" @@ -19,6 +20,7 @@ enum ODK_FieldType { ODK_UINT16, ODK_UINT32, ODK_UINT64, + ODK_INT64, ODK_SUBSTRING, ODK_DEVICEID, ODK_DEVICEINFO, @@ -27,7 +29,7 @@ enum ODK_FieldType { ODK_HASH, // The "stressable" types are the ones we can put in a stress test that packs // and unpacks random data and can expect to get back the same thing. - ODK_LAST_STRESSABLE_TYPE, + ODK_LAST_STRESSABLE_TYPE = ODK_HASH, // Put boolean after ODK_LAST_STRESSABLE_TYPE, so that we skip boolean type in // SerializeFieldsStress because we unpack any nonzero to 'true'. ODK_BOOL, @@ -58,6 +60,15 @@ struct ODK_LicenseResponseParams { std::vector extra_fields; }; +struct ODK_ReleaseResponseParams { + ODK_CoreMessage core_message; + uint32_t status; + uint32_t clock_security_level; + int64_t seconds_since_license_requested; + int64_t seconds_since_first_decrypt; + std::vector extra_fields; +}; + struct ODK_RenewalResponseParams { ODK_CoreMessage core_message; uint64_t system_time; @@ -73,7 +84,6 @@ struct ODK_ProvisioningResponseParams { ODK_CoreMessage core_message; uint8_t device_id[ODK_DEVICE_ID_LEN_MAX]; uint32_t device_id_length; - uint32_t padding_u32; ODK_MessageCounterInfo counter_info; ODK_ParsedProvisioning parsed_provisioning; std::vector extra_fields; @@ -89,6 +99,7 @@ void ODK_SetDefaultCoreFields(ODK_CoreMessage* core_message, ODK_MessageType message_type); void ODK_SetDefaultLicenseResponseParams(ODK_LicenseResponseParams* params, uint32_t odk_major_version); +void ODK_SetDefaultReleaseResponseParams(ODK_ReleaseResponseParams* params); void ODK_SetDefaultRenewalResponseParams(ODK_RenewalResponseParams* params); void ODK_SetDefaultProvisioningResponseParams( ODK_ProvisioningResponseParams* params, uint32_t odk_major_version); diff --git a/oemcrypto/odk/test/odk_timer_test.cpp b/oemcrypto/odk/test/odk_timer_test.cpp index b595d98..1190cf0 100644 --- a/oemcrypto/odk/test/odk_timer_test.cpp +++ b/oemcrypto/odk/test/odk_timer_test.cpp @@ -1,4 +1,4 @@ -/* Copyright 2019 Google LLC. All rights reserved. This file and proprietary +/* Copyright 2019 Google LLC. This file and proprietary * source code may only be used and distributed under the Widevine * License Agreement. */