Export media_cas_packager_sdk
This commit is contained in:
65
common/signing_key_util_test.cc
Normal file
65
common/signing_key_util_test.cc
Normal file
@@ -0,0 +1,65 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
Reference in New Issue
Block a user