Files
media_cas_packager_sdk/example/wv_cas_ecm_example.cc
Widevine Buildbot a30ffdd7c6 (1) Move the CryptoMode enum definition to media_cas_packager_sdk partners can use it when calling libraries in the SDK.
(2) Add a new enum value for kDvbCsa.
(3) Allow caller to specify CTR, CBC, as well as CSA when using the ecm genertor from the SDK.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219707788
2018-11-01 22:31:08 +00:00

57 lines
2.3 KiB
C++

////////////////////////////////////////////////////////////////////////////////
// Copyright 2018 Google LLC.
//
// This software is licensed under the terms defined in the Widevine Master
// License Agreement. For a copy of this agreement, please contact
// widevine-licensing@google.com.
////////////////////////////////////////////////////////////////////////////////
// Example of how to use the wv_cas_ecm library.
#include <iostream>
#include <string>
#include "media_cas_packager_sdk/public/wv_cas_ecm.h"
#include "media_cas_packager_sdk/public/wv_cas_types.h"
const int kContentIvSize = 16;
const bool kKeyRotationEnabled = true;
const char kEvenKey[] = "even_content_key"; // 16 bytes
const char kEvenContentIv8Bytes[] = "evencont"; // 8 bytes
const char kEvenContentIv16Bytes[] = "evencontevencont"; // 16 bytes
const char kOddKey[] = "odd_content_key."; // 16 bytes
const char kOddContentIv8Bytes[] = "oddcont."; // 8 bytes
const char kOddContentIv16Bytes[] = "oddcont.oddcont."; // 16 bytes
const char kEntitlementKeyId[] = "ent_key_id......"; // 16 bytes
const char kEntitlementKey[] = "entitlement_key................."; // 32 bytes
int main(int argc, char **argv) {
widevine::cas::WvCasEcm wv_cas_ecm;
widevine::cas::WvCasStatus status =
wv_cas_ecm.Initialize(kContentIvSize, kKeyRotationEnabled,
widevine::cas::CryptoMode::kDvbCsa);
if (status != widevine::cas::OK) {
std::cerr << "Failed to initialize WV CAS ECM, error: "
<< widevine::cas::GetWvCasStatusMessage(status)
<< std::endl;
}
std::string ecm;
status = wv_cas_ecm.GenerateEcm(kEvenKey, kEvenContentIv16Bytes, kOddKey,
kOddContentIv16Bytes, kEntitlementKeyId,
kEntitlementKey, &ecm);
if (status != widevine::cas::OK) {
std::cerr << "Failed to generate WV CAS ECM, error: "
<< widevine::cas::GetWvCasStatusMessage(status)
<< std::endl;
} else {
std::cout << "ECM size: " << ecm.size() << std::endl;
std::cout << "ECM bytes: ";
for (size_t i = 0; i < ecm.size(); i++) {
printf("'\\x%x', ", static_cast<uint16_t>(ecm.at(i)));
}
std::cout << std::endl;
}
return 0;
}