(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
This commit is contained in:
Widevine Buildbot
2018-11-01 22:31:08 +00:00
parent 2c05ca1be2
commit a30ffdd7c6
6 changed files with 23 additions and 13 deletions

Binary file not shown.

View File

@@ -12,11 +12,10 @@
#include <string> #include <string>
#include "media_cas_packager_sdk/public/wv_cas_ecm.h" #include "media_cas_packager_sdk/public/wv_cas_ecm.h"
#include "media_cas_packager_sdk/public/wv_cas_status.h" #include "media_cas_packager_sdk/public/wv_cas_types.h"
const int kContentIvSize = 16; const int kContentIvSize = 16;
const bool kKeyRotationEnabled = true; const bool kKeyRotationEnabled = true;
const int kCryptoMode = 1; // CTR
const char kEvenKey[] = "even_content_key"; // 16 bytes const char kEvenKey[] = "even_content_key"; // 16 bytes
const char kEvenContentIv8Bytes[] = "evencont"; // 8 bytes const char kEvenContentIv8Bytes[] = "evencont"; // 8 bytes
const char kEvenContentIv16Bytes[] = "evencontevencont"; // 16 bytes const char kEvenContentIv16Bytes[] = "evencontevencont"; // 16 bytes
@@ -29,7 +28,8 @@ const char kEntitlementKey[] = "entitlement_key................."; // 32 bytes
int main(int argc, char **argv) { int main(int argc, char **argv) {
widevine::cas::WvCasEcm wv_cas_ecm; widevine::cas::WvCasEcm wv_cas_ecm;
widevine::cas::WvCasStatus status = widevine::cas::WvCasStatus status =
wv_cas_ecm.Initialize(kContentIvSize, kKeyRotationEnabled, kCryptoMode); wv_cas_ecm.Initialize(kContentIvSize, kKeyRotationEnabled,
widevine::cas::CryptoMode::kDvbCsa);
if (status != widevine::cas::OK) { if (status != widevine::cas::OK) {
std::cerr << "Failed to initialize WV CAS ECM, error: " std::cerr << "Failed to initialize WV CAS ECM, error: "
<< widevine::cas::GetWvCasStatusMessage(status) << widevine::cas::GetWvCasStatusMessage(status)

Binary file not shown.

View File

@@ -12,7 +12,7 @@
#include <stddef.h> #include <stddef.h>
#include <string> #include <string>
#include "media_cas_packager_sdk/public/wv_cas_status.h" #include "media_cas_packager_sdk/public/wv_cas_types.h"
namespace widevine { namespace widevine {
namespace cas { namespace cas {

View File

@@ -16,7 +16,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "media_cas_packager_sdk/public/wv_cas_status.h" #include "media_cas_packager_sdk/public/wv_cas_types.h"
namespace widevine { namespace widevine {
namespace cas { namespace cas {
@@ -42,9 +42,7 @@ class WvCasEcm {
// if this is 'true' only subsequent call to GenerateEcm will be allowed, // if this is 'true' only subsequent call to GenerateEcm will be allowed,
// if this is 'false' only subsequent call to GenerateSingleKeyEcm will // if this is 'false' only subsequent call to GenerateSingleKeyEcm will
// be allowed // be allowed
// - |crypto_mode| crypto mode for encrypting content, // - |crypto_mode| crypto mode for encrypting content
// kCryptoModeCbc = 0, kCryptoModeCtr = 1
// only CTR is supported by Widevine CAS plugin for now
// //
// Returns: // Returns:
// - A status indicating whether there was any error during initialization // - A status indicating whether there was any error during initialization
@@ -52,7 +50,7 @@ class WvCasEcm {
// Note: // Note:
// - 'even'/'odd' key in the ECM will be be encrypted using AEC_CBC // - 'even'/'odd' key in the ECM will be be encrypted using AEC_CBC
virtual WvCasStatus Initialize(int content_iv_size, bool key_rotation_enabled, virtual WvCasStatus Initialize(int content_iv_size, bool key_rotation_enabled,
int crypto_mode); CryptoMode crypto_mode);
// Generate an ECM containing two keys (even and odd). Can be called when // Generate an ECM containing two keys (even and odd). Can be called when
// |key_rotation_enabled| is initialized to 'true'. // |key_rotation_enabled| is initialized to 'true'.
@@ -108,7 +106,7 @@ class WvCasEcm {
bool initialized_ = false; bool initialized_ = false;
int content_iv_size_; int content_iv_size_;
bool key_rotation_enabled_; bool key_rotation_enabled_;
int crypto_mode_; CryptoMode crypto_mode_;
}; };
} // namespace cas } // namespace cas

View File

@@ -6,8 +6,8 @@
// widevine-licensing@google.com. // widevine-licensing@google.com.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_STATUS_H_ #ifndef MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_TYPES_H_
#define MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_STATUS_H_ #define MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_TYPES_H_
#include <string> #include <string>
@@ -50,7 +50,19 @@ enum WvCasStatus {
// Returns the message std::string for the given WvCasStatus. // Returns the message std::string for the given WvCasStatus.
std::string GetWvCasStatusMessage(WvCasStatus status); std::string GetWvCasStatusMessage(WvCasStatus status);
// Crypto mode for encryption / decryption.
enum class CryptoMode : int {
kCryptoModeUnspecified = 0,
kAesCtr = 1,
kAesCbc = 2,
kDvbCsa = 3
};
std::string CryptoModeToString(CryptoMode mode);
CryptoMode StringToCryptoMode(std::string str);
} // namespace cas } // namespace cas
} // namespace widevine } // namespace widevine
#endif // MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_STATUS_H_ #endif // MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_TYPES_H_