(1) Change wv_cas_ecm to allow 16 bytes of content_iv
(2) Remove "wrapping_iv" parameters from wv_cas_ecm (3) Internally derive "wrapping_iv"s and "key_id"s (4) Add an example binary for demo the usage of wv_cas_ecm ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=218209010
This commit is contained in:
55
example/wv_cas_ecm_example.cc
Normal file
55
example/wv_cas_ecm_example.cc
Normal file
@@ -0,0 +1,55 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <string>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "glog/logging.h"
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "util/status.h"
|
||||
#include "media_cas_packager_sdk/public/wv_cas_ecm.h"
|
||||
|
||||
const char kEvenKey[] = "even_content_key"; // 16 bytes
|
||||
const char kEvenContentIv8Bytes[] = "evencont"; // 8 bytes
|
||||
const char kOddKey[] = "odd_content_key."; // 16 bytes
|
||||
const char kOddContentIv8Bytes[] = "oddcont."; // 8 bytes
|
||||
const char kEntitlementKeyId[] = "ent_key_id......"; // 16 bytes
|
||||
const char kEntitlementKey[] = "entitlement_key................."; // 32 bytes
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
|
||||
widevine::cas::WvCasEcm wv_cas_ecm;
|
||||
auto status = wv_cas_ecm.Initialize(/* content_iv_size= */ 16,
|
||||
/* key_rotation_enabled= */ true,
|
||||
/* crypto_mode= */ 1);
|
||||
if (!status.ok()) {
|
||||
LOG(FATAL) << "Failed to initialize WV CAS ECM, error: " << status;
|
||||
}
|
||||
std::string ecm;
|
||||
status = wv_cas_ecm.GenerateEcm(
|
||||
/* even_key= */ kEvenKey,
|
||||
/* even_content_iv= */
|
||||
absl::StrCat(kEvenContentIv8Bytes, kEvenContentIv8Bytes),
|
||||
/* odd_key= */ kOddKey,
|
||||
/* odd_content_iv= */
|
||||
absl::StrCat(kOddContentIv8Bytes, kOddContentIv8Bytes),
|
||||
/* entitlement_key_id= */ kEntitlementKeyId,
|
||||
/* entitlement_key= */ kEntitlementKey, &ecm);
|
||||
if (!status.ok()) {
|
||||
LOG(FATAL) << "Failed to generate WV CAS ECM, error: " << status;
|
||||
} else {
|
||||
LOG(INFO) << "Generated WV CAS ECM (in hex): "
|
||||
<< absl::BytesToHexString(ecm);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user