Entitlement rotation support
Updates also include: - Add APIs to query current Simulcrypt channel & stream status; - EMM format change (used only to carry fingerprinting and service blocking info); - Key fetcher example to use curl key fetcher.
This commit is contained in:
@@ -62,6 +62,7 @@ cc_binary(
|
||||
srcs = ["wv_cas_key_fetcher_example.cc"],
|
||||
deps = [
|
||||
"//common:status",
|
||||
"//media_cas_packager_sdk/public:wv_cas_curl_key_fetcher",
|
||||
"//media_cas_packager_sdk/public:wv_cas_key_fetcher",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -151,11 +151,11 @@ const char kTestEmmgPrivateDataProvision[] = {
|
||||
'\x47', '\x40', '\x00', '\x10', '\x0a', '\x0d', '\x77', '\x69', '\x64',
|
||||
'\x65', '\x76', '\x69', '\x6e', '\x65', '\x5f', '\x74', '\x65', '\x73',
|
||||
'\x74', '\x12', '\x09', '\x43', '\x61', '\x73', '\x54', '\x73', '\x46',
|
||||
'\x61', '\x6b', '\x65', '\x1a', '\x10', '\x66', '\x61', '\x6b', '\x65',
|
||||
'\x4b', '\x65', '\x79', '\x49', '\x64', '\x31', '\x4b', '\x65', '\x79',
|
||||
'\x49', '\x64', '\x31', '\x1a', '\x10', '\x66', '\x61', '\x6b', '\x65',
|
||||
'\x4b', '\x65', '\x79', '\x49', '\x64', '\x32', '\x4b', '\x65', '\x79',
|
||||
'\x49', '\x64', '\x32', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
|
||||
'\x61', '\x6b', '\x65', '\x22', '\x0a', '\x66', '\x61', '\x6b', '\x65',
|
||||
'\x47', '\x72', '\x6f', '\x75', '\x70', '\x31', '\x22', '\x0c', '\x66',
|
||||
'\x61', '\x6b', '\x65', '\x47', '\x72', '\x6f', '\x75', '\x70', '\x49',
|
||||
'\x64', '\x32', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
|
||||
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
|
||||
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
|
||||
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
|
||||
'\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00', '\x00',
|
||||
@@ -191,22 +191,22 @@ const char kTestEmmgEmmDataProvision[] = {
|
||||
// Start of the first TS packet (188 bytes).
|
||||
'\x47', '\x40', '\x00', '\x10', // TS packet header (4 bytes).
|
||||
'\x00', // Pointer field (1 byte).
|
||||
'\x82', '\x70', '\xbe', // Secyion header (3 bytes).
|
||||
'\x82', '\x70', '\xbc', // Section header (3 bytes).
|
||||
// Start of Widevine EMM.
|
||||
'\x01', '\x08', '\x00', '\x00', '\x00', '\x00', '\x5f', '\x3d', '\xc1',
|
||||
'\xfb', '\x00', '\x6b', '\x0a', '\x14', '\x0a', '\x03', '\x43', '\x48',
|
||||
'\x31', '\x0a', '\x03', '\x43', '\x48', '\x32', '\x12', '\x08', '\x63',
|
||||
'\x6f', '\x6e', '\x74', '\x72', '\x6f', '\x6c', '\x73', '\x0a', '\x16',
|
||||
'\x0a', '\x03', '\x43', '\x48', '\x33', '\x12', '\x0f', '\x61', '\x6e',
|
||||
'\x6f', '\x74', '\x68', '\x65', '\x72', '\x20', '\x63', '\x6f', '\x6e',
|
||||
'\x74', '\x72', '\x6f', '\x6c', '\x12', '\x18', '\x0a', '\x03', '\x43',
|
||||
'\x48', '\x31', '\x0a', '\x03', '\x43', '\x48', '\x32', '\x12', '\x06',
|
||||
'\x47', '\x72', '\x6f', '\x75', '\x70', '\x31', '\x20', '\xd2', '\x85',
|
||||
'\xd8', '\xcc', '\x04', '\x12', '\x21', '\x0a', '\x03', '\x43', '\x48',
|
||||
'\x33', '\x12', '\x06', '\x47', '\x72', '\x6f', '\x75', '\x70', '\x32',
|
||||
'\x12', '\x06', '\x47', '\x72', '\x6f', '\x75', '\x70', '\x33', '\x18',
|
||||
'\xd2', '\x85', '\xd8', '\xcc', '\x04', '\x20', '\xd3', '\x85', '\xd8',
|
||||
'\xcc', '\x04', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78',
|
||||
'\x0a', '\x71', '\x0a', '\x14', '\x0a', '\x03', '\x43', '\x48', '\x31',
|
||||
'\x0a', '\x03', '\x43', '\x48', '\x32', '\x12', '\x08', '\x63', '\x6f',
|
||||
'\x6e', '\x74', '\x72', '\x6f', '\x6c', '\x73', '\x0a', '\x16', '\x0a',
|
||||
'\x03', '\x43', '\x48', '\x33', '\x12', '\x0f', '\x61', '\x6e', '\x6f',
|
||||
'\x74', '\x68', '\x65', '\x72', '\x20', '\x63', '\x6f', '\x6e', '\x74',
|
||||
'\x72', '\x6f', '\x6c', '\x12', '\x18', '\x0a', '\x03', '\x43', '\x48',
|
||||
'\x31', '\x0a', '\x03', '\x43', '\x48', '\x32', '\x12', '\x06', '\x47',
|
||||
'\x72', '\x6f', '\x75', '\x70', '\x31', '\x20', '\xd2', '\x85', '\xd8',
|
||||
'\xcc', '\x04', '\x12', '\x21', '\x0a', '\x03', '\x43', '\x48', '\x33',
|
||||
'\x12', '\x06', '\x47', '\x72', '\x6f', '\x75', '\x70', '\x32', '\x12',
|
||||
'\x06', '\x47', '\x72', '\x6f', '\x75', '\x70', '\x33', '\x18', '\xd2',
|
||||
'\x85', '\xd8', '\xcc', '\x04', '\x20', '\xd3', '\x85', '\xd8', '\xcc',
|
||||
'\x04', '\x18', '\xfb', '\x83', '\xf7', '\xf9', '\x05', '\x12', '\x47',
|
||||
'\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78',
|
||||
'\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78',
|
||||
'\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78',
|
||||
'\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78',
|
||||
@@ -216,8 +216,8 @@ const char kTestEmmgEmmDataProvision[] = {
|
||||
// Start of the second TS packet (188 bytes).
|
||||
'\x47', '\x00', '\x00', '\x11', // TS packet header (4 bytes).
|
||||
// Continued Widevine EMM.
|
||||
'\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78',
|
||||
'\x78', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
|
||||
'\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\x78', '\xff',
|
||||
'\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
|
||||
'\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
|
||||
'\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
|
||||
'\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
|
||||
|
||||
@@ -12,8 +12,11 @@
|
||||
#include <vector>
|
||||
|
||||
#include "common/status.h"
|
||||
#include "media_cas_packager_sdk/public/wv_cas_curl_key_fetcher.h"
|
||||
#include "media_cas_packager_sdk/public/wv_cas_key_fetcher.h"
|
||||
|
||||
const char kCasEncryptionServerUrl[] =
|
||||
"https://license.uat.widevine.com/cas/getcontentkey/widevine_test";
|
||||
const char kContentId[] = "21140844";
|
||||
const char kContentProvider[] = "widevine";
|
||||
const char kTrackType[] = "SD";
|
||||
@@ -22,36 +25,16 @@ const char kSigningProvider[] = "widevine_test";
|
||||
const char kSingingKey[] =
|
||||
"1ae8ccd0e7985cc0b6203a55855a1034afc252980e970ca90e5202689f947ab9";
|
||||
const char kSingingIv[] = "d58ce954203b7c9a9a9d467f59839249";
|
||||
const char kHttpResponse[] =
|
||||
"{\"response\":"
|
||||
"\"eyJzdGF0dXMiOiJPSyIsImNvbnRlbnRfaWQiOiJNakV4TkRBNE5EUT0iLCJlbnRpdGxlbWVu"
|
||||
"dF9rZXlzIjpbeyJrZXlfaWQiOiJNUGFndXhNb1hNNkUxUzhEOUF3RkNBPT0iLCJrZXkiOiJoZ1"
|
||||
"JycmdqeUg4NjQycjY3VHd0OHJ1cU5MUGNMRmtKcWRVSUROdm5GZDBNPSIsInRyYWNrX3R5cGUi"
|
||||
"OiJTRCIsImtleV9zbG90IjoiU0lOR0xFIn1dfQ==\"}";
|
||||
|
||||
using widevine::Status;
|
||||
using widevine::cas::EntitlementKeyInfo;
|
||||
using widevine::cas::EntitlementRequestParams;
|
||||
using widevine::cas::WvCasKeyFetcher;
|
||||
|
||||
class ExampleKeyFetcher : public WvCasKeyFetcher {
|
||||
public:
|
||||
ExampleKeyFetcher(const std::string& signing_provider,
|
||||
const std::string& signing_key,
|
||||
const std::string& signing_iv)
|
||||
: WvCasKeyFetcher(signing_provider, signing_key, signing_iv) {}
|
||||
|
||||
// An example that always returns the same response.
|
||||
Status MakeHttpRequest(const std::string& signed_request_json,
|
||||
std::string* http_response_json) const override {
|
||||
*http_response_json = kHttpResponse;
|
||||
return widevine::OkStatus();
|
||||
}
|
||||
};
|
||||
using widevine::cas::WvCasCurlKeyFetcher;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
// Initialize key fetcher.
|
||||
ExampleKeyFetcher key_fetcher(kSigningProvider, kSingingKey, kSingingIv);
|
||||
// Initialize key fetcher with server url.
|
||||
WvCasCurlKeyFetcher key_fetcher(kCasEncryptionServerUrl, kSigningProvider,
|
||||
kSingingKey, kSingingIv);
|
||||
|
||||
// Create request string.
|
||||
std::string request_str;
|
||||
|
||||
Reference in New Issue
Block a user