diff --git a/libwvdrmengine/oemcrypto/odk/README b/libwvdrmengine/oemcrypto/odk/README index 44dac83f..ba8c8c73 100644 --- a/libwvdrmengine/oemcrypto/odk/README +++ b/libwvdrmengine/oemcrypto/odk/README @@ -1,4 +1,4 @@ -The ODK Library is used to generate and parse core OEMCrypto messages for +This ODK Library is used to generate and parse core OEMCrypto messages for OEMCrypto v16 and above. This library is used by both OEMCrypto on a device, and by Widevine license and diff --git a/libwvdrmengine/oemcrypto/odk/include/odk_structs.h b/libwvdrmengine/oemcrypto/odk/include/odk_structs.h index 8fcbfff2..d2cb635d 100644 --- a/libwvdrmengine/oemcrypto/odk/include/odk_structs.h +++ b/libwvdrmengine/oemcrypto/odk/include/odk_structs.h @@ -12,10 +12,10 @@ /* The version of this library. */ #define ODK_MAJOR_VERSION 16 -#define ODK_MINOR_VERSION 2 +#define ODK_MINOR_VERSION 3 /* ODK Version string. Date changed automatically on each release. */ -#define ODK_RELEASE_DATE "ODK v16.2 2020-05-30" +#define ODK_RELEASE_DATE "ODK v16.2 2020-06-02" /* The lowest version number for an ODK message. */ #define ODK_FIRST_VERSION 16 diff --git a/libwvdrmengine/oemcrypto/odk/src/core_message_deserialize.cpp b/libwvdrmengine/oemcrypto/odk/src/core_message_deserialize.cpp index f00591d5..1cef5ee7 100644 --- a/libwvdrmengine/oemcrypto/odk/src/core_message_deserialize.cpp +++ b/libwvdrmengine/oemcrypto/odk/src/core_message_deserialize.cpp @@ -67,8 +67,20 @@ bool ParseRequest(uint32_t message_type, // Other versions do not (yet) have a restriction on minor number. // In particular, future versions are accepted for forward compatibility. } - return core_message.message_type == message_type && - core_message.message_length == GetOffset(msg); + // For v16, a release and a renewal use the same message structure. + // However, for future API versions, the release might be a separate + // message. Otherwise, we expect an exact match of message types. + if (core_message.message_type != message_type && + !(message_type == ODK_Renewal_Request_Type && + core_message.message_type == ODK_Release_Request_Type)) { + return false; + } + // Verify that the amount of buffer we read, which is GetOffset, is not more + // than the total message size. We allow the total message size to be larger + // for forward compatibility because future messages might have extra fields + // that we can ignore. + if (core_message.message_length < GetOffset(msg)) return false; + return true; } } // namespace diff --git a/libwvdrmengine/oemcrypto/odk/src/core_message_serialize_proto.cpp b/libwvdrmengine/oemcrypto/odk/src/core_message_serialize_proto.cpp index 90b5fdd9..cacba429 100644 --- a/libwvdrmengine/oemcrypto/odk/src/core_message_serialize_proto.cpp +++ b/libwvdrmengine/oemcrypto/odk/src/core_message_serialize_proto.cpp @@ -87,8 +87,7 @@ bool CreateCoreLicenseResponseFromProto(const std::string& serialized_license, } parsed_lic.enc_mac_keys_iv = GetOecSubstring(serialized_license, k.iv()); - std::string mac_keys(k.key(), k.key().size()); - parsed_lic.enc_mac_keys = GetOecSubstring(serialized_license, mac_keys); + parsed_lic.enc_mac_keys = GetOecSubstring(serialized_license, k.key()); break; } case video_widevine::License_KeyContainer::CONTENT: { diff --git a/libwvdrmengine/oemcrypto/odk/src/odk_assert.h b/libwvdrmengine/oemcrypto/odk/src/odk_assert.h index 2057c40a..6fda98b1 100644 --- a/libwvdrmengine/oemcrypto/odk/src/odk_assert.h +++ b/libwvdrmengine/oemcrypto/odk/src/odk_assert.h @@ -10,11 +10,11 @@ extern "C" { #endif #if (__STDC_VERSION__ >= 201112L) -# include -# define odk_static_assert static_assert +#include +#define odk_static_assert static_assert #else -# define odk_static_assert(msg, e) \ - enum { odk_static_assert = 1 / (!!((msg) && (e))) }; +#define odk_static_assert(msg, e) \ + enum { odk_static_assert = 1 / (!!((msg) && (e))) }; #endif #ifdef __cplusplus diff --git a/libwvdrmengine/oemcrypto/odk/src/odk_endian.h b/libwvdrmengine/oemcrypto/odk/src/odk_endian.h index bfbb9bf0..2a6f143e 100644 --- a/libwvdrmengine/oemcrypto/odk/src/odk_endian.h +++ b/libwvdrmengine/oemcrypto/odk/src/odk_endian.h @@ -10,11 +10,11 @@ extern "C" { #endif #if defined(__linux__) || defined(__ANDROID__) -# include -# define oemcrypto_htobe32 htobe32 -# define oemcrypto_be32toh be32toh -# define oemcrypto_htobe64 htobe64 -# define oemcrypto_be64toh be64toh +#include +#define oemcrypto_htobe32 htobe32 +#define oemcrypto_be32toh be32toh +#define oemcrypto_htobe64 htobe64 +#define oemcrypto_be64toh be64toh #else /* defined(__linux__) || defined(__ANDROID__) */ uint32_t oemcrypto_htobe32(uint32_t u32); uint32_t oemcrypto_be32toh(uint32_t u32); diff --git a/libwvdrmengine/oemcrypto/odk/src/odk_structs_priv.h b/libwvdrmengine/oemcrypto/odk/src/odk_structs_priv.h index 991f59d0..3c5a502b 100644 --- a/libwvdrmengine/oemcrypto/odk/src/odk_structs_priv.h +++ b/libwvdrmengine/oemcrypto/odk/src/odk_structs_priv.h @@ -21,6 +21,10 @@ typedef enum { ODK_Renewal_Response_Type = 4, ODK_Provisioning_Request_Type = 5, ODK_Provisioning_Response_Type = 6, + + /* Reserve future message types to support forward compatibility. */ + ODK_Release_Request_Type = 7, + ODK_Release_Response_Type = 8, } ODK_MessageType; typedef struct { diff --git a/libwvdrmengine/oemcrypto/odk/src/odk_timer.c b/libwvdrmengine/oemcrypto/odk/src/odk_timer.c index 10a0f7dc..0fbcf18e 100644 --- a/libwvdrmengine/oemcrypto/odk/src/odk_timer.c +++ b/libwvdrmengine/oemcrypto/odk/src/odk_timer.c @@ -4,6 +4,7 @@ #include #include + #include "odk.h" #include "odk_overflow.h" #include "odk_structs_priv.h"