------------- Moves ecm_generator to media_cas_packager_sdk/internal. ------------- Add a simple TCP server listening on a port. My intention is to use this server to support the Simulcrypt APIs (TODO). Also add a simple TCP client binary for testing the server and also demo how to call the Simulcrypt APIs (TODO). ------------- If only a single key is in the ECM, it is the EVEN key. To make the code matches this understanding, change a parameter from 'false' to 'true'. But this change has NO impact on the produced ECM, regardless this parameter is 'false' or 'true' (i.e., whether using push_front or push_back), only a single key is in the ECM. ------------- Add classes that process Simulcrypt ECMG messages 1) Stream_set-up 2) CW_provision ------------- Renames server and client binaries. ------------- Make ecmg call ecm_generator to generate ecm. The return of the ecm to Simulcrypt caller will be implemented in the next CL. For now, using the 'key' (control word) in CW_provision message also as the 'key_id'. ------------- Move common folder ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=217358698
65 lines
2.3 KiB
C++
65 lines
2.3 KiB
C++
////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright 2016 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.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "common/signing_key_util.h"
|
|
#include "testing/gunit.h"
|
|
#include "absl/strings/escaping.h"
|
|
#include "common/crypto_util.h"
|
|
#include "protos/public/license_protocol.pb.h"
|
|
|
|
namespace widevine {
|
|
namespace signing_key_util {
|
|
namespace {
|
|
const char* kFrontKeyHex =
|
|
"0a1a2a3a4a5a6a7a8a9a0b1b2b3b4b5b0a1a2a3a4a5a6a7a8a9a0b1b2b3b4b5b";
|
|
const char* kBackKeyHex =
|
|
"0c1c2c3c4c5c6c7c8c9c0d1d2d3d4d5d0c1c2c3c4c5c6c7c8c9c0d1d2d3d4d5d";
|
|
|
|
std::string GenerateDerivedKey(widevine::ProtocolVersion protocol_version) {
|
|
if (protocol_version == widevine::VERSION_2_0) {
|
|
return absl::HexStringToBytes(kFrontKeyHex);
|
|
} else {
|
|
return absl::HexStringToBytes(kFrontKeyHex) +
|
|
absl::HexStringToBytes(kBackKeyHex);
|
|
}
|
|
}
|
|
} // namespace
|
|
|
|
TEST(DerivedKeyUtilTest, SigningKeyMaterialSizeProtocolVersion_2_0) {
|
|
ASSERT_EQ(crypto_util::kSigningKeySizeBits,
|
|
SigningKeyMaterialSize(VERSION_2_0));
|
|
}
|
|
|
|
TEST(DerivedKeyUtilTest, SigningKeyMaterialSizeProtocolVersion_2_1) {
|
|
ASSERT_EQ(crypto_util::kSigningKeySizeBits * 2,
|
|
SigningKeyMaterialSize(VERSION_2_1));
|
|
}
|
|
|
|
TEST(DerivedKeyUtilTest, GetServerSigningKeyProtocolVersion2_1) {
|
|
ASSERT_EQ(kFrontKeyHex, absl::BytesToHexString(GetServerSigningKey(
|
|
GenerateDerivedKey(VERSION_2_1))));
|
|
}
|
|
|
|
TEST(DerivedKeyUtilTest, GetClientSigningKeyProtocolVersion2_1) {
|
|
ASSERT_EQ(kBackKeyHex, absl::BytesToHexString(GetClientSigningKey(
|
|
GenerateDerivedKey(VERSION_2_1), VERSION_2_1)));
|
|
}
|
|
|
|
TEST(DerivedKeyUtilTest, GetServerSigningKeyProtocolVersion2_0) {
|
|
ASSERT_EQ(kFrontKeyHex, absl::BytesToHexString(GetServerSigningKey(
|
|
GenerateDerivedKey(VERSION_2_0))));
|
|
}
|
|
|
|
TEST(DerivedKeyUtilTest, GetClientSigningKeyProtocolVersion2_0) {
|
|
ASSERT_EQ(kFrontKeyHex, absl::BytesToHexString(GetClientSigningKey(
|
|
GenerateDerivedKey(VERSION_2_0), VERSION_2_0)));
|
|
}
|
|
|
|
} // namespace signing_key_util
|
|
} // namespace widevine
|