//////////////////////////////////////////////////////////////////////////////// // 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 #include #include "media_cas_packager_sdk/public/wv_cas_ecm.h" #include "media_cas_packager_sdk/public/wv_cas_status.h" const int kContentIvSize = 16; const bool kKeyRotationEnabled = true; const int kCryptoMode = 1; // CTR 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, kCryptoMode); 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(ecm.at(i))); } std::cout << std::endl; } return 0; }